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 »

900 wrote: Sun Jul 24, 2022 12:10 pm
arber333 wrote: Sun Jul 24, 2022 11:57 am Yes you need to connect cp pin and pp pin to correct LV pin of the charger and it will be able to provide as much power as evse would allow. I know the pinout for gen2, but i do not know gen3...
My intention now is just that. Replacing eltek chargers with single Tesla gen2 and connect it directly to charging port. DUE VCU i will use only to run pumps and relays and other support stuff...
Of course if you do that you cant use cp pin with due circuit. But it is still benificial to observe pp pin state as you can use its change of state to start some charging process within due. Just be careful not to connect 12v directly to DUE chip.
Do you mean you will be connecting CP and PP to Damien's Tesla charger replacement board with STM32 chip? Before the STM32 version there was a version with SAM chip (same as on Due). So I am using the code written for that board but instead of that board I am using arduino due + your shield. So I need to make CP circuitry on your shield work with that version of the code. Why can't I use CP pin with the circuit on your shield?
Sorry yes i didnt think of that. In that case populate CP line and relay so you will be able to pull in evse. To sense correct cp amperage limit you would need one nmos transistor towards cp sense due pin with pullup. I didnt look how damien did its first due design. In code i intended to calculate millis difference to determine duty, but havent worked on that yet. If you do please publish that code please.
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

arber333 wrote: Sun Jul 24, 2022 12:18 pm Sorry yes i didnt think of that. In that case populate CP line and relay so you will be able to pull in evse. To sense correct cp amperage limit you would need one nmos transistor towards cp sense due pin with pullup. I didnt look how damien did its first due design. In code i intended to calculate millis difference to determine duty, but havent worked on that yet. If you do please publish that code please.
evMacGyver has already edited the code to make your CP circuitry work. I hope he can share. Otherwise it's way out of my competence.
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

arber333 wrote: Mon Nov 29, 2021 7:03 pm There are only 2 diodes on that board. First one is power diode to protect 12V positive from reverse polarity and the second one is 30V schottky diode to rectify Cp signal for later transistor edge counting.
I have a B230A-13-F diode is it suitable as a D1? Also what is the polarity, do you have a picture? Which way the mark of a diode needs to be pointing?
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 »

900 wrote: Sun Jul 24, 2022 1:06 pm
arber333 wrote: Mon Nov 29, 2021 7:03 pm There are only 2 diodes on that board. First one is power diode to protect 12V positive from reverse polarity and the second one is 30V schottky diode to rectify Cp signal for later transistor edge counting.
I have a B230A-13-F diode is it suitable as a D1? Also what is the polarity, do you have a picture? Which way the mark of a diode needs to be pointing?
Yes 30V 2A is more than enough. You just make sure its the correct package to fit.
Also marking is oriented towards the resistors. It is suppose to rectify -12V _ +12V peak to peak evse signal into dc signal.
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

arber333 wrote: Sun Jul 24, 2022 2:30 pm Also marking is oriented towards the resistors. It is suppose to rectify -12V _ +12V peak to peak evse signal into dc signal.
Is this correct? 😊
Attachments
20220724_185807.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 »

900 wrote: Sun Jul 24, 2022 3:59 pm
arber333 wrote: Sun Jul 24, 2022 2:30 pm Also marking is oriented towards the resistors. It is suppose to rectify -12V _ +12V peak to peak evse signal into dc signal.
Is this correct? 😊
Yes, but if you are really in doubt connect 5V to CP pin and GND and measure on the other side of diode. You should get 4.8V.
Otherwise check schematic on my github, its in DS9 i think...
https://github.com/arber333/Arduino-Due ... d_v4.2.sch
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 »

900 wrote: Sun Jul 24, 2022 12:48 pm
arber333 wrote: Sun Jul 24, 2022 12:18 pm Sorry yes i didnt think of that. In that case populate CP line and relay so you will be able to pull in evse. To sense correct cp amperage limit you would need one nmos transistor towards cp sense due pin with pullup. I didnt look how damien did its first due design. In code i intended to calculate millis difference to determine duty, but havent worked on that yet. If you do please publish that code please.
evMacGyver has already edited the code to make your CP circuitry work. I hope he can share. Otherwise it's way out of my competence.
Sorry I forgot to answer earlier. So take a look to SimpBMS TeslaBMSV2.ino, in the end there is function isrCP(), simply replace "digitalRead(IN4) == LOW" with "digitalRead(IN4) == HIGH". This is how you inverts calculation.
And on "accurlim" line below remove "+ 35", because with due board you do not need additional value of 35 to calculation as board do not have opto coupler.

Basically you need this interrupt routine called isrCP(), set interrupt routine for CP pin of Due using attachinterrupt command, add variables: duration, pilottimer and accurlim. Digital pin IN4 = 7. After this accurlim is amperage that EVSE allows you to get.

For PP pin you should add some additional pullup resistor to 3v3 as Arber suggested, or it will get some noise and activate by itself time to time.
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

evMacGyver wrote: Sun Jul 24, 2022 7:59 pm Sorry I forgot to answer earlier. So take a look to SimpBMS TeslaBMSV2.ino, in the end there is function isrCP(), simply replace "digitalRead(IN4) == LOW" with "digitalRead(IN4) == HIGH". This is how you inverts calculation.
And on "accurlim" line below remove "+ 35", because with due board you do not need additional value of 35 to calculation as board do not have opto coupler.
Thank you for that. Good news is that when I plug the type2 granny cable into the socket I hear a relay in it click and charger starts outputting current. Bad news is that it's only 0.5A DC (around 1.33 AC amps). Turns out this is because either CP or PP or both is not read correctly.

The calculation for ac current limit that I tried:

Code: Select all

accurlim = (micros() - pilottimer) * 100 / duration * 600; // calculate the duty cycle then multiply by 600 to get mA current limit
And this is the calculation from SimpBMS tesla code which I also tried:

Code: Select all

accurlim = ((duration - (micros() - pilottimer)) * 60000) / duration;
Which pin on the Due you're connecting PP to? In original code it's on A0, on the shield however PP leads to pin 36.

Also any other ideas why PP or CP is not read correctly?
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

arber333 wrote: Sun Jul 24, 2022 11:57 am
Yes you need to connect cp pin and pp pin to correct LV pin of the charger and it will be able to provide as much power as evse would allow. I know the pinout for gen2, but i do not know gen3...
My intention now is just that. Replacing eltek chargers with single Tesla gen2 and connect it directly to charging port.
Arber, you're running 104s or 108s setup right? So have you tested what current your Tesla charger pulls from EVSE above 400v DC? I for some reason am only pulling 1.3A AC wonder if that's what Tesla charger limits it to or something is wrong with my setup.
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 »

900 wrote: Tue Jul 26, 2022 2:06 pm
Arber, you're running 104s or 108s setup right? So have you tested what current your Tesla charger pulls from EVSE above 400v DC? I for some reason am only pulling 1.3A AC wonder if that's what Tesla charger limits it to or something is wrong with my setup.
Not fully. I tested at 396Vdc and it pulled some 9kW. Incidentaly i have my evse setup to 14A per phase so not to overload domestic circuit. When i come home i will install it and connect coolant etc. Then i will know for sure.
What i saw with eltek showed that after 400V charger started to taper down towards 420V and then would stop regardless of can command.
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 »

900 asked me how my Gen2 charger is doing with opensource firmware.

I put it in the car now, yay! It was a whole days work. I had to lift a lot of weight under my car, i feel like i had a workout :)...
Then i had to replumb coolant and deair...
It is now wired to sense EVSE PP signal and pull in Cp signal. That works by itself and i cant use PP signal for anything else. If i connect my DUE there it would just float and DUE would not sense connection.
My setup is to use A1 output on start and that is connected to my DUE (previous PP) input pullup pin. This works really well and starts my coolant pump and car fans when charger is connected.
Also to stop charger i am using its A3 input pin which is pulled up to 12V. I can pull to GND with BMS output to stop charger.

As for charging above 400V it seems to drive current well above up to 410Vdc which is what i have tested. Today i will continue to 420Vdc and report back. Charger jumps around a bit which is why first photo is just 17A. But that is only transient and normally it keeps to 21A that my EVSE requests.
Attachments
20220808_001427.jpg
20220808_003044.jpg
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Arduino DUE VCU with analog and CAN control

Post by 900 »

arber333 wrote: Sat Jun 18, 2022 2:41 pm Uh... i dont think ULN2003 pin leaks to GND. It does have one common GND connection and one 12V connection.
Arber, so been using your shield to drive contactors for a while, it works well except very occasionaly fails to trigger precharge it seems. I'm a bit doubtful about reliability of the ULN2003 chip as Damien has also noticed. Do you think this can be replaced with something beefier for your next version of shield that you're designing? Maybe an array of NCV8401?
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 »

900 wrote: Tue Aug 23, 2022 9:01 am Arber, so been using your shield to drive contactors for a while, it works well except very occasionaly fails to trigger precharge it seems. I'm a bit doubtful about reliability of the ULN2003 chip as Damien has also noticed. Do you think this can be replaced with something beefier for your next version of shield that you're designing? Maybe an array of NCV8401?
Hm... i can quickly redesign V5 board for use with NCVs.
I will probably just keep ULN driver where it is and replaced relays to 3x NCVs. That way you could very well use the board as VCU for Chademo with the actual code. If you have interest you can make some boards and test that.

Because of better availability i went from DUE to ESP32. I have the board here and i am trying to recode it via PlatformIO.
I will let you know.
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 »

That reminded me of a project i started before chip shortages.
Here i post a VCU V5 build files with DUE CORE R3. Lately i cant get any such board, but it was a good alternative since it already had EEPROM onboard.

I will redesign the V4.2 later into V4.3 without relays...¸
EDIT: I forgot to put pcb file with gerbers...
Attachments
DUE Shield V5.zip
(168.98 KiB) Downloaded 74 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 »

I just couldnt resist and i quickly modified V4.3 DUE shield.

I added 3 NCV switches and wired them to existing power outputs.
I kept 5 ULN outputs but I did double two outputs on the ULN chip so you could use it up to 1A too.
I kept 5 pull up inputs which can be used with external buttons.
I had to reroute 12V to keep 4 PWM output transistors.
PP pin, CP pin with possible PWM sensing.
2x CAN bus
2x analog inputs prepared for hall pedal sensors
I expect Serial1 pins could be connected to Wifi module too...

I will have to work on V4 schematic in the next days but i think you get the gist.

EDIT: I forgot to add CP transistor to pull EVSE in...fixed
Attachments
DUE VCU 4.3.zip
(169.39 KiB) Downloaded 81 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 »

This weekend i designed a shield board with full Arduino due on top.
This is meant as a quick DUE VCU V6. I will probably make 5pcs for testing and later i will develop V6.1 with some more input ptotections.
Could be that DUE board would be easier to develop then ESP :).

Case is made of alu with 2x 24pin sealed connector from aliexpress. I couldnt find its 39pin equivalent pinout connector. If anyone has its library it would be much appreciated.
https://www.aliexpress.com/item/3291424 ... 4itemAdapt

EEPROM of course...
3x analog inputs via resistor divider. They were meant for throttle pedals or similar 5V inputs...
Cp pin logging
PP pin input
3x NCV transistors
Piezo buzzer for error reporting.
Quad opto for those inputs that need to be 12V.
Rest inputs i based on resistor ladder pullups to 3V3 and need to be pulled down to GND to activate. Otherwise chip may be damaged.
Likewise i used 3x ULN chips with doubled pins for true 0.5A latching. I am confident those outputs will drive any signal relay reliably.
I reserved one ULN chip to drive PWM outputs. I used 4x resistor ladder tied to 12V.
There are 2x CAN bus chips
There is WiFi connector on serial2.

Board could be used without 5V regulator, since DUE has its own. But i suggest to put one in since various pedals and switches can tax 5V regulator too much...
Attachments
DUE shield V6.zip
(210.1 KiB) Downloaded 72 times
Alibro
Posts: 827
Joined: Sun Feb 23, 2020 9:24 am
Location: Northern Ireland
Has thanked: 248 times
Been thanked: 144 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by Alibro »

arber333 wrote: Tue Aug 30, 2022 8:33 am This weekend i designed a shield board with full Arduino due on top.
This is meant as a quick DUE VCU V6. I will probably make 5pcs for testing and later i will develop V6.1 with some more input ptotections.
Could be that DUE board would be easier to develop then ESP :).

Case is made of alu with 2x 24pin sealed connector from aliexpress. I couldnt find its 39pin equivalent pinout connector. If anyone has its library it would be much appreciated.
https://www.aliexpress.com/item/3291424 ... 4itemAdapt

EEPROM of course...
3x analog inputs via resistor divider. They were meant for throttle pedals or similar 5V inputs...
Cp pin logging
PP pin input
3x NCV transistors
Piezo buzzer for error reporting.
Quad opto for those inputs that need to be 12V.
Rest inputs i based on resistor ladder pullups to 3V3 and need to be pulled down to GND to activate. Otherwise chip may be damaged.
Likewise i used 3x ULN chips with doubled pins for true 0.5A latching. I am confident those outputs will drive any signal relay reliably.
I reserved one ULN chip to drive PWM outputs. I used 4x resistor ladder tied to 12V.
There are 2x CAN bus chips
There is WiFi connector on serial2.

