RSlogix Better way to control outputs in sequence

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
 
I forgot to answer the question about the JMP instructions. It is mainly how it deals with the case of an alarm code and I also realize that this is also bad programming practice.



Right now I use B3:20 as bits to indicate an alarm code. This will be changed to using an integer value, not only to allow for more then 16 alarm codes, but the Cmore HMI panel I am using has a lookup text function and I can use that to display the alarm code with a text description. Right now my alarm screen has all 16 text messages on it and makes the text visible if the bit is set. Again, not a good way to do that.



I am thinking a better way to avoid using the JMP instruction is to simply have the condition in each rung that the rung can only be true if the alarm code integer value is zero. If it is not, the rungs would always be false.


Also, if this routine was a subroutine, once it returned to the main program, it could also evaluate if there is an alarm condition (non-zero value) and would not JSR to the routine again until the alarm code was cleared.



Mike
 
Instead of the Alarm integer equals zero in each rung, I would do a rung just for the compare and use an Alarms "OK" bit in all the other rungs, easier/faster to code, especially with the ML line you can use a Symbol: "Alarms_OK"

Or if Alarm Integer > 0, then "Alarm_Active" and use a closed contact in your other rungs.
 
The problem with using an integer for an alarm is the you can only post 1 alarm at a time
only the last posted alarm will show up in the HMI if you use the individual bits within an integer you can have all 16 alarms posted at the same time if you think you need more alarm then use double integer (32 bits) or use 2 integer words
the last rung of you ladder should be if alarm word = 0 then alarm OK bit is set
I sometimes have an additional alarm word "Old alarms " then compare the alarm word with the old alarm word if they are not equal them post new alarm to the HMI that way I don't keep posting all active alarms when a new one pops up just the new one. when I post the alarm I copy the alarms to old alarms
there are many ways to handle alarms depending on your needs
 
Instead of the Alarm integer equals zero in each rung, I would do a rung just for the compare and use an Alarms "OK" bit in all the other rungs, easier/faster to code, especially with the ML line you can use a Symbol: "Alarms_OK"

Or if Alarm Integer > 0, then "Alarm_Active" and use a closed contact in your other rungs.


That is a good idea, Thank you.


Mike
 
The problem with using an integer for an alarm is the you can only post 1 alarm at a time
only the last posted alarm will show up in the HMI if you use the individual bits within an integer you can have all 16 alarms posted at the same time if you think you need more alarm then use double integer (32 bits) or use 2 integer words
the last rung of you ladder should be if alarm word = 0 then alarm OK bit is set
I sometimes have an additional alarm word "Old alarms " then compare the alarm word with the old alarm word if they are not equal them post new alarm to the HMI that way I don't keep posting all active alarms when a new one pops up just the new one. when I post the alarm I copy the alarms to old alarms
there are many ways to handle alarms depending on your needs


Right now I am using B3:20 for the alarm codes and each bit represents an alarm. The issue I have with it is the HMI. I am using a Cmore EA3-T6CL panel and on my alarm screen I have the 16 text messages and whichever bit is set, would display the text. Not a good way to do it, but it works since I have 16 bits and all fit on the screen. I have already thought of expanding it to allow more bit codes but the issue becomes the display of them on the HMI.



Cmore has a lookup text function which will display one of 255 messages depending on the variable data. This will allow for more then 16 messages and will display the message properly.



Most likely there would only be one alarm condition to deal with since any alarm would stop all motion.



I have to figure out if there is a better way to use bit values for alarm codes as far as displaying them on the HMI.


Mike
 
One suggestion is to use an integer this can be written to on a first up basis, in other words an alarm occurs and the value is stored in the integer, the block is not processed again until that alarm had been cleared allowing further alarms to be displayed (Note: this was not exactly first up only on first alarm but subsequent alarms based on the hierarchy), many HMI's have a function to display text based on a value in a register, although we had an Alarm page, on the main display pages we had a first up alarm using text based messages from an integer. On our system they were grouped into a number of groups depending on the area. This may not suit your needs and will depend on functions in your HMI, I'm surprised that from what you say it appears not to have a proper alarm screen or are you not intending to use it.
 
Create fault logic

