Sorry, No. The company will not allow me to post source. However if you can tell us where your having problems at or post your code then maybe we can help.
I found most folks are not willing to help or share code for Industrial Protocols. Mainly because there is lots of money invested in development, or in sales.
Some code and Examples Can be found here:
http://www.modbus.pl/microchip.htm
Some Actual code can be found here on the list...
http://www.picbasic.co.uk/forum/show...=&threadid=316
It works but really needs to be doctored up some.
Modbus Specifications and Examples in C can be found here:
http://www.modbus.org/docs/Modbus_ov...al_line_V1.pdf
and
http://www.modbus.org/docs/PI_MBUS_300.pdf
Do yourself a favor and try real hard not to try and do the 3.5 character timeout. If your a slave, look for the 8 byte request, then check the ID, if good then check CRC, then Check FC and Process or Reject with Error Code. So on. Build the packet and ship back off and be done with it.
If your wanting to be the Master then there is a little more to it (not much) but some.
As in the documentation
RTU as follows:
Slave ID 1 byte, Function Code 1 Byte, Start Register 2 Bytes, Number of Regs to Get 2 Bytes, CRC16 2 Bytes
RTU example: 01 03 00 00 00 01 CRCH,CRCL
Ascii as follows:
Start of Message is a colon, Slave ID 1 byte, Function Code 1 Byte, Start Register 2 Bytes, Number of Regs to Get 2 Bytes, LRC 1 Byte, CRLF to end the message.
Ascii is sent as Ascii Hex. :01 03 00 00 00 01 LRC 0D 0A
I prefer to check the Slave ID first so I'm not checking CRC's all day long on other nodes messages.
You can handl ASCII and RTU with all the same routines, except for the following.
When Receiving the Data, you have to decode it a little differently
When Sending the Data, you have to encode it a little differently
LRC or CRC checks depending on the Protocol your using.
Under my Belt so Far.
Modbus RTU
Modbus ASCII
CAN STD and EXT
J1939
Numerous proprietary industrial protocols. Frick, Cat....
Suppose to Start on AB DF1 soon. Arghhhh Not looking forward to it.
Richard





Bookmarks