0

I have FXCPU PLC FX3G series and I create ST Structured Project in GX Works 2. The problem is I cannot loop through an array of bits. Here are my local variables.

enter image description here

Now this code in a program compiles with error

(* Do not compile! *)
FOR iCount := 0 TO 2 DO
    arOfBits[iCount] := TRUE;
END_FOR;

But this code works fine

(* Compile *)
arOfBits[1] := TRUE;

The compile error as follows

       No.: 1
    Result: Error
 Data Name: POU_01
     Class: Program compile
   Content: An invalid device OR an invalid constant is being used
Error Code: F0137

If that would be array of Words that would work fine in both examples. If it would be array of STRUCT where one property there is bit and another is WORD, then both examples would work with WORD but only the last example with bit.

The nature of the problem is that if I use Device like D100 or variable as is in example I cannot access bits but only words. To access bits, I have to use constant as array index.

Does anyone know how to address this issue?

Sergey Romanov
  • 2,949
  • 4
  • 23
  • 38
  • This really seems like a limitation of this PLC or even a bug (I've seen things like this in other brands). As workarounds, apparently you tried to point directly to a memory instead of using a symbolic variable which is what I would try... if it's really important to use a array, have you considered using an `BYTE ARRAY` and saving `0` or `1` and then convert when needed? – dwpessoa Oct 27 '22 at 17:22
  • Thank you @dwpessoa. This is what I do currently just try to access individual bits as memory address. But that does not allow me to do everything I need. For instance I have array of timers TC**. Those are bits and I need to pass that exact bit but not a bit that tells if it is ON or OFF. I mean I need to refer to it. I have just started to learn the IDE. Read only 500 pages of documentation so far. Arounf 1000 left, may be I'll yet find a solution. There is no BYTE array I can only make WORD array. But in this case, it is too big and memory only 32k. – Sergey Romanov Oct 28 '22 at 04:31

0 Answers0