View previous topic :: View next topic |
Author |
Message |
abtron
Joined: 18 Sep 2014 Posts: 2 Location: Italy
|
MODBUS 3.5 delay |
Posted: Thu Sep 18, 2014 6:37 am |
|
|
Hi All,
I know MODBUS RTU implementations are generally tolerant enough to ignore my doubts below. However…
Inter-char and inter-frame delays are written in the CCS MODBUS code as:
Code: | delay_us(1000000 / MODBUS_SERIAL_BAUD); //one stop bit. not exact
delay_us(3500000 / MODBUS_SERIAL_BAUD); //3.5 character delay |
The former sets a delay of about 1-bit between characters within a frame (104us @9600bps). That’s fine.
The latter is a 3.5 BIT-long delay i.e. about 360us (@9600bps) which is then used in the CCS code to start and close a frame.
Why only 3.5 BIT time, while MODBUS requires a 3.5 CHARACTER-long delay at least (~4ms)?
Even the original comment on that line of code talks about “character” and not “bits”, increasing my belief that was the actual intention.
Many thanks to whoever will shed some lights on this. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 18, 2014 11:08 am |
|
|
It looks like CCS accidentally left off a zero on the numerator. If you own
the compiler you could email CCS support and ask them about it. |
|
|
abtron
Joined: 18 Sep 2014 Posts: 2 Location: Italy
|
|
Posted: Fri Sep 19, 2014 12:41 pm |
|
|
Yes it seems so...
Nobody else noticed it?
Thanks |
|
|
[email protected]
Joined: 07 May 2014 Posts: 9 Location: Seattle
|
|
Posted: Mon Oct 27, 2014 2:49 pm |
|
|
I'm just getting into the modbus RTU driver and am noticing a few things that are "interesting". I haven't seen that one yet, probably because I haven't been able to get the 'modbus_serial_new' var to set to true. I'm still not clear where that gets set to TRUE.
Were you able to work through all the interesting parts of the RTU driver? Do you have any words of wisdom to pass along? |
|
|
TimW
Joined: 29 Oct 2014 Posts: 2 Location: Mechanicsburg, PA
|
|
Posted: Wed Oct 29, 2014 7:39 am |
|
|
I think this is the cause of why I have trouble sending data to a PLC. Sending single registers works fine, but I get garbage on sending four registers in succession.
Will know soon enough! |
|
|
TimW
Joined: 29 Oct 2014 Posts: 2 Location: Mechanicsburg, PA
|
modbus_serial_start |
Posted: Tue Nov 11, 2014 3:56 pm |
|
|
The library has this in modbus_serial_start (part of physical layer RTU code):
delay_us(3500000/MODBUS_SERIAL_BAUD); //3.5 character delay
My Automation Direct Click PLC's did not like when I tried to write multiple registers. Using 1.5 bits for a start bit duration, 8 data, 1 parity and 1 stop, you get 11.5 bits per character, so 11.5 * 3.5 = 40.25
delay_us(40250000/MODBUS_SERIAL_BAUD); //3.5 CHAR, NOT BITS
And it works! |
|
|
|