# How to convert this ladder logic to Sequential Function Chart

I am doing an assignment where I need to create an office management system that takes care of security, lighting, and heating on its own. It is required for us to make it in the sequential function chart logic from ladder logic, but I don't understand how to make it since we never took it. I tried to research it, but I still don't know how to convert it from ladder logic to SFC.

The program functionality should be as follows:

• All counters/timers must be reset when entering "run" mode for the first time (use the first scan bit).

• Only during the day should the current number of occupants be counted by incrementing/decrementing as they enter or leave. Counting should not be done in the middle of the night. The count should be shown on the BCD display.

• The thermostat must control the heating during the day. At night, the heating is turned off.

• The main light system must activate as follows when the office is occupied during the day (using a LIM or Compare function). Daylight switch 1 should be used to control the first row of the main lighting. Daylight switches 1 and 2 will control main lighting row 2. No daylight switch should be used to control main lighting row 3. Unless an intruder triggers the main lighting, it is turned off at night. When the office is not in use, all the lights should be turned off.

• The night lighting should only be turned on at night.

• When a presence is detected at night, the external alarm should activate (70 percent duty cycle for 3 seconds) and latch, the internal alarm should start (30 percent duty cycle for 1 second) and latch, and the main lighting should activate after a time delay of 6 seconds and remain on for 20 seconds.

• When activated, all intruder alarms latch and can only be reset by pressing the reset button.

• In the event of a mains failure (from on to off the mains power switch), the emergency lighting should turn on immediately (day or night) and latch on the external alarm after a 6-second delay. The external alarm should have a duty cycle of 60% and a duration of 2 seconds. When the mains power is restored, the external alarm should be reset.

This is my ladder logic using RSlogix5000:

My Progress so far, I don't know if I did OSR correct and how to do BSL for the BCD also I am planning to put all these in a single function block:

Timer_1.Acc:=0;
Timer_2.Acc:=0;
Timer_3.Acc:=0;
Timer_4.Acc:=0;
Timer_5.Acc:=0;
Timer_6.Acc:=0;
Timer_7.Acc:=0;
Timer_8.Acc:=0;
BSL_Array[0]:=0;

CTUD(Counter);
Counter.CUEnable:= DNSwitch and PDEntry;
Counter.Reset := RSwitch;

CTUD(Counter);
Counter.CDEnable:= DNSwitch and PDExit;
Counter.Reset := RSwitch;

if DNSwitch and Thermostat
then
Heating:=1;
else
Heating:=0;
end_if;

if DNSwitch and DLSwitch1 and (Counter.ACC >= 0)
then
Row1:=1;
else
Row1:=0;
end_if;

if (DNSwitch and DLSwitch1 and DLSwitch2 and (Counter.ACC >= 0)) or Timer_2.TT
then
Row2:=1;
else
Row2:=0;
end_if;

if (DNSwitch and DLSwitch1 and DLSwitch2 and (Counter.ACC >= 0)) or Timer_2.TT
then
Row2:=1;
else
Row2:=0;
end_if;

if (DNSwitch and (Counter.ACC > 0)) or Timer_2.TT
then
Row3:=1;
else
Row3:=0;
end_if;

if not DNSwitch
then
NLight:=1;
else
NLight:=0;
end_if;

if not DNSwitch and (PDEntry or (Intruder and not RSwitch))
then
Intruder:=1;
else
Intruder:=0;
end_if;

RTOR(Timer_1);
Timer_1.PRE:= 6000;
Timer_1.TimerEnable:= Intruder;
Timer_1.Reset:= RSwitch;

RTOR(Timer_2);
Timer_2.PRE:= 20000;
Timer_2.TimerEnable:= Intruder and Timer_1.DN;
Timer_2.Reset:= RSwitch;

RTOR(Timer_3);
Timer_3.PRE:= 3000;
Timer_3.TimerEnable:= Intruder;
Timer_3.Reset:= RSwitch;

if (Intruder and (Timer_3.ACC <= 2100)) or (MPFail and Timer_5.DN and (Timer_6.ACC <= 1200))
then
ExtAlarm:= 1;
else
ExtAlarm:= 0;
end_if;

RTOR(Timer_4);
Timer_4.PRE:= 1000;
Timer_4.TimerEnable:= Intruder;
Timer_4.Reset:= RSwitch;

if (Intruder and (Timer_4.ACC <= 300))
then
IntAlarm:= 1;
else
IntAlarm:= 0;
end_if;

If MPFail
then
Elight:= 1;
else
Elight:= 0;
end_if;

RTOR(Timer_5);
Timer_5.PRE:= 2000;
Timer_5.TimerEnable:= MPFail;
Timer_5.Reset:= RSwitch;

RTOR(Timer_6);
Timer_6.PRE:= 2000;
Timer_6.TimerEnable:= Timer_5.DN;
Timer_6.Reset:= RSwitch;

(*BCD*)
RTOR(Timer_7);
Timer_7.PRE:= 25;
Timer_7.TimerEnable:= DNSwitch and not Timer_8.DN;
Timer_7.Reset:= RSwitch;

RTOR(Timer_8);
Timer_8.PRE:= 25;
Timer_8.TimerEnable:= DNSwitch and not Timer_8.DN and Timer_7.DN;
Timer_8.Reset:= RSwitch;

OSRI_Fn.InputBit := Timer_7.DN;
OSRI(OSRI_Fn);
OSR_1 := OSRI_Fn.OutputBit;

• Hi, SFC is Sequential Function Chart not Sequential Flow Chart. Your post has been edited. May 24 at 17:47
• You just have to work out what each step of the sequence is and what the transition condition is to move from one step to another. Add your attempt into the question. May 24 at 21:47
• @Transistor I'll do that and add it later May 25 at 4:33
• @Transistor I uploaded my progress May 26 at 18:27
• That's not SFC. You've converted ladder to STL (STatement List). See assets.omron.eu/downloads/manual/en/… for example. Step and Conditions = Sequence. May 26 at 19:09