Docsity

Matlab/Simulink Real Time Windows Interface Tutorial | ME EN 5960, Assignments of Mechanical Engineering

Toggle sidebar
bg1
Matlab/Simulink Real TimeWindows Interface Tutorial
ME EN 5960 – Intro to Robot Control – Spring 2008
Page 1 of 6
Following are basic instructions for creating a Matlab Real Time
Windows application:
1. Open up the Simulink model that you wish to run in real time
(or create a new model file). A sample file is shown below:
2. Under the Simulation Menu, Select Configuration Parameters.
On the Solver Tab as shown below, do the following:
a. Select a fixed step integrator,
b. Select an integrator such as ode5,
c. Select a fixed step size (determines the sampling rate)
d. Select “Single Tasking”
3. Now select the “Real-Time Workshop” tab. Click on the
“Browse” button and select the “Real Time Workshop”
target.as shown in the figures below. Click OK on both
windows when completed.
pf3
pf4
pf5

Partial preview of the text

Download Matlab/Simulink Real Time Windows Interface Tutorial | ME EN 5960 and more Assignments Mechanical Engineering in PDF only on Docsity!

ME EN 5960 – Intro to Robot Control – Spring 2008 Following are basic instructions for creating a Matlab Real Time Windows application:

  1. Open up the Simulink model that you wish to run in real time (or create a new model file). A sample file is shown below:
  2. Under the Simulation Menu, Select Configuration Parameters. On the Solver Tab as shown below, do the following: a. Select a fixed step integrator, b. Select an integrator such as ode5, c. Select a fixed step size (determines the sampling rate) d. Select “Single Tasking” 3. Now select the “Real-Time Workshop” tab. Click on the “Browse” button and select the “Real Time Workshop” target.as shown in the figures below. Click OK on both windows when completed.

ME EN 5960 – Intro to Robot Control – Spring 2008

As an example of a system to simulate, consider the model of a first order transfer function shown on the previous page.

  1. In order to display more than 1000 data points in the scope of this simulation several settings must be made: a. Open the scope window properties and turn off “Limit data points to last:” as shown below:

b. Under the Tools menu, select “External Mode Control Panel”. In the window that opens, select the “Signal and Triggering” button. In the window that opens, change the Duration setting. If you are sampling every 0.001sec (i.e. your step size), then a setting of 10000 will show 10 seconds of data in the scope.

ME EN 5960 – Intro to Robot Control – Spring 2008

  1. To interface your model with data acquisition hardware connected in the computer, you must do the following. a. To be able to send a voltage out to the servo amplifier, add an “Analog Output” block to the model. This is found in the “Library Browser” window under “Real Time Windows Target” as shown below:

b. After adding the block, you must configure it to use the data acquisition board. The board in the computer is a National Instruments PCI 6024E if the option is not available. This is shown below after double clicking the Analog Output block.

c. Set the “Sample time” to correspond to the step size of your simulation, e.g. 0.001. Make sure the “Output channels” is set to 1. This will correspond to AO CH on the National Instruments BNC-2090 terminal block, which should be wired to the reference input of the amplifier. Finally, specify an “Initial Value” of 0 and “Final Value” of 0 so that the output always resets to 0 Volts at the beginning and end of your simulation. d. If you have a second amp, you can wire it to AO CH and change the output channels to an array: [1 2].

ME EN 5960 – Intro to Robot Control – Spring 2008

e. To count encoder pulses, add a “Counter Input” block to the model from the Real Time Windows Target library. You will eventually need to add a gain block to convert to units of choice (revolutions or degrees or radians). Double click on the counter to configure it.

f. Select the PCI-6024E board, change the “Sample time” to match your time step. Specify channel 1, which corresponds to Counter 0. Make sure the counter is set to never reset after read and to have a gate functionality of none. Also click on Board Setup and check the box for Bidirectional counter. The source input for Counter 0 is the PFI8 pin on the NI terminal block, which should be wired to the Clock Out pin on the decoder chip. The up/down input for Counter 0 is the DIO6 pin on the NI terminal block, which should be wired to the Up//Dn Out pin on the decoder chip. If the encoder has an index channel, you can wire that to the Counter 0 gate, which is pin PFI on the NI terminal block, and select a gate functionality of reset on rising or falling.

g. If you have two encoders, you can change the input channels to an array: [1 2]. The source, up/down, and gate pins for channel 2 (Counter 1) are PFI3, DIO7, and PFI4, respectively. h. You can now rebuild the real time model, transfer it to the target, and then run it as described in the previous step.