Deterministic control in c++

C

Campbell, Kevin (IndSys, GEFanuc, TCP)

Determinism is generally related more to the machine and OS then the
programming language itself. Most functionality in C++ other than dynamic
memory allocation will be deterministic. There are several features in C++
that can produce unexpected overhead (like unexpected copy constructors) but
this will not affect the determinism of your software, it will just slow it
down.

You will get better determinism with native Windows NT than Windows 98.
There are several features in Windows NT you can use to improve your
determinism:
1) Use Multi-media timers to obtain 1ms accuracy for timing and sleep calls
(by default this is 10ms).
2) Use the Real-Time Class for your process to put yourself above the user
mode portions of the OS and avoid the dynamic thread priority balancing of
the lower classes
3) Replace poorly behaved kernel mode device drivers. Because any kernel
mode processing runs above your user mode task, these device drivers will
impact the determinism of your system. The default Hard Disk Driver (ATAPI)
is particularly bad and violates several of Microsoft's own guidelines for
limiting processor stalls. By replacing this with a Bus Mastering DMA
driver, you reduce the interrupt load on the CPU and will have more
deterministic behaviour for your control thread.
4) Use VirtualLock on your code and data pages to eliminate paging to HD. A
Page fault from disk will cause a spike in the order of 30ms

If you have very tight determinism requirements or need timing below 1ms,
your best approach is to use a real-time extension to NT like VenturCom's
RTX.

Kevin

Kevin Campbell
Development Manager
Total Control Products
A Subsidiary of GE Fanuc
(780) 420-2033
[email protected]
 
R

Robert Trask

>Rant ON:
>
>One really good reason to use C and C++ for deterministic
>programming is so you can buy that fantastic package that
>emulates 4 plc's in sanskrit, latin, and those other iec1131
>languages. I wouldn't use NT for that though. That half hour
>reboot recovery is hard to do in a deterministic fashion.

reply...

Huh?

What half-hour recovery? What is a deterministic reboot anyway?

Robert Trask, P.E [email protected]
Wilmington, NC USA
 
A

Armin Steinhoff

At 10:27 29.11.99 -0500, Robert Trask, P.E. wrote:
>1) What is the package you use?
>
>The package is TwinCAT by Beckhoff. The full software package can be
>downloaded at www.beckhoff.com and used for 30 days with no obligations. I
>do not work for Beckhoff so I feel comfortable posting this to the list.
>The software is only recently available in the US. It is quite amazing
>stuff.
>
>2) What are the resolution and jitter(uncertainty) times for I/O read
>and writes?
>
>The resolution depends on the I/O hardware. The jitter is also hardware
>dependent and the software has an easy to access screen that displays the
>jitter. On my laptop running the software with a minor control program and
>a DeviceNet PCMCIA scanner the jitter is on the order of 4-5 microsecond.

If the PCMCIA scanner is a scanner with a co-processor .... I don't believe
that
this jitter has something to do with the TwinCAT software and NT. In that case
it depends on bus traffic of the CAN bus and the scanner software running
at the
PCMCIA interface.

If the PCMCIA scanner is a so called 'dump' interface board ... then I believe
that the jitter is fairly high. For instance ... a complete message exchange
between two tasks can be done under QNX in a time frame of 4 to 5 microseconds
with a jitter in the nanosecond range. (task switch ~450 nsec / K6 III 400Mhz)

Regards

Armin Steinhoff

http://www.steinhoff.de
 
Top