to be able to communicate with the MCP2515 chip.
Two modifications in the library source code are to disable DEBUG to save memory, and increase the timeout value in the
Documents/Arduino/libraries/MCP_CAN_lib-master/mcp_can_dfs.h: (line 40 and 45)
// if print debug information //#define DEBUG_MODE 1 /* * Begin mt */ #define TIMEOUTVALUE 100
The original TIMEOUTVALUE of 50 is too low and brings errors on sending frames in a CAN bus. (Depends on how much traffic is on the CAN bus.)
It is very important to disable DEBUG_MODE otherwise there is not enough memory available. The Arduino IDE will complain about this, and RCAN will reboot continuously.
The difference between the standard PIC based and Arduino boards is the FLAT addressing scheme, and only support long events.
(Long/Short events are detected in Rocrail automatically.)
The GPIO is compatible with the CANGC2. (Except of the addressing scheme.)
|Nano's with the ATmega328P cannot use port A6 and A7 as digital I/O, and are only available as input with analogRead.|
Note: Use a Nano Every to be able to use GC2a port 9 and 10 as output too.
|1||Node configuration byte|
|2…17||Port configuration bytes|
|18…19||Port state bytes (Read only)|
|0||1||Save state||Save output states in EEPROM on a power off command.|
|1||1||Short events||Not used.|
|2,3||0,0||250ms pulse time|
|2,3||1,0||500ms pulse time|
|2,3||0,1||1000ms pulse time|
|2,3||1,1||2000ms pulse time|
|4||1||Report all on SoD||Report also low input values instead of only high.|
|0||1||Input|| Initialise the port as input with internal pull-up resistor.
The GC2a board will also provide 10kOhm resister arrays because the internal pull-up value is too high.
|0||0||Output||Initialise the port as output.|
|1||1||Input off delay||Input 2 seconds off delay for occupancy detectors.|
|1||1||Output pulse||Pulse length according the global node configuration.|
|2||1||Invert||Invert the digital port value.|
|4||1||Sync||Synchronise output also with the SYNCID|
The CBUS protocol is copyrighted by Mike Bolton & Gil Fuchs.
|Event node number → CANID||Node-ID||0…127 (default 127)||CBUS uses the 4 MSBits for priority. (The standard CAN Frame ID is 11 bit.)|
|Event address → Port||Address||1…16 (fixed)||This is the Port Number.|
Module node number and module CANID are the same and just one value in the firmware.
The CBUS learning mode is not supported and not needed.
The same flat addressing scheme can be used with the PIC based boards by setting the event node numbers to the modules node number and the event addresses to the corresponding port number, and disable the short event option.
In case the RCAN based modules are planned to be used in an existing CBUS network, it is recommended to convert the existing modules to the flat addressing scheme to make it transparent.
Support for Märklin CAN protocol.
|usbon/usboff||Activate/deactivate the USB interface for GridConnect. (default deactivated)|
|dump||Shows the EEPROM first 64 bytes|
|sod||Start of Day|
|init||Re-init all I/O|
|stat||Shows the I/O state|
|pub||Publish board identification and type|
|loop||Set the loopback mode for this session.|
|norm||Set the normal mode. (default)|
|cbus||Switch to CBUS protocol. (125k) (default)|
|mbus||Switch to Märklin CS2 protocol. (250k)|
|8m||Set MCP2515 clock speed to 8MHz. (default)|
|16m||Set MCP2515 clock speed to 16MHz.|
|gpio||16 port I/O|
|servo||4 port servo and 12 port I/O|
|=<id>||Set the CANID. Replace <id> with a number between 1 and 255.|
|$pppppppppppppppp|| Configure multiple ports: The <p> maybe: 0 for output, 1 for input, 2 for input with off delay, 3 for pulse output.
Example: "$1111" will configure port 1 to 4 as input.
|#<port><config>|| Configure a port. Replace <port> with a character between 0…9 and a…f.
The <config> maybe: 0 for output, 1 for input, 2 for input with off delay, 3 for pulse output.
Example: "#a1" will configure port 10 as input.
| :SxxxxNxx…xx; |
| ASCII frame which will be send on the CAN bus and evaluated by the board. (GridConnect scheme as used by MERG CBUS.)
See chapter 10 of the MERG "Developer’s Guide for CBUS".
Also all CAN traffic and supported OPCs are traced in the serial monitor.
|The original text is found in the Microchip MCP2515 manual in section 10.4.|
Loopback mode will allow internal transmission of messages from the transmit buffers to the receive buffers without actually transmitting messages on the CAN bus.
This mode can be used in system development and testing.
In this mode, the ACK bit is ignored and the device will allow incoming messages from itself, just as if they were coming from another node.
The Loopback mode is a silent mode, meaning no messages will be trans- mitted while in this state (including error flags or Acknowledge signals). The TXCAN pin will be in a recessive state.
MBus 0x3017 pinlayout=0 CAN bps=250, MCP2515 8MHz hash 0x0F27 :X00310F27N000030170300460C; :X00230F27N0017000800010000; :X00230F27N0017000900010000;
With the FLAT addressing it is not possible to activate outputs with one command, NN+DN, on multiple boards(nodes).
This option is not or only hardly used, and makes the setup of boards needlessly very complex.
Tip: With the SYNCID the outputs can be synchronised with other IDs.
The push button on the Arduino keeps its original function: Reboot.
After every reboot an OPC_PNN will be send to popup the CBusNode dialog in Rocview with selected node.
This feature can be used to identify a node.
The GC2a can be used parallel as CBus/MBus interface.
It uses the same ASCII framing as the CANGC1(e) interface. (See chapter 10 of the MERG “Developer’s Guide for CBUS”.)
Line setting must be set to:
With this option, the GC2a can also be used standalone; The minimal CBUS setup.
Note 1: Because the ACK slot bit will not be set by other CAN modules, a send error will be reported, but can be ignored in standalone mode.
Note 2: For best performance a 16MHz crystal should be used.
The SyncID option is added to be able to synchronise input event from board X with output states on board Y.
The port mapping is 1:1.
It can also be use to switch multiple outputs with a single Rocrail command.
On board with ID 33 is input port switched to ON.
Another board with ID 22 hast set SyncID to 33, and will check if the corresponding port is an output and will synchronise it with the input port of board 33.
This situation is often used for switch panels.