Board could be used without 5V regulator, since DUE has its own. But i suggest to put one in since various pedals and switches can tax 5V regulator too much...
That's amazing work mate. Would it work with your Outlander charger sketch?
I need a bigger hammer!
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 »

Alibro wrote: Tue Aug 30, 2022 8:34 pm That's amazing work mate. Would it work with your Outlander charger sketch?
Certainly! There are I/Os that need to be redeclared but it is the same idea as Leaf VCU or my DUE shield.
Of course i will test it and correct the code.
Alibro
Posts: 827
Joined: Sun Feb 23, 2020 9:24 am
Location: Northern Ireland
Has thanked: 248 times
Been thanked: 144 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by Alibro »

arber333 wrote: Tue Aug 30, 2022 9:06 pm Certainly! There are I/Os that need to be redeclared but it is the same idea as Leaf VCU or my DUE shield.
Of course i will test it and correct the code.
In that case put me down for one as it could save me many hours trying to sort my charging.
I'm sure others here would be equally interested.
I need a bigger hammer!
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 »

Imade some small changes to V6 board.
I put a voltage divider on input pins of the opto. Now they can be used even if you dont have the opto. You just populate those resistors so you can sense 12V signals directly.
I rotated Wifi module so it will clear the casing.
I added 5V to 3V3 regulator. The argument is sometimes 3V3 regulator on DUE can ack up and the second one can provide stable power.
I also needed to reconnect 5V lines and 12V input. 5V is so limited it cant be used to drive logic of DUE board. But just for testing you can use the board 5V output. I recommend you add true 5V converter later for a full product.
I replaced the files in my previous post so you will need to redownload them. I dont want to make 6.1 design before i even have proof of concept made.

I will send boards for manufacture. I only get the bare boards, that is the reason behind this shield conforming to DUE board...

Incidentaly when i made a CAD (carboard) board design :) i discovered i would need to remove the DUE board power socket. It seems a small sacrifice and i will power the board from its Vin pin anyway.
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 got my V6 boards from MFG. Some photos later.
Its a simple dock for Arduino DUE board so maybe not really robust, but i have used that in my Pug for 2 years now. I only had to replace DUE board once and it was my fault... providing 12V into pulldown pin!!! :twisted: .

For now it seems i can use this VCU setup for at least 4 things if not 5.
1. Chademo protocol control with some reshuffling of I/Os in code
2. Leaf drive stack VCU control
3. SimpBMS like controler which would require code porting
4. Outlander drive VCU again requires some code porting, but most of the stuff work with my V4 already
5. Any other I/O control with 2x CAN bus, maybe even Zombieverter.

Sadly i dont have 4x CAN bus transcievers so i dont think we could use this for control of Lexus drivetrain. Would have to make another board... maybe later :).
Attachments
20221013_204826.jpg
20221013_204843.jpg
20221013_204739.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 »

Like i showed before i developed a V1 of ESP32 VCU design. I shuffled outputs a bit so i cleared the dubious pins. I still need to test it, but it looks good.
My goal is to develop the code for this board which would be able to run Chademo process a BMS or use it as VCU with option for wifi interface.
Attachments
20221013_204812.jpg
20221013_204755.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 »

I managed to get the CAN bus code working YAY!
I have the I/Os working as well, though not in the way as i intended. I cant get the opto coupler chip working from 12V inputs. I will simply replace that chip by series of 4 resistors and reverse the sensing. This will pull the signal lines to GND and effect signal change in ESP32 chip.
Buzzer coupled with signal on BMS pin is really loud. I had to tape it over for testing.
IMG-20221027-WA0001.jpeg
IMG-20221027-WA0003.jpeg
I still need to test the behaviour of AD converter for analog pins and PWM output pins though.
Alibro
Posts: 827
Joined: Sun Feb 23, 2020 9:24 am
Location: Northern Ireland
Has thanked: 248 times
Been thanked: 144 times
Contact:

Re: Arduino DUE VCU with analog and CAN control

Post by Alibro »

Keep going mate, you're doing well. :)
I need a bigger hammer!
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, 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.
Post Reply