Arduino DUE VCU with analog and CAN control

arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

PaulUdrea wrote: Sat Oct 29, 2022 11:14 pm Hello Arber, great work. Do you intend to sell the controller? From what I read, it should be useful for my conversion. I am at the stage of selecting a charger and a BMS. Finally I’ve got the batteries, Kokam 75Ah (used). Before purchasing the BMS and the charger I want to make sure that all the equipment will work with each other. I would be interested to know if it will be available for purchase.
Well yes i can offer it for sale when i have tested it thoroughly. I intend to use it primarily as Chademo controler as well as a separate BMS control similar to SimpBMS. Price will have to be low, near the 130€s since the ESP32 low value. I hope i can manage that.
For now all components are setup for hand assembly as is my phylosophy.
I dont want to fit ESP32 chip directly on to the board since this can create all sorts of headaches with ground loops and wifi etc...

This board for now drives only one CAN transciever. I consider it enough for now. Later i will add another SPI if need be, but i see quite a lot of development to do that. For now the code itself is enough of a challenge :).

My BMS plan includes those active JKBMS modules and its 250kbaud CAN output to make a complete system. Zero user involvment into BMS while battery is working properly and very simple UI via WIfI or BT to identify individual cells gone astray. Or just to observe situation.
Buzzer is there to provide audial warning in various cases.
I intend to make use of a simple BMS pulldown pin which would signal stop of (fast) charge and turttle mode in case of low battery.

Will see how that goes... hopefully i will have enough time theese days to develop the code for my VCU to read BMS report. From then on i can learn myself some html programming :).

Or i can make a BT app? What do you think would be more convenient?
PaulUdrea
Posts: 25
Joined: Wed Aug 04, 2021 8:29 pm
Location: Toronto, Canada
Has thanked: 11 times
Been thanked: 1 time

Re: Arduino DUE VCU with analog and CAN control

Post by PaulUdrea »

Hello Arber, thanks for your prompt reply. The price sounds quite reasonable to me. BT app means controlling through the phone? This sounds very good. Not sure how much effort it requires. Maybe initially controlling through a web interface might be enough if this involves less work. I am a mechanical engineer with no knowledge about programing and electronics, so from my point of view the easier it is with minimum involvement the better. In order for me to better understand, I can try to write a user manual with your guidance. I can draw on AUTOCAD the diagrams. I have Solidworks if needed. I have been looking at JK BMS lately. It is one of the BMS systems I am considering. How would your VCU integrate / work when the charger is connected to a level 2 source i.e. 230 VAC /40 A? Most of the times the car will be charging via level2.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

PaulUdrea wrote: Sun Oct 30, 2022 12:35 pm .... I have been looking at JK BMS lately. It is one of the BMS systems I am considering. How would your VCU integrate / work when the charger is connected to a level 2 source i.e. 230 VAC /40 A? Most of the times the car will be charging via level2.
Really good question.
There would be one output on this VCU dedicated to HMI BMS warning - a buzzer. Also since there is a single CAN and it needs to run at 250kbaud it can only control those JK balancers. I cant use 250kbaud signal to command 500kbaud charger... So i intend to use another output, active low to keep the charging process alive in the other VCU which would actually control the charger and other systems like AC or heater. I really like Outlander way of single CAN telegram that works as a heartbeat. Remove that and all processes cease. So in my instance i intend to use a simple pulldown pin to command 0x285 CAN telegram to stop transmitting. That will stop chargers as well as running gear, but keep contactors alive.
Or i can do it the FAILSAFE way; to command the heartbeat by that active BMS signal. If you remove the signal everything fails safe.... Havent decided yet.

I have already implemented PP and CP signalling. Board also has PWM duty sensing pin which can be used to correct power as required from the EVSE.

This version of VCU actually could also be used to run Leaf or Outlander inverter. It has the analog pins and correct inputs and outputs as well. So practicaly to run the car, L2 charger, BMS and chademo one would need like 3 or 4 of theese VCUs. Overkill? Time will tell.

Later on i will develop a VCU with 2x CAN transcievers working at different speeds. Maybe that way we could use a single VCU then. But i am not so sure as it would require playing with port expander chips and other strange unknowns :). Havent moved to that place yet..

