LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Labview to read a modbus

I need to read the modbus of a process gas chromotograph. I'd like to use labview since I am familiar with it and I use it in other parts of my application. I've found some German and Norwegian sites with Labview modbus VIs, but they all seem to require RS232 communication, and the people that put together my GC only allow communication with the modbus using RS422. So, I need to write a program using regular Labview VIs to read the modbus over RS422. I can probably figure it out eventually, but I'm crunched for time. Can anyone out there give me any idea of the problems I am going to encounter, how to go about this, etc?
0 Kudos
Message 1 of 18
(9,263 Views)
Hi Denise,

RS-232 to RS-422 converters are cheap and readily available.

By one of these, plug it in, use the existing drivers.

Problems? maybe wiring the gizmo if you do not have documentation on pin-outs.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 18
(9,261 Views)
hello ben,

all i can say is 'duh'! it's so easy! too bad i always miss the easy solutions. thanks for helping me get my head back on straight. 🙂
0 Kudos
Message 3 of 18
(9,261 Views)
Denise,

I would like to recommend to use a ModBus PCI card instead of the
converter. Modbus is half-duplex (both data directions, but one after
the other one) and RS232 is full duplex, needs one more wire and so both
data flow directions are allowed at the same time.
Using Converters you have to to switch between send and receive
typically with the RTS signal availible on the RS232 plug. You have to
wait some time for the answer and you need to find some delay times for
the switch between send and receive.
Using a PC card (ie Moxa Industio) you have not to care about this
switching timing problems - you can just send and receive data as it
would be full duplex, all the problems are handled by the card and it's
buffers.

Good luck
Urs Bogli

Ben schrieb:


> Hi Denise,
>
> RS-232 to RS-422 converters are cheap and readily available.
>
> By one of these, plug it in, use the existing drivers.
>
> Problems? maybe wiring the gizmo if you do not have documentation on
> pin-outs.
>
> Ben
0 Kudos
Message 4 of 18
(9,261 Views)
urs,
thank you for pointing out the timing problems that come with using a converter. i wasn't aware of those. however, i might not have to worry about it.
the gas chromotograph modbus output is half-duplex 422, but it is wired as if it were full duplex with all 5 wires needed for full duplex communication. the company that made the gc built it that way. would this eliminate the need to worry about the timing issues?
also, i have a national instruments 2-port 485 card. would using this to receive the signal take care of the timing problems? i know it can send and receive 422 signals.
if i have to use rs422 or 485 hardware, i'll have to modify the labview programs i've found because all of them are set up for rs232 communication an
d not 422. most of them are password protected so i cannot change the VIs. this leads back to the original problem i was hoping to avoid - having to write my own program to read the modbus.
so i'm hoping you write back and tell me that having my gc output already wired as full duplex takes care of the problems you talked about. 🙂
0 Kudos
Message 6 of 18
(9,261 Views)
You a stuck on a non-issue. As far as the software is concerned, 232,
422, and 485 are all the same. Using modbus is still just serial port
communication for the software. There are hardware differences, but the
485 board you have is fine for use with 422 modbus as I have done that to
different modbus hardware many times.
Bart
0 Kudos
Message 7 of 18
(9,261 Views)
bart,
you're telling me that i can use the regular serial VIs to read and send data to the modbus, right? so what's the point of the special programs i've been told about, like busview? does this special software simply take out the need for me to know about things like sending a colon at the start of messages in ASCII framing or knowing how to calculate CRC error checking numbers in RTU framing? from what you've said, the type of serial protocol is totally irrelevant. what about busview, which has regular code imbedded in the VIS. these are probably C or something like that. do other programming languages care about which serial protocol is being used?

denise
0 Kudos
Message 8 of 18
(9,262 Views)
Denise,

RS-232, RS-422 and RS-485 are Electrical Standards that define how bits are sent down a wire.
(plus and minus voltages, etc, you really don't need to know anything more about the standard to use
it, the UART in your PC handles everything for you) These standards have nothing to do with modbus.

Modbus is a protocol, a master/slave language used to communicate between hardware devices over
RS-232, 422 or 485.

You need a modbus "driver" or piece of software to communicate over the wire between the
devices. One half of the driver is the master (usually at your PC) and the other half is the slave,
usually residing in firmware in your instrument.

Soooo, if you have an RS-485 card in your PC, you can send
modbus messages to your instrument using
your LabVIEW modbus driver software.

Clear as mud?

Alan




"Denise Brown" wrote in message
news:50650000000500000092770000-1019262487000@exchange.ni.com...
> bart,
> you're telling me that i can use the regular serial VIs to read and
> send data to the modbus, right? so what's the point of the special
> programs i've been told about, like busview? does this special
> software simply take out the need for me to know about things like
> sending a colon at the start of messages in ASCII framing or knowing
> how to calculate CRC error checking numbers in RTU framing? from what
> you've said, the type of serial protocol is totally irrelevant. what
> about busview, which has regular code imbedded in the VIS. these are
> probably C or something like that. do other programming languages
> care about which serial protocol is being used?
>
> denise
0 Kudos
Message 9 of 18
(9,262 Views)
alan,
man, i must come off sounding more ignorant than i thought. it's okay. when i wrote my first message, i didn't know what 'modbus' meant, other than my gc had one and i had to get numbers out of it. 🙂

