nathanRamaNoodles / CANopen-ESP32-nodes

Playing around with CANopenNode to fully expand the true potential of CAN bus on ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CANopen-ESP32-nodes

Playing around with CANopenNode to fully expand the true potential of CAN bus on ESP32 while obeying ESP-idf rules. Link to this repo on Github

Why use CAN?
  • Better wired communication between multiple ESP32s and other CAN enabled chips like STM32.
  • High reliability over long distances.
  • Great for home automation.
  • Widely used protocol by big industries.
Why use CANopen?
  • Like anything else, a higher level protocol is essential to avoid re-inventing the wheel, and to guarantee reliability in a commercial product.

Forks

The Forks folder consists of projects I've seen over the internet, and I've tried to re-write in ESP-idf platform:

  • Alexander Miller's implementation uses the Apache License 2.0
    • Only implements the Master Node. Alexander has other CANopen devices to play with like the Dunker motor
    • Both nodes communicate, but I don't know how PDO mapping and the object dictionary works.
  • Guillermo-ruffino's implementation:
    • Consists of an LSS Slave node.
    • Node two implements Guillermo's code, but node one is a raspberry pi, so I don't have enough info. Thus, node one uses Alexander's node one.

Requirements

You will need the following materials:

  • ESP32 (2 or more)
  • SN65HVD230 (or SN65HVD233) CAN bus transceiver chip for each ESP32.
  • A PC (preferably Linux)

How to use

  1. Download esp-idf, and follow their instructions.
  2. Enter into a root directory for one of the nodes for this repo, like cd ./Forks/Alexander_Miller/node_one/
  3. You should edit your GPIO configurations in the CO-config.h (located in the components/CANopen for each esp-idf project) for your CAN transceiver.
    • For my case, all my node_one's are: (GPIO_TX, GPIO_RX) = (12, 32) And all my node_two's are: (GPIO_TX, GPIO_RX) = (16, 17).
    • Make sure you connect your CAN transceiver to your chosen GPIO pins (it doesn't matter which GPIO you choose).
  4. Enter into terminal
    1. idf.py menuconfig
      • You will see a GUI, but we can skip this.
        • Ctrl + C to exit
    2. Build and upload to port (I'm on linux so /dev/ttyUSB0 and my second port is /dev/ttyUSB1):
      • idf.py build && idf.py -p /dev/ttyUSB0 flash monitor
    3. You can exit the monitor by pressing Ctrl + ].
    4. To view the serial again:
      • idf.py -p /dev/ttyUSB0 monitor
  5. Most of the code here requires multiple terminals to be open to see the output for each CAN node. So, redo step 2 and 3 for as many nodes.

Note: if builds fail, then try to run idf.py fullclean. and run build idf.py build again

License

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
...

About

Playing around with CANopenNode to fully expand the true potential of CAN bus on ESP32.

License:Apache License 2.0


Languages

Language:C 99.7%Language:C++ 0.1%Language:CMake 0.1%Language:Makefile 0.1%