I am having trouble saving the location using MATLAB. I have spent hour trying to get this to work. Can you please help me?
Here is me code... (i know that I am connected to the device)
%save current location
send(port,'!');
%move to a new spot
move(port, 1,-1);
%display
send(port,'x');
if port.BytesAvailable > 0
x = fscanf(port, '%e', port.BytesAvailable)
end
close all;
clear all;
%close all ports
if ~isempty(instrfind)
fclose( instrfind);
end
clc;
%Set up port
port = setPort(11,9600);
echoOff(port);
%%
cmd = ['C,I1M-6000,R'];
fprintf(port,cmd);
scan = '';
while ~strcmp(scan,'^')
%pause(1);
scan = fscanf(port,'%c',1);
display(scan);
end
while ~strcmp(scan,'R')
fprintf(port,'V');
scan = fscanf(port,'%c',1);
display(scan);
end
%%
fprintf(port,'!');
%%
fprintf(port, 'x')
while ~strcmp(scan,'R') fprintf(port,'V'); scan = fscanf(port,'%c',1); display(scan); end
I think that main problem is the reading data. I keep trying to read the reply with no response or a there is a delay.
I have the system hooked up through serial to USB could this be causing my problem?
I have another question. I am trying to read my current position.I read one of the other postings in the group and got the code:
fwrite(port,'X');
pause(.1);
if port.BytesAvailable > 0
scan = fscanf(port, '%e', port.BytesAvailable);
end
But I get the Error:
Warning: Unsuccessful read: Matching failure in format.
--
You received this message because you are subscribed to a topic in the Google Groups "Velmex Controls" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/velmex-controls/S96zUYMiIXc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to velmex-contro...@googlegroups.com.
To post to this group, send email to velmex-...@googlegroups.com.
Visit this group at http://groups.google.com/group/velmex-controls.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Velmex Controls" group.
To unsubscribe from this group and stop receiving emails from it, send an email to velmex-contro...@googlegroups.com.