Alternating Logic...?

shoelesscraig

Member
Join Date
Apr 2009
Location
LA
Posts
382
Hey guys, been programming for quite some time, but I need a push in the right direction for some (for lack of a better term) "alternating logic".

Basically, I'm displaying alarms on an HMI. The HMI will read a single integer (we'll call it INT1). So if alarm condition 1 is met, then INT1 = 1, if alarm condition 2 is met then INT = 2, and so on. If I have a single alarm, everything works great.

What I need however, is that if I have conditions 1 and 7 met, that INT1 will bounce back and forth between "1" and "7". If condition 22 is then added, then INT1 will add "22" to its rotation. Then of course, as alarms are cleared, they will drop out of the rotation.

I'm sure there's something on this already, but I couldn't find it b/c I'm not sure what to call it! Anybody done this before and have an example they'd be willing to share?

And FYI, b/c of my particular situation, no, I cannot use the built in alarm function on the HMI that would normally do this for you...gotta do it this way.
 
Set up your conditions to produce your bits 1 - 15.
No error : errorWord = 0
if errorWord > 0 then cycle through the bits (using a 6 second timer) and set Int1 to whatever bit is set (bit 6; Int1=6)
 
That function could be done with Sequencer instructions. For each alarm, a number is added to the sequence using the Sequencer Load (SQL) instruction. The Sequencer Output (SQO) is triggered every X seconds, and it then sends out each alarm, one at a time, for however many is in the stack. You can use a self-resetting timer to rotate the alarms.

You would have to add logic to remove alarms from the sequence. This might be done by using RES (Reset) at the end of the SQO (when DN goes ON) to remove all alarms, then use SQL to reload with the current valid alarms.

Dan's method is much better.
 
Last edited:
Set up your conditions to produce your bits 1 - 15.
No error : errorWord = 0
if errorWord > 0 then cycle through the bits (using a 6 second timer) and set Int1 to whatever bit is set (bit 6; Int1=6)

I see what you're saying...but this is the part that gets me.

So if bit 1 becomes active, then INT1 = 1, if bit 3 becomes active then INT1 = 3....how do I make INT1 = 1 for 6 seconds and then IMMEDIATELY = 3? It would have to ignore the fact that bit 2 is NOT set. And then after 3 is displayed for 6 seconds, it needs to skip 4-15 and IMMEDIATELY come back to bit 1.

I don't want to change INT1 to "3" and then leave it there while I wait 6 seconds for bit 4, 5, 6, etc until I get back around to bit 1. This would cause Alarm 1 to display for 12 seconds, and Alarm 3 to display for 78 seconds.

Or am I misunderstanding you??
 
That function could be done with Sequencer instructions. For each alarm, a number is added to the sequence using the Sequencer Load (SQL) instruction. The Sequencer Output (SQO) is triggered every X seconds, and it then sends out each alarm, one at a time, for however many is in the stack. You can use a self-resetting timer to rotate the alarms.

You would have to add logic to remove alarms from the sequence. This might be done by using RES (Reset) at the end of the SQO (when DN goes ON) to remove all alarms, then use SQL to reload with the current valid alarms.

I did consider this...and I also considered loading/unloading a FIFO, but I hated to come up with something so complicated! If I have to, than so be it, but I thought someone might have a simple solution I was just overlooking!
 
I would say as each alarm gets set, send that alarm number to an array or stack incrementing a counter each time a new alarm gets set, every second or 2 (however long you want each one to be displayed) index to the next array element, use the counter acc to know when to reset back to the first alarm.
 
Use an ADD instruction to increment the testing pointer to the bit number (indirectly addressed) - this is done each scan if you're not busy displaying an error.
If you're not busy displaying an error, and you find a bit set, seal-in a rung to run the timer and move the bit number into Int1.
When the timer expires, return to indexing (ADDing) away at the bits.
 
Hmm mine is just the manual way of doing what Lancie said...I do agree though dan does seem to have a better/simpler idea
 
Heres another way to do it.

Steve

OOps forgot to modify the equals comparisons (cut & paste)
 
Last edited:
Atatched is one way of sequencing up to 32 alarms (bits set in a DINT) to a number which is held for a time.

Unzip and import it as a routine.

Bernie....this is totally genius. Exactly what I was looking for!

Nehpets, I'm sure your way is good too...I just got to Bernie's first! Thanks guys!
 

Similar Topics

Today I was making an online edit to a 5/40 Series E Rev K.2 with about 14% free memory. I was removing one branch in a large rung. Accept...
Replies
4
Views
3,167
I have 2 pumps not alternating at a lift station. When im at the panel and use the test switches to initiate the pumps,it alternates in the PLC...
Replies
22
Views
5,833
Hello I have been thinking in some way to operate 3 pumps in the same way (I have schneider modicon m340 PLC): -the pumps feed a tank. - As...
Replies
3
Views
1,876
Hi Everyone, trying to get an alternating output to work. Read through the forums on flip flop, toggle, etc. Found this site...
Replies
5
Views
4,217
Hi I'm kinda new at PLC programming sorta teaching myself. I need to alternate between two motors run one till satisfied the when it calls again...
Replies
2
Views
1,498
Back
Top Bottom