Specifications

6
CHAPTER 2. IMPLEMENTATION OF SOFT- AND HARDWARE
The Acquisition Delay option in the AIn Simulink GUI has a big impact on the Ain driver function
AiGetAIValue. First a command to acquire data is send to the PowerDAQ PD2-MF-16-500/16H
board. The executable starts to evaluate the next command parallel to this. However the next command
is reading the acquired data from the board, but the board is still acquiring. This results in bad read-
outs and/or sometimes even a shuffled channellist.
Another difference between the functions AiGetAIValue and PdUModeAO32Write is their
place in the Simulink-Time-Step loop, see figure 2.1. The function to write data is called for every
channel in the channellist individually, while the function to acquire data is called once for the com-
plete channellist, defined in the initialization by CHLIST_ENT.
The drivers do not require any installation, merely put them in the same directory as the model
which makes use of them!
2.3 Getting started
When all the software in the appendices is installed properly, the DACS can be used. Before
starting with the checklist, beware of the limitations of External Mode. Changing a parameter that
results in a change of the model structure is not allowed. For example, changing the following is not
possible:
The number of states, inputs or outputs of any block.
All options in the simulation parameters menu.
The name of the model or of any block.
The parameters to the Fcn block
If any of these changes have to be made, new code must be generated and compiled.
2.3.1 Checklist
Type the command modprobe pwrdaq in the console window. This loads the user space
library of the boards used in the Soft Real-Time part.
To check if they are loaded properly type cat /proc/pwrdaq
Then type loadrtai to load the required RTAI modules.
In Matlab Command Window type mex uei_pd2mf_ai.c and mex uei_pd2ao_ao.c.
This is not necessary if both mex-functions already exist.
In Simulink check the following.
Execution mode is set to external mode, Simulation -> External.
The discrete-time execution requires a fixed-step solver, Simulation -> Simulation
Parameters.
When using the model the following has to be done before every run.
In the Simulink model, select Tools -> Real-Time Workshop -> Build Model...
or use (ctrl+B) to build the RTW model.
PLEASE NOTE: When the model is build while the RTAI module is not loaded yet, the
execution of that model produces rubbish!
Go back to the konsole and type ./"directory"/"filename" to start execution of the
model and use the options -tf 3(sec) and -w.
Not specifying -tf runs the model infinitely long.