Thanks for the offer of SW design. I appreciate it :). I am ME myself and i find it increasingly difficult to connect to newer CAD interfaces. SW is a known quantity though.
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: Arduino DUE VCU with analog and CAN control

Post by aot93 »

Hi Arber,

Good progress, I've not had any time to play with the board.

For a phone app take a look a http://ai2.appinventor.mit.edu/ it's a super simple and fast way to build basic apps for Android

I made a virtual dash for an ice car for while back, I've attached it if you want to take a look.
Attachments
gauge_1Screen.zip
(357.22 KiB) Downloaded 75 times
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

aot93 wrote: Mon Oct 31, 2022 8:16 am Hi Arber,

Good progress, I've not had any time to play with the board.

For a phone app take a look a http://ai2.appinventor.mit.edu/ it's a super simple and fast way to build basic apps for Android

I made a virtual dash for an ice car for while back, I've attached it if you want to take a look.
Yes MIT inventor is exactly what i had in mind.
However I would want to make an app for the purpose of maintenance of battery not to watch the cells while i drive.
Idea is to collect cell data from several arrays within the code and display them on several screens.
Then there would be innitial screen that would show general data from BMS such as complete voltage, temperature, balancing state, alarm status etc...

Say aot93, do i send you the latest board to play with? :) I changed several things there and now i have working CAN code together with functional I/Os. At least that is for the VCU part.
I still need to code in a functional CAN readback, but since i use can common library i dont see it being much different from DUE.

What i am working on now is BMS code which is somewhat different in that i use revolving ID telegrams. Whenever i need to send a querry to N+1
modules i spit out a function with several cases which revolve from 0 to N. This means a quick succession of BMS requests with immediate reports.
The same functionality i use to turn on/off balancing for all the modules.
Will see how this works in a real system...
PaulUdrea
Posts: 25
Joined: Wed Aug 04, 2021 8:29 pm
Location: Toronto, Canada
Has thanked: 11 times
Been thanked: 1 time

Re: Arduino DUE VCU with analog and CAN control

Post by PaulUdrea »

Hello Arber, sounds quite impressive what you are building. If I can use it with the Outlander or Leaf chargers and JK BMS and can be integrated with the rest of the equipment, then I am interested; you can put my name on the purchase list.
Cheers,
Paul
PS. Ease of use would be quite important for "non programing" people like myself. Even if the first version doesn't have all the features planned, but it works, then I am willing to buy one to learn.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

I have contact! 8-)
I managed to get my JK BMS modules to report to VCU request. I also see i can directly command balancing switch.
I now need to setup cell arrays and find some way of reporting cell difference.
I will use error reports as well. I will need totest it though..

I alsi see an averaging report per module and will use it to condition cell balancing from the SOV side.
PaulUdrea
Posts: 25
Joined: Wed Aug 04, 2021 8:29 pm
Location: Toronto, Canada
Has thanked: 11 times
Been thanked: 1 time

Re: Arduino DUE VCU with analog and CAN control

Post by PaulUdrea »

Excellent Arber, great to hear you are making progress.
Cheers,
Paul
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: Arduino DUE VCU with analog and CAN control

Post by aot93 »

Good progress!

I'm on your V1 board, but I'm away for a while now so playing for me!
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

aot93 wrote: Tue Nov 01, 2022 1:19 pm Good progress!

I'm on your V1 board, but I'm away for a while now so playing for me!
I might need some help with the ESP32 code here :).
My idea is to have a continuous process which spits a BMS request for data every 500ms. So we get new data 2 per second.
Then everything will be read from that data report.
I like to setup flags form my conditionals which should make a logical process without too much code.

I have done that with DUE board using Collins DueTimer library and its simple declaration to attach a function to an interrupt.
https://github.com/collin80/DueTimer

Code: Select all

Timer4.attachInterrupt(sendCANframeURGENT).start(10000);
Does anyone know if there is a similar ESP32 library or simple command set to have my function running in a loop disconnected from what the system is doing?

tnx for any suggestion...
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

