Home > Forum > IEC 61131 Programming (LogicLab) > Manage timings in ST language
- This topic has 3 replies, 2 participants and was last updated 13 years, 9 months ago da Sergio Bertana.
-
AuthorPost
-
July 27, 2010 at 3: 04 pm #34883AuthorlessIdle
I have to manage a timing in ST language. Previously I was using your Picolog products and programming in "C" language.
The IsMsecTimeOver () function was available in your libraries which made timing execution extremely simple. There is something like this on SlimLine ?
July 27, 2010 at 3: 07 pm #36500Sergio BertanaAdministrator ForumThe IsMsecTimeOver () function is based on the system tick control, which automatically increments every 1 mS in Picolog systems.
In systems SlimLine from ST language it is possible to test the system variable SysTime of the UDINT type, which increases each time the maximum value is reached and reinitializes. In practice to execute the timing similarly to what you did in "C" on Picolog systems you can do something similar to the program below which performs the inversion of the Do00M00 output every second. The variable RefTimeBuf must be declared as type UDINT.
(* Initial reference time at first program loop. *)
IF SysFirstLoop THEN
RefTimeBuf: = SysTime; (* Save the reference time *)
END_IF;(* Check if 1 Sec is passed and invert the logic DoOOM00 state. *)
IF (SysTime> (RefTimeBuf + 1000)) THEN
RefTimeBuf: = SysTime; (* Save the reference time *)
Do00M00: = NOT (Do00M00);
END_IF;July 27, 2010 at 3: 23 pm #36501Sergio BertanaAdministrator ForumThe function also exists SysGetSysTime () which allows the reading of a system tick that increases every uS, in this case the previous program can be modified in the way.
(* Initial reference time at first program loop. *)
IF SysFirstLoop THEN
RefTimeBuf: = SysGetSysTime (TRUE); (* Save the reference time *)
END_IF;(* Check if 1 Sec is passed and invert the logic DoOOM00 state. *)
IF (SysGetSysTime (TRUE)> (RefTimeBuf + 1000000)) THEN
RefTimeBuf: = SysGetSysTime (FALSE); (* Save the reference time *)
Do00M00: = NOT (Do00M00);
END_IF;Note the call to SysGetSysTime () with the flag FALSE to have the same time used in the comparison and not to lose the uS of time necessary for the execution of the comparison instructions.
July 27, 2010 at 3: 52 pm #36502Sergio BertanaAdministrator ForumHowever, there are also function blocks eTOF, Timer Off ed eTON, Timer On that the languages of the IEC5 can be used in all 61131. Both function blocks execute timings with time definable in mS.
-
AuthorPost
- You must be logged in to reply to this topic.