This documentation is out of date.
The new version of the documentation is here: https://cannylogic.com/docs |
Difference between revisions of "CANNY 7, CAN Driver"
[unchecked revision] | [checked revision] |
(→Driver's registers) |
(→Driver's registers) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | == General Description == | |
Two dedicated external outputs of CANNY 7 controller, located on the 4-pin connector: CAN-H and CAN-L, provided for connection to digital information '''[https://en.wikipedia.org/wiki/CAN_bus CAN-bus]'''. | Two dedicated external outputs of CANNY 7 controller, located on the 4-pin connector: CAN-H and CAN-L, provided for connection to digital information '''[https://en.wikipedia.org/wiki/CAN_bus CAN-bus]'''. | ||
− | + | == Driver's registers == | |
Below is a description of valid values for registers controlling CAN-bus driver operation. | Below is a description of valid values for registers controlling CAN-bus driver operation. | ||
Line 134: | Line 134: | ||
|- valign="top" | |- valign="top" | ||
|Data transmission/reception speed, Kbit/s | |Data transmission/reception speed, Kbit/s | ||
− | |10; 33; 50; 83; 95.2; 100; 125; 250; 500; 1000 | + | |10; 20; 33.3; 50; 83.3; 95.2; 100; 125; 250; 500; 800; 1000 |
|} | |} | ||
Line 271: | Line 271: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |width="70px" style="padding-left:0.5em;"|0... | + | |width="70px" style="padding-left:0.5em;"|0...'''0xXX'''08 |
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"|a value equal to the number of bytes of data in the received message, | + | |style="padding-left:0.5em;"|a value equal to the number of bytes of data in the received message, where '''0хXX''' is: 0x00 (for standard format), 0x40 (for standard format with RTR), 0x80 (for extended format) or 0xC0 (for extended format with RTR). For more information, see note. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 296: | Line 296: | ||
{| | {| | ||
|valign="top" style="padding-left:0.5em;"|''Note:'' | |valign="top" style="padding-left:0.5em;"|''Note:'' | ||
− | |valign="top" style="padding-left:0.5em;"|''CAN Received Data Register ERL, in addition to the number of bytes in the received message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT | + | |valign="top" style="padding-left:0.5em;"|''CAN Received Data Register ERL, in addition to the number of bytes in the received message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT flag & bit 14 - RTR flag. Where EXT = 1, when receive a message in the extended format, EXT = 0 for a standard message format; RTR = 1 when receiving remote data request, RTR = 0 when receiving normal message.'' |
|} | |} | ||
Line 356: | Line 356: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |width="70px" style="padding-left:0.5em;"|0... | + | |width="70px" style="padding-left:0.5em;"|0...'''0xXX'''08 |
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"|the value equal to the number of bytes of data in the transmitted message | + | |style="padding-left:0.5em;"|the value equal to the number of bytes of data in the transmitted message, where '''0хXX''' is: 0x00 (for standard format), 0x40 (for standard format with RTR), 0x80 (for extended format) or 0xC0 (for extended format with RTR). For more information, see note. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 381: | Line 381: | ||
{| | {| | ||
|valign="top" style="padding-left:0.5em;"|''Note:'' | |valign="top" style="padding-left:0.5em;"|''Note:'' | ||
− | |valign="top" style="padding-left:0.5em;"|''CAN Transmit Data Register ERL, in addition to the number of bytes in the transmitting message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT | + | |valign="top" style="padding-left:0.5em;"|''CAN Transmit Data Register ERL, in addition to the number of bytes in the transmitting message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT flag & bit 14 - RTR flag. Where EXT = 1, when transmitting a message in the extended format, EXT = 0 for a standard message format; RTR = 1 when transmitting remote data request, RTR = 0 when receiving normal message.'' |
|} | |} | ||
+ | |||
+ | == Examples of message transmitting == | ||
An example of a functional diagram of the data sent to the CAN bus. Performing diagram the controller once every 100 ms, transmits to the bus at a speed of 125 kbps, the data about the state of its three inputs, using a standard format message with the identifier 0x123, contains a single byte of data. | An example of a functional diagram of the data sent to the CAN bus. Performing diagram the controller once every 100 ms, transmits to the bus at a speed of 125 kbps, the data about the state of its three inputs, using a standard format message with the identifier 0x123, contains a single byte of data. | ||
[[File:6_9_2_1.png]] | [[File:6_9_2_1.png]] | ||
+ | |||
+ | An example of a functional diagram for sending a CAN message with a standard identifier is '''0x001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78''' by the appearance of a signal on the channel #8 of the controller. | ||
+ | |||
+ | [[File:6_9_2_4.png|500px]] | ||
+ | |||
+ | An example of a functional diagram for sending a CAN message with the extended identifier is "0x1f110001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78" by the appearance of a signal on the channel #8 of the controller. | ||
+ | |||
+ | Differences in sending an extended message from sending a standard one: set bit 15 of the register '''[CAN Transmit Data Register ERL]''', the leading part of the identifier should be written to the register '''[CAN Transmit Data Register IDH]'''. | ||
+ | |||
+ | [[File:6_9_2_5.png|500px]] | ||
+ | |||
+ | Example of a functional diagram for sending a CAN message with the standard identifier "0x001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78" by the appearance of a signal on the channel #8 of the controller, and sending a message with the same ID, but with zero data when the signal on the channel #8 of the controller is disappears. | ||
+ | |||
+ | [[File:6_9_2_6.png|700px]] | ||
+ | |||
+ | An example of sending several CAN messages periodically. | ||
+ | |||
+ | [[File:6_9_2_7.png|800px]] | ||
+ | |||
+ | == Examples of message reciving == | ||
An example of a functional diagram of the data receive from the CAN bus. Performing the diagram controller, receiving message from the bus in standard format with ID 0x0123, containing one byte of data, sets on three of its outputs, states in accordance with received value. | An example of a functional diagram of the data receive from the CAN bus. Performing the diagram controller, receiving message from the bus in standard format with ID 0x0123, containing one byte of data, sets on three of its outputs, states in accordance with received value. |
Latest revision as of 16:50, 27 August 2019
Contents
General Description
Two dedicated external outputs of CANNY 7 controller, located on the 4-pin connector: CAN-H and CAN-L, provided for connection to digital information CAN-bus.
Driver's registers
Below is a description of valid values for registers controlling CAN-bus driver operation.
CAN driver configuration registers allows to set the parameters of the controller as a CAN bus node:
Address | Expected values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
| |||||||
|
| |||||||
|
| |||||||
|
|
Note: | In passive receiving CAN messages mode (listen only), unlike normal CAN mode, the driver operates to receive data from CAN-bus, but does not send a confirmation of reception and does not puts network in an error state when it detects such. Thus, the controller remains invisible to the other devices on the bus, does not prove itself. For normal network operation, there must be present at least two devices operating in the normal mode. |
Note: | When filter mode enabled the CAN driver will accept only those messages whose identifiers match values in CAN message receive filter installation registers, ignoring all others. |
CAN driver configuration is defined by a constant predetermined data transmission/reception speed.
Parameter | A list of acceptable values |
---|---|
Data transmission/reception speed, Kbit/s | 10; 20; 33.3; 50; 83.3; 95.2; 100; 125; 250; 500; 800; 1000 |
Named constants that represent CAN configuration parameters combination, available to the user in the "CAN Modes" CannyLab constants directory, which can be accessed via function block entry context menu having "constant" type.
CAN driver diagnostics registers allows the user to determine the status of the driver in one or another moment of a diagram execution.
Address | Returning Values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
| |||||||
|
|
CAN driver receiving registers allows access to the values obtained on the bus.
Address | Return values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
| |||||||
|
| |||||||
|
|
Note: | CAN Received Data Register ERL, in addition to the number of bytes in the received message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT flag & bit 14 - RTR flag. Where EXT = 1, when receive a message in the extended format, EXT = 0 for a standard message format; RTR = 1 when receiving remote data request, RTR = 0 when receiving normal message. |
CAN transmit registers are used to accommodate data in the transmission buffer to be sent.
Address | Expected values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
| |||||||
|
| |||||||
|
|
Note: | CAN Transmit Data Register ERL, in addition to the number of bytes in the transmitting message 0 ... 8 least significant bits, contains in its most significant bits information about special message attributes: bit 15 - EXT flag & bit 14 - RTR flag. Where EXT = 1, when transmitting a message in the extended format, EXT = 0 for a standard message format; RTR = 1 when transmitting remote data request, RTR = 0 when receiving normal message. |
Examples of message transmitting
An example of a functional diagram of the data sent to the CAN bus. Performing diagram the controller once every 100 ms, transmits to the bus at a speed of 125 kbps, the data about the state of its three inputs, using a standard format message with the identifier 0x123, contains a single byte of data.
An example of a functional diagram for sending a CAN message with a standard identifier is 0x001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78 by the appearance of a signal on the channel #8 of the controller.
An example of a functional diagram for sending a CAN message with the extended identifier is "0x1f110001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78" by the appearance of a signal on the channel #8 of the controller.
Differences in sending an extended message from sending a standard one: set bit 15 of the register [CAN Transmit Data Register ERL], the leading part of the identifier should be written to the register [CAN Transmit Data Register IDH].
Example of a functional diagram for sending a CAN message with the standard identifier "0x001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78" by the appearance of a signal on the channel #8 of the controller, and sending a message with the same ID, but with zero data when the signal on the channel #8 of the controller is disappears.
An example of sending several CAN messages periodically.
Examples of message reciving
An example of a functional diagram of the data receive from the CAN bus. Performing the diagram controller, receiving message from the bus in standard format with ID 0x0123, containing one byte of data, sets on three of its outputs, states in accordance with received value.
An example of a functional diagram of the data receive from the CAN bus. Performing the diagram controller, receiving message on the bus in standard format with an ID 0x01F3, analyzes contained in one of the message bytes a value and sets on its outputs and built-in LED corresponding states.