ESP32 VCU development

Development and discussion of fast charging systems eg Chademo , CCS etc
Post Reply
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

ESP32 VCU development

Post by arber333 »

I have prepared a board with ESP32 chip for testing and VCU development.
Primary goal would be to develop low cost version of BMS/chademo controler but using this as simple VCU is not excluded.

Main caveat is this only has a single CAN.
Good point would be integration of buzzer for error signalling etc...
While i develop the code i intend to add another CAN to SPI pins... this should make it a great board especially so since it has BT/WiFi functionality already integrated.

If someone already developed something for ESP32 that works i intend to shamelesly ripoff their hard work and use it in true engineering spirit...
You may do the same to me.
Attachments
20220823_212035.jpg
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: ESP32 VCU development

Post by aot93 »

Nice work, I look forward to having a play. 8-)

Talking esp I had this come up on my phone today, looks like it could be a handy low-cost CAN tool.

https://www.crowdsupply.com/meatpi-electronics/wican
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: ESP32 VCU development

Post by arber333 »

Yes the idea is to replace the module with the clear ESP32 chip in the end. I need to know which pins i can trust and what would actually be better BLE or Wifi. I am really impressed by my BMS ability to connect via bluetooth showing all the cells and data...
mario
Posts: 23
Joined: Fri Dec 14, 2018 10:20 pm
Has thanked: 67 times
Been thanked: 10 times

Re: ESP32 VCU development

Post by mario »

arber333 wrote: Wed Aug 24, 2022 8:41 pm Yes the idea is to replace the module with the clear ESP32 chip in the end. I need to know which pins i can trust and what would actually be better BLE or Wifi. I am really impressed by my BMS ability to connect via bluetooth showing all the cells and data...
I did some programming of the ESP32 dev boards and during that came up with the list of usable pins...
Mostly using board with 38 pins and those have voltage regulator like LM1117 so it should work on up to 16V without extra voltage regulator components. However, when connected directly to 12V from car (on pin 5V) voltage regulator gets really hot and results with the board reset... On first startup it works for about 40 secs, and after every restart working time is shortened. I guess 14-15V is too close to top limit and it results with overheat.
Ended up adding additional voltage regulator as I see on your picture.

If you plan to use WiFi intensively then avoid using ADC2 pins as those are used for WiFi comms.

I detected total 14 pins free to use by firmware. Of those, 4 are input only.

Free to use IO pins:
5, 16, 17, 18, 19, 21, 22, 23
ADC1 pins that can be safely used:
32, 33 - as IO
34, 35, 36, 39 - as input only

It is critical to avoid pins 6 to 11 as those are used for SPI flash, and also ADC2 pins (if WiFi is used) 0, 2, 4, 12, 13, 14, 15, 25, 26, 27

For sensing use ADC1 pins 32, 33, 34, 35, 36 and 39. ADC1 also uses pins 37 and 28 for channels 1 and 2 but I think those are not populated on dev boards.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: ESP32 VCU development

Post by arber333 »

True, first i tested that board and found out that 14V is stretching the LDO. This is why i decided to use 2 stage power.
1A 5V regulator first then 1A 3V3 LDO regulator.
What i figured is i need one GND layer and a second power layer. But 5V in the power layer is a bit too much for inputs. So i decided to split that. On the top and right edge i have 5V, but 3V3 is everything else.
I made a first mistake when i fixed CAN transciever to 5V layer. tx is pulled up to Vcc and that will show 5V to ESP directly. I will make a change to 3V3 in next iteration. For now i just cut that layer above CAN and fed 3V3 to it from the side.

Thanks for the pins count. I already figured out some of that limits, but its good to know more.
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: ESP32 VCU development

Post by rstevens81 »

2 things that are worth noting from my adventures with the esp32 on spaceballs ... is that you'll struggle to build a on chip board design at a reasonable cost with jlc as the extended parts fees and the cost themselves for the esp32 and the usb-uart chip even using the ch340 you'll struggle against a known good AliExpress supplier (for the Dev boards). If I got myself an PCB re-flow oven for the extended parts I reckon I could bring costs but that's allot of extra complication. Plus hand soldering the esp isn't recommended as you struggle to get solder to the heat pad under the chip themselves.

Plus there is the added 3rd dimension when using a dev board, this allows the can transceiver chip and an MCP can chip with their associated chips to be put underneath the Dev board. You run out of space really quick once you have connectors and test points 😆

For my next revision I'm going to use these... https://www.digikey.co.uk/en/products/d ... E/12091811

As for the price point I can't get near it as it's genuine cp2102 usb uart chip, extra ram and rom plus you can choose internal or external antenna!

edit: yes i have swollen the esp32 pill completely!! such an insane chip for the price point.
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: ESP32 VCU development

Post by rstevens81 »

mario wrote: Thu Aug 25, 2022 9:10 am
If you plan to use WiFi intensively then avoid using ADC2 pins as those are used for WiFi comms.

I detected total 14 pins free to use by firmware. Of those, 4 are input only.

Free to use IO pins:
5, 16, 17, 18, 19, 21, 22, 23
ADC1 pins that can be safely used:
32, 33 - as IO
34, 35, 36, 39 - as input only

It is critical to avoid pins 6 to 11 as those are used for SPI flash, and also ADC2 pins (if WiFi is used) 0, 2, 4, 12, 13, 14, 15, 25, 26, 27

For sensing use ADC1 pins 32, 33, 34, 35, 36 and 39. ADC1 also uses pins 37 and 28 for channels 1 and 2 but I think those are not populated on dev boards.
I'm curious how gpio27 is on the banned wi-fi list? as this is what has been used for the colin kidder/jack rickard/evtv esp32-candue im surprised that this was missed if that were the case.

any info on this would be appreciated.
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
projectgus
Posts: 47
Joined: Tue Dec 08, 2020 10:33 am
Location: Castlemaine, Australia
Has thanked: 19 times
Been thanked: 14 times
Contact:

Re: ESP32 VCU development

Post by projectgus »

mario wrote: Thu Aug 25, 2022 9:10 am It is critical to avoid pins 6 to 11 as those are used for SPI flash, and also ADC2 pins (if WiFi is used) 0, 2, 4, 12, 13, 14, 15, 25, 26, 27
rstevens81 wrote: Thu Aug 25, 2022 5:52 pm I'm curious how gpio27 is on the banned wi-fi list? as this is what has been used for the colin kidder/jack rickard/evtv esp32-candue im surprised that this was missed if that were the case.
The ADC2 pins can be used as GPIO or for digital peripheral functions without restriction. The limitation is that you can't use them as ADC inputs if Wi-Fi is also used (as Wi-Fi uses ADC2 internally).

There are however some strapping pins on this list which it's safer not to assign. if you do use them then it's important to take care of the state coming out of reset, or the chip may misbehave. GPIOs 0, 12 (aka MTDI), 15 (aka MTDO) are the ones to pay most attention to. The ESP32 datasheet Strapping Pins section has this information. There are also some handy diagrams around, for example https://docs.espressif.com/projects/esp ... pin-layout
mario
Posts: 23
Joined: Fri Dec 14, 2018 10:20 pm
Has thanked: 67 times
Been thanked: 10 times

Re: ESP32 VCU development

Post by mario »

rstevens81 wrote: Thu Aug 25, 2022 5:52 pm I'm curious how gpio27 is on the banned wi-fi list? as this is what has been used for the colin kidder/jack rickard/evtv esp32-candue im surprised that this was missed if that were the case.

any info on this would be appreciated.
On this link https://randomnerdtutorials.com/esp32-p ... nce-gpios/ (comment from August 31st) I've seen reported problems with gpio4 so decided to avoid using wifi pins if not necessary.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: ESP32 VCU development

Post by arber333 »

mario wrote: Thu Aug 25, 2022 9:10 am It is critical to avoid pins 6 to 11 as those are used for SPI flash, and also ADC2 pins (if WiFi is used) 0, 2, 4, 12, 13, 14, 15, 25, 26, 27
So i should avoid pin 4? I am already trying to use it as my CANrx pin with pin 5 . Do you think i should use different pins for CAN then? I want to use Wifi or BLE.
User avatar
aot93
Posts: 198
Joined: Mon Feb 15, 2021 5:45 pm
Location: UK, West Sussex
Has thanked: 6 times
Been thanked: 43 times

Re: ESP32 VCU development

Post by aot93 »

I tried 4 and 5 for can Comms without success.

Pins 16,17 have worked just fine though.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: ESP32 VCU development

Post by jon volk »

I’m running CAN on pins 4 and 5 for the ESP32 driving my Bluetooth head unit I built. I’m pretty sure it’s a wroom-32 model.
Formerly 92 E30 BMW Cabrio with Tesla power
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: ESP32 VCU development

Post by arber333 »

jon volk wrote: Sat Aug 27, 2022 12:05 pm I’m running CAN on pins 4 and 5 for the ESP32 driving my Bluetooth head unit I built. I’m pretty sure it’s a wroom-32 model.
which driver are you using?

I am trying to work with Collins ESP32 can driver with CAN common driver.
https://github.com/collin80/esp32_can
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: ESP32 VCU development

Post by jon volk »

The ESP-IDF from Espressif, not using the Arduino framework.
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: ESP32 VCU development

Post by rstevens81 »

I would use the default which are GPIO_NUM_17, GPIO_NUM_16 from esp32_can_builtin.cpp if you can as they are known working pins. The easiest way I found to work out known good pins was to look at the evtv due manual (http://media3.evtv.me/ESP32CANDue.pdf) if you do want to spi can you have to edit the library to uncomment the mcp2515.
My rationale for copying the pin out was to (a) it's a known good configuration and (b) I can use the board with saavycan
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: ESP32 VCU development

Post by arber333 »

I now use VCU code directly in my Pug. It finally works without glitches and artifacts.
Because a flowing code would not work with CAN telegrams being controled from within i had to reprogram several flags which define states.
The code is not a state machine but rather flowing code setup to react per different states.
Flags define the corners of event envelope such as AC compressor control or charger control.
I take several CAN telegram reports and use them in a feedback loop control. For example charger code uses chargers own voltage report which in turn stops that charger (or several) when battery is considered full.
There are other loops even aux voltage can be observed and low state resolved, for example if a car would be parked for a long time.
PWM pins are defined but i havent used them as of yet. One could control pumps and fans with that.
My VCU has watchdog defined to check sanity at 3s rate.

I will now work on the Wifi interface to be able to see some parameters as part of regular servicing. Mainly CAN reports such as HV voltage, AC compressor report, HV heater report and DCDC report. Eventually this could go to BMS as well.

Further improvements will include addition of quad AD converter chip on I2C since ESP32s own AD is a shabby deal for throttle input.
The idea is to use VCU to control outlander or Leaf inverter via CAN bus. While i could do it already i see a lot of movement in AD values and that is not good for throttle control.

Code is here... https://github.com/arber333/ESP32-VCU/
Viewtop1
Posts: 11
Joined: Wed Sep 14, 2022 9:07 am
Has thanked: 3 times

Re: ESP32 VCU development

Post by Viewtop1 »

What version of the ESP Core are you guys using for this.

I am on ESP32 by esspressif System 2.09 in Arduino Boards Manager.

I cannot get the collins ESP32_Can Library to work. The examples don't get past "Initializing" ( It seems to get stuck on CAN0.begin(500000);)

So it seems like the CAN Driver is never started. I get no error codes, it just sits there doing nothing.

The ESP32 VCU basically fails at the same point.

I am using a ESP32 Dev kit, with can module. Which happily works my S-BOX...
Post Reply