На ST вроде не сложно:
Код:
function_block Alarm //имя функционального блока.

    var_input //объявление входных переменных
        A1 : bool;
        A2 : bool;
        A3 : bool;
        A4 : bool;
        A5 : bool;
    end_var

    var_output //объявление выходных переменных
       Q : bool;
    end_var

    var //объявление локальных переменных
        curAlarm : udint;
        Count : udint := 0;
        Ton : SYS.TON;
        Toff : SYS.TON;
        Tp : SYS.TON;
    end_var

    If Count = 0 then
        Tp(I:=true, T:=T#1s);   // Выдерживаем паузу
        if Tp.Q then
            case curAlarm of    // Определяем кол-во моргушек по текущей аварии
                0: if A1 then Count:=2; end_if
                1: if A2 then Count:=3; end_if
                2: if A3 then Count:=4; end_if
                3: if A4 then Count:=5; end_if
                4: if A5 then Count:=6; end_if
            end_case
            curAlarm := curAlarm + 1;   // Переходим к следующей аварии
            if curAlarm >= 5 then       // И так по кругу
                curAlarm := 0;
            end_if
            Tp(I:=false);
        end_if
    else
        Ton(I:=true, T:=T#500ms);       // Зажигаем лампочку
        if Ton.Q then
            Toff(I:=true, T:=T#500ms);  // Выключаем лампочку
        end_if
        if Toff.Q then
            Ton(I:=false); Toff(I:=false); Count := Count - 1;  // Минус одна моргушка
        end_if

        Q:=Ton.Q and not Toff.Q;    // Состояние лампочки на выход
    end_if

end_function_block