How to re-initialize tags to certain values after a power loss?

RNilsson

Member
Join Date
Jan 2020
Location
Stockholm
Posts
3
Hello, PLC rookie here working with an AB CompactLogix LI6ER in RSlogix 5000. So far I've only used structured text.

I'm working on an application where the power to the PLC module gets cut on a daily basis. On power up I want some tag values to not be retained and instead start at zero. I tried using the S:FS bit to do this but it seems it only works when I toggle the run/program switch. On power off -> on it seems like this bit isn't set on the first pass.

Is this something I should handle in the power-up handler instead?
 
Hey!

It's a mix of DINTs and booleans. Mostly counters and some status bits.

I guess I should elaborate a little on the system. It's basically a conveyor that should start as soon as the PLC is done initializing. There's zero interaction with the PLC from the operator, so no push buttons etc except for a breaker to the conveyor power that has nothing to do with the PLC. Sensors check the load on the conveyor and the PLC then controls parameters like speed, stacklights, hydraulic valves etc based on the information.
 
S:FS is something I've never had a problem with. It behaves as you describe on a power up as well.

You can of course just use the S:FS and mov commands to write the values on power up, or latch and unlatch bits for bools.

If they are not getting written elsewhere during a normal cycle, then those values will remain from the S:FS

Useful info here:
http://www.plctalk.net/qanda/showthread.php?t=109974
 
A sure way is to program your own FirstScanBit at the END of your routine. That way the bit will not be on for the first scan whether it is powerup or program/run.

Use your bits to zero out the numbers and unlatch or latch bits.

Beware of latching bits though, if later there is an OTE that would turn it off if the rung were false a latched bit will stay on.

For that have a rung with :

BST XIC ConveyorOn NXB XIO FirstScanBit BND OTE ConveyorOn

That way your first scan will activate the conveyor bit and once it's on it will stay on until the other line turns it off.
 
S:FS should without exception be on for the first scan whether the processor has switched from program to run, or been power cycled. If your logic isn't behaving as you expect, I'd bet significantly more than Ron Beaufort's pocket change that the S:FS bit itself is not your culprit. You can prove it with a simple test rung:
Code:
|    S:FS          Test_Bit
|-----| |------------( L )--|
|

Turn the Test Bit off then power cycle the PLC. When it powers up, go back online and your bit should be on. Provided the routine you placed the test rung in is being executed and so on.

That said, you may not need that bit at all. All tags in any Allen-Bradley PLC are retentive. You set a DINT to 12345 or a REAL to 123.456 or a STRING to "IPityTheFool", and after a power cycle, that's exactly what they'll still be. The only way to change them is to have logic that does so (or directly manipulate them in the tag browser, of course).

The exceptions are things like timers and BOOL instructions that are attached to an OTE instruction (but not OTL/OTU). The AB PLC's run a prescan before the actual "first scan". There is quite a lot of nuance to how it works, and a lot of great threads on the topic (particularly by the aforementioned Ron Beaufort). But the short version is, before the PLC starts executing code in the traditional sense, it will scan through the program once. It will turn off any bits that have been attached to an OTE anywhere in the program, reset any non-retentive timers, and so on. It won't change counters, retentive timers, DINT's, REAL's, STRING's, or any bits that aren't attached to an OTE. So depending on what you're trying to achieve, you may find that it works that way by default, and your solution is actually to remove the "startup logic" you've put in to try to achieve the same end!
 
The simplest way is to create a task that is called on the first scan
put all data moves in it
it will only run on the first scan
 
Something to consider....

The Power-up Handler only runs on a power cycle in Run or Remote Run mode. It does not execute on a transition from Program to Run. That would be if you were in Run and lost power. Then power returned and it powers up into Run. Also if you have the SD card configured to automatically load the application and enter Run on power up.

I believe it does not execute if you cycle power in Program mode and then on power up manually switch to Run. I'd want to verify that though.

The S:FS is SET on any transition from Program to Run as well as on power up.

So you could use the Power-up Handler to recover following a power cycle while running. But use S:FS for any change from Program to Run.

Just food for thought.

OG

OG
 
Thanks for the input everyone, I managed to solve the problem :)

As you all said, S:FS is set on first pass on power-up. My issue was that I was running most I/Os over an ArmorBlock which caused enough latency between some system parts that the desired behaviour didn't display on power up, but did when I toggled the run/program switch on the PLC. Everything's working now with some logic to account for the latency.

Thanks for the help!
 

Similar Topics

When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
137
"Failed to Initialize the service {3F883B87-2208-11D4-B0E7-001083022E04}" Along with "Failed to load HMI Server Service" Hello, I am getting...
Replies
2
Views
705
Hey all, I have a local STRING tag inside of an AOI. I want to initialize it with a value INSIDE of the AOI. For example, @ First scan...
Replies
9
Views
1,627
Hello Everyone! New guy here posting first time. I'm kind of lost with this, when I open my excel file I got this error message. Any one that can...
Replies
0
Views
1,332
Hi folks, I'm new to connected components and I have some projects coming up that require it. I am trying to initialize an array I created using...
Replies
1
Views
2,389
Back
Top Bottom