Brandon_K
Member
This program is part of a "Saw" type of device we designed. The program consists of a bunch of games within the device to escape from, but I'm having issues with one specific portion of the program (specifically pertaining to rungs 11 through 49 in the program).
I'll try to give some background on "The Device".
There are 6 player stations. Each station has a 6" stroke cylinder mounted above a players wrist with a fake knife blade attached to the rod. Each cylinder has 3 mag prox sensors on it, giving each cylinder 5 positions (fully retracted, position 1, position 2, position 3 and fully extended). The game is 5 minutes long. The cylinders all start in a fully retracted state. Every 90 seconds, the cylinders each extend 1.5", until the 5 minutes is up. If they have not completed the game at the end up the 5 minutes, the cylinders fully extend "cutting off" the players hand.
The original program I wrote had a pair of compare contacts to activate the solenoid valves down to the first mag prox on the cylinder body. So from 90 to 92 seconds into the game, that activated the valve to move the cylinder downward to it's first sensor. I put a NC contact in for each valve so that when it hit the first prox on the cylinder, it would stop the valve. Then from 180 to 182 seconds it would move to it's 2nd position, 270 to 272 seconds it's 3rd position and at 300 seconds it would fully extend.
I chose 2 second gaps to activate the valve to allow for differences in speed in the flow controls and to make sure there was enough time to get the cylinder to travel from point to point, since the prox on the cylinder should be stopping the PLC from activating the valve.
The problem I'm having is even with the flow controls at the slowest speed without chattering, the PLC didn't seem to be "catching" the prox input so the cylinder would sail past the sensor and continue extending to it's full stroke length. In the original program the scan time was 10ms. The detection area on these cylilnders is very small so I believe it may have been missing the input during it's scan.
Since I've been back to the hotel I've rewritten that portion of the program. Previously the contact blocks to stop the valve from continuing were simply the prox input. I've changed that so now the prox input sets a control bit (I did some testing on it using that setup before I left the site and it worked better, but still not ideal).
I've also changed the inputs to be "Immediate" which I think may have been a large portion of my problem in the first place. I've never had to program something with such quick pulses of inputs before and I've never used the "Immediate" option.
At this point what I'm looking for is to have you guys look at it and tell me what you would have done different. The way I have it now may work (I'll know in the morning when I get back to the site), but I'm still far from proficient in ladder, so I want to see how the pro's would have gone about it.
Just looking at the program overall (specifically, the cylinder control portion), it seems very long. With all of the X > set control bits, it's even longer now. It just doesn't seem efficient to me. As a direct example, I have 5 control bits for each physical valve output. I feel like there has to be a better, more efficient, less code way to go about it than I've chosen.
I would love any input you guys have. I always try to put enough info in the rung comments and address nicknames. Program is attached (change the extension from .zip back to .ckp). It's an AD Click. I've attached some pics of the game in various stages of it's build as well, to give a better idea of what it does.
I'll try to give some background on "The Device".
There are 6 player stations. Each station has a 6" stroke cylinder mounted above a players wrist with a fake knife blade attached to the rod. Each cylinder has 3 mag prox sensors on it, giving each cylinder 5 positions (fully retracted, position 1, position 2, position 3 and fully extended). The game is 5 minutes long. The cylinders all start in a fully retracted state. Every 90 seconds, the cylinders each extend 1.5", until the 5 minutes is up. If they have not completed the game at the end up the 5 minutes, the cylinders fully extend "cutting off" the players hand.
The original program I wrote had a pair of compare contacts to activate the solenoid valves down to the first mag prox on the cylinder body. So from 90 to 92 seconds into the game, that activated the valve to move the cylinder downward to it's first sensor. I put a NC contact in for each valve so that when it hit the first prox on the cylinder, it would stop the valve. Then from 180 to 182 seconds it would move to it's 2nd position, 270 to 272 seconds it's 3rd position and at 300 seconds it would fully extend.
I chose 2 second gaps to activate the valve to allow for differences in speed in the flow controls and to make sure there was enough time to get the cylinder to travel from point to point, since the prox on the cylinder should be stopping the PLC from activating the valve.
The problem I'm having is even with the flow controls at the slowest speed without chattering, the PLC didn't seem to be "catching" the prox input so the cylinder would sail past the sensor and continue extending to it's full stroke length. In the original program the scan time was 10ms. The detection area on these cylilnders is very small so I believe it may have been missing the input during it's scan.
Since I've been back to the hotel I've rewritten that portion of the program. Previously the contact blocks to stop the valve from continuing were simply the prox input. I've changed that so now the prox input sets a control bit (I did some testing on it using that setup before I left the site and it worked better, but still not ideal).
I've also changed the inputs to be "Immediate" which I think may have been a large portion of my problem in the first place. I've never had to program something with such quick pulses of inputs before and I've never used the "Immediate" option.
At this point what I'm looking for is to have you guys look at it and tell me what you would have done different. The way I have it now may work (I'll know in the morning when I get back to the site), but I'm still far from proficient in ladder, so I want to see how the pro's would have gone about it.
Just looking at the program overall (specifically, the cylinder control portion), it seems very long. With all of the X > set control bits, it's even longer now. It just doesn't seem efficient to me. As a direct example, I have 5 control bits for each physical valve output. I feel like there has to be a better, more efficient, less code way to go about it than I've chosen.
I would love any input you guys have. I always try to put enough info in the rung comments and address nicknames. Program is attached (change the extension from .zip back to .ckp). It's an AD Click. I've attached some pics of the game in various stages of it's build as well, to give a better idea of what it does.
Attachments
Last edited: