arduino:rcan-en
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
arduino:rcan-en [2020/07/01 07:52] – [CBus] rjversluis | arduino:rcan-en [2024/03/13 09:21] (current) – rjversluis | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== RCAN: GC2a ====== | ====== RCAN: GC2a ====== | ||
+ | |||
+ | |||
\\ | \\ | ||
{{: | {{: | ||
\\ | \\ | ||
=====Introduction===== | =====Introduction===== | ||
+ | {{ : | ||
The current __**[[: | The current __**[[: | ||
RCAN is firmware for CAN based solutions on the Arduino platform.\\ | RCAN is firmware for CAN based solutions on the Arduino platform.\\ | ||
- | The firmware target is the Arduino Nano __**[[https:// | + | The firmware target is the Arduino Nano and __**[[https:// |
\\ | \\ | ||
=====Dependencies===== | =====Dependencies===== | ||
- | {{ : | + | {{: |
- | The only not standard Arduino library used is | + | Add the **mcp_can** library in the Arduino IDE to be able to communicate with the MCP2515 chip.\\ |
- | | + | |
- | to be able to communicate with the MCP2515 chip.\\ | + | |
====Modifications==== | ====Modifications==== | ||
- | Two modifications | + | One modification |
+ | '' | ||
<code cpp> | <code cpp> | ||
// if print debug information | // if print debug information | ||
+ | #ifndef DEBUG_MODE | ||
//#define DEBUG_MODE 1 | //#define DEBUG_MODE 1 | ||
- | + | #endif | |
- | /* | + | |
- | | + | |
- | */ | + | |
- | #define TIMEOUTVALUE | + | |
</ | </ | ||
- | 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.__\\ | __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.__\\ | ||
\\ | \\ | ||
=====GPIO Board===== | =====GPIO Board===== | ||
- | 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 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 __**[[: | The GPIO is compatible with the __**[[: | ||
| Nano's with the ATmega328**P** __cannot use port A6 and A7__ as digital I/O, and are only available as input with analogRead. | | | Nano's with the ATmega328**P** __cannot use port A6 and A7__ as digital I/O, and are only available as input with analogRead. | | ||
\\ | \\ | ||
- | ====Input only pins on ATmega328P==== | + | ====Input only pins on Nano ATmega328P==== |
- | ^ Nano Pin ^ GC2a ^ ArduCAN-IO | + | |< >| |
- | | A6 | 10 | + | ^ Nano Pin ^ GC2a ^ |
- | | A7 | 9 | 1 | | + | | A6 | 10 | |
+ | | A7 | 9 | | ||
+ | |||
+ | |||
+ | **Note | ||
+ | **Note 2:** //For best performance a **16MHz crystal** should be used.//\\ | ||
====Variables==== | ====Variables==== | ||
Line 67: | Line 71: | ||
| 1 | 1 | Output pulse | Pulse length according the global node configuration. | | | 1 | 1 | Output pulse | Pulse length according the global node configuration. | | ||
| 2 | 1 | Invert | Invert the digital port value. | | | 2 | 1 | Invert | Invert the digital port value. | | ||
- | | 3 | 1 | IR port | Not used. | | ||
| 4 | 1 | Sync | Synchronise output also with the SYNCID | | | 4 | 1 | Sync | Synchronise output also with the SYNCID | | ||
Line 74: | Line 77: | ||
//The CBUS protocol is copyrighted by Mike Bolton & Gil Fuchs.//\\ | //The CBUS protocol is copyrighted by Mike Bolton & Gil Fuchs.//\\ | ||
^ CBUS-> | ^ CBUS-> | ||
- | | 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 node number -> CANID | Node-ID |
| Event address -> Port | Address | 1...16 (fixed) | This is the __**[[: | | Event address -> Port | Address | 1...16 (fixed) | This is the __**[[: | ||
Module node number and module CANID are the same and just one value in the firmware.\\ | Module node number and module CANID are the same and just one value in the firmware.\\ | ||
Line 109: | Line 112: | ||
| 8m | Set MCP2515 clock speed to 8MHz. (default) | | 8m | Set MCP2515 clock speed to 8MHz. (default) | ||
| 16m | Set MCP2515 clock speed to 16MHz. | | 16m | Set MCP2515 clock speed to 16MHz. | ||
- | | l0 | Set pin layout to fit the CANGC2a. (default) -> Push the reset button to make changes active. | + | | gpio | 16 port I/ |
- | | l1 | Set pin layout to fit the ArduCAN-I/O. -> Push the reset button to make changes active. | + | | servo | 4 port servo and 12 port I/O | |
| =<id> | Set the CANID. Replace <id> with a number between 1 and 255. | | | =<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: " | ||
| #< | | #< | ||
| : | | : | ||
Line 177: | Line 181: | ||
* Linefeed | * Linefeed | ||
With this option, the GC2a can also be used standalone; The minimal CBUS setup.\\ | With this option, the GC2a can also be used standalone; The minimal CBUS setup.\\ | ||
- | > Note: Because the [[https:// | + | > Note 1: Because the [[https:// |
+ | > Note 2: For best performance a 16MHz crystal should be used. | ||
\\ | \\ | ||
Line 190: | Line 195: | ||
\\ | \\ | ||
+ | |||
=====Source Code===== | =====Source Code===== | ||
+ | * {{: | ||
* https:// | * https:// | ||
- | * https:// | ||
====Documentation==== | ====Documentation==== |
arduino/rcan-en.1593582744.txt.gz · Last modified: 2020/07/01 07:52 by rjversluis