07-28-2009 03:06 PM
RachtheSabu,
What you really need to know is what all is included in the response from the robot. You know to expect an I16. Does the response include other things like a termination character? A null is often used for this. It really sounds like part of the first response is ending up being read with the second response.
07-29-2009 07:52 AM
A sample of the string from the VISA read is : "ÿò"
Sometimes the string read in from the VISA has a space before the characters such as : "_ÿò" (where the '_' represents a space). I tried replacing the bytes at port with just the constant 2, but doing so I get incorrect values. Looking at what is being read in from the VISA read with the constant bytes, I typically only receive one character at a time (instead of 2). I have another way to communicate with the robot (that for a user is much less intuitive) and after writing the Hex commands 8E13, receive 2 Hex values back (i.e. 00 44) everytime.
07-29-2009 09:24 AM
When you specify 2 bytes to read, you will either get 2 bytes or an error. You will not get 1 byte unless you've done something silly like enable the the termination character with the VISA Initialize Serial Port.
07-29-2009 10:49 AM
07-29-2009 12:05 PM
ÿþ
ÿü
ÿø
ÿû
ÿ ü
ÿ ú
ÿû
ÿü
ÿ ü
ÿ û
ÿ ú
ÿ ú
ÿú
ÿ ù
ÿ ù
As you can see, the format is not constant and has spaces - the root of my problem (I think). I do have time waits between each write and read.
07-29-2009 12:10 PM
07-29-2009 12:38 PM
07-29-2009 12:40 PM
Again, the first section is using bytes at port, the second section using the constant 2 bytes. (The formatting was a little hard to tell, so the '-->' represents a tab - number to the left is from the first read, number to the right is from the second read.)
00FF FE -->
00FF FD -->
00FF FA -->
00FF --> FA
00FF FB --> 0000
00FF --> FA00
FFFB --> 0000
FFFA --> 0000
00FF --> FB00
07-29-2009 12:53 PM
It appears that either the manual does not adequately explain the communication protocol or you have not totally understood what it says. while it does seem that the data consists of 2 bytes, the robot is actually sending 3 and it is using the null character to separate the data. Wayne mentions this above. In order to synchronize the data being read, you can do a read until you detect a null, discard the null, and then read 2 bytes. After that, you can probably just always read 2 bytes, use that data, read 1 byte and discard.
07-29-2009 01:11 PM
RachtheSabu,
We seem to be going in circles here. If you look at the data you posted, a hex FFFE, FFFD, FFFB and a FFFA would all represent small negative numbers when converted to I16. The zero's are also expected. The problem is that your reads are not properly synced with the incoming data. The bit of code you posted shows sending a 4 byte ascii command and that you expect a 2 byte reply. I understand that. Where is the data from the other VISA Read coming from? Did you send a different command? Is this data continuously streaming from the robot?
If at all possible please post a copy of your vi and copy of communications manual for robot.
Dennis,
I think the tab "-->" characters were added to the post to differentiate first and second read data.