TCPIP Connection problem in matlab?

1 view (last 30 days)
Salil Anand
Salil Anand on 9 Aug 2012
Can any body help me out with the problem I am facing while making a tcpip connection with an instrument.Its like when I make a connection with the tcpip address using the following it works perfectly fine for any no of times.
1.test and measurement tool(TMTOOL in matlab)
2.Zoc terminal
3.teraterm.
but when I try to implement the following script its does run but dont know some how doesn't seem to send the command to the pan and tilt unit which I am tryin to control.
I am trying with two scripts:
A.
obj1=tcpip('169.254.32.28',4000);
fopen(obj1);
cmd=5000;
fprintf(obj1,'pp%d',cmd)
fclose(obj1);
delete(obj1);
I am trying to send a command pp5000
B.
%commands
lat=51.57668;
lon=-1.26765;
alti=500;
% Find a tcpip object.
obj1 = instrfind('Type', 'tcpip', 'RemoteHost', '169.254.32.28', 'RemotePort', 4000, 'Tag', '');
% Create the tcpip object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = tcpip('169.254.32.28', 4000);
else
fclose(obj1);
obj1 = obj1(1)
end
% Connect to instrument object, obj1.
fopen(obj1);
i=1;
tic
for i=1:10
% Communicating with instrument object, obj1.
fprintf(obj1, 'gg%f,%f,%f',lat,lon,alti);
i=i+1;
toc
end
fclose(obj1);
delete(obj1);
Desired result:
gg51.57668,-1.26765,500
The second script is just a little bit modified version of the automatic script generated from TMTOOL im matlab
Basically I want to print some commands on the desired object every half a second.
can anyone suggest some alternative or improvement that could be done to achieve the desired results.
I have been unable to execute these scripts and I think it should be correct with whatever small knowledge of matlab I have.I am a new user and I would appreciate if you could help.
Thanks
Salil

Answers (1)

Salil Anand
Salil Anand on 10 Aug 2012
Hi Lucas,
many thanks for your help.Tough i like your idea but I haven't had time to work on the code you suggested I will be posting very soon.

Community Treasure Hunt

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

Start Hunting!