View Single Post
  #1  
Old 10-08-2010, 12:41 AM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Unhappy Question about serial port

Hi.
I need help about serial port problems.
My program currently using treadmill as output device for position data and patriot for orientation data.
I`m using serial port module like most of this forum user using right now.
Matlab is my main program previously but i changed to vizard recently.
But i still use my original matlab m.file as reference.
This is my original matlab command.

#set serial port
s1=serial('COM1');
set(s1,'Terminator','CR');
set(s1,'InputBufferSize',1024);

#open port
fopen(s1);

#unlock treadmill and read data
fprintf(s1,'S0000');
OutData=fread(s1,5);
OutData=OutData(2:4,1);

#lock treadmill
fprintf(s1,'Z');

I can set my treadmill to lock@unlock without no problem.
When i run the program no error occured but i received no output bytes from it.

x=ser.read()
print x
print 'received',len(x),'bytes'

input/output window show:
['']
received 0 bytes

I`m pretty sure i got no mistake about serial setting or vizard command because i adjust the parameter for serial and i can lock@unlock my treadmil.
So i assume there must be a problem with the connection of terminator and inputbuffersize command in matlab.
I`m not really sure this is the cause for my problems but i dont know how to set this in vizard so i just assuming it.
Any menthod to changed this in vizard fot this 2 parameter to the way i changed it in matlab?
Or did i miss some commands?
I already tried this for this whole week but still no positive results.
Really need help.
Thanks.

MJ
Reply With Quote