Rayyan_Shaikh
Facing error while compiling the program 
 
 
my code is :
 
 
PROGRAM TrafficSignal
VAR
timer: TON; // Timer object for timing intervals
redLight: BOOL := TRUE; // Red light status
yellowLight: BOOL := FALSE; // Yellow light status
ChangeSignal: BOOL := FALSE; // Green light status
END_VAR
METHOD ChangeSignal : BOOL
VAR
currentState: BOOL;
BEGIN
currentState := timer.IN;

IF currentState THEN
// Red light ON, Yellow and Green light OFF
redLight := TRUE;
yellowLight := FALSE;
ChangeSignal := FALSE;

IF timer.Q THEN
// Switch to next state after red light interval
timer(IN:=FALSE, PT:=T#2s); // Set the timer for next interval
RETURN TRUE; // State changed
END_IF
ELSE
// Yellow light ON, Red and Green light OFF
redLight := FALSE;
yellowLight := TRUE;
ChangeSignal := FALSE;

IF timer.Q THEN
// Switch to next state after yellow light interval
timer(IN:=FALSE, PT:=T#2s); // Set the timer for next interval
RETURN TRUE; // State changed
END_IF
END_IF

RETURN FALSE; // No state change
END_METHOD
METHOD Execute
VAR
stateChanged: BOOL;
BEGIN
stateChanged := ChangeSignal();

// Output signals
// Connect the outputs to the actual hardware pins on the PLC
// Example: MyOutputPin := redLight;
// MyOutputPin := yellowLight;
// MyOutputPin := ChangeSignal;
END_METHOD
END_PROGRAM
 
 
 
 
 
 
 
 
exited with status 1 (pid 10668)
C:\Users\rayya\OpenPLC_Editor\editor\examples\Traffic Signal ST\build\plc.st:160-14..161-11: error: unknown syntax error.
In section: PROGRAM program0
0160: END_PROGRAM;
In section: END_PROGRAM
0161: END_PROGRAM
1 error(s) found. Bailing out!
Error : IEC to C compiler returned 1
PLC code generation failed !
Reply 0 0
thiagoralves
You shouldn’t write the PROGRAM and VAR sections. Those are defined in the Editor itself
Reply 0 0
Rayyan_Shaikh
Sorry @thiagoralves but being a begineer can't able to understand what you are trying to say......since 2 days tried many methods including your suggested solution  but not getting the output can you please elaborate your suggested solution definitely it will help me a lot
Reply 0 0
thiagoralves
It looks like you got this code from somewhere else. If you’re a beginner, try a simpler code
Reply 0 0
Reply