×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

PLC Ladder Diagram to Arduino Sketch Conversion

PLC Ladder Diagram to Arduino Sketch Conversion

PLC Ladder Diagram to Arduino Sketch Conversion

(OP)
Hi all,

I'm trying to operate a linear actuator (SMC LEY25B-300) using an Arduino based PLC (Controllino MAXI), in retrospect i would have used a regular PLC with ladder logic but it's to late for that (for now).
Anyway, I've figured how everything should work but I'm stuck on the programming part.
The controller of the actuator is LECP6 PNP type.

The PLC is programmable just like any other Arduino board which sounded just like what needed at first, as the first prototype was controlled by two Arduino UNO boards (instead of the actuator we used rack and pinion driven by a servo motor).
Now that we are upgrading the prototype to something more robust with industrial parts, coding for the actuator isn't as straight forward as i thought.
I'm having a hard time with getting the timing right between the commands, so after searching for a while i learned that there is a possibility to create a ladder logic diagram and then converting it to an Arduino sketch.

So if anybody has any experience and can suggest a good program, guide or anything else that you think might help, will be much appreciated.

RE: PLC Ladder Diagram to Arduino Sketch Conversion

(OP)
Thanks for the help!

I found that post already (prior to posting here).
I asked the question for the same reason you mentioned yourself, there isn't much info and what is out there, is a mess and nothing concrete.
So i thought that I'm missing something.

Anyway, thank you again!

RE: PLC Ladder Diagram to Arduino Sketch Conversion

Just a random guess, if you are having timing problems it could be that you are using interrupts and putting too much code in them.
I made that mistake on a similar project. Try to do as little as possible in the interrupts, just increment or toggle a variable and then check the variable in your main loop to see if the interrupt was triggered.

RE: PLC Ladder Diagram to Arduino Sketch Conversion

(OP)

Quote (mudandsnow)

Just a random guess, if you are having timing problems it could be that you are using interrupts and putting too much code in them.
I made that mistake on a similar project. Try to do as little as possible in the interrupts, just increment or toggle a variable and then check the variable in your main loop to see if the interrupt was triggered.
Thanks, sounds very reasonable. But the thing is that I'm not using the interrupts just yet.
Tried to make the actuator move between two positions (initial and final) to simulate a simplified version of the ventilation sequence that we need from our machine, so there isn't much going on in the code.
But the most peculiar thing happens when i run the code, if i leave the code to run just the initialization of the actuator and the commands to move to position 1 (initial) everything seems to work fine.
But when i add the second part, that moved the actuator to position 2 (final), which is basically a copy-paste when the only difference is a single input pin change that corresponds with the position 2 the whole thing stops from working.
After playing with the code Iv'e noticed that if i add the "delay" function it helps, but it adds up to more than 8 seconds of delay time, that makes the operation very inefficient.
I just cant understand why adding the same piece of code that initiates only after the first part was compiled completely ruins the WHOLE thing.

RE: PLC Ladder Diagram to Arduino Sketch Conversion

That does sound strange. Could be a copy-paste error, maybe you missed one of the changes you should make to the copy. That's where I usually screw up my copy-pasting. You could try locating the problem by commenting out portions of the position 2 code until the position 1 code starts working. If you post your code I'll see if I can find anything.

I am curious what you mean by 'ventilation'? Is this a building vent or a human lung emulator or something else?

RE: PLC Ladder Diagram to Arduino Sketch Conversion

(OP)

Quote (mudandsnow)

I am curious what you mean by 'ventilation'? Is this a building vent or a human lung emulator or something else?
It's part of an MVP prototype for a therapeutic machine for lung treatment.

About the code, it's crazy simple, about 15 lines for each direction. But i had it rewritten so many times that it stopped working all together.
I'll get it back to working order (with the cumulative delay) and post it, because I'm at a loss.

RE: PLC Ladder Diagram to Arduino Sketch Conversion

It's hard to bother with version tracking for such short code but I recommend saving a copy of your code every time you have a successful test. I found having an 'InProgress' folder and a 'Working' folder makes it a lot easier to revert to working code.

Funny coincidence, my linear actuator that used Arduino was for lung stuff too. Not treatment though, just simulation. VacuMed makes a much nicer one than I made. I'm guessing you need something different but this could give you some ideas.

http://www.vacumed.com/zcom/product/Product.do?com...

RE: PLC Ladder Diagram to Arduino Sketch Conversion

(OP)
Thanks for the advice and the link!
It was my first suggestion as a possible solution, to use a rotating link with a connecting rod, this will give a perfect sinusoidal air flow but for some reason it was rejected.
Instead the linear actuator was opted as a solution, I'm guessing that the fact that this an MVP prototype and the link-rod solution requires much more calculations to control the flow withing the set parameters.

RE: PLC Ladder Diagram to Arduino Sketch Conversion

That rotating link seems so much simpler and safer than making a linear actuator change speed throughout its stroke and turn around at adjustable end points. The one thing I liked about the linear actuator is it allowed us to try non-sinusoidal breath patterns but in the end that wasn't really needed and it could have been done with a rotating link.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close