Sequencing problem has me stumped.

rta53

Lifetime Supporting Member
Join Date
Feb 2003
Location
North Carolina
Posts
619
I am working on an RSLogix 500 project that has me very frustrated. I had already done this program for a ML1200 and it works fine. The basic program opens 5 different solenoids at 5 minute intervals to measure water quality. I won't get into the specifics of the system. All I am doing is opening SV-101 for 5 minutes and then at the end of the cycle I move an analog value into a word buffer and then close the solenoid. I then open SV-102 for 5 minutes........and so on until I cycle through all 5 solenoids and then start back at the first one. This process continually repeats itself. I just have the done bit of one timer start the next timer. Pretty simple. Well now I have been told to come up with a way to change the order of the sampling. Instead of 1-2-3-4-5 they want to be able to do 3-1-2-5-4 or whatever. I have tried and tried to figure out a way to do this but nothing has worked so far. Oh, the way the operator will change the order is to have 5 multistate push buttons each numbered 1 to 5 on a PanelView. Below is part of my existing program. B3:0/0 starts the process and after solenoid SV-105 timer (T4:5.DN) finishes it resets the process. I have spent several hours trying different solutions. :confused:

seq.jpg
 
I'd do it this way. Have the multi-state pushbuttons set numbers in 5 different integers. So you have 1,2,3,4,5 in the integers in any order. You may have to have logic to ensure there's one of each if the operators can't be trusted to set that properly. Then start your 5 minute timer. Have it's 'DN' output trigger a counter. For each solenoid, see if the count is equal to that assigned to that solenoid. Do whatever outputs you need. Store the value into the proper register the allow the 'DN' bit to go to the next one.
 
Sounds like a job for.....

Indirect Addressing!

I'm rushed, so I'm just going to post some code, with a brief explanation:

[attachment]

Registers N20:1 through 5 contain the order that you want to run the valves (1-2-3-4-5, or 3-1-2-4-5, or whatever (even 1-1-1-1-1).

Not shown is how you program which valve goes on which step.

One way (if they have their hearts set on using 5 buttons on the panelview) is to change the value in the N20 file being pointed to by N19:0 (e.g., MOV x N20[N19:0]) depending on which button is pushed. That is, the sequence may start 1-2-3-4-5, and if they press the "3" button on step 1, then the new sequence would be 3-2-3-4-5. When valve 2 starts on step 2, they press the 1, and valve 2 closes, valve 1 opens, and the sequence is programmed 3-1-3-4-5. And so forth.

Another method would be to have a "Learn Mode", which would have a different pointer move through the sequence on a button press, and load the value of the button into the sequencer.

Good luck

plcnet.jpg
 
Bernie,
I do have an integer for each pushbutton and I also plan to put the start/stop bit on the first rung of each solenoid sequence followed by an equal to instruction. The 1 pushbutton position in the integer is a 0 so that would tell my logic which solenoid to start first. I'm still studying your suggestion about the counter.

Allen,

Indirect addressing is the first thing I thought of but never could get it to work right. I will try again.
Thanks
 
Last edited:
Using Bernie's idea I came up with this very simple way of doing this but it seems to work. Anyone see any problems with this? I did just 3 sequences for test purposes. N14:3, N14:4, & N14:5 are my 3 pushbuttons. Hopefully this is not too hard to see for you(us) old guys.

timer3.jpg
 
You may have to have logic to ensure there's one of each if the operators can't be trusted to set that properly

ok, this is got me stumped too. How can I verify that 5 integers each have different values without using a ton of not equal to instructions?
 
Indirect addressing to the rescue!!!

Here's a quick test to see if each value is unique and in range:

[attachment]

If you've got two of the same values in N24:3, N24:4, or N24:5, the same bit in N30:0 will be set twice, and therefore one bit won't be set. Therefore the expected value won't be right.

The value is 14 because bits 1, 2, and 3 are set. (2+4+8 = 14). For 5 words, the expected answer is 62 (assuming values of 1,2,3,4 and 5, in any order).

There's still the question of what you are going to do if the data is wrong, or how you are going to get the right data in there in the first place.



My method and Bernie's aren't all that different.
Bernie's determines what step a valve is open on.
Mine determines which valve is open on a step.

With Bernie's, you have the potential problem of opening two valves on the same step.
With mine, you have the problem of opening the same valve on different steps.
I have no idea which consequence is worse.



BUG ALERT. Oops. I realized after posting that if the value of one of the N24 words change, then there will be nothing driving that bit, and so the bit will remain set. The solution is to CLR N30:0 before the logic above, so that the only bits set will be those with the current values of the N24 words.

plcnet.jpg
 
Last edited:
rta53 said:


ok, this is got me stumped too. How can I verify that 5 integers each have different values without using a ton of not equal to instructions?
You could program a series of search instructions. Search the N20 file for '1', then '2', etc. If you detect multiple hits on any given search argument some action can be taken. I'm not too familiar with the micrologix. Does it have a built in search function? If so, the position of all matches could be noted and easily presented to the operator for correction.
 
Re: Indirect addressing to the rescue!!!

Allen Nelson said:

There's still the question of what you are going to do if the data is wrong, or how you are going to get the right data in there in the first place.

I still like the idea of a separate "Learn Mode" screen.
On the screen, have the 5 valve buttons (multistate, 2 states, with indicator feedback), and a "LEARN" button.

Sequence:

1) LEARN is pressed.
- Set LEARN MODE bit
- Counter is set to one.

