VAR
la_ton : TON;
not_q : BOOL;
acc_dint : DINT;
virtual_master_encoder : BOOL;
END_VAR
la_ton(IN:=not_q,PRE:=t#128ms); [COLOR=blue][B] (* Timer at ~8Hz *)[/B][/COLOR]
not_q := NOT la_ton.Q; [COLOR=blue][B](* Make timer repeat *)[/B][/COLOR]
[COLOR=Blue][B](* [/B][/COLOR][COLOR=Blue][B][COLOR=blue][B]Generate [/B][/COLOR]~8Hz signal at 50% duty cycle: *)[/B][/COLOR]
virtual_master_encoder := (TIME_TO_DINT(la_ton.ACC) AND 64) > 0;
[B][COLOR=blue](* OR, if ST syntax implementation allows, *)
[/COLOR][/B]virtual_master_encoder := TIME_TO_DINT(la_ton.ACC).6;[B][COLOR=blue]
(* OR *)[/COLOR][/B]
virtual_master_encoder := TIME_TO_DINT(la_ton.ACC) > 63;
[COLOR=blue][B](* OR Generate ~8Hz signal at 25% duty cycle *)[/B][/COLOR]
virtual_master_encoder := TIME_TO_DINT(la_ton.ACC) > 31;
[COLOR=blue][B](* OR Generate ~16Hz signal at 50% duty cycle *)[/B][/COLOR]
virtual_master_encoder := (TIME_TO_DINT(la_ton.ACC) AND 32) > 0;
[COLOR=blue][B](* OR, if ST syntax implementation allows, *)[/B][/COLOR]
virtual_master_encoder := TIME_TO_DINT(la_ton.ACC).5;