LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial port in labview

Hello,

I have a question about working with the serial port in LabVIEW. I know about existing VIs that write strings to and read strings from the serial port. But is it possible to control each pin?
For example:
Is it possible to implement the following BASIC-Code in LabVIEW:

OUT &H3FC, (&H1 OR INP (&H3FC))

Thanks in advance,
Hans
0 Kudos
Message 1 of 9
(4,411 Views)
Not being familiar with the BASIC code you present, it's not clear to me what is meant by "...control each pin?". (Since RS232 serial only has two data pins - one for Tx and one for Rx) If you are talking about contolling and monitoring DTR, CTS etc. - LabVIEW's serial VISA functions do this quite no problem. Also, if you are wanting to write/read raw HEX data rather than string values, LabVIEW can do this as well. You make your HEX data in the form of a byte (U8) array, then use the "Byte Array to String" function to do a data type conversion just before inputing it into the serial function.

I think you will find LabVIEW's serial capability to be very extensive, flexible and quite efficient - especially if you are using the latest NI-VISA drivers.
Message 2 of 9
(4,407 Views)
The truth is, I also don't know how the mentioned BASIC-Code exactly works. I found an old data-acquisition board for the RS232-interface and the only information (about controlling and using the board) I got, was a short piece of BASIC Code.

Now I want to write a VI for reading and processing the data that are aquired by the board.
I'm going to try some of the VISA-VIs.
Thanks for your advice.

hans
0 Kudos
Message 3 of 9
(4,407 Views)

Hello,

 

How can I control other pins of the serial port?

For example:

Write/Read RTS(pin7 of serial port) signal.

 

Thanks advance!

Steven

0 Kudos
Message 4 of 9
(4,237 Views)

have a look at the VISA property node. 

Start with the bytes at serial port on your diagram and select the modem line of your choice and decide if you want to read or write the value

Message Edited by Henrik Volkers on 06-13-2006 03:16 PM

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 ǝɥʇ'


Message 5 of 9
(4,220 Views)

Hi Hans,

If I had understood your question right, you need to control the serial port pins ( switch it ON and OFF as and when you wish)??? If that is so, you can do it in two ways either with VISA or by writing directly into the registry for the ports in your computer. For the latter, you may use Out Port.VI to switch ON/OFF the port pin and IN Port.VI to read the status of the port pin. I think with VISA, you could not read the status of the pins, though i'm not sure of that.

To get an idea about this, look at the LV examples in the category "portaccess". I use this VI to control the Parallel Port of my computer from my LV application and it is simply fantastic and easy to programm.

But note, you have to first determine the address of the serial port register in your computer to control your port.

Regards,

Mohan.

0 Kudos
Message 6 of 9
(4,208 Views)

Oh, thanks guys,

The one way that W/R the port form properties it is OK. but in another way how can I get the port address? how about the pin definition?Smiley Indifferent

 

 

 

0 Kudos
Message 7 of 9
(4,190 Views)
Hi Steven,
 
Depending on the serial port, there are several ways to get the memory address of your serial port. If you have a non-plug and play AT serial board, you would manually set the I/O address (via jumpers or switches in most cases). If you are using a built-in serial port,look at your motherboard specs for built-in ports. Otherwise, open the windows device manager, find the port and look at the resources page. After finding this base address, it does not correspond directly to pins. The I/O range is something like 03F8-03FF and that corresponds to the registers that are required to program a 16C550 UART in most cases, but you would need to know what you are doing. If you put in the wrong I/O address you have the potential to destroy your computer because you are writing values in the kernel which has access to the entire computer (hard drive, video driver, etc). There is NO bounds checking.
 
If you want to see what damage you could do, open the device manager, and click on View->Resources by type. Expand the I/O folder and you can see all of the things you don't want to accidentally write to: the PCI bus, the system timer, the DMA controller, etc. That one little VI can write to any one of those, and it won't check to see if it's safe. Be careful.
 
I would suggest using VISA instead. Read and write these from the VISA property nodes. It is much safer, and you don't have to manually look up the I/O range in the device manager before you get ready to use a port every time. And VISA should be easier. Smiley Wink
 
I hope this helps.
 
Regards,
Missy S.
Project Engineer
RoviSys
0 Kudos
Message 8 of 9
(4,152 Views)
By the way,
maybe it is interesting that when you are able to control your
serial/parallel port in LabVIEW you can also control electronic applications
over USB.
For this you can use the Modules that are available from
http://www.ftdichip.com or you can use microcontrollers (like from
microchip) where you have an USB controller in it.

I think there are much projects online where you can see how you can use the
Serial and parallel port in LabVIEW, try expermenting with VISA;

kind regards,
http://www.vhdl.eu


"Steven_huang" <x@no.email> wrote in message
news:1150198806706-377775@exchange.ni.com...
> Hello,
> &nbsp;
> How can I control other pins of the serial port?
> For example:
> Write/Read RTS(pin7 of serial port)&nbsp;signal.
> &nbsp;
> Thanks&nbsp;advance!
> Steven


0 Kudos
Message 9 of 9
(4,140 Views)