i know all about the different serial protocols, down to standard pinouts and voltage levels on each. i've learned the modbus 'language', so to speak, in one night. it's just a bunch of function codes and addresses, really, sent in a specific format, and differences in what is sent depend on the type of framing used. before i learned the 'language' i was looking for drivers that would do all the dirty work for me to save time.

now that i know the format and the order numbers are sent using the specific protocol of the modbus in my gc (it's a modicon 584), i'm thinking i might not need those special drivers. i already use labview to communicate with microcontrollers via rs232, so i've got serial communication down. it was modbus protocol that i didn't understand. now that i know that, i'm looking for specifics that might trip me up later. for example, i had to learn that if i send data to my microcontrollers before they are ready to receive, i fill up the 2 byte buffer and an error bit gets set, which disables serial receiving until i clear that bit. it's things like that i am now looking for - little errors that aren't in the general documentation on a modbus that can set me back for days while i search through fine print, or general knowledge that isn't written anywhere that people in the field know, but the people that wrote my documentation don't.
i didn't think of any problems associated with converting half-duplex rs422 to 232. this way, i pay attention to it now instead of hooking it up, finding it doesn't work, and spending hours learning what someone that's already tried it could tell me in 1 minute.

so, to give an idea of what i'm doing: my labview program is the master, my gc is the slave, i'm going to check an output register to see if a change in the number stored in that register has occured, and if it has, i'm going to read 3 input registers. i'm going to do all of this over rs422 (unless i have more problems getting my 485 card to work in my dell), and i'm going to write my own program to do it using labview visa serial functions. i will format my commands in RTU framing (which is the only mode the gc uses), calculate the CRC number, send the 'command', and figure out what the modicon modbus protocol manual means by that timing stuff that seems to be so important in RTU mode. then i will read the response from my slave (gc), and i have my data, which i'm going to store in a file. the numbers in that file will later be sent to those microcontrollers i was talking about and used by them to maintain some gas concentration setpoints.

so, does anyone out there see any problems in this that i'm missing due to the fact that i've know about modbus protocol for exactly 5 days now?

and by the way, how does one get a half-duplex 422 signal to output on full duplex wiring? the guys who built my gc have 5 wires coming out of the modbus that are set up like full duplex, but it's a half duplex modbus. (they've been a little vague on the subject because the only guy who actually knows about the thing is out on sick leave for the next month). i think knowing some specifics on this might save me some headaches. i've learned that nothing is ever as easy as it looks on paper.
0 Kudos
Message 11 of 18
(8,609 Views)
alan,
man, i must come off sounding more ignorant than i thought. it's okay. when i wrote my first message, i didn't know what 'modbus' meant, other than my gc had one and i had to get numbers out of it. 🙂

i know all about the different serial protocols, down to standard pinouts and voltage levels on each. i've learned the modbus 'language', so to speak, in one night. it's just a bunch of function codes and addresses, really, sent in a specific format, and differences in what is sent depend on the type of framing used. before i learned the 'language' i was looking for drivers that would do all the dirty work for me to save time.

now that i know the format and the order numbers are sent using the specific protocol of the modbus in my gc (it's a modicon 584), i'm thinking i might not need those special drivers. i already use labview to communicate with microcontrollers via rs232, so i've got serial communication down. it was modbus protocol that i didn't understand. now that i know that, i'm looking for specifics that might trip me up later. for example, i had to learn that if i send data to my microcontrollers before they are ready to receive, i fill up the 2 byte buffer and an error bit gets set, which disables serial receiving until i clear that bit. it's things like that i am now looking for - little errors that aren't in the general documentation on a modbus that can set me back for days while i search through fine print, or general knowledge that isn't written anywhere that people in the field know, but the people that wrote my documentation don't.
i didn't think of any problems associated with converting half-duplex rs422 to 232. this way, i pay attention to it now instead of hooking it up, finding it doesn't work, and spending hours learning what someone that's already tried it could tell me in 1 minute.

so, to give an idea of what i'm doing: my labview program is the master, my gc is the slave, i'm going to check an output register to see if a change in the number stored in that register has occured, and if it has, i'm going to read 3 input registers. i'm going to do all of this over rs422 (unless i have more problems getting my 485 card to work in my dell), and i'm going to write my own program to do it using labview visa serial functions. i will format my commands in RTU framing (which is the only mode the gc uses), calculate the CRC number, send the 'command', and figure out what the modicon modbus protocol manual means by that timing stuff that seems to be so important in RTU mode. then i will read the response from my slave (gc), and i have my data, which i'm going to store in a file. the numbers in that file will later be sent to those microcontrollers i was talking about and used by them to maintain some gas concentration setpoints.

so, does anyone out there see any problems in this that i'm missing due to the fact that i've know about modbus protocol for exactly 5 days now?

and by the way, how does one get a half-duplex 422 signal to output on full duplex wiring? the guys who built my gc have 5 wires coming out of the modbus that are set up like full duplex, but it's a half duplex modbus. (they've been a little vague on the subject because the only guy who actually knows about the thing is out on sick leave for the next month). i think knowing some specifics on this might save me some headaches. i've learned that nothing is ever as easy as it looks on paper.
0 Kudos
Message 12 of 18
(8,608 Views)