Why does this NOT re-cycle after delay

You can make it work. Add an GRT or GEQ to monitor when Station reaches 3 and then use that to trigger a RES on the timer and a CLR for Station. Put that rung above the timer so it will reset on the next scan instead of the same scan.

OG

Reset.JPG
 
Last edited:
I confirmed it works as originally conceived when there is work for it to do in other programs (by adding some stuff in the other programs). I just wont work by itself. Even adding the GRT above the timer didn't allow it to work as I thought and for the reason you said.

To verify this I placed CTRs in the same ladder looking for the changing state of STATION, but as you say, the entire ladder is evaluated before updates are made so it just blasts right through it and updates at the last evaluation. I don't see a way around that and I suppose I don't need to if it works otherwise.
 
Hmm. I have it running fine here. I also used the example of having the NOT DN ahead of the timer and removing the rung I suggested. I also used counters to verify the ADD instructions were triggering. My logic isn't EXACTLY the same but functionally it should be the same.


OG

Reset.JPG
 
Last edited:
Btw, the two instructions [BST GRT Station TotalStations NXB LES Station 1 BND] could be replaced by [LIM TotalStations Station 1]*, as long as TotalStations is greater than 1.

* or summat like that; LIM has special behavior when the first parameter is greater than the last parameter.
 
Ah yes, You right... I did remove the XIC in front of the timer and missed it. That does make it work.

I think I'm all good now... Thanks folks. Some days you just can't do it alone. :)
 
Btw, the two instructions [BST GRT Station TotalStations NXB LES Station 1 BND] could be replaced by [LIM TotalStations Station 1]*, as long as TotalStations is greater than 1.

* or summat like that; LIM has special behavior when the first parameter is greater than the last parameter.

I did put a LIM with the limits reversed in there at one point but removed it thinking it was obscuring something, I'll try it again. Can't remember if its inclusive or exclusive in that mode. I'll find out. :)
 
The limits are exclusive in that config. This means to use a LIM I have to create a value one larger than Total Stations to use as the upper limit. This adds another instruction so no real gain I can see.
 
3* appears to not be a station, is that correct?

* actually (TotalStations+1)

So ...

If none of the .EnableStation bits are 1
it's actually

  • 1, 2, pause, 1, 2, pause, ...
    • where "pause" is effectively equivalent to "3"
  • there is no station 3 (= TotalStations+1), so while Station is 3, nothing should happen other than the timer running.
Is that correct?
If any of the .EnableStation bits are 1
How should the behavior of Station change from the [no-.EnableStation bits = 1] case above?

When the station N .EnableStation bit is 1 and Station is N, should that prevent Station from incrementing away from N?
I agree with the others that your code, or something close to it, will do what you want, or at least what I think you want.

But I can't help thinking this code is more complicated than it needs to be for the desired behavior. There is "it works, I will move on" and "it works, but I want to be able to debug and/or modify it three months hence."


Did swapping the last two rungs appear to cause the pause, but not the repeat? Are you sure it was not repeating, with a minimal time (1-2 scans) between the end of one pause and the start of the next?
 
3* appears to not be a station, is that correct?
* actually (TotalStations+1)
So ...
If none of the .EnableStation bits are 1
it's actually
  • 1, 2, pause, 1, 2, pause, ...
    • where "pause" is effectively equivalent to "3"
  • there is no station 3 (= TotalStations+1), so while Station is 3, nothing should happen other than the timer running.
Is that correct?
Yes that is correct, 3 is "Pause" This number will increase to 50 or so as work progresses and stations are added.
If any of the .EnableStation bits are 1
How should the behavior of Station change from the [no-.EnableStation bits = 1] case above?

When the station N .EnableStation bit is 1 and Station is N, should that prevent Station from incrementing away from N?
I agree with the others that your code, or something close to it, will do what you want, or at least what I think you want.
If enabled they would be included in the sequence. Otherwise skipped.
But I can't help thinking this code is more complicated than it needs to be for the desired behavior. There is "it works, I will move on" and "it works, but I want to be able to debug and/or modify it three months hence."
I'm not above simplifying it, what did you have in mind.
Did swapping the last two rungs appear to cause the pause, but not the repeat? Are you sure it was not repeating, with a minimal time (1-2 scans) between the end of one pause and the start of the next?

