From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to link labview to a custom RS232 PCB

I want to know how to create a protocol in C (or other langage)  between the Labview software and a custom microprocessor board using Labview software. Am I obliged to use an interface and a NI driver or not? Offer to me a solution if it is impossible

Thanks

0 Kudos
Message 1 of 7
(3,526 Views)

All serial communication in LabVIEW is done with VISA and that is the only thing that needs to be installed. There are shipping examples (search for 'serial').

 

p.s. In the future, post questions to the Instrument Control board since this has nothing to do with NI Digital boards.

0 Kudos
Message 2 of 7
(3,521 Views)

Since you are creating the protocol, it can be whatever you want it to be.  The transmission channel is RS232 so you will need the VISA driver on the LV side and whatever translation hardware (i.e. MAX3232) to convert the RS232 input of your custom CPU to signals the CPU can use. That may already be part of the CPU board.

 

The protocol can be as simple or complex as required to get the job done.  When I create fixtures with embedded PICs, I keep things simple and use fixed length commands and keep everything (commands and data) as bytes.  This way I don't have to create a complex command interpreter on the PIC side.  As I am writting both drivers, I know exactly what is going on between the two systems.  Then just document the protocol so the next guy knows what's going on. An example of one of my "protocols" is:

 

 

S? = Return software version (vYYYYMMDD.xx)
F? = Return fixture ID (CAF-0023 Fixture <FIXT_ID>)
R(c) = Read fixture A/D channel (c) where (c) is the channel.  (c) must be
          passed as the ASCII value of the channel in the lower nibble and the ADC
          channel as a bit bit position in the upper nibble.
       
           ADC1 for Channel 0-7 (0x10 -> 0x17)
          ADC2 for Channel 8-15 (0x20 -> 0x27)
          ADC3 for Channel 16-23 (0x40 -> 0x47)
     
        i.e. to read channel 11, pass:
       
       r & Chr(&H23) 
       
       Will return 254 bytes of raw data as read from the A/D.  Data will be 
       returned as 127 2-byte pairs, MSB first in the format defined
       by the MAX-1202 spec. sheet.
       
r(c) = Similar to R(c) but only returns a single 2-byte value.
o(b) = Output byte (b) to the lower byte (Dout 0-7) of the output I/O expander.
O(b) = Output byte (b) to the upper byte (Dout 8-15) of the output I/O expander.
I? = Read the 16 bit input I/O expander.

 

 

Like I said, very simple.

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

Thank for the quick response but I don't know yet (because I don't know well the labview software) how the VISA work to configure a RS232 link. I have to define the baud rate, the number of bits the parity bit ... I know to do that in the PIC side but not in the Labview side. Have you some example to give to me?

0 Kudos
Message 4 of 7
(3,502 Views)

There are serial examples that come with LabVIEW. Help>Find Examples<Haardware Input and Output. Or just do a search.

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

If I want a USB link is it more complex or not ? In the PIC side I can place a USB driver but how to do a simple point to point link without having problem of identification

0 Kudos
Message 6 of 7
(3,496 Views)

It is much more complex if you use USB RAW instead of RS-232.

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