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] CAN bus and MOD bus master RTU. #5087
Comments
There has been some discussion on the Micropython forum about modbus: You can get some more info on ESP32 CAN use via this: |
Hello, |
Hello, Do not hesitate to open an issue for any new request or just to highlight any bug on the code. |
hava a example? |
I have updated the Quick Ref file. Here the link to CAN Bus section: https://github.com/nos86/micropython/blob/esp32-can-driver-v1/docs/esp32/quickref.rst#can-bus |
Actually not, my goal was to develop the driver for CAN hardware for my project. |
Things go slow when not incentivized... Last post 29 days old... Might a modest bounty speed things up? I'd really like a proper CAN implementation (with proper documentation to go with it) for ESP32... It's very odd that PyBoard and other MCUs with CAN are supported in uPython, but somehow ESP32 got a miss on it... How it got to a 1.0 release with this glaring omission is kinda ... wut? Car v1.0 doesn't have tires or a gas tank... [confusion] I can't code worth a damn, but I can spend money... |
Hi @nos86, |
It's about to be a native part of MicroPython thanks to this excellent fellow. See here: #5310 |
Great work! I really could use this for a project I'm doing since I don't care much for writing all this C-code. How does the ESP32 hold up with CAN & micropython when the can bus is quite busy? |
Hello @neographikal, For the next releases, I'm planning to incorporate the configuration of hardware filter (best option for very high bus load) and some software filter handled at low level by C in order to improve the flexibility of the library. |
Good to know :) Thanks! |
Going to ask some stupid questions; Is this lib meant for the onboard can bus controller on the ESP32? The SDA/SDL references threw me off a bit, or is the internal one also i2c based? I'm using the internal controller with an 2551 transceiver. I have an proof of concept working in C now;
is the baudrate parameter 250 for 250kbps? Thanks :) Going to try this, nice to have some spare time in the holidays ;) |
Driver is designed for internal controller with external transceiver (likes mcp2551). Please find the example inside my repo (example/esp32_can.py) https://github.com/nos86/micropython/blob/esp32-can-driver/examples/esp32_can.py There you can find how to initialize the driver. More details on https://github.com/nos86/micropython/blob/esp32-can-driver/docs/library/esp32.CAN.rst Let me know if you need more help |
@nos86 Thanks a lot. I'm really looking forward that you CAN driver is included into Micropython. Do you have a build ready to be tested? Another question I have is: What about sniffing a CAN bus that has both, standard and extended frames. Would it work? Is it possible to send both types on the same bus one after the other? I can see from your example that it is possible to switch but is it also possible to detect extended frames when receiving them in standard mode? |
Can there be two CAN bus at the same time? What are the available pin combinations? |
According to my knowledge, esp32 has only one can driver. I didn't try to use mixed messages, I'll try it as soon as a return from vacation. |
Hello @nos86 can you release a build? You have forked from a reasonably new version of repository and in fact I (possibly many others) are using an older MicroPython release. So we could avoid setting up the whole build system if you could make a recent build available. In a sense I've already been waiting for the last 2 months for your driver to get integrated with the main branch but it's not moving forward. |
I'm on vacation without internet. I'll be able to upload a build by end of next week. |
Hi @nos86. First of all, thanks for all the work on this! While I consider myself experienced in these matters, I'm new to the whole ESP32 ecosystem. Following these instructions, it's not clear where to run "make" without a configured ESPIDF. After cloning the esp-idf repository, there is no Makefile in that directory. It would be great if I could download a build rather than setting up the whole build system. |
Hi @jbakuwel, |
Hi @nos86, |
@mlokhandwala, firmware.bin is the hex file to be loaded in ESP32. It is a Mycropython installation that includes the CAN driver. Please refer to https://docs.micropython.org/en/latest/esp32/tutorial/intro.html#deploying-the-firmware for the installation. Clearly, you have to use my firmware instead the official one. |
If I could find some DOCs, I'd be sending and receiving over CANBUS /w muh SN65HVD230s, MCP2551s, and TJA1051s right now! |
Hi @nos86
My apologies! I was expecting it to be the full installation but when I saw the size of the firmware.bin for some reason I thought it was too small and probably just the CAN lib. |
Hi @nos86 , I suppose the build you have uploaded is for modules with SPI. After I flash it I get the following error (loop): rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) I am using the following chip with 4MB flash and no SPI Chip is ESP32D0WDQ6 (revision 1) |
I made no changes in Makefile. it is the same of the mainstream. Have you tried to flash again the official micropython firmware to check if it works? |
Hi, I guess there must be some make file switch for SPI / No SPI Flash. Even the official firmware is available in SPI / No SPI Flash versions. |
Hi, MicroPython esp32-can-driver-v2-4-gc8afef6e8-dirty on 2020-01-09; ESP32 module with ESP32
Any idea of how to fix this error ? |
Hello skpang, Can you try it and tell me if this fixes your problem? |
CAN.SILENT didn't work either.
I am looking at the example at: Also at: |
I also tried:
Is there a newer binary image available for the ESP32 with CAN ? |
Please, download latest version: https://github.com/nos86/micropython/releases/tag/esp32-can-driver-v3 Refer to https://github.com/nos86/micropython/blob/esp32-can-driver-v3/docs/library/machine.CAN.rst as documentation for usage. Several changes has been done since first version in order to harmonize the driver across different hardwares. Moreover, pay attention, in order to save space, several constants have been removed from code. If you want to use it, you have to declare in your script. |
Hi nos86, I've just tried the new v3 binary but after flashed the board I'm getting this error: Is this the correct binary for an Adafruit HUZZAH32 – ESP32 Feather Board ? |
Hello @nos86, first great work implementing the CAN drivers. Did you finish the complete implementation with filters? How can I use it with the lastest MicroPython and not your bin file? |
@nos86 Anything I can do to help with the development for this? |
Hello @Tbruno25, The module is already ready for integration and I'm still waiting for merging. I saw several people that are not able to use the HEX file I've compiled. Unfortunately at this time, I don't have an hardware ready for test and I cannot check a new compiled file. Are you able to do it? If yes, it would be very useful for the community until my implementation is not merged in main project. |
Hi nos86, |
Hi @skpang, The best option is that someone has the envirmoment setup and the hardware so he will be sure that the image works without problem and then I can release it for all. |
The previous .bin you provided worked for me... I've got about 20 ESP32 boards laying about... They're not expensive. What happened to yours? Are they hard to get where you live? I can send you some... I've got some machines running Arch Linux that could be used, ssh, etc... Even if I don't understand, you can ssh and I'll plug an ESP32 into the USB port... Willing to do stuff, but not good at this #LearnToCode stuff since nobody ever writes intelligible docs or wants to explain anything... |
@nos86 I can definitely help with that. First I compiled a new .bin from your master and have encountered the same issue @skpang reported above. it seems to go into an infinite boot loop with the following error:
I then realized the master branch has no
|
@nos86, @Tbruno25 for what it's worth: v2 of the firmware loads fine on the ESP32 board I have here but v3 goes into the mentioned infinite boot loop. What has changed between v2 and v3 that could cause this? @nos86, The board I have has three CAN buses, do you think it's feasible to make all those accessible with uPython? |
hi @nos86 just wanted to leave behind some positivity by telling you I appreciate all the hard work you've put into this. I really hope you are able to continue the work. |
While we are waiting for this to be added to the official micropython repo, if you need CAN bus you can give this firmware a try. It's a modified version of Pycom's WIPY firmware which implements CAN -- confirmed working with a sn65hvd230 on an esp32-wroom-32. |
I see that it's been a while since the last update.... |
WIP: esp32 CAN(TWAI) driver |
Is there any progress with this PR? I was able to build it with latest master version (1.19.1) with replacing definition of MP_DEFINE_CONST_OBJ_TYPE(
machine_can_type,
MP_QSTR_CAN,
MP_TYPE_FLAG_NONE,
make_new, machine_hw_can_make_new,
print, machine_hw_can_print,
locals_dict, (mp_obj_dict_t *)&machine_can_locals_dict
); but it is not working with my hardware. Maybe I missed something? I'm using VP230 for converting TTL levels of esp32 to CAN BUS levels. According to oscilloscope it should send and receive some data, but the only thing I can see is increasing |
Hello.
Are there support or plans to support CAN bus on ESP32? I see that there are a implementation for pyboard https://docs.micropython.org/en/latest/library/pyb.CAN.html - is that a similar implementation on the ESP32?
And about the MOD bus master RTU on micropython?
I think that, differently of CAN bus, MOD bus implementation is not a microcontroller dependent, just works over UART, is that correct?
I not found a implementation for the modbus master RTU in micropython libs and so on, anyone know if are there a third lib for that?
Thank you so much.
The text was updated successfully, but these errors were encountered: