Schneider Unity Pro indirect bit addressing

sarahc

Member
Join Date
Oct 2005
Location
Waikato, NZ
Posts
22
I have to check 1024 (sequential) bits for change of state in any of the bits and record which bit changed.
I was going to do something like this:

A = ARRAY[0..63] OF INT (gives me 1024 bits to check)
B = ARRAY[0..63] OF INT (reference array to compare against)
WordIndex = INT
BitIndex = INT
Res = INT (record bit location)

FOR (WordIndex :=0 TO 63) DO
FOR (BitIndex :=0 TO 15) DO
IF A[WordIndex].[BitIndex] NE B[WordIndex].[BitIndex] THEN
B[WordIndex].[BitIndex] := A[WordIndex].[BitIndex];
Res := (WordIndex*16) + BitIndex;
(other stuff) ;
END_IF;
END_FOR;
END_FOR;

Only problem is that Unity won't let me reference the bits in the word like this.
A[WordIndex].0 is fine, A[WordIndex].[BitIndex] is not.
Is my syntax wrong or is this not possible?
 
They're working you late over the hill there!

I don't believe you can reference the individual bits like that. Square brackets denote an array, which the individual bits in the word technically aren't.

You might need to use one of the type conversion EFBs to break out the individual bits as type bool and then compare. I'd use two arrays of type bool then you can loop through the elements kinda like how you were thinking.

But i have a question. .. what if more than one bit in this array of 1024 changes state? Result will only hold the bit that changed in the higest word that had a change (i.e. if word 5 and word 20 both had a bit change then only the bit in word 20 would be recorded as it gets checked last).

I guess it would be useful to know what this logic is trying to achieve.

If i was just trying to see IF a bit changed but wasn't concerned with which one, then I'd just use an XOR of the current array with a copy of the array from the last scan. Then check each word for non-zero.
 
Can you use bool array: "array [0..1023] of bool" then loop trought 0..1023 or 1..1024 same way than now, depending if you start array with 0 or 1.
 
Saffa - in this weather rather be working late at home curled up in front of the fire than working on site - currently a mudhole. Top of the new Lichfield drier disappears into the fog/low flying cloud.

As I'm only interested in bits turning on, previous logic discards any changes 1 -> 0.

The FOR loops then checks for the 1st changed bit, loads the location (0-1023) of the changed bit to a buffer, updates the reference array so that change is not detected again, then keeps looping until whole array checked.

Thought of using array of BOOLs which works fine for the processing of bits, but creates a problem when I have to load the ARRAY[0..1023] OF BOOL as the data comes from a ControlLogix in format INT[32]. So I'd have to somehow get INTs to BOOL maybe using EXTRACT?
 
Had a suggestion from another forum to use a mask and Shift Left to check the bits in the word which I think will do the job for me.

FOR (WordIndex :=0 TO 63) DO
FOR (BitIndex :=0 TO 15) DO
wMask := SHL(16#0001, BitIndex );
IF A[WordIndex] AND wMask NE B[WordIndex] AND wMask THEN
B[WordIndex] := B[WordIndex] OR (A[WordIndex] AND wMask);
Res := (WordIndex*16) + BitIndex;
(other stuff) ;
END_IF;
END_FOR;
END_FOR;
 
Not always!

This (or equivalent code) is going to run on 100's of PLCs:
- PLC5
- ControlLogix L55 - L73 and everything in between
- Quantum 140 CPU 113 02 to 140 CPU 652 60 and everything in between
- M340
- M580
- and maybe more....

Already done the Logix 5 and Logix 5000 code, still to do Concept and 984.
What fun.
 
The Quantum 140 CPU 113 has been obsolete for nearly a decade I thought? We swapped a few out for a newer (but still LL984) processors for a couple years ago.

Running the code you have now in ST -execution in one scan. Probably not too much sweat for an M580. Trying to do the same in LL984.. painful.

Probably quicker to import that ol LL984 into a new unity quantum and stick your newly imported bit checker DFB in on top.
 

Similar Topics

Hi, I've exported a PL7 application to the .FEF file succesfully. Imported the .FEF file in my Unity Pro project, but two of the five sections in...
Replies
0
Views
766
I want transfer my I/O data from schneider (Unity Pro) as a write data and RS Logix 5000 as a read data. I use Ethernet as an communication...
Replies
0
Views
689
Is there a tool to convert a ControlExpert project (.sta, .ztx or .zef in v14.1 or v15) to be opened using Unity Pro (v11 or V10) ? Thanks,
Replies
6
Views
2,218
Hi all, I'm sure this is a stupidly simple question, but I'm really struggling to find any EFB or similar to do this. I want to map a block of...
Replies
10
Views
3,381
Hi All, Can anyone explain to me: 1) What are 'PLC initialisation values", 2) What are 'Local initialisation values', and 3) Why I am getting a...
Replies
5
Views
7,671
Back
Top Bottom