CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

MODBUS 3.5 delay

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
abtron



Joined: 18 Sep 2014
Posts: 2
Location: Italy

View user's profile Send private message

MODBUS 3.5 delay
PostPosted: Thu Sep 18, 2014 6:37 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 11:08 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 19, 2014 12:41 pm     Reply with quote

Yes it seems so...

Nobody else noticed it?

Thanks
kbrown@hysecurity.com



Joined: 07 May 2014
Posts: 9
Location: Seattle

View user's profile Send private message

PostPosted: Mon Oct 27, 2014 2:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 29, 2014 7:39 am     Reply with quote

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

View user's profile Send private message

modbus_serial_start
PostPosted: Tue Nov 11, 2014 3:56 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group