|
Q: How fast is a CAN/CANopen® I/O cycle? (read INPUT trasmit via
CANopen®, write OUTPUT)
A: Unfortunately there are MANY factors going into this formula. If
you are looking at an entire I/O cycle, you have the following potential delays:
- Input scan/recognizing loop until setting CAN transmit bit.
Depending on microcontroller performance and priorities this will be some 200us or more.
With input filters, polarity changes or configurable "mapping" (which input goes
to which CAN message) as provided by CANopen® this might more than double.
- CAN message on bus delay.
All delays here are multiple bit times. At 1Mbit, a single bit time is 1us. At 250kbit,
bit time is 4us. If there is currently a message on the bus, it cannot be
aborted/interrupted. The maximum delay until any node gets a chance to try to arbitrate
the bus depends on the longest possible message on the CANbus. With CANopen® that is
typically about 135 bit times.
- CAN arbitration delay.
Assuming the message of our node gas the highest priority, this delay will be zero.
However, each message currently waiting to be transmitted anywhere on the bus having a
higher priority will get the bus befor our node. Each message delay is another 47 to 135
bit times.
- Actual CAN transmit time
See www.esacademy.com/faq/calc/can.htm:
Some 47 to 135 bit times.
- CAN receive interrupt delay in Output module.
Depending on microcontroller performance and interrupt priorities this will be some 100us
or more. With output filters, polarity changes or configurable "mapping" (which
CAN message contents goes to which output is configurable) as provided by CANopen® this
might more than quadruple.
Many commercial CANopen® stacks leave the CAN receive interrupt before applying the output
"sometime" later in the background task, making the worst-case MUCH longer.
MINIMUM TOTAL (1Mbit example, highest priority):
200us + 135us + 0 + 60us + 100us = 495us
"REALISTIC" TOTAL (1Mbit example, medium priority):
300us + 135us + 135us + 60us + 300us = 930us
Conclusion: A complete I/O cycle can be completed within 1ms on a
CANbus running at 1Mbit, if the priorities (interrupts on controllers and CAN message) are
fairly high.
As soon as the bus' bitrate is slowed down or a lot of CANopen®
protocol functionality is added, the total I/O cycle time will be closer to 2-3ms. |