I managed to develop a VCU that i can use with JK balancers with CAN bus.
I will post further development in the BMS thread as this thread is more appropriate for DUE based VCU/BMS development.

Here is the link to BMS master thread:
viewtopic.php?t=2256
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

OK, this is applicable here as well.
I managed to assemble a good alarm buzzer function.
Idea is to signal alarm state by short and long beeps
example:
Cell overvoltage alarm 3 short, 1 long
Cell undervoltage alarm 5 short 1 long
Cel overtemperature alarm 6 short 1 long
and variations...

I will build a table of alarms that i consider vital so we will know immediately what BMS is telling us.
Any suggestion of alarms for VCU?
User avatar
uhi22
Posts: 554
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 83 times
Been thanked: 392 times

Re: Arduino DUE VCU with analog and CAN control

Post by uhi22 »

If you have more than a few alarm codes, I'd propose to just use morse code, e.g. two digits 00 to 99 so plenty of room and understandable by "every"-(radio amateur)-one :-)
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

uhi22 wrote: Mon Dec 12, 2022 4:09 pm If you have more than a few alarm codes, I'd propose to just use morse code, e.g. two digits 00 to 99 so plenty of room and understandable by "every"-(radio amateur)-one :-)
I rather not thanks. It can quickly become unwieldy codewise. I will simply make up to 10 possible codes using short pulses with long pulse as terminator.
That way you can count and drive at the same time hopefully :).
As suggestion wise i meant at what fault states should buzzer sound.

1. Overvoltage
2. Undervoltage
3. Too high cell difference
4. Overtemperature
5. Undertemperature ?
6. CAN link lost for more than 3 consecutive cycles
????

Some of the error states would only go together with sxme operating states such as Overvoltage - charging function and Undervoltage - drive...
Also i could be using some of the codes for VCU as well as BMS. This would probably mean VCU would have error codes that end with two long beeps...
User avatar
uhi22
Posts: 554
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 83 times
Been thanked: 392 times

Re: Arduino DUE VCU with analog and CAN control

Post by uhi22 »

Maybe 7. Startup (to detect unwanted resets, due to power issues or watchdog resets).
And if 2 means "Undervoltage of the traction battery", then 8. undervoltage of the 12V supply.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

uhi22 wrote: Mon Dec 12, 2022 8:15 pm Maybe 7. Startup (to detect unwanted resets, due to power issues or watchdog resets).
And if 2 means "Undervoltage of the traction battery", then 8. undervoltage of the 12V supply.
Ah ok... i didnt setup any analog channel to measure 12V level. I will hardwire it to next VCU revision.
BMS shouldnt need that one i imagine.

Edit: otoh i think i will simply wire 12V power to analog sensing. This should then measure AUX voltage and turn on DCDC at critical voltage level.

Any VCU code i make lately has watchdog setup for 3s. It is literally the first function i build in.

Hm... i will work on error flags more as flag is a state not a conditional. So it should remain ON until power is reset. Which is what i want from important function.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

ESP32 VCU with analog and CAN control

Post by arber333 »

arber333 wrote: Mon Dec 12, 2022 8:33 pm Ah ok... i didnt setup any analog channel to measure 12V level. I will hardwire it to next VCU revision.
I tested ESP32 12V signal sensing on one of my analog inputs. Rather cubersome, using throttle input for that but it works :).

On the more important note i managed to setup watchdog function so it does not reset the chip every so often...
CAN bus signaling works within function now. I had to use flags as conditionals do not work with yet undeclared parameters (can values).
VCU would read Mitsubishi charger/DCDC aux voltage from CAN and decide to start it up if it drops too low. On the charge side VCU would read HV voltage and stop charger from going too high. There are AC compressor and heater functions too.
Tesla DCDC CAN signal i tested too.
Eltek charger commands.

I think it is time to publish the details :).
Links to schematic and design are in github
https://github.com/arber333/ESP32-VCU
Attachments
VCU pinout.pdf
(288.11 KiB) Downloaded 91 times
ESP32 VCU pinout.jpg
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

To be more precise; i published the VCU code which works with Mitsubishi, Eltek, Elcon and Tesla CAN commands. It can sense EVSE presence and react with running coolant pump and DCDC. Aux battery monitoring function is added to keep 12V system topped up.
I set it up to use flag state within CAN functions. That way one can use single event for multiple functions in real time.

To github i added BMS code as well even though it is not nearly finished. Simply because you can already use existing board. I will use this with JK BMS active balancers. Difference is it runs CAN at 250kbps.

Eventually i will redesign BMS board to use direct voltage/current sensing in a similar way to ISA shunt. This should simplify SOC tracking and indication. Idea is to be able to show SOC by PWM signal directly connecting to fuel level probe. Voltage could be shown as a dial function as well as current directly connected to RPM indicator. That is the idea.
evMacGyver
Posts: 108
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 19 times
Been thanked: 5 times

Re: Arduino DUE VCU with analog and CAN control

Post by evMacGyver »

arber333 wrote: Tue Aug 30, 2022 8:33 am This is meant as a quick DUE VCU V6.
Arber, would you like to share schematic file for v6? Currently I use your v4.1 board but its highly modified with some add-on boards for needed features. I really have to develop some better solution before summer with casing and proper connectors so your v6 could be very good point to start and it would save me a lot of time. For now I'm not looking to port code for some else.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

evMacGyver wrote: Fri Feb 24, 2023 7:30 am Arber, would you like to share schematic file for v6? Currently I use your v4.1 board but its highly modified with some add-on boards for needed features. I really have to develop some better solution before summer with casing and proper connectors so your v6 could be very good point to start and it would save me a lot of time. For now I'm not looking to port code for some else.
Huh i would love to, but i never made schematic :(. I just quickly drew a prototype and distributed the pins to the similarity with V4.3. I only have one prototype built and havent tested it yet. I intend to draw out a schematic or at least pinout since i would have to test its operation sometime. But i am working on ESP32 VCU now.

I will try to make the v4.3 code and pinout to fit V6 board untill next week.
If you want me to send you an example PCB you can pm me.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

I have decided aot93s throttle matrix is too complex for me and i am looking towards Lebowski polynomal throttle.
There are three coefficients you can set in code that determine the curve. a, b, and c are floats because they can be less then 1.
x is the throttle value and y is the result.
y = a*x + b*x^2 + c*x^3

I will think on how to make those coefficients possible to set in code as well.

@aot93 how would your RWD motor inverter behave if you would apply full torque request? Does it have any sanity buit in or is it just trying to fulfil command?
I am asking because i would probably have to make a terminating factor (multiply by zero) in case of brake input and overspeed protection. I might built it as a dw/dt filter like acceleration limiter
evMacGyver
Posts: 108
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 19 times
Been thanked: 5 times

Re: Arduino DUE VCU with analog and CAN control

Post by evMacGyver »

arber333 wrote: Fri Feb 24, 2023 8:39 am Huh i would love to, but i never made schematic :(
Ok, did you find datasheet of the casing and dimensions for pcb? And did board fit nicely to connector and case fixing holes?
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

evMacGyver wrote: Mon Feb 27, 2023 7:24 am Ok, did you find datasheet of the casing and dimensions for pcb? And did board fit nicely to connector and case fixing holes?
Well my design is on the github https://github.com/arber333/Arduino-DUE-VCU
I will add schematic later this week.
Photos of my built example. It just clears theconnector pins and casing.
Attachments
IMG-20221027-WA0005.jpeg
IMG-20221027-WA0007.jpeg
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

I managed to make a simple V6 schematic at least for the output connectorss. I will work on the internal connections some more.
As i still need to make the code work those may change.
Attachments
DUE shield_v6 - Schematic.pdf
(177.21 KiB) Downloaded 88 times
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by arber333 »

arber333 wrote: Fri Mar 17, 2023 12:46 pm I managed to make a simple V6 schematic at least for the output connectorss. I will work on the internal connections some more.
As i still need to make the code work those may change.
Bah! I tested the V6 DUE VCU in my car... i cant use this VCU directly as DUE is a bit too large. I cant access the native USB by a cable. So this design was a partial failure. I can still use the preconfigured DUE directly but there is no way of setting the parameters after you connect. I will refocus to ESP32 VCU design.
Post Reply