struglling to alternate pumps

One simple way to do this is to use a one-shot and an add instruction to add 1 to an integer. Whenever you add 1 to a number, the last bit of that integer will alternate. Therefore, you can use the last bit of that integer to control your pumps.

If you are worried about an overflow, move 0 into the value when it is an even number. If you wish to bypass the alternator because one of the pumps is faulted, you can just move a 0 or 1 into the integer depending on which pump you want to run.
 
One simple way to do this is to use a one-shot and an add instruction to add 1 to an integer. (1) Whenever you add 1 to a number, the last bit of that integer will alternate. Therefore, you can use the last bit of that integer to control your pumps.

If you are worried about an overflow, move 0 into the value when it is an even number. If you wish to bypass the alternator because one of the pumps is faulted, you can just move a 0 or 1 into the integer depending on which pump you want to run.

(1) "last bit" could mean lowest order bit, or highest order bit, depending on interpretation. Much better to say "bit 0 of the integer"

In most cases for a "toggle", I would use a counter, the ONS is buit-in, and it will just count forever, with bit 0 of the accumulator toggling on and off each time the counter is newly enabled.

There's no need to worry about overflow conditions, they are just flagged up with status bits you can safely ignore, and there's no need to kick it back to zero, as it will "rollover" when "full" into numerical territory you can ignore.

A counter's accumulator value is also retentive during power outages etc., unlike some "toggle" solutions I have seen.

I strongly believe a toggled bit should NOT be reset by the processor restarting, that should be actioned by the logic, if required.
 
(1) "last bit" could mean lowest order bit, or highest order bit, depending on interpretation. Much better to say "bit 0 of the integer"

In most cases for a "toggle", I would use a counter, the ONS is buit-in, and it will just count forever, with bit 0 of the accumulator toggling on and off each time the counter is newly enabled.

There's no need to worry about overflow conditions, they are just flagged up with status bits you can safely ignore, and there's no need to kick it back to zero, as it will "rollover" when "full" into numerical territory you can ignore.

A counter's accumulator value is also retentive during power outages etc., unlike some "toggle" solutions I have seen.

I strongly believe a toggled bit should NOT be reset by the processor restarting, that should be actioned by the logic, if required.

Would please provide sample for your method ?
 
One simple way to do this is to use a one-shot and an add instruction to add 1 to an integer. Whenever you add 1 to a number, the last bit of that integer will alternate. Therefore, you can use the last bit of that integer to control your pumps.

If you are worried about an overflow, move 0 into the value when it is an even number. If you wish to bypass the alternator because one of the pumps is faulted, you can just move a 0 or 1 into the integer depending on which pump you want to run.

I have used this method before assign a number to reset it before you ever reach the overflow value
 
Why wouldn't you want the PLC to come up in a known off "good" state?

For the very simple fact that the PLC cannot determine that the OFF state is the correct state - that decision is down to the programmer and the application that the toggle is used in. Toggled bits are used for many things, and while some need to be reset on processor restart, some don't....

The PLC should never ever assume it knows what is right and wrong. It is only the programmer and designer of the system who know what those reasons are.

A bit in memory should come back after a power outage or whatever in the same state, and it is up to the program designer and coder to decide whether it should, or should not be reset when the processor restarts. This mirrors exactly the behaviour of a "latched" bit.
 
I have used this method before assign a number to reset it before you ever reach the overflow value

the overflow is not a problem, it is only a status you can monitor, or ignore. You don't need the additional code to reset the "accumulator".

2,147,483,647 + 1 = -2,147,483,648

In the binary world of maths, bit 0 just keeps on toggling, forever !
 

Similar Topics

Hello All, I want to publish my data in sql server in Excel format as daily report. And xl reported pro version seem to be much expensive which...
Replies
1
Views
496
I'm looking for alternate module that I can use in place of Rockwell 5069-IO mainly for safety output card (OBV8S). Looking at the lead time, I...
Replies
2
Views
1,200
Good morning everybody, I hope you are very well. I share with you the information of the PLC LOGO! Siemens and expansions that we have...
Replies
4
Views
1,097
Hello All, Currently I am migrating S7 300 to S7 1500 & I am unable to use DP send & receive data from Master PLC. Which instruction is...
Replies
4
Views
1,640
Hi guys Do you have some experiences with Power Analyzers such as Siemens SENTRON PAC4200?.. I have alternative analyzer installed on machine...
Replies
6
Views
2,055
Back
Top Bottom