Begin with the MB Serial Master Query VI. Save as a new name and work with that.
I am attaching a screen shot with some notes. Full details on Modbus can be found at
www.modbus.org. particularly
An input register (Read is command code 4) read from registers that are in the 30,000 series. Address 0 in NI will be register 30001. Address 1 will be 30002. (Usually you have to play with this to confirm you are reading from the correct register.) These are read only registers. You can only read data from them, not write to them.
A holding register (Read is command code 3, write a single is 6, write multiple is 16) are the registers that are in the 40,000 series. Again there is a offset of 1, and its best to verify this with your device. Holding registers you can read to and write from.
Coils relate to boolean storage locations you can read or write to. They are either on or off, true or false.
Discrete inputs are boolean storage you can only read from.
Between these they are the 0000 series and 10000 series. I can't remember which is which.
I usually use the multiple register functions because I often have 32 bit words I'm dealing with which takes up 2 registers. In those cases you have to deal with little endian and big endian to determine which 16 bit register is the significant word and which is the least significant. That may require swapping registers and joining U16 values to make a U32 value.
The results show up in the Registers Output Cluster in either an array of U16's (one for each register) or an array of booleans (also 1 for each register) all depending on whether you are reading registers or booleans. Whether you want it to show up as decimal or hex is all in how you set the display for the array indicator. You will need to index the arrays as necessary to send the data to wherever you need it to go in your program.
I hope this information helps. It is accurate as far as I know, but there is always a chance I said something wrong. You can use this query as your basic subVI in your main program. You shouldn't need to string along any other VI's. In some of my programs, I have wrapped this in other VI's where I created type def'd enums so that I could create something that says Get and Motor Status to be my commands and buried the knowledge of what exact register I'm referring to in a case select structure in the wrapper VI.
Message Edited by Ravens Fan on
02-16-2008 09:13 PM