03-23-2012 12:57 PM
Hi everyone, first post!
My problem is: I have a slave that is communicating modbus RTU / serial RS485. I got myself a USB-485 because my representative told me that is what I need to communicate with modbus.
Now, what would be my first steps ? All I tried by my own didn't work (not even able to read the serial port on a buffer). I think I just don't start the process adequatly. Please tell me what would be my first step.
I don't need detailled steps, but a high level view of those steps.
03-26-2012 06:43 AM - edited 03-26-2012 06:43 AM
Get a feeling that you miss some knowledge about your problem.
First of all RS-485 is a hardware type interface. Regardless of the data type.
ModBus is a data protocol. Regardless of the hardware interface.
You have a RTU / RS485 slave. So your USB interface is correct.
Now you need to handle the ModBus protocol. Simple writing something (and reading) is not enough.
Use the ModBus library from NI. You can find it here.
03-26-2012 07:00 AM
Thank for the reply.
I do know difference between serial and ModBUS. I have already tried the ModBUS lib, but can't make it works and this is hard to debug myself because there is no help detail with that lib (well it has, but do not work, when I open help on a VI's, return me a blank/error internet page on the help window), maybe you have this help written somewhere else so I could use it.
That is why I decided the start from the beginning by opening a serial com and just look if I can see data at my port. I see nothing.
03-26-2012 08:54 AM
Whenever I have to talk to a ModBus device I do not use the MB lib. I just create my own ModBus messages.
During testing it was easier to use my own VI's and after that it was easier for me to keep using them.
MB is rather simple to use.
It also depends on what MB commands you need to use.
03-26-2012 09:12 AM
The only command I need to do is read and write holding registers, nothing to much complicated. I have my table of registers and I do have suceed in the past to communicate with my actual slave with another device via modbus.
If you tell me the MB lib from NI isn't appropriate (as I tough at first) I will write my own protocole, but never did it before, this is why I asked what would be the steps to acheive it from the beginning and what method could be used to test my serial com is actually working.
03-26-2012 12:22 PM
It is not that the MB lib is not appropriate, but for me it is better and easier to construct the MB messages myself.
You can start with the MB loopback command. Every MB slave should support this command.
If you send the following 8 bytes:
0108 0000 8844 8638
you should receive the same bytes back from your slave.
01 is slave address
08 is the loopback command
0000 is data of the LB command (must be zero)
8844 is custom data can be anything
8638 is the CRC of this command
The bytes are in hex so you must set your string control to hex
Let me know what you can do with this command.
03-26-2012 02:29 PM
Please have a quick look at the test VI I quickly built. How I understood it, I write the loop back command at the serial port and I should read it at the read buffer, am I right? This does not work, read buffer's always empty '' ''.
If yes, I will start looking at my hardware slave... maybe my problem lays there.
03-28-2012 06:07 PM
Did some works... finally found the problem was not software, but hardware. I did a loopback (shorting Tx - Rx) with my USB-485. Works very well. Doing so I realized the pinout of the DB9 connector was not as I tought it was (pdf joined).
I need to build a new cable to interface the USB485 to my slave. My question is the following:
I am not sure which pin of the USB485 i should use. My slave pinout is only RS485+, RS485- and shield. I do not have Tx+ Tx- Rx+ Rx-.
How do you think I should make the connection between my slave and the USB485????