LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port reads unconventional characters

Hi,
     I'm using the serial port to read 32 8bit numbers and have been getting some strange characters read back.
    I've tested the hardware with Matlab which works fine but with Labview I get the following string
 
    À Ð à Ð àÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐÿÐ À
 
   Since these are not standard characters I can't seem to convert them to any other format. I've also used an ActiveX control (AComPort) in Matlab to do the same thing and I get the identical string above, so its something to do with the format rather than an error in the reading I think.  However if I use AComPort to read one byte at a time (rather than a string) I get the correct numbers, so could I do the same thing in Labview?
Thanks for any help
 
Emrys  
0 Kudos
Message 1 of 7
(3,084 Views)

Looks like hex communitaction to me.  This is not ASCII so you will not get back readable characcters unless you convert them and they still may not be readable.  Use the String to Byte Array Function to see if they make any sense and consult the ASCII Table.

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 7
(3,080 Views)

hi there

i bet there's something wrong with the serial port settings

- Enable Termination Char (T)
- Termination Char
- data rate
- data bits
- polarity
- stop bits

you can adjust these settings with the "VISA Configure Serial Port.vi". please check if the settings are correct.

you wrote "However if I use AComPort to read one byte at a time (rather than a string) I get the correct numbers", so try 8 databits, 1 stopbit, no parity and disabled termination character or see the documentation of AComPort .

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 7
(3,077 Views)
Agree, start with the obvious.  STEP #!: Check you serial port settings. 
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 4 of 7
(3,074 Views)

Thanks, the string to byte array conversion works fine, although I'm still not certain why the characters look odd.  Exactly what format are they in?

Incidentally, if I want to write two 8bit numbers what is the best way of doing it. If I create a string from '255' and '32' will I have to pad them out with zeros to '255032' ?  

 

Thanks again

Emrys

0 Kudos
Message 5 of 7
(3,071 Views)

Assuming it is Hex, use Byte Array to String to Send Characters.  What exactly are you talking to?  Is there a manual?

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 6 of 7
(3,061 Views)

The hardware for the serial communication was custom built to write seven bytes and read thirty-two. There is no manual but I know the guy who made it and so can ask him. I'm sure its not using Hex values but if the string-byte conversion works then I'm happy to use it.

Thanks

Emrys

0 Kudos
Message 7 of 7
(3,055 Views)