Hi I am learning PLC programming, especially codesys, I am used to program MCU's like Atmega2560 or ST32 or DSP430 etc.. I use to do it with c++ and I find structured text very similar to C code language but again it is different. If I want to make a state machine with switch case, can I do that in codesys using structured text?
Yes, a case structure is a great way to make a state machine in structured text. Here's an example from Codesys help: CASE iVar OF 1, 5: bVar1 := TRUE; bVar3 := FALSE; 2: bVar2 := FALSE; bVar3 := TRUE; 10..20: bVar1 := TRUE; bVar3= TRUE; ELSE bVar1 := NOT bVar1; bVar2 := bVar1 OR bVar2; END_CASE; Source: help.codesys.com/api-content/2/codesys/3.5.12.0/en/_cds_st_instruction_case/
Nice one!!
Hi I am learning PLC programming, especially codesys, I am used to program MCU's like Atmega2560 or ST32 or DSP430 etc.. I use to do it with c++ and I find structured text very similar to C code language but again it is different. If I want to make a state machine with switch case, can I do that in codesys using structured text?
Yes, a case structure is a great way to make a state machine in structured text. Here's an example from Codesys help:
CASE iVar OF
1, 5: bVar1 := TRUE;
bVar3 := FALSE;
2: bVar2 := FALSE;
bVar3 := TRUE;
10..20: bVar1 := TRUE;
bVar3= TRUE;
ELSE
bVar1 := NOT bVar1;
bVar2 := bVar1 OR bVar2;
END_CASE;
Source: help.codesys.com/api-content/2/codesys/3.5.12.0/en/_cds_st_instruction_case/
How simple)) And how dificult to find this example in ST (SCL)