As mentioned, use a single bit to tell if there is / isn’t a fault, and use all fault bits as XIC in that fault bit’s logic setup. This way, there can be several faults occurring at the same time. You can use whatever fault bits you want, from Integers to fault bits.

The above article has pictures of the ladder logic, so you can see how it looks.
 
There are several good articles on the website I have been reading and will be helpful to correct some of my issues.


I also have to see what new features the Micrologix 1400 has over the Micrologix 1000. I have it on order and awaiting for it. I am also waiting to get a copy of RSlogix Micro starter which is what I need to program the ML 1400 since the free version does not.



Mike
 
Here is a graphic representation of a SQO that I use in classes.


Thanks, I will have some time before I start the next phase of programming. Once the new PLC arrives, I will have to tear down and rebuild my controls. I will have to experiment with this using the emulator and see how it works.


Mike
 
Instead of the Alarm integer equals zero in each rung, I would do a rung just for the compare and use an Alarms "OK" bit in all the other rungs, easier/faster to code, especially with the ML line you can use a Symbol: "Alarms_OK"

Or if Alarm Integer > 0, then "Alarm_Active" and use a closed contact in your other rungs.


Thinking about what you said it also would make it cleaner if I also included the two bits, "Automatic mode" and "Emergency Stop" combined with the test for no alarms. Just have to think of what to call that bit value that would be in each rung. Maybe something like "Good to go" ? :)


Although this is only a model train layout, I did wire my controls with a proper Emergency stop circuit to follow the model of proper control building. The monitor contacts of the safety relay are an input to the PLC so it knows the control power was shut down. If the button is pressed, it cuts off all power to the track, stopping the trains and cuts off the 24Volts that feeds all the outputs of the PLC.



Mike
 
Since the time I posted this, I got the new PLC and built the new controls. The Micrologix 1400 has analog capability so I modified a spare Lionel transformer to utilize it.



Going back to my original question of controlling outputs in sequence, originally I was latching and unlatching outputs which was bad programming practice. One suggestion was to use a bit value so if any of the bits were on, the output would be turned on. This does make sense since it avoids latching all together.



The outputs in question are for the track power (6 outputs) While a routine is executing, a section of track power will be turned on and off to manipulate the train.



My plan is to have a routine to do a certain task (subroutine) One as an example would be a version of the main and side interchange program which I had a version of it running.



Instead of using a bit value to control outputs (example B3:10 > 0 = O:0/10) (any bit value in B3:10 is on, the output will be on) What If I used an integer? If the integer value is non-zero, the output would be on. This way for debugging purposes I can write in different values so I can determine the last rung that put that value in the integer? Then when I want the output off, I just write a zero in it. In addition, if an alarm is detected, it would write a zero in the integer, turning off the track power.



The reason I am asking is I plan on several routines for the layout and would require a block of bit values to control the single track power output. Thoughts?


Mike

0205201650 (Medium).jpg 1127192036_HDR (Medium).jpg 1229191856.jpg
 
Off but related topic, if you are using an AC/DC transformer to control the trains, you can connect the AC side of it to a PowerFlex 4 series drive and control the speed. I was surprised at how well it worked and how smooth it was.
 
I do a lot of SQO for cleaning cycles where valves go through a certain sequence. I have one or two words of bits and one of timer presets. With AB SQO you can have all of them use the same control register. That keeps them all in sync. The timer preset one have a MOV to move the preset seconds (or 10ms) into the .PRE of the timer. There is also a RESet of the timer.


Where you have multiple conditions that need to be verified before the sequence can go to the next step I pair an SQI before the SQO. That way you have 16 bit conditions that must be meet. You can mask which conditions need to be met using the MASK word the same as the INPUT word. So if a bit is on the condition must be met.


The SQI SQO work great for pick-n-places to ensure a movement wont be made until the previous movement is verified.
 
Last edited:

Similar Topics

Hello all, I have a question in regards to RSlogix 5000. I am having issues with the program force closing when I try to make online edits. We...
Replies
0
Views
95
I am having trouble with getting no control of my analog output signal. I am using the SCL function block to control my analog output. The logic...
Replies
11
Views
210
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
115
Greetings ... someone sent me a request for some student handsouts that I developed ... turns out that I had this hosted on my business website...
Replies
0
Views
111
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
101
Back
Top Bottom