2-6) Each of the valve buttons is pressed in turn.
If Button_X_Already_Pressed = False, then:
- Value of Counter is moved into corresponding VALVE address (buffer register, not the N24: one being used by the sequence)
- Set Button_X_Already_Pressed flag (This bit, one for each button, is the indicator for the PV button, which will cause it's appearance to "Grey out". This tells the operator that it's been "used" and can't be used again.)
- Advance the Counter.

7) When Counter reaches greater than 5, OR, if LEARN button is pressed while LEARN MODE bit is set:
- Reset LEARN MODE bit.
- Reset all Button_X_Already_Pressed bits.

8) If Data_Valid (see code above),
- COPy VALVE addresses into N24:'s
 
Last edited:
Quickly...

SOR CPT N7:10 (N7:0+N7:1+N7:2+N7:3+N7:4) EOR
SOR EQU N7:10 15 OTE VALID_SEQUENCE EOR

Basically add all the entries together. If they don't equal 15 then they've duplicated a number.

grs
 
Allen,

You beat me to it. I was typing the same answer. I also wondered if multiplying the correct numbers would produce a unique value but I'm too tired to think about it.

Randy
 
:D

Ok, it was quick. And given the amount of cribbage I play I should've caught that.

But who says it has to be 1,2,3,4,5? Why not 1,2,4,8,16 or something else?

grs
 
grs said:
Why not 1,2,4,8,16 or something else?

That's essentially what my solution does - turns 1,2,3,4,5 into 2,4,8,16,32 and then adds them together.



Randy:

You seem reluctant to use indirect addressing? Can you post an example of the code that you "never could get ... to work right"?
 
Last edited:

Similar Topics

Does anyone have sample logic with conveyors that start and stop according to product on the line?
Replies
1
Views
116
Hello, I am struggling to figure out some logic. I have an analog pressure sensor coming into the PLC and would like to have multiple timing...
Replies
4
Views
166
One of my customers builds equipment with a MicroLogix 1100 using a program I wrote some years ago. Now he wants to transition to a Micro 820...
Replies
1
Views
1,863
Well Gentlemen, once again, I am trying to figure out how to do something in Logix, and I cannot seem to get it to work like all the YouTube...
Replies
13
Views
2,949
I need to make a sequence of lights flash on and off in automation studios using AB PLC. I have to use timers and counters. The required sequence...
Replies
51
Views
13,595
Back
Top Bottom