LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending binary data over RS232 without conversion to ascii

I need to send binary data to a PIC without the data being converted to ascii. With the VISA vi's, when I want to send 11111111, it gets converted to a string "255", and is sent as "2","5","5" in ascii.
How can I send it as one byte?
0 Kudos
Message 1 of 11
(7,117 Views)
You can use the byte array to string function to convert the byte to a string for VISA. This requires you to create an array. Else you can cast the data. I've attached a vi that has a couple of examples.
Message 2 of 11
(7,119 Views)
Perfect. That's exactly what I need. Thanks.
0 Kudos
Message 3 of 11
(7,119 Views)

I have the same problem: I want to send binary data over the RS232. Unluckily the suggested solution doesnt work for me since the communication protocol that is implemented on the target hardware expects a 9bit wide command. The 9bit command cannot be converted to an ascii character. Is there a way i can still make use of the VISA functions to transmit 9bit command instructions over serial protocol at 19200 baud, 1 stop bit and odd parity check?

Thanks for any suggestion.

0 Kudos
Message 4 of 11
(6,570 Views)

I have to run but try seraching " 9 bit" on this site and chasing the links.

 

This has been discussed before (mat Fitzimons?) and takes advantage fo using tow stop bits and lying about the parity.

 

It here somehwere.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 11
(6,553 Views)

What I want to know is what kind of idiot engineer designed a system to use a 9-bit command using a protocol designed for 7 or 8 bit data?  Duuuhhhh.... Smiley Indifferent

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 11
(6,540 Views)

Hi I found a thread in the knowledge base that addresses the 9 bit protocols, there is even an example that can be downloaded:

http://digital.ni.com/public.nsf/allkb/3bdc7ff03541f772862564990057f919
http://sine.ni.com/devzone/cda/epd/p/id/850

 

However, I am not sure if this solves my problem, since the protocol on my target hardware makes use of the odd parity bit. Does the Mark or Space parity bit add another 10th bit to the command or can i only use either ODD parity/Mark/Space?

 

@tbob: I probably shouldnt tell my customer that he's an idiot, and obviously 9 bit addressing/signalling modes seem to be not so uncommon in industry, so ur post does not really contribute to solve the problem.

0 Kudos
Message 7 of 11
(6,534 Views)

 

 


@r_keller wrote:

@tbob: I probably shouldnt tell my customer that he's an idiot, and obviously 9 bit addressing/signalling modes seem to be not so uncommon in industry, so ur post does not really contribute to solve the problem.


Well I wouldn't call my customer an idiot either.  I didn't know he was your customer.  Sorry.  Not every comment posted here is intended to directly solve a problem.  We are a fun loving group, and occasional ribbings take place here.  I still think that trying to use 9 bits over an 8-bit protocol is not a good way to go.  But if it is the only way, then so be it.


@r_keller wrote:

 Does the Mark or Space parity bit add another 10th bit to the command or can i only use either ODD parity/Mark/Space?

 


According to the link you attached, the parity bit adds only one more bit.  If the number of bits is set to 8, then the parity is the 9th bit, and you can only use Mark or Space to force that 9th bit to either 1 or 0 respectively.  If you try to use odd or even parity, the protocol will determine the parity and change the bit accordingly, and it may not be the one you intended to send.  The start and stop bits are fixed by the protocol and cannot be used for extra data bits.

 

Actually, until I read that article about using Mark and Space, I had no idea at all that sending 9 bits at a time was possible.

 

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 11
(6,526 Views)

 


@tbob wrote:

What I want to know is what kind of idiot engineer designed a system to use a 9-bit command using a protocol designed for 7 or 8 bit data?  Duuuhhhh.... Smiley Indifferent


The same one who designed I2C with 7-bit addressing and then discovered, that oh, wait, we need 10-bit addressing.

 

0 Kudos
Message 9 of 11
(6,524 Views)

@smercurio_fc wrote:

 


@tbob wrote:

What I want to know is what kind of idiot engineer designed a system to use a 9-bit command using a protocol designed for 7 or 8 bit data?  Duuuhhhh.... Smiley Indifferent


The same one who designed I2C with 7-bit addressing and then discovered, that oh, wait, we need 10-bit addressing.

 


Yeah, I've had to deal with that issue too.  I had to write new code to handle 10 bit addressing.  Why can't they just standardize on one and dissolve the other? 

 

If you think that is something, you should see the different flavors of SPI.  Each designer has to throw in his own little quirk, 4-wrie SPI, 3-wire SPI, 5 bit address, 6 bit address, 7 bit address, etc...

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 11
(6,517 Views)