Why does channel specific communication with my conditioning ampifier not work when using the Instrument Control Toolbox 2.6 (R2008a)?

2 views (last 30 days)
I am communicating with a conditioning ampifier via the serial port on my computer. To do this, I make use of SERIAL interface objects available in the Instrument Control Toolbox. The hardware that I am interfacing with does not have hardware flow control capability.
I am able to communicate with the device using HyperTerminal, and I receive the expected response for every command that I issue. However, when using the Test and Measurement Tool (TMTOOL) GUI of the Instrument Control Toolbox to issue commands to my device, some commands do not generate the expected results.
For example, the SCPI command IDEN? to identify the instrument works correctly. However, when I do a channel dependent query such as Upper Frequency Limit of the first channel (IC1UFL), I do not receive the correct response.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Oct 2009
One of the possible causes for this issue to manifest when using the TMTOOL GUI, but not when using HyperTerminal could be that there is an overrunning of the small buffer on the amplifier with the longer messages required for channel specific communication.
When using TMTOOL, the entire query is sent out all at once and it is expected that the device is capable of buffering the characters in the command. If the device does not have the necessary buffering capacity, the results can be unpredictable. When working in HyperTerminal, each character is sent out one at a time and so the buffering capacity of the device is no longer an issue.
It is possible to workaround the buffer overflow problem if the specific device supports hardware flow control, by simply enabling this feature. However if the device does not have hardware flow control capability, you can resolve this issue by writing data to your device one character at a time with a small pause (say 20 milliseconds) between each character written. This is illustrated in the code below:
s = serial('COM1');
fopen(s);
data = double(['I' '_' 'C' '_' '1' ':' 'U' '_' 'F' '_' 'L' '?']); %convert to numeric
data = [data 10]; %include terminator
for i = 1:length(data);
fwrite(s, data(i)) %write one character at a time
pause(0.02) %pause for 20 milli seconds
end
dataread = fscanf(s) %do read operation
fclose(s);
delete(s); %clean up object
clear s

More Answers (0)

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!