Prox / RFID
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Resume / Consulting
Contact Me

LDmicro Forum - Modbus RTU on LDmicro

(you are viewing a thread; or go back to list of threads)

Modbus RTU on LDmicro (by Evan Raftery)
Has anyone written a code in LDmicro for modbus as a slave in PIC16F887.
I have looked at the instruction length and it seems that once the code is written there would not be much room for anything else.
If not 16F887 would the ATMEGA128 be suitable?
Sat Nov 14 2009, 00:13:49
(no subject) (by David R)
I would love modbus as well, but I think it would be A lot of work for Jonathan inside the program as there is so many ways of using modbus and how the data is processed,master,slave, etc.

I might be wrong but I think It can't be done using the ASCII commands as the 'CRC' system is different to ASCII.
Mon Nov 16 2009, 04:53:57
(no subject) (by Evan Raftery)
I was thinking along the lines of constructing the code within the ladder format. There is two forms of modbus that can be approached. It can be done using ASCII with LRC being used for error check. The other form is RTU. This is done with timers and uses the CRC system. The time spacing between words is 3.5 char and is checked with timers.
What seems to be a difficult area is the addressing for the coils, inputs & holding registers etc. For example holding registers begin at 400001. Will the contents be accessed by the address name or is their another way of identifying registers in the PIC r AVR. Any ideas on this?
Mon Nov 16 2009, 08:42:54
(no subject) (by David R)
I don't know of any gear that uses the ASCII Modbus only RTU.

How do you get arround not having the CRC as the other station will not respond if it see A CRC error.
Tue Nov 17 2009, 01:57:58
(no subject) (by Evan Raftery)
Redlion Datastations use either ASCII or RTU in slave or master mde for both.
The CRC reporting may have to be synthesised to give affirmative response in the beginning & hope for the best (bad I know). Probably by keeping baud rate down at say 9600 or 4800 it may function with PIC.
I have done a bit of searching and there is no standalone modbus IC to my knowledge

I did find however this link


with free source code for PIC18 which could be rewritten for PIC16

I have attached file with relevant internal source codes etc that I found on the site if anyone can do something with it.
Tue Nov 17 2009, 06:36:45, download attachment modbus.rar
(no subject) (by Jonathan Westhues)
It would be possible to do the Modbus protocol just in ladder logic, including stuff like the CRC; but not in any way practical, and maybe not within the timing constraints.

Real Modbus support might be useful; but that would require actual support in the compiler.
Tue Nov 17 2009, 11:59:36
(no subject) (by Evan Raftery)
Yes it looks feasible in ladder but would be ugly & require compromises on reliability.

Modbus support would be fantastic. Even if it took up most of the program memory it would allow transmission of converted analogue signals, give serial remote IO capability and even allow connection to HMI's etc

I have a modbus network here setup ready to test LDmicro 2.2 beta & have ordered 3x MAX485 chips.

I am begging now!
Tue Nov 17 2009, 17:21:36
Modbus will be fine (by Joao Pereira)
""I have a modbus network here setup ready to test LDmicro 2.2 beta & have ordered 3x MAX485 chips.""

where we can download the 2.2 beta LDmicro
Thu Dec 17 2009, 05:15:47
(no subject) (by Evan Raftery)
I was being pre-emptive (Australian type humour) and you would have to ask Jonathan when 2.2 will be released.
Jonathan mentioned Modbus support would be best implemented from within the compiler and I started begging :-)

I understand it may not be practical from a logistics viewpoint however as interfacing for the different micro's may be a gargantuan task.

It would be nice though.
Thu Dec 17 2009, 15:33:44
(no subject) (by David R)
That is funny !!!, close to New Zealand humour.
Fri Dec 18 2009, 01:23:05
(no subject) (by napalm0)
The MODBUS RTU will considerably enrichs the LDMicro compiler, in that way it will grow up to industrial-like compilers
Sun May 9 2010, 04:12:54
(no subject) (by kendhill)
the table used to create the lrc part needs to be reduced in size becouse it would take up a large area: the crc is a 2's compiment calculated by size and data;

i think the table could be made smaller becouse the lrc is a repeating pattern:
jest a though on maybe adding modbus ;maybe commands 1-6 and some others;
have a great day all
Mon May 10 2010, 08:11:31
Sonar detector for tetection web break on prtinting machines (by maximus)
I have programed ld micro for detection off paper web break, for rescue damage in silinder printing.And iwant make disply for this program but i don't now to make it
can any body correction this ld, and give me some program for dispaly matching measuring detection and seting.....
Wed Sep 21 2011, 23:18:25, download attachment sonar edit.ld
sonar (by maximus)
here I'm programmed sonar detection.....
Can you correction this LD...?
Wed Sep 21 2011, 23:21:36, download attachment sonar edit.ld
modbud (by maximus)
Can any body send modbus rtu communication between 2 or more avr atmega 128 ....?
Wed Sep 21 2011, 23:27:34
modbus rtu (by sadi)
please send me source of 16 digital output modbus rtu with ldmicro and atmega8
Mon Feb 25 2019, 16:13:46
modbus rtu (by sadi)
please send me source of 16 digital output modbus rtu with ldmicro and atmega8
Mon Feb 25 2019, 16:15:03
Post a reply to this comment:
Your Name:
Your Email:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):