User:DukeEgr93/DSPACE2

From PrattWiki
Jump to navigation Jump to search

Building a Basic Model

Building a basic Simulink model and running it on the dSPACE cards is fairly straightforward:

  1. Start the dSPACE ControlDesk.
  2. Start MATLAB - note that on a PC, the first time MATLAB is run after the PC has been turned on may take quite a bit of time to start.
    • MATLAB must run a configuration script to communicate with dSPACE. In Hudson 149, the script is already set to run. If that is not the case, dspacerc.m must be run. That script is provided with the dSPACE card and software.
  3. In MATLAB, start Simulink.
    • The block library should already include the dSPACE blocksets, though the individual blocks may need to be loaded. To load them, simply expand the dSPACE RTI1104 blockset.
    • In the Simulink Library Browser, go to File->New->Model; when the model comes up, save it inside the folder you chose when creating the experiment. For this demo, it will be called OutputDemoModel.
    • The model needs to know the properties of the DSP card in order to compile the model properly. To set these properties, go to the model's window, go to Simulation->Configuration Parameters
      • Solver: make sure to use a fixed-step solver; change the Fixed-step size if need be
      • Hardware Implementation: choose the following:
        • Device type: "Custom"
        • Byte ordering: "Big Endian"
        • Signed integer division rounds to: "zero"
    Once done, you can save the model.

Generating Output Signals

There are several methods in Simulink for generating a signal. Most of these methods can be dynamically adjusted via the ControlDesk once the Simulink model is built and once an appropriate Layout is constructed in ControlDesk. For this documentation, a simple sinusoidal input will be used.

  1. Using the Simulink Library Browser, drag the following blocks into the OutputDemoModel window:
    • Source->Sine Wave
    • Math Operations->Gain
    • dSPACE RTI1104->DS1104 MASTER PPC->DS1104DAC_C1
    • Sink->Out1
      This block will provide a convenient way for the ControlDesk to access the value sent to the DAC; it does not serve any other purpose in the model.
    Once these blocks are in place, connect the Sine Wave to the Gain, connect the Gain to the DAC, and connect the Out1 to the wire between the Gain and the DAC. Your model should resemble: