Hi guys! need your help for proper syntax in calling a function block using structured text since i am a total noob in ST! this is kinda basic for those using ST but iv been trying to figure how to do this for 2 days and i just can't seem to get it so im seeking enlightenment again from the gurus =D
so here's what i want to do:
1. I have a function block, ill call it "Block" with "Start" and "Stop" Inputs and 1 output "Out"
2. i want to call the function block 10 times using the FOR instruction (so i have 10 different "start" and "stop" inputs, and 10 "out" outputs... i can have them named as start1, start2...start10, etc.)
*i use an integer variable "i" to correspond to the block # called
3. My expected output is to have 10 different outputs corresponding to their inputs by using just this one call function.
* I can do this in ladder by calling the function block and assigning the variables individually but it would be very tedious to do it if i have 100 blocks!
Here's what i did so far:
declare:
i as integer
Block1 as Block
Block2 as Block
.
.
.
Block10 as Block
---
Start1 as In_Var for Block
Start2 as InVar for Block
.
.
.
Start10 as InVar for Block
Stop1 as In_Var for Block
Stop2 as InVar for Block
.
.
.
Stop10 as InVar for Block
Out1 as Out_Var for Block
Out2 as Out_Var for Block
.
.
.
Out10 as Out_Var for Block
---
FOR i:=1 TO 10 BY 1 DO
Block(
in_start:= Start,
in_stop:= Stop);
out:=Block.out
END_FOR
*** im still stuck with Ladder programming so its kinda hard for me to figure out how to do this properly... im still confused whether "i" should be integer or array or if the "block" and inputs and outputs should be array! as i said, total noob to ST programming! but i can see the benefits of learning it so i have to try =) hope to be enlightened on this =))
so here's what i want to do:
1. I have a function block, ill call it "Block" with "Start" and "Stop" Inputs and 1 output "Out"
2. i want to call the function block 10 times using the FOR instruction (so i have 10 different "start" and "stop" inputs, and 10 "out" outputs... i can have them named as start1, start2...start10, etc.)
*i use an integer variable "i" to correspond to the block # called
3. My expected output is to have 10 different outputs corresponding to their inputs by using just this one call function.
* I can do this in ladder by calling the function block and assigning the variables individually but it would be very tedious to do it if i have 100 blocks!
Here's what i did so far:
declare:
i as integer
Block1 as Block
Block2 as Block
.
.
.
Block10 as Block
---
Start1 as In_Var for Block
Start2 as InVar for Block
.
.
.
Start10 as InVar for Block
Stop1 as In_Var for Block
Stop2 as InVar for Block
.
.
.
Stop10 as InVar for Block
Out1 as Out_Var for Block
Out2 as Out_Var for Block
.
.
.
Out10 as Out_Var for Block
---
FOR i:=1 TO 10 BY 1 DO
Block(
in_start:= Start,
in_stop:= Stop);
out:=Block.out
END_FOR
*** im still stuck with Ladder programming so its kinda hard for me to figure out how to do this properly... im still confused whether "i" should be integer or array or if the "block" and inputs and outputs should be array! as i said, total noob to ST programming! but i can see the benefits of learning it so i have to try =) hope to be enlightened on this =))