sm0key
Hi,
 
I am just trying to set up a PLC environment and initialise a few registers of which I can use for probing.
I do not have any hardware set up for this but chose the rpi option as well as a load of others thinking it would solve my issue, however it didnt.
 
I assume the reason it cannot find these files is my code is incorrect.
I've been trying to get ChatGPT to teach me how to code in .st however it is genuinely awful and cannot seem to do anything right.
 
 
Here is my current code:
PROGRAM program0
VAR
    
    Input1 : BOOL;
    Input2 : BOOL;

    
    Output1 : BOOL;
    Output2 : BOOL;

    
    AnalogIn1 : INT;
    AnalogIn2 : INT;

    
    AnalogOut1 : INT;

    
    HoldingReg1 : INT;
    HoldingReg2 : INT;

    Counter : INT;
END_VAR


Output1 := Input1;
Output2 := Input2;


Counter := Counter + 1;
IF Counter > 10000 THEN
    Counter := 0;
END_IF;

AnalogOut1 := Counter MOD 1024;


HoldingReg1 := HoldingReg1 + 1;
HoldingReg2 := HoldingReg2 - 1;
IF HoldingReg2 < 0 THEN
    HoldingReg2 := 9999;
END_IF;

END_PROGRAM
 
I am unsure how correct this is however I assume it's pretty bad.

My current error is:
Generating C files...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Including Siemens S7 Protocol via snap7
Moving Files...
mv: cannot stat 'Config0.c': No such file or directory
mv: cannot stat 'Config0.h': No such file or directory
mv: cannot stat 'Res0.c': No such file or directory
Error moving files
Compilation finished with errors!

 
I'd appreciate any support as I am completely new to PLCs & programming them.
Cheers!
Reply 0 0
thiagoralves
You need to use the OpenPLC Editor to generate your code as opposed to submitting the project by yourself. On the editor, declare your variables in the variable table at the top (instead of using VAR constructs in the code). For Modbus usage, you also need to locate your variables (e.g. %QW0, %QW1, etc) otherwise they won’t be mapped to Modbus registers
Reply 0 0
Reply