Hopefully someone can put me right here
I've wrote the following which should function as follows:
Scan x no of Bits (Highest to Lowest) and if a '1' is found move the current loop count to x Register
User specifies how many bits to scan (Decrementing)
User specifies how many consecutive registers to store results
e.g if set to 5,
register 1 will hold the highest result
register 2 next highest
register 3 etc
register 5 will hold the lowest result.
The Loop will exit either when 5 results are found or loop completes.
PLC is currently Omron but will need to be ported to Mitsi & S7
Here's what i have done but Line 6 has issues.
Variables
INPUT
iMaxBits INT
iMaxLines INT
bStartAddress BOOL
INTERNALS
iLine INT
iBits INT
Code
Errors i get are as follows
ERROR: Line 6: Invalid array index
ERROR: Line 6: Unexpected syntax '['
ERROR: Line 6: Missing THEN
ERROR: Line 6: Missing :=
Line 6 is the following!
IF bStartAddress[iBits] THEN
ERROR: Line 6: Invalid array index
i dont want to hardcode array limits
ERROR: Line 6: Unexpected syntax '['
I thought this was ok for indirect addressing?
ERROR: Line 6: Missing THEN
ERROR: Line 6: Missing :=
Red herring caused by []??
Really would apprieciate some help with this.
Thanks
I've wrote the following which should function as follows:
Scan x no of Bits (Highest to Lowest) and if a '1' is found move the current loop count to x Register
User specifies how many bits to scan (Decrementing)
User specifies how many consecutive registers to store results
e.g if set to 5,
register 1 will hold the highest result
register 2 next highest
register 3 etc
register 5 will hold the lowest result.
The Loop will exit either when 5 results are found or loop completes.
PLC is currently Omron but will need to be ported to Mitsi & S7
Here's what i have done but Line 6 has issues.
Variables
INPUT
iMaxBits INT
iMaxLines INT
bStartAddress BOOL
INTERNALS
iLine INT
iBits INT
Code
Code:
iLine := 1;
iBits :=501;
REPEAT
iBits := iBits -1;
IF bStartAddress[iBits] THEN
iLine := iBits;
iLine := iLine + 1;
END_IF;
UNTIL (iMaxBits) <= 0 OR (iLine >iMaxLines)
END_REPEAT;
ERROR: Line 6: Invalid array index
ERROR: Line 6: Unexpected syntax '['
ERROR: Line 6: Missing THEN
ERROR: Line 6: Missing :=
Line 6 is the following!
IF bStartAddress[iBits] THEN
ERROR: Line 6: Invalid array index
i dont want to hardcode array limits
ERROR: Line 6: Unexpected syntax '['
I thought this was ok for indirect addressing?
ERROR: Line 6: Missing THEN
ERROR: Line 6: Missing :=
Red herring caused by []??
Really would apprieciate some help with this.
Thanks