mikeexplorer
Supporting Member
OP
I agree the best way to control outputs in sequence is with the SQO function
I have used it on many projects
It is challenging the first time you use it but you will catch on quickly
You can have u to 255 steps per SQO that would give you 16 bits per step if you use an integer data type
If you need more bits then that you can use add a second SQO. There are many options there if needed.
You may also look at SQI function for inputs
Check the online help for them
On a side note I looked over you ladder program and a few observations
You have 2 subprograms shown in you structure tree Lad 6 and 7
But I could find no place in your lad 2 where you call the sub programs I may have missed it.
You call then with the JSR function with the number of the subprogram you want to call 6 or 7
With the RS500 the only program that will run on power up is LAD 2 someplace in that ladder you must call the subprogram. If you don’t call it will never run.
I also noticed that you call a JMP to LBL Q2:10 at different places in the ladder program
The LBL Q2:10 is the last rung in the adder program if you call it with( JMP) to it from any point in the program all the ladder rungs between the JMP and LBL are skipped completely and never evaluated
When the program is running after rung 35 (the last rung ) is excited the program will rollover to rung 00
It is possible for the program to run 00 to 09 then jump to 35 and back to 00 and not even scan any of the rungs between is that really what you want to do?
You do the same thing in both LAD 6 and LAD 7
Anytime you do JMP to jump over all the code between the JMP and the LBL it is not evaluated and the outputs are not cleared or set use them very carefully I have seen many programmers get in trouble with them. They spend many hours trying to figure out why the code doesn’t work.
I did buy a book about PLC programming and it does mention the SQO instruction but the explanation of it was vague. I will have to experiment with it to see if that is a better way to do this project. I do have another ML1000 setup with push buttons as a trainer unit.
You are correct, in the program I posted, it never calls the subroutines. I keep a blank Rslogix file with these subroutines in place and for the purpose of that program, I was developing the parking routine, I did write it as ladder 2 (main program) for development purposes to see how it worked. The plan for it is for it to become another subroutine. It would not need to call either of the other subroutines since it is designed only to bring the train into the block and stop it, then sense if it overshot the sensors and then back it into place.
It was when I was coding this to be the next subroutine I hit a wall and could not get it to work and I realized the way I am coding these programs is bad practices which is why I reached out for help. An example where the subroutines are used is in my interchange program which was the last program written that worked well.
https://youtu.be/vrGwERqydGI
There is also a routine to deal with the chatter I have been seeing on the inputs and the link posted above for that other website has an excellent illustration of debouncing inputs.
The Omron block (block with the green SSR) is to provide isolation between the track and the PLC. If a train derails it is possible a short could happen and cause the AC track power to surge into the block detect input. This Omron block would prevent a PLC input from blowing out in that case.
Mike