mbridges
Using PLCOpenEditor 1.2 for OpenPLC v2.

I generated the following based on the oscillator example discussed here.
osc.png 
Loading produces this error:
Quote:
compiling new program...
./st_files/SoftPLC.st:14: error: invalid expression after ':=' in ST assignment statement.
./st_files/SoftPLC.st:14: error: ';' missing at the end of statement in ST statement.
./st_files/SoftPLC.st:14: error: invalid statement in ST statement.

3 error(s) found. Bailing out!
Error compiling program. Please check console log


Here's the code generated:

PROGRAM My_Program
VAR
button AT %QX0.1 : BOOL := 0;
lamp AT %QX0.0 : BOOL := 0;
END_VAR
VAR
oscillator : BOOL := 0;
TON0 : TON;
TOF0 : TOF;
END_VAR

TON0(IN := NOT(oscillator), PT := T#1000ms);
TOF0(IN := TON0.Q, PT := T#1000ms);
lamp := [ OR button;
oscillator := TOF0.Q;
END_PROGRAM


CONFIGURATION Config0

RESOURCE Res0 ON PLC
TASK TaskMain(INTERVAL := T#50ms,PRIORITY := 0);
PROGRAM Inst0 WITH TaskMain : My_Program;
END_RESOURCE
END_CONFIGURATION


It works as expected when I manually edit to change the "lamp := [ OR button;" to "lamp := oscillator OR button;".

Is there a workaround for this?  I get the same error even if I use an OR block to join the two lines.

Thanks!
Reply 0 0
thiagoralves
The problem is with your ladder logic, you're putting two coils in series and this operation is illegal. If you want the oscillator to drive your lamp based on the status of a button, you must do this:
Capture.png    
Put the oscillator in one rung first. Then on the next rung put your button and the oscillator. Then you drive your lamp. In this code the button and the oscillator are in parallel, which means that your lamp will be blinking always, unless you press the button, and then the lamp will stay on while the button is pressed. You can also put the button and the oscillator in series, which will cause the lamp to stay off all the time, until you press the button. While the button is pressed, instead of staying on, the lamp will blink.

PS: I agree with you that the editor is generating bad code, and this is a bug. It should rather complain about the problem in your ladder logic instead of trying to generate the code.
Reply 1 0
mbridges
Thanks so much for the quick answer and for setting me straight.  I made a slight modification as I was intending to use the button more to override the oscillator (solid when closed, blink when open).  
osc.png 

It works as expected, but let me know if you see another rookie mistake.
Reply 0 0
thiagoralves
Yeah, I noticed that from your structured text code and fixed my image =)
Reply 1 0
Reply