Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 Driver #198

Closed
guillermo-ruffino opened this issue Jun 19, 2020 · 18 comments
Closed

ESP32 Driver #198

guillermo-ruffino opened this issue Jun 19, 2020 · 18 comments

Comments

@guillermo-ruffino
Copy link

Is there any reason ESP32 is not done already? (Other than nobody did it I mean)

I might need this so I can try, I'm pretty new to can bus and can open in general, so quite lost.

I've been looking what is needed to support it, and I guess I could try to adapt the SDK given by espressif for the driver.

This thing uses FreeRTOS, so for thread management, etc, is there some driver which uses this already I could look into? I only found #28 (comment) regarding FreeRTOS so far.

I'm building my own network of nodes, so no compatibility with other systems is needed so far, so I still have to learn how to setup the nodes, if I understand properly, I have to use the example and somehow configure them differently so they are different nodes?

I have ESP32's and sn65hvd230 transceivers to connect them. I've already got them communicating in plain can bus.

I don't expect full feedback of this broad question, just any tips you think are worth mentioning I'll appreciate.

@martinwag
Copy link
Collaborator

martinwag commented Jun 22, 2020

Hi,

no specific reason, it's just that nobody needed it yet :-). Didn't even know that ESP32 has CAN bus integrated...

We have a FreeRTOS port of the driver that works with an self-written hardware layer driver. That's why I didn't add it to main repo.
If you're intrested I can push it, you then have to adopt the hardware layer driver to the ESP32 stuff.

@guillermo-ruffino
Copy link
Author

Yes! I guess that will be great if I can reuse the sync macros for FreeRTOS, I was about to start digging in Zephyr as they support ESP32. But I'd like to learn FreeRTOS more

@martinwag
Copy link
Collaborator

martinwag commented Jun 23, 2020

https://github.com/martinwag/CANopenNode/tree/neuberger-freertos/stack/neuberger-FreeRTOS

This is based on v1.3-master repo. Please be aware that this was not made to be added to main stack.

  • You should be able to use the thread stuff, which does all the timing things.
  • The driver port only adds canopen specific stuff to the hardware layer driver. The hardware layer driver is not included in this commit! (STM32 specific anyway...)
  • You can remove the log / LED stuff, it's not needed for general use.

@guillermo-ruffino
Copy link
Author

Well thanks, I'm doing some progress here, got the library kind of working, still need many details.
Ended up using latest version, not 1.3 and the threading will need to dig deeper later.

I am using PlatformIO, so project structure has changed, now all .h files are in an include folder, and c files in other.

The esp32 has a custom FreeRTOS, modified mostly because the esp32 is a dual core mcu, it is based in FreeRTOS 8, and the code you gave me is using stuff which is not available in that version, so wasn't a plug and play solution.
Anyway, esp32 has other constructs like real time timers which I'm using, I still hasn't pay much attention to sync stuff so race conditions are there waiting to fail.
Heartbeat and NMT seems to work as intended, I can change the preop / start / stop modes, also SDO for changing the heartbeat speed works.

I really don't know where to start for PDO stuff, as I'm very new to CANopen and even CAN Bus, I still need to figure out how to setup PDO communication, unfortunately this is not in the great readme guide of CANopenNode which I'm using successfully with a Raspberry PI and I connected an MCP2515 to it.

I see there are at least 2 ways of sending PDOs,

  1. unsolicited, i.e. I believe my app logic just wants to send a PDO, should I call a function of CANopenNode?
  2. via the Sync mechanism, again, how I'm suppoused to make a fresh value available to the lib?

@CANopenNode
Copy link
Owner

You setup PDOs in running CANopen network by changing PDO mapping and communication parameters.

Your application must only use some variable from OD and "fill" it with data. This variable is then ready to be mapped into TPDO, for example.

@guillermo-ruffino
Copy link
Author

Thank you! I got it working now, it sends data when it changes, still need to learn how the SYNC option works

Quick question, is the library comparing memory to check if there is a need to send a TPDO?

@martinwag
Copy link
Collaborator

Yes.

@Bascy
Copy link

Bascy commented Jul 10, 2020

Im really interested in running CanOpen on ESP32, our project will have several boards with ESP32 SOCs communicating with eachother, connected through a CANbus. I already have a propriety protocol running, but looking to expand and standardize the communication so we can create a more generic solution.

@guillermo-ruffino Are you willing to share your results so far?

@CANopenNode
Copy link
Owner

I added a link to Neuberger-FreeRTOS into /doc/deviceSupport.md file.
If there will be something new, feel free to send a pull request or just write a note about update in deviceSupport.md file.

@guillermo-ruffino
Copy link
Author

@Bascy yes, I haven't worked much on this after my last comment, but I can send you what I have done which is not much, but will allow you to start working from something that communicates data. The easiest for me will be to zip the thing and send it to you or post it here, I'm using platformio to build the project on vscode, so I had to modify the structure, all .h files are in an include folder, etc.

@Bascy
Copy link

Bascy commented Jul 14, 2020

@guillermo-ruffino Thanks, a zip to basschouten65(AT)gmail.com would be great
Im using the same set of tools so no problem there

@guillermo-ruffino
Copy link
Author

esp32_CANopenNode.zip

hope this helps!

@CANopenNode
Copy link
Owner

CANopen is the internationally standardized higher-layer protocol for embedded control system built on top of CAN.
There are books about CANopen. For basic information please see README.

@CANopenNode
Copy link
Owner

@guillermo-ruffino, thank you, link to your file is now in deviceSupport.md

@jblanz
Copy link

jblanz commented Jan 4, 2021

As I am also interested to use CANopenNode on ESP32: Has anyone tried to integrate the work of @guillermo-ruffino into the Eclipse IDE?

@guillermo-ruffino: Thanks for your very kind contribution! Did you make any progress since you provided the link to the zip archive? I am wondering if PDO Tx/Rx is working and if Sync objects can be processed?

Thanks a lot for your feedback!

@Torgano
Copy link

Torgano commented Mar 18, 2021

I am also interested in CANopen for ESP32.
My question: is

esp32_CANopenNode.zip

still the most recent work to start from / continue with?

@jblanz
Copy link

jblanz commented May 9, 2022 via email

@notiflux
Copy link

For anyone interested, here's a version of the object dictionary file that works with the current version of CanOpenEditor. Note that, as of writing this comment, the latest binary release contains a bug in which the logic is reversed for RPDO/TPDO mappings (see this PR), so either build from the bugfix branch or apply the patch from the PR manually. Don't forget to switch the exporter to CANOPEN_LEGACY.

Also, remember to set CO_VERSION_MAJOR=3 in your build flags in platformio.ini.

deviceFile_barebones.xdd.txt (remove .txt from filename)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants