« MSX-Box-CPCI: PAC system with CompactPCI backplane | HomePage | Time improvement in item measurement tasks »
02/02/2011
Fast PID control with the MSX-Box
PID controls are standard tasks in measurement and automation technology.
PID controllers in fact involve a lot of computational output, but they enable very fast control procedures. However, the control itself must be fast enough.
The MSX-Box is best equipped for such a task. As the floating point calculation runs directly in the real-time kernel mode, not in the user mode, the cycle times are reduced. The control is therefore faster overall, with the possibility of achieving PID controls of under 50 µs.
If you develop your control with a PID controller, you can use our new programming sample for the MSX-Box PAC system.
Program setup:
A timer is started with a cycle of 15 µs.
When the timer has run out, an interrupt routine is called up (“my_interrupt” in the example).
In the “my_interrupt” interrupt routine, the following actions are performed:
Time measurement at the start of the timer (= “before” time)
Read auto-refresh counter
Read measurement value of the analog input 0
Check whether it is a new measurement value (using the auto-refresh counter)
Activate FPU calculation (floating point unit)
Perform PID calculation
Deactivate FPU calculation
Check whether the D/A converter is free
If yes: Write the new value on the analog output
Time measurement at the end of the timer (= “after” time)
Times:
Average value of the interrupt jitter on the MSX-Box: 3.5 µs to 4 µs
Duration of the floating point calculation: 2 µs
A 32-bit INport/OUTport access requires approx 1.5 µs.
Maximum cycle time (= speed of “my_interrupt”): 15 µs
“after”-“before” time = 5 µs
Expansion to 8 inputs and 8 outputs (e.g.: CPCI-3120-16-8-AR)
The CPCI-3120-16-8-AR offers an auto-refresh mode, i.e., the inputs are constantly acquired and the values are stored in a type of RAM structure on the board so that the access time or conversion time is minimised.
Equally, the outputs are permanently written in a RAM structure, so that setting the outputs also requires very little time.
This results in the following times:
- Reading an analog input: approx. 2 µs (= 16 µs with 8 analog inputs)
- Writing an analog output: approx. 2 µs (= 16 µs with 8 analog outputs)
- Reading additional digital inputs: approx. 2 µs
The time which can be reached for reading/setting the inputs or outputs is 32 µs or 34 µs with additional digital inputs.
Including the PID control, i.e.,
-
Average value of the interrupt jitter on the MSX-Box: 3.5 µs to 4 µs
-
Duration of the floating point calculation: 2 µs (= 16 µs with 8 channels)
there is an overall time of
16 µs (read analog inputs)
+ 2 µs (read digital inputs)
+ 4 µs (interrupt jitter)
+ 16 µs (PID calculation)
+ 16 µs (write analog outputs)
= 54 µs
* Auto-refresh mode: The board and the acquisition are initialised. If the acquisition is started, it runs automatically. In the above-mentioned case (100 kHz), the measurement values are stored on the board in a RAM structure for each channel every 10 µs and can therefore be called up at any time by a task of the operating system. Access to the measurement values is hereby reduced to a minimum
of time.
Ask for the sample by sending us an e-mail: msx-box@addi-data.com
16:41 Permalink | Comments (0) | Email this

