LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I write bits through the COM1 serial port?

I'm trying to write bits through the serial port COM1.
Labview "Write VI" only writes everything in string. It seems. How can I write bit by bit through COM1?

Thank you,
Van
0 Kudos
Message 1 of 7
(3,797 Views)
Serial transmission (COM port) protocol requires sending a group of bits at one time. You cannot just send one bit. Standard COM port settings must be either 7 or 8 data bits, 1 or 2 stop bits, etc... You have to group your bits 7 or 8 at a time. You could probably send a 0 byte or a 1 byte. This would be like sending 0000 0000 for a low bit and 0000 0001 for a high bit. Your receiving end would have to know how to interpret what you are sending if you choose this method. Of course you have to convert your byte into a string before sending to COM port. Wire a U8 data type to a Build Array input. Then wire the array output to a Byte Array to String input. The output of this function will be the character representation of your byte suitable for sending acr
oss a serial port.
- tbob

Inventor of the WORM Global
Message 2 of 7
(3,797 Views)
Thank you Bob.
I will try this.
Is "Byte Array to String" vi
found under string pallete?

Much appreciated.
Van
0 Kudos
Message 3 of 7
(3,797 Views)
You are welcome.
Look under String palette, then under Byte/Array/String sub palette.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 7
(3,797 Views)
Thank you again.

Keep in touch.
Van
0 Kudos
Message 5 of 7
(3,797 Views)
This won't work, on the face of it, because an asynchronous serial stream contains 'start' and 'stop' bits, and the port returns to the 'stop bit' level at the completion of sending the current character. When a new character is put into the serial port register, a 'start bit', which is the opposite polarity of the stop bit, is sent, followed by the rest of the data bits, followed again by a stop bit. You'd probably be better served to look at using a parallel port bit for this job, as its output bit state should be latched in whichever state you last write to the port.

Hope that helps!

Bob Donnell
0 Kudos
Message 6 of 7
(3,797 Views)
Your receiving side could be programmed or configured to read the data and store the data byte (1 or 0). In other words, some program can read the serial port and just store the data value that was sent. The LSB of the data can be the bit that is used. Of course the proper hardware and software must be present on the receive side to make it work. You cannot just tie the RS232-RD line to whatever you intend to control.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 7
(3,797 Views)