| Newsgroups |
gmane.comp.hardware.rabbit-semiconductor |
| Organization |
Omniverter Inc. |
| Message-ID |
<[email protected]> |
Hello, Tom and Mircea:
Thank you for your response. They are valuable for me. Do you have any code
to describe ISR to keep the UART loaded with bytes? In fact, I use BL4S200
RS485 functions to develop my Modbus slave function. As I understand,
BL4S200 RS485 functions are top of lower serial port function.
Regards,
Yang
From: [email protected] [mailto:[email protected]]
Sent: Wednesday, August 10, 2016 11:17 PM
To: [email protected]
Subject: Re: [rabbit-semi] listening to rs485 serial port on BL4S200
Mircea,
Thanks for the detailed response! I don't have any experience with MODBUS,
so it sounds like for a slave you'd want to modify the interrupt handler for
received bytes to automatically frame the messages based on the 3.5
character delay between messages.
Queuing an entire message in the outbound serial buffer should be fine,
since the Rabbit uses an ISR to keep the UART loaded with bytes.
If you were marking the start/end of each message inside the ISR, servicing
the message queue every 15ms would suffice based on your statement that
replies can take up to 1 second to send.
-Tom
On Aug 10, 2016, at 8:03 PM, [email protected] <mailto:[email protected]>
[rabbit-semi] wrote:
Hi Yang,
Sorry I have to disagree with Tom but Modbus is quite sensitive to timing
issues: You have the 1.5 characters maximum delay between characters and the
3.5 characters spacing at the end of each message. Even parsing messages
becomes complicated if you don't rely on the 3.5 characters gap between
messages.
Not too long ago I had to implement a Modbus master on a a Rabbit module and
pretty much I had to start from scratch. There is a Digi library for Modbus
but exactly this low level part is not very well implemented.
At 115K baudrate (assuming 8-N-1 format which makes for 10 bits per char)
the delays you are dealing with are:
- 1.5 chars = 0.13ms You have to send your answer without any gaps larger
than that. Make sure you prepare your whole reply before starting to send
and don't even dream about not using interrupts to pump out the whole
message.
- 3.5 chars = 0.3ms Any receiving gap larger than this must be interpreted
as an end of message and you have to parse that message. If the message is
not addressed to you, the other slave will probably reply and will see its
reply in your receive buffer (that's just the nature of RS485 bus). The only
guidance you have to make sense of all that traffic are the 0.3ms gaps that
you will see in the data stream.
When I'm talking about the 3.5 characters gap it doesn't mean you have to
answer immediately when that delay expires. Most masters will accept a
reasonable delay (frequently 1 sec) for a slave to answer. It means only
that you must be prepared to correctly interpret the Modbus traffic, even if
it is generated by communication with a very fast client.
If you need more explanations let me know. Also if you need my code (sorry,
it is for a Modbus master).
Cheers,
Mircea
---In [email protected] <mailto:[email protected]> ,
<yang@... <mailto:yang@...> > wrote :
Hello, Tom:
Thank you for your response. Actually, I am using serval "costate" with
different loop timing. My current serial port use one of them "costate" with
15 msec loop time. My RS485 port use 115kbps. Do you think how often
checking serial port is reasonable according to your experience?
Regards,
Yang
From: [email protected] <mailto:[email protected]>
[mailto:[email protected]]
Sent: Wednesday, August 10, 2016 2:01 PM
To: [email protected] <mailto:[email protected]>
Subject: Re: [rabbit-semi] listening to rs485 serial port on BL4S200
Your program is the only thing running, and the BL4S200 runs at a fixed
speed. A typical program is going to have a big loop where it checks for
things to do. The overhead of checking for available data on a serial port
is negligible in the overall time it takes that loop to run, so it's
probably fine as it is. And in most cases, you're better off processing
serial data at a known point in program execution, instead of interrupting
some other task to process it.
-Tom
On Aug 10, 2016, at 10:28 AM, yang@... <mailto:yang@...> [rabbit-semi]
wrote:
I am using BL4S200 for my control project. BL4S200 is a slave device. Other
equipment uses Modbus RS485 to communicate BL4S200. Actually, everything is
working, but the only thing is I need use loop to check serial port weather
I receive any request, is it possible to use some internal interrupt to
detect information received on serial port? so I can remove the fast loop to
save some resource.