WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 4.67 average. Display Modes
  #1  
Old 10-08-2010, 01: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
  #2  
Old 10-11-2010, 01:13 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Are you reading in the data every frame through a function registered with vizact.ontimer or vizact.onupdate?
Reply With Quote
  #3  
Old 10-12-2010, 01:47 AM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Thanks for the reply Jeff.
Yes i already tried with both function vizact.ontimer and vizact.onupdate but still no positive results.
The input/output window still show results as below.

['']
received 0 bytes

Is there any way i can put this command in vizard?

set(s1,'Terminator','CR');
set(s1,'InputBufferSize',1024);

I`m not sure this have connection or this is the reason i cant get the data.
But i dont know how to change this command in vizard so i cant test it out.
I also searched about this two functions on website but seems all the results is just related to matlab.
I really need help about this.
Thanks

MJ
Reply With Quote
  #4  
Old 10-18-2010, 01:31 AM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
Hi.
I try changed the command and sometimes got this in input/output command window.

['R']
received 1 bytes

What is the meaning of this?
Is it mean i got the data but can`t read it in vizard?
I supposed to get counts(numbers) but i got letter 'R' as my output.
I already tried about this serial for this last two weeks.
I really need help about this.

MJ
Reply With Quote
  #5  
Old 10-19-2010, 11:45 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Are you using the pySerial module? There should be no problem getting serial data in Vizard using that, it is just an add on for Python. The pySerial documentation should have examples of reading data into a Python script.
Reply With Quote
  #6  
Old 10-21-2010, 01:58 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Using default port parameters?

It looks like you're mostly using the default values for the serial port parameters (baud rate, parity, and so on). It might be worth checking that these defaults are the same in pySerial as they are in Matlab...perhaps find out what values the Matlab serial port uses and explicitly set those in the Python code...
Reply With Quote
  #7  
Old 11-21-2010, 04:53 PM
mizutani_jun mizutani_jun is offline
Member
 
Join Date: Jun 2010
Posts: 23
I already solved this problem.
Thanks.

Last edited by mizutani_jun; 11-21-2010 at 04:56 PM.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading form serial port strangeness nige777 Vizard 6 06-22-2010 01:04 PM
serial port with vizard Moh200jo Vizard 3 03-13-2009 04:21 PM
General question and question regarding arrays dan12345 Vizard 1 01-15-2008 11:15 AM
PPT error Plymouth Precision Position Tracker (PPT) 2 05-25-2006 04:40 AM
A simple Plug_in for reading data from serial port sled Plug-in development 0 08-12-2003 10:52 AM


All times are GMT -7. The time now is 05:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC