Step 5 Conditionally loading data

M

Thread Starter

Malc

I am using bits for the status of a device and converting this to an integer for the HMI. I wish to check if the Bit is true then set the correct integer value (like a CASE statement). This will be done in a program block, hense I shall not be using Labels and it is not done at the end so I can't use BEU.

If all else fails I shall set/reset all the bits to create the integer but this is very confussing to read and wasteful.

Can you help.....
 
S

Scott Gramling

Can you send me what you have so far on this? I have some ideas but would like to see if I can explain it in your code. By the BEU command I see that you're using STL.

Scott
[email protected]
 
You can use JC and jump to a dedicated PB or FB and set your integer in there.

The other ways I know, is to use SF.. Set Flag, SS..Set S flag, or SD... Set bit a data block.
 
D

Donald Pittendrigh

Hi All

You can conditionally jump to a label or conditionally jump to a block of code or do an arithmetic calculation to work out the right number, but in a program block as you can't calculate or jump (as you have pointed out) you have to do a series of load and transfer operations interspersed with logic and BEC (block end conditional) statements :

load integer for condition 1
transfer to resultant register
query logic condition
1 block end conditional
load integer for condition 2
transfer to resultant register
query logic condition 2
block end conditional
load integer for condition 3
transfer to resultant register
query logic condition 3
block end conditional

Good luck

Cheers Donald P
 
Top