Instrument Control Toolbox

Testing an Electronic Throttle

Contents

Introduction

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.

Connecting to an Instrument

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.

d

Instrument Device Object Using Driver: tektronix_tds2024.mdd

Instrument Information
    Type: Oscilloscope
Manufacturer: Tektronix
Model: TDS2024

Driver Information
  DriverType: MATLAB interface object
DriverName: tektronix_tds2024.mdd
DriverVersion: 1.0

Communication State
  Status: closed


We can then connect to the instrument through the device object.

connect(d);

Acquiring Information About the Device

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)

Acquisition:
Calibration:
Channel:
ConfirmationFcn:
Cursor:
Display:
DriverName:
DriverType:
InstrumentModel:
Interface:
Language:
LogicalName:
Math:
Measurement:
Name:
ObjectVisibility:
ResponseHeaderState:
RsrcName:
Status:
System:
Tag:
Timeout:
Trigger:
Type:
UserData:
VerboseEnabled:
Waveform:
  [1x1 icgroup]
[1x1 icgroup]
[1x4 icgroup]
''
[1x1 icgroup]
[1x1 icgroup]
'tektronix_tds2024.mdd'
'MATLAB interface object'
[1x56 char]
[1x1 gpib]
' english'
'GPIB0-2'
'ch1 - ch3'
[1x6 icgroup]
'scope-tektronix_tds2024'
'on'
'off'
''
'open'
[1x1 icgroup]
''
10
[1x1 icgroup]
'scope'
UserData: []
'on'
[1x1 icgroup]

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.

get(d, 'InstrumentModel')

ans =
    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' )

ans =
    rising

Since the trigger slope is currently set to rising, we can simply change the setting to falling.

set(trigger_group, 'Slope', 'falling');

Acquiring Data

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' )

HwIndex:
1
   HwName:
Waveform1
   Type:
scope-waveform
   Name:
Waveform1

[x, y] = invoke(waveform_group, 'readWaveform', 'Channel1');

Displaying Data

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')
xlabel('Time(sec)'); ylabel('Volts')


When we are done acquiring our data, we can disconnect from the instrument and clean up.

fclose ( g);
disconnect( d);
delete( d);
delete(g);
clear d g