Because of the speed I'm not sure what swapping the rungs did, It changed what it counted to, but still didn't present the entire sequence. In its present incantation they don't need to be swapped.
 
Last edited:
Y
Because of the speed I'm not sure what swapping the rungs did, It changed what it counted to, but still didn't present the entire sequence. In its present incantation they don't need to be swapped.


The swapped rungs were a quick fix to ensure the timer would reset (the OP said it only ran once and did not repeat): With the swapped rungs, Station would be 2 at the top of at least one scan, so the ORed GRT and LES instructions would both be False, and a False rung into the TON would reset the TON. Station was still counting from 1 to 3, but if there is now an [XIO PollCycleDelay.DN] in front of the TON, then the order of the EQU/ADD rungs does not matter.
 
Agreed, its working as predicted once I had it doing work and adding the XIO allowed it to work with no "loads".

Still curious about the simplification you mentioned.
 
I'm not above simplifying it, what did you have in mind.

If the [CLR Station] were changed to a [MOV 3 Station], then the [XIC EnablePolling] and [LES Station 1] instructions could be dropped.

yyy.png


Whether the [XIO ProcessCycleDelay.DN] is needed before the TON depends on how the other rungs are handled e.g. if they were done one per scan, on an array of objects that have the .Poll and .EnablePolling members, then that would reset the TON on its own. The other advantage is that it would not require a rung for each station; just one rung would handle all the stations, although it would occur over the course of [TotalStations] scans.
 
I can see the first point. Would require modifying 2 data points when the system count was increased. But that can be fixed with a CPT but that adds CPU cycles (not that those are at a premium here)

Second part I'm not sure I follow. I can see incrementing through a bit array to eliminate the rungs, but adding .enables to the array members would be more complex and maybe harder to follow?
 
[Update: it might make sense to change the [OTE B255:[STATION]] to an OTL, and AND the GEQ with a [GRT STATION 0], on Rung 0002 to ensure there are no indirect addressing errors if STATION goes out of the range [1:TotalStations+1]]



I can see the first point. Would require modifying 2 data points when the system count was increased. But that can be fixed with a CPT but that adds CPU cycles (not that those are at a premium here)


Actually, only the INT TotalStations needs to be modified when the system count is increased; see below. The array would also need to be expanded unless it was already sized large enough at the start, with its tail end unused.



... I can see incrementing through a bit array to eliminate the rungs, but adding .enables to the array members would be more complex and maybe harder to follow?


The ".enables" already exist in the per-station UDT, do they not? I see blur.EnableStation in the code in Post #1.

Anyway, see below for a working implementation. This code

  • increments through one station per scan, starting at station 1;
  • stops to poll any station that has a value of 1 in its .EnableStation bit*;
  • pauses for 2000s after the last station, as determined by TotalStations;
  • starts over with station 1 after the 2000ms pause.
* I assume either the polling process or something else would eventually put a 0 into that bit so incrementing through the stations could continue.

There is a PDF in the .ZIP. I did it with a MicroLogix, using Data File B255 as a proxy for the array of one-per-station structures with boolean members .EnableStation and .Poll.

xxx.png

yyy.png
 
Last edited:

Similar Topics

L P#0.0 T MW 20 A m0.0 L mw 20 + 2 T mw20 Why not increase during the cycle?
Replies
2
Views
1,800
I am trying to connect with a Schneider plc which has a firmware version only available in Somachine v4.2. In Machine expert After taking upload...
Replies
0
Views
112
They are installed in a control panel that was made in France and are intended for the termination of analog inputs. Each of the red capped...
Replies
4
Views
418
So, I'm really just trying to get some experience by practicing with arrays. I'm using studio 5000 v33. I have one rung with an XIC bit that's...
Replies
5
Views
229
Back
Top Bottom