LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communications and the change of numbers to characters

I am doing a simple write and read using a serial connection. I am using Labview 7.0. The code is really close to the example code that comes with labview. I am controlling 4-Red Lion T48 controllers and 2-Red Lion PAX meters. They are all connected using an RS-485 cable and then goes through a RS-485 to RS-232 converter and then comes into the computer through an RS-232 serial connection. I have no problem writing to the controllers and meters. When I recieve information some of the numbers are changed to symbols. The numbers and their representations are listed below. I am wondering if this is caused by a setting in labview or if I just need to take it for what it is and write a search and replace to my code. My other concern is that this might be caused by the converter.
 
0-- superscipt 0
1--1
2--2
3-- superscript 3
4--4
5-- (mu)
6-- (paragraph symbol)
7--7
8--8
9-- superscript 1
 
If you need the code let me know.
 
0 Kudos
Message 1 of 17
(4,377 Views)
The code would also help, but what are the actual ASCII values that are being returned for each of the numbers? The ASCII values for the numbers should be 30 through 39 hex, or 48 through 57 decimal.

Also does this happen consistently or is it random.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 17
(4,363 Views)
I am away from the computer that has the code but I will be able to post that tommorrow afternoon. I am sorry but I don't understand what you mean by ASCII values but if I am supposed to get back 34 I get a superscript 3 and a normal 4. If you put the numbers in code format then it displays \s\s\s\s\B34. If I am supposed to get back a 46 then I get back a normal 4 and a paragraph sign. The code form is \s\s\s\s4\B6 This happens consistently.
 
Ben Williams

0 Kudos
Message 3 of 17
(4,357 Views)
Can you post an entire string in the code format along with what you think is supposed to be there? It looks like the ASCI values are being modified in some way and seeing a complete string might help me figure out what is going on.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 17
(4,342 Views)
Hi Ben,
 
 it sounds like the data may be being sent as binary data as opposed to ASCII characters for the data.  There may 2 ways to solve this.  One way is to confirm that the format of the data sent is indeed ASCII and if not changing settings on the Red Lion gear.   I
 
 f this is on an option, fire up Hyperterminal on your computer (Start-> Accessories->Communications->Hyperterminal under winxp) and see what the data looks like there.  This step isn't going to solve anything but it may well give you clues to othe exact nature of the problem.
 
 Within labview, I would suggest type casting the string that comes out of the buffer to a number.  The type of the number will have to match what is being sent but this may give you what you are after.  I had to do this when sending data that was a mix of strings and numbers where the receiver was expecting the data in binary representation of the data and did not want ASCII.
 
 Please let us know how you go.
 
Cheers,
Peter
0 Kudos
Message 5 of 17
(4,338 Views)

Hello,

please also add some ms sleep between the reads and writes, that helped us a lot!

Regards, Martin

0 Kudos
Message 6 of 17
(4,323 Views)

It looks to me as though the Red Lion kit is sending the character out in even parity, and you're reading in 8bit/no parity.

The bit patterns of the ASCII characters 1, 2, 4 7 and 8 all contain an odd number of 1's, (example the ASCII character 1 has a bit pattern of 0011 0001, ie three 1's) so aready odd parity and are transmitted without change.

The other characters have a bit pattern containing an even number of 1's, for example the ascii character 6 has a bit pattern of 0011 0110, so when tranmitting this over a data link in 7data/odd parity, the top bit is set to 1 to make an odd number of 1 bits, so it is transmitted as 1011 0110. It is thic character+parity that I think you are reading into a string. As an example, If I set an 8-bit unsigned to this value, and flatten it to a string, I get the paragraph symbol.

So.... Check the parity setting when you configure the serial port. My guess is that you have 8bit/no parity (or possibly 7/even) on the LabVIEW, and the Red Lion is set to 7bit/odd parity and it ignore parity errors on receipt.

 

Rod.

 

Message Edited by Rod on 07-12-2007 05:37 PM

Message Edited by Rod on 07-12-2007 05:43 PM

Message 7 of 17
(4,306 Views)
Whoa... Nice piece of detective work there Rod.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 17
(4,290 Views)

Oops did anyone else spot the deliberate mistake?...

 

For "It looks to me as though the Red Lion kit is sending the character out in even parity", read "It looks to me as though the Red Lion kit is sending the character out in ODD parity" and the rest follows logically.

 

 

Message 9 of 17
(4,286 Views)

Thank you all for your replies. I do however have the serial port set to the odd parity and 8 bits. The red lion hardware is also set to odd parity. Though I have concluded my problem lies in the fact that Red Lion is sending me numeric information and the serial read is reading a string. Thanks to Rod's post I believe this is why I am getting these symbols. If someone could tell me how to fix this I would be most appreciative.

 

Ben Williams

0 Kudos
Message 10 of 17
(4,273 Views)