12-21-2005 09:27 AM
12-21-2005 09:41 AM
Most probably, you never get the right chars on the receiver side since you didn't provide a way of synchronization. How many chars should you receive ? Your receiver will get only the chars already arrived on the serial port, even if the string has not be received entirely, resulting in an error. And of course, at the next loop iteration, the things will get even worse, since reading the serial port will bring the unread remains of the previous com...
Read the port until you have received all the chars, before converting to actual numerical values.
12-21-2005 11:20 AM - edited 12-21-2005 11:20 AM
Message Edited by 8144-9199 on 12-21-2005 11:24 AM
12-22-2005 02:44 AM
12-22-2005 03:22 AM
Synchronization is not the only issue in your vi. There is also a mistake in the way you convert from double to U8 in the sender, and back on the receiver side. Any number would be converted to an integer value between 0 and 255, and I don't thik that this is what you had in mind. There are several solutions. I have attached a simple one, to convert the double array into a tab separated string, then back to an array.
An example of what you could do to synchronize the reception is also given. As I said, it is an example, not a solution to your problem. You will have to get a better understanding of what is going on when you communicate between machines. For instance, what happens during the first communication, immediately after start ?
12-22-2005 01:56 PM - edited 12-22-2005 01:56 PM
Message Edited by 8144-9199 on 12-22-2005 01:59 PM
12-22-2005 02:02 PM
01-06-2006 01:40 PM - edited 01-06-2006 01:40 PM
Message Edited by 8144-9199 on 01-06-2006 01:44 PM
01-07-2006 12:56 AM
I already told you that your conversion was a mess, but you didn't listen to me... and you didn't either verify your work !
You are creating a curve with 1000 points (doubles) that is exactly 8000 bytes long. Then you convert it implicitely to a 1000 bytes U8 array (means that the highest value will be equal to 255, all the negative values will be converted to 0, and all intermediates values in between will be rounded to integers. If your sine waves had an amplitude equal to one, you will finish with a nice square wave !). The residual 1000 U8 array is then converted to a string, successfully sent through the serial port, then converted back to U8 and to Doubles. Of course there is no way to recover the initial values since the first conversion step has spoiled the data.
I have modified your test vi, just removing the communication operations. See my point now ?
There are several other ways to convert numerical values to serial string. The simplest one is to use the Fract/Exp String to Number function, in the string/number conversion subpalette. A more advanced technique would be to convert your double array to a string using the Type Cast function (in the Advanced/Data Manipulation subpalette) then back to a double array. I have added this method in the attached vi. Just see in the case structure...
01-09-2006 08:36 AM