![background image](http://html1.mh-extra.com/html/omron/cx-supervisor-v2-0/cx-supervisor-v2-0_user-manual_744213309.webp)
APPENDIX B – Frequently Asked Questions
OMRON
Page 286
Release 2.0
Q How does Sleep() work?
The CX-Supervisor Sleep function is designed to create a short pause in script execution. The
parameter specifies the duration of the pause in milliseconds. For example:
<statements A>
<statements B>
Sleep(100)
<statements C>
In this example 'statements B' will begin executing immediately when 'statements A' complete,
though 'statements C' will not begin execution until 100ms after 'statements B' have completed.
Note 1: In a well designed, truly event driven system use of the Sleep() statement should never be
required. Always consider if the statements after the Sleep should be in their own script, executed
when a Condition occurs.
Note 2: The Granularity (or intervals) differs between Operating Systems. In Windows NT (and
2000) expiration is checked every 10ms, so 'Sleep(100)' actually pauses for 100 to 109.99
milliseconds depending on when it was started. For Windows 98 and ME the granularity is 55ms so
'Sleep(100)' actually pauses for 110 (2 times 55) to 164.99 milliseconds (nearly 3 times 55). For this
reason, Sleep statements can act differently on different Operating Systems making the application
OS dependant.
Note 3: Sleep should never be used as a delay for timing processes, for the following reasons:
- The actual time delay depends on the OS
- There is always an error of 0 to 1 granularity, depending on when the action is started.
- The frequency cannot be guaranteed as the OS may be busy, or handling other processes.
Note 4: Because of Note 2 and Note 3 above, Sleep should not be used for creating output or logic
pulses e.g. setting a bit on, sleeping, then setting the bit off. Instead, just use the PC to set the bit and
allow the PLC to clear the bit, either after a duration timed by the PLC real time clock or when the
triggered process is complete.
The requirement for Sleep is quite simple but the implementation is actually very complex. In the
example above, the application must continue to run during the pause i.e. read PLC data, log data,
check alarms, animate graphics etc. For this reason, any script with a Sleep statement must be
executed in parallel with the system. This can result in unexpected results when a Sleep is added, and
previously functioning script commands are now running in parallel. Redesign the script considering
parallel processing.
This can also result in unexpected behaviour when a Sleep is added to a Project initialisation or Page
initialisation script as some parts of the system or objects may not be loaded at time of execution.
Summary of Contents for CX-SUPERVISOR - V2.0
Page 2: ...CX Supervisor User Manual Software Release 2 0...
Page 3: ......
Page 5: ...CX Supervisor User Manual OMRON Page ii Revision 2 0...
Page 7: ...CX Supervisor User Manual OMRON Page iv Revision 2 0...
Page 11: ...CX Supervisor User Manual OMRON Page viii Revision 2 0...
Page 13: ...CX Supervisor User Manual OMRON Page x Revision 2 0...
Page 15: ...CX Supervisor User Manual OMRON Page xii Revision 2 0...
Page 17: ...CX Supervisor User Manual OMRON Page xiv Revision 2 0...
Page 19: ...CX Supervisor User Manual OMRON Page xvi Revision 2 0...
Page 21: ...CX Supervisor User Manual OMRON Page xviii Revision 2 0...
Page 23: ......
Page 67: ......
Page 97: ......
Page 137: ...CHAPTER 7 Graphics Library OMRON Page 114 Release 2 0...
Page 183: ...CHAPTER 9 Animation OMRON Page 160 Release 2 0...
Page 215: ......
Page 263: ......
Page 269: ......
Page 274: ...OMRON CHAPTER 16 Connecting to Omron Industrial Components Release 2 0 Page 251...
Page 275: ......
Page 285: ......
Page 319: ......
Page 331: ......
Page 351: ......
Page 359: ...GLOSSARY OF TERMS CX Supervisor User Manual OMRON Page 336 Release 2 0...