extendedSolutions
Member
(subtitle: should I bother with structured text? AKA: Panasonic FP gurus please contact me.)
Newbie question, but hope someone can help me clarify some basic points. I do apologize if I am not using the right lingo for technical specifics, my background is more in embedded systems (microcontrollers) and classical software development (c, c++, python... hence my interest in Structured Text - ST) So please use some imagination while reading this post. Also, you will probably find some of my understandings inaccurate, please do point those out and correct me.
In ladder logic, each rung is equal, and all rungs (connected to power rail) are active at the beginning of each scan cycle. Since rungs are not executed sequentially, the programmer controls sequential behavior by triggering a cascade of coils (R registers for example.) I do not expect sequential execution from rung 1 to rung N, or should I?
In Structured Text, can I expect sequential execution of code line by line, or should I view ST as just a different way to specify ladder rungs? Below is an example of ST:
(* rung 1... *)
if( X1 ) Then
variableJJ := 5;
end_if;
(* rung 2.. 3...4.... 5... *)
(* rung 6 *)
if( X1 ) Then
variableJJ := 80;
end_if;
Should I expect (Scenario 1) rung 1 will execute first, then 2, 3, 4... and finally 6, in discrete time steps? Or (Scenario 2) should I read this as rung 1 and rung 6 both executes at the same time, and variableJJ could be 5 or 80, depending the how the compiler generates the instructions or a race condition in the CPU? or is it CASE 3, *you tell me.*.
If Scenario 1 is true, PLC programming in ST is great! I get free sequential features of single-thread programming without setting a bunch of coils. In this case, I can think of Scan time being divided into smaller steps for each rung/line of my code.
If Scenario 2, ST is just another way to input ladder logic with no additional benefits. BTW, in this case ST is reminiscent of a concurrent programming language, like Erlang (without the recursive calls.)
For example, in serial communication we often need to send different parameters one after another. I am seeing some strange things happen when I try:
(* in ST code - Modbus write register address with data *)
(* strange syntax is for Panasonic, 16# is for hex. *)
sendSerialCommand(address:=16#30, data:=16#FF);
sendSerialCommand(address:=16#31, data:=16#0F);
sendSerialCommand(address:=16#32, data:=16#F0);
(*assume I wrote a function called sendSerialCommand that works if called once. *)
Calling a function (that worked when called once) twice produced behavior that is not expected. I.e., did not send parameters correctly. (Sadly, I use Panasonic hardware, so not much help on the web. If you are a Panasonic user, please contact me. We want to find a capable individual to program this project for us.)
Love to hear your thoughts!
Newbie question, but hope someone can help me clarify some basic points. I do apologize if I am not using the right lingo for technical specifics, my background is more in embedded systems (microcontrollers) and classical software development (c, c++, python... hence my interest in Structured Text - ST) So please use some imagination while reading this post. Also, you will probably find some of my understandings inaccurate, please do point those out and correct me.
In ladder logic, each rung is equal, and all rungs (connected to power rail) are active at the beginning of each scan cycle. Since rungs are not executed sequentially, the programmer controls sequential behavior by triggering a cascade of coils (R registers for example.) I do not expect sequential execution from rung 1 to rung N, or should I?
In Structured Text, can I expect sequential execution of code line by line, or should I view ST as just a different way to specify ladder rungs? Below is an example of ST:
(* rung 1... *)
if( X1 ) Then
variableJJ := 5;
end_if;
(* rung 2.. 3...4.... 5... *)
(* rung 6 *)
if( X1 ) Then
variableJJ := 80;
end_if;
Should I expect (Scenario 1) rung 1 will execute first, then 2, 3, 4... and finally 6, in discrete time steps? Or (Scenario 2) should I read this as rung 1 and rung 6 both executes at the same time, and variableJJ could be 5 or 80, depending the how the compiler generates the instructions or a race condition in the CPU? or is it CASE 3, *you tell me.*.
If Scenario 1 is true, PLC programming in ST is great! I get free sequential features of single-thread programming without setting a bunch of coils. In this case, I can think of Scan time being divided into smaller steps for each rung/line of my code.
If Scenario 2, ST is just another way to input ladder logic with no additional benefits. BTW, in this case ST is reminiscent of a concurrent programming language, like Erlang (without the recursive calls.)
For example, in serial communication we often need to send different parameters one after another. I am seeing some strange things happen when I try:
(* in ST code - Modbus write register address with data *)
(* strange syntax is for Panasonic, 16# is for hex. *)
sendSerialCommand(address:=16#30, data:=16#FF);
sendSerialCommand(address:=16#31, data:=16#0F);
sendSerialCommand(address:=16#32, data:=16#F0);
(*assume I wrote a function called sendSerialCommand that works if called once. *)
Calling a function (that worked when called once) twice produced behavior that is not expected. I.e., did not send parameters correctly. (Sadly, I use Panasonic hardware, so not much help on the web. If you are a Panasonic user, please contact me. We want to find a capable individual to program this project for us.)
Love to hear your thoughts!