TDTRP User Guide
Use TDTRP to directly communicate with TDT hardware from MATLAB.
Requirements
-
TDT Drivers
-
TDT ActiveX package
About TDTRP
TDTRP is a MATLAB class that serves as a wrapper for the RPcoX ActiveX control that installs with the TDT ActiveX package. It provides direct access to TDT hardware (connect, load/run circuit, read/write tags on the hardware, send software triggers) and is generally easier to use than calling the RPcoX object directly.
TDTRP installs with the ActiveX controls into:
C:\TDT\ActiveX\ActXExamples\Matlab
or you can download it in the ActiveX Controls example zip.
TDTRP Functionality
This section includes methods, examples, and comparisons to RPcoX.
Note
See ActiveX User Reference for the complete RPcoX programming guide.
Creating a TDTRP object
obj = TDTRP(CIRCUITPATH, DEVICETYPE, 'parameter', value, ...)
obj
is what you want the structure to be called for your code. In
this document obj will be 'TDT' after we make our first call to
TDTRP below. However, obj can be any unique variable name.
TDT = TDTRP('C:\TDT\ActiveX\ActXExamples\RP_Files\Continuous_Acquire.rcx', 'RZ6')
TDT
is the returned object. The target device is an RZ6 processor. I only
have one, so no need to set the 'NUMBER' parameter, and it has a fiber optic
interface built into it, so it uses the default 'GB' interface.
RP = actxserver('RPco.X');
RP.ConnectRZ6('GB',1)
RP.LoadCOF('C:\TDT\ActiveX\ActXExamples\RP_Files\Continuous_Acquire.rcx');
e = RP.Run
if e == 0
error('error running circuit')
else
disp('Circuit ready to run')
end
Setting the mode with TDTRP
TDT.halt % stop any existing processing chain
TDT.load % load the processing chain
TDT.run % run the processing chain
>> circuit = 'C:\TDT\ActiveX\ActXExamples\RP_Files\Continuous_Acquire.rcx';
>> TDT.halt;
>> TDT.load(circuit);
>> TDT.run;
% Calling TDTRP() does the equivalent of calling halt, load, and run
% load and run the circuit onto the specified device
RP.Halt
circuit ='C:\TDT\ActiveX\ActXExamples\RP_Files\Continuous_Acquire.rcx';
e = RP.LoadCOF(circuit); % Loads circuit
if e == 0
error('Error loading circuit')
else
disp('Circuit ready to run')
end
e = RP.Run
if e == 0
error('Error running circuit')
else
disp('Circuit ready to run')
end
Software Triggers
Use software triggers to pulse a TrigIn
component in RPvdsEx for
one sample.
TDT.trg(TRIGNUM) % TRIGNUM is the software trigger index (1-10)
TRIGNUM determined by number after 'Soft' in the TrigIn
component.
TDT.trg(1);
RP.SoftTrg(1);
Writing to Parameter Tags
TDT.write(TAGNAME, VALUE, 'parameter', value, ...)
TAGNAME
is a string. VALUE
is the single value or array that you want to push
onto the tag. Whether the tag is pointed to a scalar component or buffer will
determine what is a valid write. Examples of these paradigms are below in the
examples below.
Parameter Tag pointing to a scalar value |
% writing a single scalar value to a ConstF component
TDT.write('MyTag', 3.14);
RP.SetTagVal('MyTag', 3.14); % for single value
Parameter Tag pointing to memory buffer |
% writing an array of values to a SerSource, which is a serial buffer
TDT.write('MyTag', 1:10);
RP.WriteTagVEX('MyTag', 0, 'F32', 1:10); % for array of values
Reading from Parameter Tags
TDT.read(TAGNAME,'parameter',value,...)
Similar to the TDT.write method, what the tag is pointed to will determine what a valid read is. A scalar tag must be on a scalar component. An array must be on a buffer.
Parameter Tag pointing to a scalar value |
Parameter tags always point towards a component port.
% read single value parameter tags
ScalarVal = TDT.read('ReadMe');
RP.GetTagVal('ReadMe'); % for single value
Parameter Tag pointing to memory buffer |
% This will read all values stored in the SerStore serial buffer
ArrVals = TDT.read('ReadMe');
RP.ReadTagVEX('ReadMe',0,1000,'F32','F32',1); % for 1 chan array of 1000 values
Examples Using TDTRP
You can find examples of ActiveX code using TDTRP installed with ActiveX in:
C:\TDT\ActiveX\ActXExamples\Matlab
or you can download it in the ActiveX Controls example zip.