Instrument Control Toolbox
Electronic throttle control systems are able to tune a throttle's dynamic behavior. They replace the mechanical linkage between the accelerator pedal and throttle with an electronic one.
To design a controller that provides a wide range of capabilities, you need a thorough understanding of the open-loop dynamic response of the throttle body. To gain this understanding, you need to execute a series of tests to acquire operating information about the throttle.
The results of this series of tests can be used to develop a robust numerical model of the throttle body. The basic process demonstrated in this example can be applied to a wide range of system integration challenges. This example focuses on collecting test data to characterize the throttle response. We will use the Instrument Control Toolbox to control and communicate with an oscilloscope to collect test data for further analysis in MATLAB.
Below is an image of the throttle body tested
Here, we used a Tektronix TDS 2024 oscilloscope, which can be connected to a PC through its serial or GPIB port, to configure the test. The GPIB communication capabilities of the Instrument Control Toolbox are used to configure the oscilloscope for testing and to import data from the oscilloscope into MATLAB.
First we create an interface object that will handle the communication with the instrument.
g = gpib('mcc', 0, 2);
Once the interface object, g , is created, we can construct a device object using a MATLAB instrument driver that has specific information about the Tektronix TDS 2024 instrument, and the interface object. The instrument information is defined in a MATLAB instrument driver called tektronix_ tds2024.mdd .
d = icdevice('tektronix_tds2024', g);
We can easily acquire basic information about the instrument by looking at the device object, d.
|Instrument Device Object Using Driver: tektronix_tds2024.mdd
|DriverType: MATLAB interface object
We can then connect to the instrument through the device object.
Using the get command, we can access different properties and groups of the device object. To get a full list of properties and groups for the device object, we use the following command:
out = get(d)
'MATLAB interface object'
'ch1 - ch3'
The output is saved in the structure out in the MATLAB workspace.
To return the current value of a particular property, we use the get command along with the device object and property name.
TEKTRONIX,TDS 2012,0,CF:91.1CT FV:v2.06 TDS2CM:CMV:v1.04
You can also use the
get command to get group objects. Group objects are special properties of device objects that have their own properties and functions. We want to make sure that we have the oscilloscope configured correctly for our test. The oscilloscope should be set to trigger when the slope is falling. First, we will get the trigger group object.
trigger_group = get(d, 'Trigger');
Then we use the get command with the group object and the property name.
get(trigger_group, 'Slope' )
Since the trigger slope is currently set to rising, we can simply change the setting to falling.
set(trigger_group, 'Slope', 'falling');
In this example we want read the data from channel 1 of the oscilloscope. We can do this by getting the waveform group and invoking the readWaveform function.
waveform_group = get( d, 'Waveform' )
[x, y] = invoke(waveform_group, 'readWaveform', 'Channel1');
Once we have acquired the waveform into MATLAB, we can simply plot the waveform data.
plot(x,y, 'LineWidth', 2)
set(gca, 'xgrid', 'on', 'ygrid', 'on')
When we are done acquiring our data, we can disconnect from the instrument and clean up.
fclose ( g);
clear d g