How do I vary the values of the Analog Output signals during real-time simulation on my target in xPC Target 2.7.2 (R14SP2)?

1 view (last 30 days)
I have a model in which I am receiving signals, via my target, from an amplifier using the PCI-6052E Analog Input block. I am then sending signals to the amplifier using a PCI-6052E Analog Output block. I would like to be able to change the signals being sent by the Analog Output block once the model has been built and is running in real-time. Furthermore, the signals are independent of the Analog Input signals and I would like to be able to specify the values of these signals at any time.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This can be done in xPC Target 2.7.2 (R14SP2) by using a Look-Up Table block. The attached model, lookupex.mdl, provides a simple example of this. The Lookup Tables are fed by constant blocks. If you build this model and enter the command:
set(tg,'ShowParameters','on');
you will see the following tunable parameters:
Parameters = INDEX VALUE TYPE SIZE PARAMETER NAME BLOCK NAME
0 [...] DOUBLE 1*10 Value Constant
1 [...] DOUBLE 1*10 Value Constant1
2 [...] DOUBLE 1*10 InputValues Lookup Table
3 [...] DOUBLE 10*1 OutputValues Lookup Table
4 [...] DOUBLE 1*10 InputValues Lookup Table1
5 [...] DOUBLE 10*1 OutputValues Lookup Table1
Therefore, you can completely specify vectors for the Analog Output using the values for the Constant blocks and the the Output Values in the Lookup Tables with the SETPARAM function as follows:
setparam(tg,3,rand(1,10));
Match up the first input value with the Output Value you would like for the first element of the vector, and so on. You could do this independent of Analog Input values, or any other values for that matter. You can also set the sample times based on the length of time you want the signals to be output.

More Answers (0)

Products


Release

R14SP2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!