Hello Guest it is April 28, 2024, 01:34:45 PM

Author Topic: Help with PLC Ladder Logic  (Read 967 times)

0 Members and 1 Guest are viewing this topic.

Help with PLC Ladder Logic
« on: December 09, 2021, 09:31:08 PM »
I have a previous post about coding a macro for a duplomatic lathe turret. That method seemed a little more complicated that I had anticipated.  I talked a little bit with Cbyrdtopper and we decided the PLC route would be a better (easier) more reliable option. So I ordered a click plc from automation direct as well as a brainboxes ethernet switch. I intend to use modbus. None of which I have any experience with. I have only ever used the basic I/O options with bob's. I have read several getting started tutorials and understand this ladder logic somewhat. I am still kind of stumped on where to start. Do I use an input for mach4 to tell the PLC when to start a tool change? How do I tell the PLC which tool? Can I do this with registers? reading and writing between the plc and mach4 with modbus?
Re: Help with PLC Ladder Logic
« Reply #1 on: December 09, 2021, 10:11:28 PM »
Ok so from what I understand I can use registers to read and write registers both in mach4 and for the PLC. So I get that much of it. So the PLC side of things is where im going to require a little help.
Re: Help with PLC Ladder Logic
« Reply #2 on: December 10, 2021, 12:52:50 AM »
So I setup modbus within mach4. I have the ESS and the PLC connected to the ethernet switch. Should i be able to maintain a connection with both the PLC and the ESS? If i connect with the PLC i drop the ESS and vice versa. Is this normal?
Re: Help with PLC Ladder Logic
« Reply #3 on: December 11, 2021, 01:27:20 AM »
ok, I have been reading all day and watching videos on automation directs site on the basics of PLC's and how to program them. The basics. I have been reading, rereading, and rereading Cbyrdtopper forums post https://www.machsupport.com/forum/index.php?topic=34228.30 helping another member get his turret setup. While it has helped me a lot, his turret is a little more simple than what mine seems to be. Hopefully not.

I have the ESS and the Switch PLC both connected. I followed  Cbyrdtopper instructions on setting up modbus and the required inputs, outputs, and registers in mach4. All that is done.

Im still stuck on this ladder logic. It seems so simple yet I am struggling with it. I have everything wired on the bench so I can test as I go. If someone could post a pic of their PLC turret program even remotely similar. Just for me to compare to would be helpful. The starting point and determining that its changing to the correct tool is my first issue.

I have DS1 setup as a register, mach will send the tool number over for the plc to change to tool 1 thru 8 by comparing DS1 = 1 thru 8. Do I assign my tool info to a DS1 variable? The only way to know the position of the turret is by the BIT signals.

So inputs 1-3 on the PLC are bit signals from the turret, So tool one would be on-off-off or 1-0-0. The PLC will see those 3 signals followed by a Strobe signal which needs to trigger a solenoid. Im confused as to how to write this all out in ladder logic or any other code for that matter.  From what I've read I can write the repetitive stuff out in a subprogram and call it after the tool is assigned.
Re: Help with PLC Ladder Logic
« Reply #4 on: January 08, 2022, 02:40:47 AM »
If it just binary representation of numbers for each location? Mach4 PLC can do bitwise ops.

So, just convert the input signals to a binary number in the PLC ladder program using or and bitshift (3 different rungs, 1 storage variable for result).
Trigger the output based on the value of the inputs at binary number on another rung. I think you'll need 8 different rungs for the outputs.

This should be simple to do. If you actually have to move the turret to a specific location based on tool number change, can get tricky.
Re: Help with PLC Ladder Logic
« Reply #5 on: January 08, 2022, 04:57:38 AM »
I had to mess with this more...I was wrong about the binary stuff in the PMC. I just can't figure out how that shift register works but you could just use contacts assigned to input signals right next to eachother on each rung for binary representation like following.

0x001 (0x01) would be contact 1 negated, contact 2 negated, contact 3 high ---> trigger coil (output)  .... adding them on same rung back to back without branch is just like a logical AND. I don't think the mach PMC does branches on rungs for OR'ing.

each contact can be assigned as a mach4 input signal or a hardware input, your choice.

The tricky part is shutting off the coil. I haven't figured out the delays, timers or reset functions of the PMC yet. It's worth a go and doesn't look too difficult.

I only tried the first three possibilities (0x00 - 0x02) in the attached images.

Hope the images and pmc example file I attached can help.
« Last Edit: January 08, 2022, 05:03:12 AM by compewter_numerical »
Re: Help with PLC Ladder Logic
« Reply #6 on: January 09, 2022, 08:09:32 PM »
Thank you compewter_numerical for your reply. Thanks to you and a few other members I have this portion working now. I am almost finished with the rebuild, still a few things left to do within mach4. I will post a final update when I complete this project. So everything will be in one place. So hopefully it helps someone in the future. While I was trying to research all of this stuff for the first time, I found very little info on what I was trying to do.