I am building PLC IDE. Traditionally PLC is programmed with one of the 5 IEC 61131-3 standard languages. My IDE will support only one of those which is ST (Structured Text) that looks like Pascal and actually based on it.
There is no ST compilers or interpreter out there. Only privately owned by companies like 3S (Codesys), Siemens, … My first idea was to transpile ST program to C/C++, then I thought about transpiling it to nodejs. But recently I investigated GO and it looks like a perfect candidate.
I know that for most of you, one example may tell about a language more than long article so here is and example how ST program might look like
TYPE Shelf :
STRUCT
TemperatureIN: POINTER TO WORD;
Temperature: INT;
TemperatureHMI: POINTER TO WORD;
TemperatureStatus: POINTER TO BYTE;
OutByte: POINTER TO WORD;
ByteNum: USINT;
Correction: POINTER TO WORD;
END_STRUCT
END_TYPE
FUNCTION_BLOCK TON_M
VAR_INPUT
IN: BOOL;
PT: TIME;
RS: BOOL;
END_VAR
VAR_OUTPUT
Q: BOOL;
TP: WORD;
TW: TIME;
END_VAR
VAR
TON1: TON;
SR1: SR;
RT1:R_TRIG;
TimeWorked : TIME;
xProcess :BOOL;
END_VAR
IF pt = T#0S THEN
Q := TRUE;
RETURN;
END_IF
IF RS OR (TimeWorked > PT) THEN
TimeWorked := T#0S;
TON1(IN := FALSE);
RETURN;
END_IF
IF NOT TON1.Q AND NOT IN THEN
TimeWorked := TimeWorked + TON1.ET;
END_IF
TON1(IN := IN, PT := SEL(IN, T#0MS, PT - TimeWorked), Q => Q);
TW := TimeWorked + TON1.ET;
TP := REAL_TO_WORD(TIME_TO_REAL(TW) * 100.0 / TIME_TO_REAL(PT));
END_FUNCTION_BLOCK
So, my question, am I on the right track of using GO?
There PLC Runtime later might be based on Linux or perhaps based on simply STM32 chip (but this is not likely) primarily it is developed to run on Linux based PLC as hardware as softPLCs on online servers.
Would it be a smart choice to select GO?
Another thing that I’ll have to have in online monitoring. It is when I can run code and see what variables what values have as it is right now in PLC. But that is eventually but not now.