03-29-2012 02:04 AM
Hi Eric,
What you have is a 4-wire RS-485 and a 2-wire RS-485 connection.
No problem to connect the hardware. Connect the TX+ and RX+ from one side to the RS-485+ on the other side. Same for the -. Also connect the 0V. Some say this is not necessary but believe me it is better to connect it. btw. this is not the shielding. Shielding should be connected to the ground (earth / case).
Your master device should support this. The receiver must be disabled during transmit. Otherwise you receive your transmitted message back.
Which USB device are you using ?
Kees
03-29-2012 03:38 PM
Thank you, seems to work.. well at least now I see on my port what I write.
Do you agree that if I write the following at my serial port:
0106 AAEC 0001 C070
It should write the value 1 to my holding register #43756 of the slave addr #1
??
Thank you
Eric
03-30-2012 02:18 AM
Hi Eric,
The command is OK but according to my calculation the CRC must be A827.
Kees
04-05-2012 02:07 PM
Hi Kees,
How do you calculate that CRC? Seems that everyone has his own way to calculate it... but the only way that seems to work is yours...
Thanks
Eric
04-06-2012 09:33 AM - edited 04-06-2012 09:35 AM
Hi Eric,
The problem is that there are many different definitions. Probably all correct but all for different situations.
The CRC within the NI ModBus lib is also correct. Otherwise it would not work.
It is attached as 'MB CRC-16.vi' set the string control and indicators to HEX display so you can see the input and output.
My version 'MBcrc.vi' (Don't know if I made it or copied it) the input is plain readable ASCII and the output is string in HEX display.
Just depends on the other VI which one is best.
Have fun with it.
Kees
04-10-2012 08:53 AM
Hi Kees,
Thx, indeed the lib from Modbus lib works pretty well.
Even though, still have not suceed to read or write something to my slave... Only thing that is working well is the loopback cmd.
When I try to write/read something, my slave do not react and I have a byte read count of 5 bytes instead of 8...
Example, if I try to send:
0106 AAEC 0001 A827 (should write 1 in the register 43756 of the slave addr 1)
I read
0186 02C3 A1
Any idea of what could be the problem?
Thx again
Eric
04-10-2012 12:29 PM
Hi Eric,
Your slave reacts just fine...with an error message
I don't understand what you write about the 5 or 8 byte count.
The answer:
01 slave address
86 is the command byte you sent with the high bit set indicating an error
02 the error number
C3A1 is the CRC
Consult the manual of your slave device. Something like wrong address or data I think.
I am at home now. Tomorrow morning I will check the command structure.
What slave device do you use ?
Regards, Kees
(from The Netherlands)
04-10-2012 01:35 PM
Hi Kees,
OK, at least I know that the communication is good, so the hardware is...
My slave is a DGC-2020. You can easily find its doc on the net... but I have joined the section about the modbus protocol, if you want to have a look.
Do yo work for NI?
Thanks
Eric
04-10-2012 02:04 PM - edited 04-10-2012 02:06 PM
Yeah, now it will get confusing.
First the addresses. The manual says register holding address 43756. The 4 at the start indicates that these are holding registers. Readable with ModBus command 4 and they use command 3. In practice both the same.
Try both addresses 43756 (0xAAEC) and 3756 (0x0EAC) to be sure.
The data for this register is Int32. So that is 4 bytes. On page B-6 of the manual the byte order is explained.
I think the complete command is: 01 06 0E AC 00 01 00 00 71 1A
Can you try this ?
No, I don't work at NI. 'They' will not give you these answers Sorry guys.....
Here I work. Support engineer for this half my time and repair engineer for the high-end T&M.
Kees
Hope I still get answers when I ask NI something.
04-11-2012 10:54 AM
Hi Kees,
Tried it rapidly, did not work, still got error messages. I had not realized at first look that my slave had 32bit reg addr. I will closely read its doc before continuing searching.
The CRC calculation will have to change?
Its a lot harder then I though it was at this start...
Regards,
Eric