Problem to initiate Remote Mode in serial port communication with PR745 spectroradiometer

1 view (last 30 days)
Hello,
I am trying to drive a PR745 spectroradiometer from SpectraScan using serial port communication with Matlab. I can succesfully send and receive characters to the device from Matlab once I have initiated the Remote Mode externally with a Putty terminal. The way to do this is by opening the serial connection in Putty and typing PHOTO. Then, the instrument returns REMOTE MODE and initiates the remote mode. My problem is that I want to avoid having to pass through Putty for initiating the remote mode, but I cannot make the initial PHOTO command work in Matlab. I paste the function I use to initialize the serial connection.
function [pr_obj, flag] = init_PR_remote(port)
% This function receives the name of the virtual serial port where the PR % is connected, opens the communicaion and returns a flag with the status of % the comunication. % INPUTS: % -port: The virtual serial port where the PR instrument is connected (check it in % the device manager of Windows). 'COM3', 'COM6'...
% OUTPUTS: % - pr_obj: the serial object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pr_obj = instrfind('type','serial','port',port);
% Check if port is already in usage and if it is close it in order to % reopen:
if ~isempty(pr_obj)
fclose(pr_obj);
delete(pr_obj)
clear pr_obj
end
% Create the serial port object and set correct properties: try
pr_obj = serial(port);
fopen(pr_obj);
pr_obj.BaudRate = 9600;
pr_obj.Terminator = {'CR/LF',''};
pr_obj.DataBits = 8;
pr_obj.FlowControl = 'none';
pr_obj.StopBits = 1;
pr_obj.Parity = 'none';
catch ME
end
if strcmp(pr_obj.Status,'open')
flag = 1;
else
flag = 0;
end
comm='PHOTO';
fprintf(pr_obj,comm);
pause(2);
pr_obj.BytesAvailable
pr_obj.ValuesSent
a=fscanf(pr_obj);
pr_obj.Terminator = {'CR/LF',13};
end
I set first the Terminator to empty (in the instrument manual, it says that you don't need to press CR for the PHOTO command), and then set it to CR for the usual commands. Flag is 1, ValuesSent is 5, BytesAvailable is 0 after I execute this function, indicating that the port is open but the instrument does not receive the command properly. The a variable is empty and a timeout error is generated.
I am in touch with the technical support team of Spectrascan but they tell me they cannot help because it is an issue related to Matlab (I agree as well, since the remote mode initialization works fine through Putty). I would appreciate so much some help and suggestions on what I am doing wrong! Thank you in advance,
Eva M. Valero
  1 Comment
Russell Cohen
Russell Cohen on 25 Mar 2020
Hi Eva!
I'm currently learning how to remote control this device from MatLab. So thanks for giving me a head start (i'm a total newbie to this)! I was wondering if you ever figured out this issue.
Thanks!
-Russell

Sign in to comment.

Answers (1)

Eva M. Valero
Eva M. Valero on 25 Mar 2020
Hi, Russell!
Unfortunately not, I did not find a way to directly control the instrument from Matlab. I had to use PUTTY to get access to the device port.
Good luck with fixing this problem!

Categories

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

Products

Community Treasure Hunt

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

Start Hunting!