LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

comm with serial devices with data collision avoidance

Anybody do have LV VIs which communicate with two or more serail devices independently, with transmit and receive data with collision avoidance?
May be I use the wrong term collision avoidance, may be a traffic controller.
0 Kudos
Message 1 of 6
(4,147 Views)
I have used vi's that communicate to a DUT on one serial port (COM1) and to a barcode scanner on a different port (COM2). They run nicely without collision.

Is this what you are referring to? If so, it is quite simple. You can use VISA to setup the serial port and its attribute for one device and use another VISA for the other device (with it's own attributes).

Simply make sure you never cross your reference lines ;o)

VISA is quite simple to use & setup in LV7. LV6 offers a choice but experiment with VISA. "Traffic control" is taken care of by LV. As I said, make sure you label each COM port well and make sure you use the right reference when "feeding" within your vi.

Hope this was clear. If not, give me more details, such as which version of LV
you are using and what you are trying to achieve with the serial ports.

JLV
Message 2 of 6
(4,147 Views)
Hi Joel,

I apologize for not clear about number of COMport. I meant only one COM1 to three devices using a little adapter convert RS232 to RS485.
COM1 <-> weigh scale, HP DMM and Serial Temperature.
0 Kudos
Message 3 of 6
(4,147 Views)
okay...

I unfortunately do not have a vi to do this. You may want to create an event-driven with semaphores to control the communication to the devices.

Event-driven in the sense that when you transmit or receive communication, you could use some sort of header to identify source/target of communication.

Semaphore: in the sense that there is a key which only allows communication to one device at a time..

I know this is a very crude suggestion..

Hope it does help..

JLV
Message 4 of 6
(4,147 Views)
Hi,

The serial protocol does not define any mechanism for multiple access to the bus. In RS-232 is meant to be for point-to-point connection (single device). RS-485 provides different transceivers that allow the connection of multiple electrical interface, but logically there isn't any mechanism that controls bus access. The frame format for RS-232 and RS-485 is the same. In fact, both use the same UART (serial controller).

You need to specify your own protocol to avoid collisions. Typically, RS-485 networks work in a master-slave model. The master asks a device for info, the device sends the data. No device sends data until it is queried by the master.

Hope this helps.

DiegoF
National Instruments.
0 Kudos
Message 5 of 6
(4,147 Views)
Do the three devices have RS-485 interfaces for a two-wire, multi-drop bus, or do they have RS-232 interfaces and you were hoping to add a converter to each device so they would communicate via a common RS-485 bus?

If they have RS-485, look at the manufacturer's specs for the command protocol to use. Typically, each device will be configured with an 'address' having two hex digits, and will only respond to commands that start with the correct address value. At the PC end, make sure your converter is one that can correctly handle enabling/disabling its transmitter as needed - sometimes called 'auto-gating'.

If they have RS-232, you are probably out of luck. You might get it to work if (a) all three devices only send data in response to a query from the PC,
rather than constantly spitting out measurements, and (b) no device returns any error message when it gets a command intended for another device - but I think this is unlikely. (I'm not aware of any 232-485 converters that selectively pass messages depending on the address value, but that would be a solution.)

It's probably much easier to equip your PC with extra serial ports - maybe using an external, multi-port USB-serial or ethernet-serial box that you could install near to the devices.
0 Kudos
Message 6 of 6
(4,147 Views)