Help with Structured Text ST/SCL

STL???

Member
Join Date
Sep 2005
Location
UK
Posts
879
Hopefully someone can put me right here :confused:

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;
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
 
Wow, what is that ?
I dont recognize the editor.

Is it the new STEP7 v11 ?
Or STEP7 v10.5 for S7-1200 ?
Or maybe it is not for Siemens S7. Since you mentioned SCL i jumped to that it had to do with S7.

Anyway, the variable bStartAddress must be declared somewhere.
 
I did try to declare bStartAddress as an Array, but i dont have the option as a FB input (advanced is greyed out).

Will have to try a different approach. think ill try an SCL implementation first.

untitled12.jpg
 
Wow, what is that ?
I dont recognize the editor.

Is it the new STEP7 v11 ?
Or STEP7 v10.5 for S7-1200 ?
Or maybe it is not for Siemens S7. Since you mentioned SCL i jumped to that it had to do with S7.

Anyway, the variable bStartAddress must be declared somewhere.

Hi Jesper, its Omron's CX programmer ST editor, i mentioned SCL in the title because i thought the syntax is the same with it conforming to IEC whatever its called.
 
Unfortunately the various IEC programming softwares seems to disaggree on what "conforming" really means.

Somehow arrays must be declared somewhere. Try to look up arrays in the help files.
 
Limitation for arrays from an Omron manual. Use an INPUT_OUTPUT declaration for the array.

I have spent hours looking for that little nugget o_O
Couldn't find that on a dual layer manuals DVD.

annoyed with myself for not trying it.

Originally Posted by TurpoUrpo
Even then, you always need to have limits for your array. You have no option of myArray[0..iMax].
I found an array example being utilized in a FOR loop, seems the Array is defined with 1 element as size, but it is possible to access sizes greater than 1 because the PLC doesn't check bound sizes at Runtime.

i really need to get proficient with this stuff and stop losing so much time, seems the portability aspect is out of the window.

Thanks everyone for taking the time to read and reply.
 
Unfortunately the various IEC programming softwares seems to disaggree on what "conforming" really means.
The specfications are very vague in some areas. In many cases there compiler writer can implement things anyway he wants but can't break certain rules so there will be a lot of small variations in the implementation of the standard.
 
What PLC are you using?

The CJ range can have a ST section, rather than trying to do it in a FB.
From what you said, you wanted to search through an Array of booleans, find a '1', then load the position of that find into another register?

I'm assuming the reason for the FB is for portability/security?
 

Similar Topics

Hey guys, was hoping someone could give me a bit of advice here in a couple spots. I'll start off with my dumb code and explain after...
Replies
10
Views
2,825
Hi All, I'm really new to structured text. My PLC experience is mainly PLC5 (ladder), Omron (ladder), and Micro850 (function block). I'm trying...
Replies
3
Views
2,985
Good morning, Guys: I have a structured text (Rslogix 5000), i couldn't understand it. can anyone help me and explain its meaning. thanks!
Replies
7
Views
1,579
Hi all, this is a long one, so there's a TL;DR at the bottom :) I have a situation where I'm dragging data from an external database into a UDT...
Replies
9
Views
4,735
Hi all, I'm trying to assign the individual characters from a STRING data type to an array of BYTE's as below: text : STRING(5) := 'hello'; char...
Replies
7
Views
7,006
Back
Top Bottom