mikeexplorer
Supporting Member
I have been learning to program an Allen Bradley PLC by having it control a model railroad layout. Right now I am using a Micrologix 1000 but will soon be upgrading it.
In the course of writing programs for the trains I do depend heavy on sequence. Attached is a routine for parking a train. I also made a video of the program running here.
https://youtu.be/IYy2prl0q7Q
I am using B3:15 as my sequence steps, as each condition is satisfied it sets a bit in B3:15 so only certain rungs would be allowed to be true if the conditions are right. I do plan to change this to using an integer rather then latching bits as this has gotten messy.
If you look over the code, (Ladder 2) ignore the other subroutines as they are not used for this program. You will see I have to latch and unlatch the same output during the course of the program. O:0/9 is the track power for the section of track where the train will be parked. I have come to discover that this is bad programming practice, one, referencing the same output in multiple rungs of code, and second, to use latch and unlatch for outputs in this way.
I need suggestions on a cleaner way to do this. After this program I hit a wall with programming and got stuck and I think this is why. I have read several articles on sequence logic but dealing with the output I still have not figured out since during the sequence, the same output has to be turned on and off depending on what is going on.
I am using B3:20 as my alarm codes, this will also change, bits do get latched in there if an alarm condition exists.
Mike
In the course of writing programs for the trains I do depend heavy on sequence. Attached is a routine for parking a train. I also made a video of the program running here.
https://youtu.be/IYy2prl0q7Q
I am using B3:15 as my sequence steps, as each condition is satisfied it sets a bit in B3:15 so only certain rungs would be allowed to be true if the conditions are right. I do plan to change this to using an integer rather then latching bits as this has gotten messy.
If you look over the code, (Ladder 2) ignore the other subroutines as they are not used for this program. You will see I have to latch and unlatch the same output during the course of the program. O:0/9 is the track power for the section of track where the train will be parked. I have come to discover that this is bad programming practice, one, referencing the same output in multiple rungs of code, and second, to use latch and unlatch for outputs in this way.
I need suggestions on a cleaner way to do this. After this program I hit a wall with programming and got stuck and I think this is why. I have read several articles on sequence logic but dealing with the output I still have not figured out since during the sequence, the same output has to be turned on and off depending on what is going on.
I am using B3:20 as my alarm codes, this will also change, bits do get latched in there if an alarm condition exists.
Mike