Compare commits
2 Commits
8efbfb7f1d
...
5756ccb16e
Author | SHA1 | Date |
---|---|---|
|
5756ccb16e | |
|
f580385ef9 |
118
README.md
118
README.md
|
@ -1,65 +1,107 @@
|
|||
# SLGreen
|
||||
<img src="https://cdn.theiremi.fr/images/slgreen/banner.png" />
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
SLGreen turns your Arduino equipped with a MCP2515 into a Serial to CAN bridge using the SLCan / CAN232 / Lawicel protocol.
|
||||
This project facilitates usage of CAN bus on your computer by allowing you to make cheap CAN interface with your Arduino and those [chinese CAN boards](https://www.aliexpress.com/w/wholesale-MCP2515-arduino.html).
|
||||
|
||||
## Dependencies
|
||||
# Hardware
|
||||
|
||||
### Components needed
|
||||
SLGreen require two compoments to function properly :
|
||||
- An MCU compatible with Arduino (Any Arduino board, ESP32...)
|
||||
- An MCP2515 controller board, chosen according with the MCU logic voltage
|
||||
|
||||
### Wiring
|
||||
|
||||
The wiring of the MCP2515 module is basically the same as any SPI slave device :
|
||||
- MOSI, MISO, SCK : Check your board documentation
|
||||
- SS : Pin 10
|
||||
|
||||
**The INT pin doesn't need to be connected**
|
||||
|
||||
Here is a wiring example for an Arduino Uno :
|
||||

|
||||
|
||||
|
||||
# Installation instructions
|
||||
**To install and use the SLGreen software, follow these steps:**
|
||||
|
||||
1. Clone this repository using `git clone` or download it directly as ZIP.
|
||||
2. Install the dependencies listed below using the Library Manager of the Arduino IDE.
|
||||
3. Check the configuration options to make sure your SLGreen board will work.
|
||||
3. Open `SLGreen.ino` with the Arduino IDE and upload it to your Arduino.
|
||||
|
||||
|
||||
### Dependencies
|
||||
- **MCP_CAN Library**: This project uses the `mcp_can` library by coryjfowler for communication with the MCP2515 CAN controller. It can be found here: [MCP_CAN_lib](https://github.com/coryjfowler/MCP_CAN_lib).
|
||||
|
||||
## Hardware Installation
|
||||
To set up the hardware for SLGreen, follow these steps:
|
||||
|
||||
1. **Required Hardware**: You will need an Arduino and an MCP2515 CAN Bus module.
|
||||
2. **Hardware Setup**: Connect the MCP2515 CAN Bus module to your Arduino as per the technical documentation.
|
||||
|
||||
## Software Installation
|
||||
To install and use the SLGreen software, follow these steps:
|
||||
|
||||
1. **Code Download**: Clone this repository using `git clone` or download it directly from the GitHub page.
|
||||
2. **Dependencies Installation**: Install the dependencies using the Library Manager of the Arduino IDE.
|
||||
3. **Script Deployment**: Open `SLGreen.ino` with the Arduino IDE and upload it to your Arduino.
|
||||
|
||||
|
||||
|
||||
## Configuration
|
||||
Several configuration options are available on top of the SLGreen.ino file.
|
||||
Depending on your hardware and your needs, it may be useful to modify them.
|
||||
**In any case, you should take a look at the table below to check if the default values are correct for your usage.**
|
||||
Several configuration options are available at the top of the SLGreen.ino file. Depending on your hardware and your needs, it may be useful to modify them.
|
||||
|
||||
**⚠ In any case, you should take a look at the table below to check if the default values are correct for your usage ⚠**
|
||||
|
||||
### Parameters Table
|
||||
|
||||
| Parameter | Default Value | Recommended/Available Values |
|
||||
|---------------------|-------------------|-------------------------------------------------------------------|
|
||||
| `SERIAL_SPEED` | `115200` | `115200`, `150000`, `250000`, `500000`, `1000000`, `2000000` |
|
||||
| `MCP_FREQUENCY` | `MCP_8MHZ` | `MCP_8MHZ`, `MCP_16MHZ`, `MCP_20MHZ` |
|
||||
| Parameter | Default Value | Recommended/Available Values |
|
||||
|---------------------|-------------------|------------------------------|
|
||||
| `MCP_CS` | `10` | Any value making your hardware work |
|
||||
| `MCP_FREQUENCY` | `MCP_8MHZ` | `MCP_8MHZ`, `MCP_16MHZ`, `MCP_20MHZ` |
|
||||
| `SERIAL_SPEED` | `115200` | `115200`, `150000`, `250000`, `500000`, `1000000`, `2000000` |
|
||||
| `DEFAULT_CAN_SPEED` | `CAN_500KBPS` | `CAN_10KBPS`, `CAN_20KBPS`, `CAN_50KBPS`, `CAN_100KBPS`, `CAN_125KBPS`, `CAN_250KBPS`, `CAN_500KBPS`, `CAN_1000KBPS` |
|
||||
|
||||
### Details
|
||||
|
||||
- **`SERIAL_SPEED`**: Defines the baud rate for serial communication. Adjust this value based on your project requirements and the capabilities of your hardware.
|
||||
- **`MCP_FREQUENCY`**: Sets the clock frequency of the MCP2515 CAN controller. Choose the frequency that matches your MCP2515 module. Using a frequency different from your module's specification may lead to communication issues.
|
||||
- **`DEFAULT_CAN_SPEED`**: Sets the default speed for the CAN bus. This value is used if the computer doesn't choose a CAN speed. Select the speed that best suits your network environment and the specifications of your CAN devices.
|
||||
- **`MCP_CS`**: Define the Chip Select pin of the MCP2515
|
||||
- **`MCP_FREQUENCY`**: Sets the clock frequency of the MCP2515 CAN controller
|
||||
- **`SERIAL_SPEED`**: Defines the baud rate for serial communication
|
||||
- **`DEFAULT_CAN_SPEED`**: Sets the default speed for the CAN bus, in case the computer doesn't choose one
|
||||
|
||||
|
||||
## SLCAN (Lawicel) Implementation
|
||||
SLGreen implements the SLCAN (Lawicel) protocol to allow interactive communication with the CAN bus via a serial port. Here are some key details of the implementation:
|
||||
- Implemented commands: `O` (open CAN bus), `L` (close CAN bus), `C` (configure CAN bus), `V` (software version), `N` (software name), and `S` (configure CAN bus speed).
|
||||
- Commands for sending CAN frames: `t` and `T` are available for sending standard and extended frames, respectively. The commands for receiving CAN frames `r` and `R` are not implemented but are open for implementation by the community.
|
||||
- CAN frames are continuously sent; the `X` command for automatic mode control is not active.
|
||||
- Commands `F`, `W`, `M`, `m`, `U`, `Q` for various frame management and filtering functionalities are not implemented.
|
||||
SLGreen implements the SLCAN (Lawicel) protocol to allow interactive communication with the CAN bus via a serial port. To get more details about this protocol, [check this link](https://www.canusb.com/docs/can232_v3.pdf)
|
||||
|
||||
### Implementation status
|
||||
- [x] `S` : Configure CAN speed (speed 7 / 800Kbps not implemented)
|
||||
- [ ] `s` : Alternative configuration of CAN speed
|
||||
- [x] `O` : Open CAN bus
|
||||
- [x] `L` : Open CAN bus in listen-only mode
|
||||
- [x] `C` : Close CAN bus
|
||||
- [x] `t` : Send standard CAN frame
|
||||
- [x] `T` : Send extended CAN frame
|
||||
- [ ] `r` : Send standard RTR frame
|
||||
- [ ] `R` : Send extended RTR frame
|
||||
- [ ] `P` : Retrieve received frame
|
||||
- [ ] `A` : Retrieve all received frames
|
||||
- [ ] `F` : Retrieve status flags
|
||||
- [ ] `X` : Configure if frames are directly send when received (forced ON)
|
||||
- [ ] `W` : Filter mode setting
|
||||
- [ ] `M` : Acceptance Code Register
|
||||
- [ ] `m` : Acceptance Mask Register
|
||||
- [ ] `U` : Define a new serial baud rate
|
||||
- [x] `V` : Return software version
|
||||
- [x] `N` : Return serial number
|
||||
- [ ] `Z` : Configure if timestamp is included when transmitting received frames (forced OFF)
|
||||
- [ ] `Q` : Save the configuration for the next startup
|
||||
|
||||
For more details on the SLCAN (Lawicel) implementation and protocol specifications, please refer to the documentation provided in the repository.
|
||||
|
||||
## Usage
|
||||
After uploading the script to your Arduino, you can interact with the CAN bus using the provided functions. For specific usage examples, please refer to the comments in the code.
|
||||
|
||||
## Contribution
|
||||
Contributions are welcome. If you wish to contribute, please fork the repository, create a new branch for your changes, and submit a pull request for review.
|
||||
**Contributions are welcome !**
|
||||
|
||||
## License
|
||||
A lot of features are yet to be integrated into this project, so any help doing this will be greatly appreciated !
|
||||
|
||||
If you wish to contribute, please fork the repository, create a new branch for your changes, and submit a pull request for review.
|
||||
|
||||
### License
|
||||
This project is licensed under the MIT License. For more information, please consult the `LICENSE` file or visit https://opensource.org/licenses/MIT.
|
||||
|
||||
## Contact
|
||||
For any questions or suggestions, please feel free to contact Theirémi:
|
||||
### Contact
|
||||
For any questions or suggestions, please feel free to contact me :
|
||||
- Website: [theiremi.fr](https://www.theiremi.fr/#contact)
|
||||
- Email: [contact@theiremi.fr](mailto:contact@theiremi.fr)
|
11
SLGreen.ino
11
SLGreen.ino
|
@ -15,16 +15,17 @@
|
|||
*/
|
||||
|
||||
//----- CONFIGURATION -----//
|
||||
#define SERIAL_SPEED 115200 //Recommended values : 115200, 150000, 250000, 500000, 1000000, 2000000
|
||||
#define MCP_CS 10;
|
||||
#define MCP_FREQUENCY MCP_8MHZ //Available values : MCP_8MHZ, MCP_16MHZ, MCP_20MHZ
|
||||
#DEFAULT_CAN_SPEED CAN_500KBPS; //Available values : CAN_10KBPS, CAN_20KBPS, CAN_50KBPS, CAN_100KBPS, CAN_125KBPS, CAN_250KBPS, CAN_500KBPS, CAN_1000KBPS
|
||||
#define SERIAL_SPEED 115200 //Recommended values : 115200, 150000, 250000, 500000, 1000000, 2000000
|
||||
#DEFAULT_CAN_SPEED CAN_500KBPS; //Available values : CAN_10KBPS, CAN_20KBPS, CAN_50KBPS, CAN_100KBPS, CAN_125KBPS, CAN_250KBPS, CAN_500KBPS, CAN_1000KBPS
|
||||
//----------//
|
||||
|
||||
//Don't forget to search on mcp2515 library sources to understand how functions works
|
||||
//Don't forget to search in mcp_can library sources to understand how functions works
|
||||
#include <SPI.h>
|
||||
#include "mcp_can.h"//MCP2515 library
|
||||
|
||||
MCP_CAN CAN(10); // Set CS pin
|
||||
MCP_CAN CAN(MCP_CS); // Set CS pin
|
||||
|
||||
void setup() {
|
||||
Serial.begin(SERIAL_SPEED);
|
||||
|
@ -265,7 +266,7 @@ void slcanProcessRX(uint8_t rx_buffer_len, uint8_t *rx_buffer)
|
|||
else if(rx_buffer[0] == 'N')
|
||||
{
|
||||
Serial.write('N');
|
||||
Serial.print("SLCA");
|
||||
Serial.print("SLGR");
|
||||
Serial.write(13);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue