Error to transmit hexadecimal codes in instrument using matlab

1 view (last 30 days)
Hello I have a serious problem.I want to transmit hexadecimal codes command in my instrument but , there is always error in command window like:
Warning: The specified amount of data was not returned within the Timeout period. is thre a solution please?
thanks.
My code.
obj2 = instrfind('Type', 'serial', 'Port', 'COM5', 'Tag', '');
obj2 = serial('COM5');
else
fclose(obj2);
obj2 = obj2(1);
end
set(obj2,'BaudRate',9600,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','CR');
set(obj2,'Timeout',0.1);
set(obj2,'OutputBufferSize',88);
% Connect to instrument object, obj1.
fopen(obj2);
txdata = ['10';'02';'00';'00';'10';'03'];
txdata_dec = hex2dec(txdata);
fwrite (obj2, txdata_dec, 'uint8');
rxdata_dec = fread(obj2);
fclose(obj2)
delete(obj2)
clear obj2
  1 Comment
dpb
dpb on 8 Aug 2014
Edited: dpb on 8 Aug 2014
_set(obj2,'Timeout',0.1);)
Try increasing the timeout, maybe???

Sign in to comment.

Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!