11-19-2007 03:27 AM
11-20-2007 02:44 PM
11-20-2007 06:33 PM
11-20-2007 07:29 PM - edited 11-20-2007 07:30 PM
11-20-2007 10:35 PM
11-21-2007 06:40 PM
03-27-2008 05:32 AM
03-27-2008 10:48 AM - edited 03-27-2008 10:51 AM
You may need to post a little more information, like a link to the manual describing the communications for your device.
In Modbus, each register is 16 bits. Often, you would use 32 bit values which would go to a pair of 16 bit registers. Which is the the high order word and which is the low order word could vary depending on the device you are trying to talk to. On the Numeric/Data manipulation palette are several function for joining and splitting numbers which are very useful for combining 2 registers into a single 32 bit number, or splitting a 32 bit number for writing to 2 registers.
64 bit numbers are rather unusual for ModBUS applications. I haven't seen any using them yet. But it would require 4 16 bit registers to handle them.
Attached is a LV 8.0 version of the previous file. You may have a broken arrow because of missing typedef's for some of the constants. Also I made a copy of the NI modbus VI's and added CTA which was my project name to help prevent conflict with some other applications. With this file and the screenshot above, you should be able to clean up the errors for the broken arrow. You will have to rework to make it fit your application. This was just basically a wrapper so that I could use more meaningful names in my top level application and hide the MB register address details in a subVI.
As for error 6002, I think I've seen it before, but I don't remember where it comes from. I want to say it is either a timeout type of error or something being generated from within one of the MB subVI's. I ran a MB query and the timeout error was 6101 and was generated from a MB read subVI. So I think 6002 is a related error from one of the MB VI's.
03-27-2008 12:20 PM
Thanks for that...yeah my mistake...I meant one 32-bit number sent to two 16-bit paired registers. Currently we can only send one 16-bit number to the first register, where we actually need to send it to the second 16-bit register. We have tried writing to multiple registers (setting the first to all zeros) however this gave us an error. The starting address only seems to signify the first of the pair of registers, while the other seems to be inaccessable to us at the moment.
What we want to try now is pad our 16-bit command with zeros at the begging so it spans across to the second register. I've attached the pdf specifying the modbus protocol for our device, which contains an example start-up request and error codes. I thought the "6002" error code may have been related to the "Illegal Data Address" code shown in the manual.
So far when we write a single register, no matter which set-up/arrangement we try, the register is showning a number "62403." Again not sure if that corresponds to something that is vendor specific or is a saturated variable.
Thanks.
03-27-2008 12:52 PM - edited 03-27-2008 12:53 PM
Hi G.noble,
I'm looking at page 8 of the document you attached, and it confuses me.
It says "The following table details the register addresses assigned to the GCC data. Note that float types use two registers"
But the table shows all the register addresses only separated by 1. Usually for paired registers 40,001 and 40,002 will be one pair for one value, 40,003 40,004 would be the next pair for the next value.
It may be worth giving them a call to clarify how they address the registers. Also, do they provide any software of their own for communication? If they do, it might be worthwhile to run that and use NI-SPY or some other port capture program to captures some communication between that software and the device to see how it accesses the addresses.
Also be careful about just writing a bunch of zeroes to one register. IEEE 32 bit assigns certain bits to the mantissa, certain ones to the exponent, and also to the sign. So reading the bits for 32 bit floating number is not an easy conversion like it is if you were convering from binary to decimal integers.
Also always try reading from registers before writing to them. That way you can confirm if the value you read is what you expect based on reading it using their software, or a front panel interface, .... Otherwise you could write a completely wrong value by accident either by because the registers are shifted by one, or you are working with the wrong pair. Once you know you have things figured out so that the reads are correct, then you can work with writing.
It is a good chance that 6002 means illegal data address. I just don't have any Modbus hardware powered up at the moment to confirm this.
EDIT: Another thing I just noticed is that the vast majority of those registers are Read Only, so most of them you can't write to.