The only not standard Arduino library used is
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 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.|
|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.|
|3||1||IR port||Not used.|
|4||1||Sync||Synchronise output also with the SYNCID|
|Event node number → CANID||Bus||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.
Support for Zimo CAN protocol. (Z21)
|Ext. CAN Frame|
|1||4||6||2||16||4||4||16||48||Nr of bits|
|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.|
|norm||Set the normal mode. (default)|
|cbus||Switch to CBUS protocol. (125k) (default)|
|mbus||Switch to Märklin CS2 protocol. (250k)|
|zbus||Switch to Zimo CAN protocol. (125k)|
|8m||Set MCP2515 clock speed to 8MHz. (default)|
|16m||Set MCP2515 clock speed to 16MHz.|
|l0||Set pin layout to fit the CANGC2a. (default) → Push the reset button to make changes active.|
|l1||Set pin layout to fit the ArduCAN-I/O. → Push the reset button to make changes active.|
|=<id>||Set the CANID. Replace <id> with a number between 1 and 127.|
|#<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.
GPIO board MBus 0x3017 __AVR_ATmega328P__ pinlayout=0 port 00(02) set INPUT_PULLUP port 01(03) set INPUT_PULLUP port 02(04) set INPUT_PULLUP port 03(05) set INPUT_PULLUP port 04(06) set OUTPUT port 05(07) set OUTPUT port 06(08) set OUTPUT port 07(09) set OUTPUT port 08(15) set INPUT_PULLUP port 09(14) set INPUT_PULLUP port 10(13) set INPUT_PULLUP port 11(12) set INPUT_PULLUP port 12(11) set INPUT_PULLUP port 13(10) set INPUT_PULLUP port 14(0F) set INPUT_PULLUP port 15(0E) set INPUT_PULLUP CAN bps=250, MCP2515 8MHz :X00310327N000030170300460C; change of port 12 0->1 conf=1 timer=0 :X00230327N0017000C00010000
The CBUS protocol dictates the number of data bytes for all OPC ranges.
This makes no sense for CAN, because the DLC field is responsible for the number of data bytes used in a message.
The CBUS protocol seems to reflect the LocoNet scheme…
The OPC_PNN, a response on a query modules OPC_QNN, will not set the DLC to 6 but to 8. The last two bytes will contain the firmware version.
Officially the OPC_PNN is in the range of 6 data bytes.
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: 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.
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.