DATA BLOCK TABLE
I have started to use a data block table to store groups of recipes.
Everything works fine for numerical data BUT my application also has BOOLEAN settings associated with each recipe. There are pumps, valves and motors each requiring different ON/OFF states within each recipe.
Each is assigned a unique bit within an WORD in the PLC data table.
So far the ONLY way I can think of getting this to work is to assign a a full WORD in the NS for each BOOLEAN state and the combine all words with multiple OR statements. The result can then be written to the PLC WORD.
For example:-
Pump 1 uses BOOLEAN H2.00 in the PLC and WORD $HW0 as a FIELD in the DATA BLOCK TABLE of the NS-Screen.
Pump 2 uses BOOLEAN H2.01 in the PLC and WORD $HW1 as a FIELD in the DATA BLOCK TABLE of the NS-Screen.
Pump 3 uses BOOLEAN H2.02 in the PLC and WORD $HW1 as a FIELD in the DATA BLOCK TABLE of the NS-Screen.
etc. etc.
When
Pump 1 is ON then H2.00 is ON and $HW0 = 1 [Turn on bit 0 of $HW0], IF OFF $HW0 = 0 and H2.00 is OFF.
Pump 2 is ON then H2.01 is ON and $HW1 = 2 [Turn on bit 1 of $HW1], IF OFF $HW1 = 0 and H2.01 is ON
Pump 3 is ON then H2.02 is ON and $HW2= 4 [Turn on bit 2 of $HW2], IF OFF $HW2 = 0 and H2.00 is OFF
etc. etc.
The DATA BLOCK TABLES use an $HW word for each FIELD.
Combining all $HW words using multiple OR statements could then be written to the PLC's HW2 word thus representing all BOOLEAN states in each recipe.
So IF recipe requires the following BOOLEAN states:-
PUMP 1=ON then $HW0 = 1 = [0000000000000001]
PUMP 2=OFF then $HW1 = 0 = [000000000000000]
PUMP 3=ON then $HW2 = 4 = [0000000000000100]
Result of multiple OR's is 0000000000000101 is now written to WORD H2.00 in the PLC.
This seems an overly complicated way to incorporate BOOLEAN states as individual FIELDS within DATA BLOCK TABLES.
I also will need to figure out how to show ON or OFF text in each FIELD versus a value.
For example:-
$HW0 = 0 display OFF in data table FIELD for PUMP 1.
$HW2 = 4 display ON in data table FIELD for PUMP 3.
.
I'M REALLY STUMPED ON THIS ONE!!
AM I MAKING THIS WAY TOO COMPLICATED?
ANY ONE HAVE SOME SUGGESTIONS!!!
Question 2
In relation to the above anyone know the macro syntax [if it works] for the following problems:-
16 consecutive NS internal BOOLEAN bits $B100 thru $B115.
1 NS internal WORD $W100.
Need to copy the state of all 16 bits to the word.
Copy the value of the word to all 16 bits.
1 NS internal WORD $W200.
What macro syntax could be used to examine the BOOLEAN state of individual bits in $W200.
What macro syntax could be used to change the BOOLEAN state of individual bits in $W200.
ANY IDEAS??