View Single Post
  #1  
Old 02-12-2008, 02:46 PM
Rachel Rachel is offline
Member
 
Join Date: Feb 2008
Posts: 3
Incoming floating point values

Thanks for your help last week setting up a socket to write from an external machine. That is working, and I'm able to communicate with Vizard, but there are a few behaviors I don't understand. I'm using an external computer to send position data simultaneously to a motion base and to Vizard. The goal is to syncronize the viewpoint in Vizard with the excursions of the motion base. Three things are troubling me.

1. I want to send Vizard floating point values. I'm sending from Matlab running on another machine. When I send using an "fwrite" command, which writes binary text to an instrument, the data Vizard displays (when I ask for it using the print command) isn't what was intended. If I send a 5, it displays ENQ. If I send a 1, it displays SOH. But, if I send from Matlab using "fprintf", which writes text to an instrument, I get the 5 and the 1.

If I call the incoming position values "data" and say:
data = float(data)
and send Vizard a list of -2, -4, -2, -4,
it is received as -2.0, -4.0, -2.0, -4.0, which is fine.
But if I send it a +2, it reports an "invalid literal for STX" (how it reads a 2)

Vizard does okay using this fprintf workaround as long as I don't send an integer or a zero. Any value with decimals seems to work. But, I'd like to find a way to get them there using "fwrite" instead of "fprintf", because I sometimes get float errors on the Vizard side and I think if the data were coming in via the "fwrite" command, as binary data instead of text, things might go better.

My question is, am I misusing the float command? Should I do something else to make sure I get a 2 and not STX, for example?

2. A follow-on question is whether there is a way to determine how fast Vizard is reading incoming data. I know how fast I'm sending from Matlab, but can I verify how fast Vizard is reading it in? The reason I ask is...

3. The position data (sinusoidal) sent to the motion base and to Vizard is the same. But, the base is starting the motion at a center point whereas Vizard is starting at the left extreme. So, when viewed together, it looks like there is a 90 degree phase shift, or it's as if the base is moving as a sine wave and the Vizard viewpoint is moving as a cosine wave. Any idea why that might be?

As always, my sincere appreciation for your time and input.
Rachel
Reply With Quote