LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help for RS232 Bit data communication

Hi, and thanks all people can help me...

I'm using Labview 5.1 from two months and i'm not very expert
programmer.
I must send a sequence of 27 indipendents bit on serial port, theese
signals are used to command an electronic system. The RS232 function
on LabView utilize strings for communication, in this case the 1 and 0
(char of string) are 110001 and 110000 in binary code and determine a
bad operating on electronic system. I've thinked to convert my binary
data to string, but can't operate directly in binary mode, because the
number (for example) 001101 is used for 1101, this is correct but i
must have all bit of a number to command the electronic system
correctly.
Exist a function or a mode to manage directly bit for signals
and send
it on serial port?
Thank you very much!
Kaso.
0 Kudos
Message 1 of 11
(3,867 Views)
You can install and use the VISA commands to gain control over the individual pins of the COM port if this is what you need. You can then set the pins for the required time perion using software and so generate a pulse train over the serial port.

If you are looking to output a String which represents a bit pattern, the normal VIs should do the trick. Please make sure the baud, parity and stop bits are correctly set so that both parties involved can communicate.

Please note that the String 1101 is very different to the bit pattern 1101 (It`s a lot longer for one thing). This is of critical importance in deciding how to achieve what you want.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 11
(3,867 Views)
Hi Jack,

you can convert a number into a bit string by using the "Format into String" function. Use "%027b" as format string to get a string with the length of 27 bit and paddes with zeros. Your number 001101 will then be "000000000000000000000001101".
The 0 in the format string forces to pad with zero and the 27 is the total length.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 3 of 11
(3,867 Views)
Jack,

the RS232 protocol not only send out your characters as a serial high-low sequence, there is also one start and at least one stop bit. I don't know if the VISA or the 'core' COM driver supports a 27bit sequence.
For me it sounds like you want to control some hardware without the RS2323 protocol, more like the I^2C stuff. Driver for these can be found in the web for the printerport with some shematics. One ready example is http://www.xicor.com/pdf_files/seminars/Using%20Labview.pdf

Regards
Henrik
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 4 of 11
(3,867 Views)
You cannot use the serial port to send out an arbitrary pattern of 27 bits. The port is wired to send out characters, each character consisting of one start bit (0) 5-8 data bits (1/0), maybe a parity bit (1/0), and one or two stop bits (1). You cannot get rid of the start and stop bits.

If you mean you need to send out 27 BYTES of 0 or 1, you can set your string to show "\" codes and enter a "\00" or a "\01". But each byte you send out will have a start bit, 8 data bits, and a stop bit.

If you mean you need to send out 27 CHARACTERS of 0 or 1 - you're set.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 5 of 11
(3,867 Views)
Actually, even if the serial port OS driver wanted to write 27 bits at a time, the 16550-based hardware (UART) doesn't allow it.
0 Kudos
Message 6 of 11
(3,867 Views)
I disagree, although the procedure is somewhat tedious.

The VISA interface allows individual setting of some pins (not all: DTR is available for example). By using a timed loop, it is possible to send a pulse train just as you could with an I/O card. Of course the timing is limited by the OS, but the basic principle remains. If the period of the pulses is acceptable (around 10 ms should be do-able) then this approach can be used. This approach, of course, has nothing to do with the serial protocol and circumvents the start bit, stop bit and the baud setting.

If I`m wrong on any points, please correct me.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 7 of 11
(3,867 Views)
True, you can bit-bang RTS, but you have very little control over timing.
0 Kudos
Message 8 of 11
(3,867 Views)
You are correct.
I should have said "You cannot use the normal transmit functions of a serial port to send an arbitrary pattern of 27 bits."

It could be done, if the baud rate is low enough, and if the timing accuracy is not that critical, and if the program / OS is not that busy otherwise.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 9 of 11
(3,565 Views)
"Bit bang"?

I like this phrase. I think it sums up the brute-force nature of the solution. I agree this is a very limited, crude method of doing things, but it does work in some cases. I would only use it as a last resort though (And have only had to do so once thankfully).

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 10 of 11
(3,867 Views)