Arduino DUE VCU with analog and CAN control

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: Arduino DUE VCU with analog and CAN control

Post by rstevens81 »

Almost, seems like ti have some in the time between posts
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget πŸ€ͺ
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Chademo VCU with analog charging control

Post by 900 »

arber333 wrote: ↑Tue Dec 22, 2020 8:12 am But now a question arises... is our current sensor inside a car mandatory to be on the complete energy lines (draw and charge) or can it be on CHADEMO lines to show actual charging only? Is there any risk involved?
Arber, can your shield be used as a chademo controller? Have you tried this? I'm not familiar with chademo charging does it need a current sensor also? Something else?
Also can chademo be set to charge at lower power like 10 or 20 kw? Thanks
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Chademo VCU with analog charging control

Post by arber333 »

900 wrote: ↑Fri Oct 29, 2021 6:17 pm Arber, can your shield be used as a chademo controller? Have you tried this? I'm not familiar with chademo charging does it need a current sensor also? Something else?
Also can chademo be set to charge at lower power like 10 or 20 kw? Thanks
I have set up my DUE shield with chademo charging in mind. Hence the two CAN bus chips. One to serve the car and another to work with CHADEMO.
Also there are several digital pins available through a darlington array that could run contactors. Also PWM pins and other I/Os.
Code would have to be adjusted, but Isaac code was written for SAM3X so it should work.
I havent tried yet with chademo. But i certainly plan to do it. If anyone beats me to it i wont hold a grudge :).
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Chademo VCU with analog charging control

Post by 900 »

arber333 wrote: ↑Fri Oct 29, 2021 8:32 pm Code would have to be adjusted, but Isaac code was written for SAM3X so it should work.
Do you have a working chademo in your car at the moment? You mean pin numbers would have to be changed?
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 uploaded various code files that i use or ave used at one time or other:
https://github.com/arber333/Arduino-Due-CAN-shield

DCDC_outlander_pug.rar file contains past adaptation of CAN code for Mitsubishi DCDC and charger with temperature command and aux battery top-up.
DCDC_outlander_mazda.rar file contains past adaptation of CAN code for Mitsubishi DCDC and charger with temperature command and aux battery top-up.
Eltek_program.rar file contains code to reprogram Eltek charger parameters
DCDC_pug_eltek.rar file contains latest code with Eltek charger, Volt gen2 DCDC and Mitsubishi heater and AC compressor code

EDIT: I also added BOM in xls file. If you consider i have prepared the I/Os in such a way you can use input as output too. You need to be carefull though and consider output is still 3V3 level.
You can use it as input with internal pullup. In that case you need to remove 2K7 resistors to GND.
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: ↑Thu Oct 21, 2021 11:40 am I posted new document on my github with 4.1 schematic in pdf.
https://github.com/arber333/Arduino-Due ... ematic.pdf
Are you sure this is latest schematic? For example CP seems to be routed to D7 instead of D8 as in schematic?
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 Nov 29, 2021 6:39 pm Are you sure this is latest schematic? For example CP seems to be routed to D7 instead of D8 as in schematic?
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. The second one could become D7 or D8 through various design changes because i was not attentive enough. I will try to correct it...
V4.1 to V4.2 has almost no difference.
I added another 5pin connector to the far edge of the board that you can use it for inputs with weak pullup resistor. I will add that on next schematic version.
Just this weekend I have implemented a single push button code to toggle between 3 charger CAN signal. Other pins may include AC compressor starting or Heater switch on...
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: ↑Mon Nov 29, 2021 7:03 pm
evMacGyver wrote: ↑Mon Nov 29, 2021 6:39 pm Are you sure this is latest schematic? For example CP seems to be routed to D7 instead of D8 as in schematic?
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. The second one could become D7 or D8 through various design changes because i was not attentive enough. I will try to correct it...
I was referring to Due pin D8 in schematic being D7 in real board. Also after CP transistor there is place for resistor that I cannot find in the schematic, have not verified is bottom copper flood ground or 3V3, so might be either pull down or pull up, for that resistor to have some sense it should be pull up - I think? Therefore just thinking PDF schematic might be different version than real v4.1 board, but I can handle.
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: ↑Tue Nov 30, 2021 3:16 pm I was referring to Due pin D8 in schematic being D7 in real board. Also after CP transistor there is place for resistor that I cannot find in the schematic, have not verified is bottom copper flood ground or 3V3, so might be either pull down or pull up, for that resistor to have some sense it should be pull up - I think? Therefore just thinking PDF schematic might be different version than real v4.1 board, but I can handle.
Yeah... you are correct. I have made an error in digital pins for PWM. Correct transistor output pins are D2, D6, D7 and D8.
I have made schematic before i checked which timer to use for my PWM code so those pins would be to the correct timer. It was not the case in the start.
Top copper is GND, lower is 3V3.
Pin D9 is the input pin to measure state changes for CP signal PWM duty detection. I havent written the code yet though i have an idea how to measure CP duty. Resistor (R25) just before sense transistor is gate current limiting and the two resistors after transistor are pullup/pulldown. I havent decided on how to detect PWM yet so i like to leave my options open... I think i will decide on transistor pulling down D9 internal pullup thus sensing the PWM top and bottom and measure time between both in us. With 1kHz signal i should get good enough % duty value.

In any case resistors after CP diode are there to pull the signal down with a relay. R3 (2K7) and R4 (1K3) via relay. I am sure there are more pullup resistors on the board that i havent accounted for. I put them there to have more options in experimenting. Also there are several "resistors" as jumpers to make or break a signal, such as either analog pot signal or direct digital signal presence on the same line without the code change.
Also you can populate all the caps if you want, they are mostly for decoupling.
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 Nov 30, 2021 9:55 pm Pin D9 is the input pin to measure state changes for CP signal PWM duty detection. I havent written the code yet though i have an idea how to measure CP duty.
Toms code on SimpBMS or at least TeslaBMSV2 does work quite nice for CP duty detection, just see the interrupt code. You need to change calculation polarity as shield board uses NPN or NFET for grounding IO pin. Additional optocoupler decade of 35ms needs to be removed.

Due pin D19 was routed to EEPROM /WC, same D19/RX1 is used for USART1 receive. I decided to pull EEPROM /WC pin up from PCB and ground pin by wire.
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: ↑Wed Jul 14, 2021 12:21 pm I am revisiting this thread since i have built a VCU shield for Arduino Due.
Arber, how would you go about switching on 3v and 5v signals with your shield? Just need to turn on these as enable signals for a charger.
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 Mar 01, 2022 5:14 pm
Arber, how would you go about switching on 3v and 5v signals with your shield? Just need to turn on these as enable signals for a charger.
That depends if you need to sense a signal or just output a signal to close a relay...
I have used ULN2008 chip as relay driver. This means i pull relay winding to gnd.
ULN-with-AC-LOAD.png
Then i use 4 NMosfet that i run via pwm outputs. But with N channel you need pullups so you get weak voltage signal when transistor is off. DUE is 3V3 logic and i use mosfets to run 12V logic on the other side.
be584f11167f84e86e526be4a1cbe91ea8ecfd46.png
be584f11167f84e86e526be4a1cbe91ea8ecfd46.png (801 Bytes) Viewed 109898 times
If you want safe inputs from 12V to 3V3 though you can use resistor divider. Not too elegant... But if you want protection use optocoupler chip. Use 1k resistor with 12V line and turn opto on. On the other side you pull internal chip pullup (10k) to gnd.
v2FGx.png
v2FGx.png (9.39 KiB) Viewed 109898 times
You can also use a relay and toggle gnd to the chip input. In that case you can use whatever logic as long as they have common gnd.
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: ↑Tue Mar 01, 2022 5:39 pm That depends if you need to sense a signal or just output a signal to close a relay...
I have used ULN2008 chip as relay driver.
Thanks! I don't need to sense a signal just provide 3V and 5V to the charger according to command by the DUE code. Does ULN2008 only have 5 outputs? Is ULN2008 powered from 12 V and would I need 12V relays for it? Another question where to source 5V and 3V signals for relays to switch on? Use resistor dividers from 12V to not overload DUE outputs? Having electronics background would help but I am still lacking in that area.
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 Mar 01, 2022 7:00 pm
Thanks! I don't need to sense a signal just provide 3V and 5V to the charger according to command by the DUE code. Does ULN2008 only have 5 outputs? Is ULN2008 powered from 12 V and would I need 12V relays for it? Another question where to source 5V and 3V signals for relays to switch on? Use resistor dividers from 12V to not overload DUE outputs? Having electronics background would help but I am still lacking in that area.
Hm... I use 2 pins of ULN to run both relays on the shield. What is left are 5 outputs.
ULN2008 is meant to provides GND signal to a relay or another chip input with pullup. Maybe you could provide a 10K resistor across one ULN pin and +5V. I am sure there is 5V expressed on board, as DUE provides it.
What kind of signal do you need? If it is PWM maybe it would be better to use dedicated PWM pins. In V4 i expressed 4 pins to PWM use to be connected with external mosfet module. In V4.1 i use 4 Nmos transistors to amplify signals with 12V pullup. Maybe you could cut that 12V trace and wire a 10K resistor as 5V pullup.
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 Oct 04, 2021 8:51 am This shield uses ULN2008 chip with 7 transistors
Hi, you also previously mentioned ULN2003 chip so can I use this instead of ULN2008 one on the 4.1 shield? Because this is what I have at the moment.
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 Mar 06, 2022 12:10 pm Hi, you also previously mentioned ULN2003 chip so can I use this instead of ULN2008 one on the 4.1 shield? Because this is what I have at the moment.
Hm... ULN2008 is a bit different driver made for microwave ovens. Better check its I/O.
Maybe you meant ULN2803 driver? That one is 8ch darlington driver the same as ULN2008.
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 Mar 06, 2022 12:40 pm Hm... ULN2008 is a bit different driver made for microwave ovens. Better check its I/O.
Maybe you meant ULN2803 driver? That one is 8ch darlington driver the same as ULN2008.
Sorry I think there was a misunderstanding because you mentioned both ULN2003 and ULN2008 in your previous posts. So correct chip to use as IC8 is ULN2003 right? 😊
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: ↑Mon Mar 07, 2022 7:23 pm Sorry I think there was a misunderstanding because you mentioned both ULN2003 and ULN2008 in your previous posts. So correct chip to use as IC8 is ULN2003 right? 😊
True, i think i made a mistake stating that yes. ULN2803 you could use if you adapted your own board. My shield was made for ULN2003 in SO package.
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.
Hi, what is the orientation (polarity) of the D1 diode for soldering on the shield? I want to be abe to use EVSE cable with the shield which components should I populate for use with Tom's code?
Regarding ULN2003 I wired a relay which can switch 2 channels and seems to work fine I can use 1 output from ULN to switch both 3v and 5v signals. Pitty there is no space for more relays on the shield would be much neater. Also I wonder if the shield can be made bigger than the due board to accomodate more components? 😊
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: ↑Sat Mar 12, 2022 7:45 pm Hi, what is the orientation (polarity) of the D1 diode for soldering on the shield? I want to be abe to use EVSE cable with the shield which components should I populate for use with Tom's code?
Regarding ULN2003 I wired a relay which can switch 2 channels and seems to work fine I can use 1 output from ULN to switch both 3v and 5v signals. Pitty there is no space for more relays on the shield would be much neater. Also I wonder if the shield can be made bigger than the due board to accomodate more components? 😊
Ok, D1 is meant to rectify signal from the outside, so it is pointing towards the chip. You can see this on the pdf schematic in my github.

Toms code? As it SimpBMS? That is a brave preposition. Well CAN transciever for one. Then ULN driver for outputs and relays of course. You can use them as precharge and DC contactor relays.
Will you use analog inputs at all? You can convert them to digital in that case...
Also PWM transistors you can use as straight outputs as well.
I dont think you will use D8 transistor, as it was meant to translate EVSE signal for sensing duty.

I was playing with idea for V5 of the board to invert the board and plug the DUE into the shield from above. Also make it larger and fit more relays and more ULN drivers. I could also fit LIN bus in place of CAN1 transciever...
I now see benifit of opto separated inputs. DUE is protected from 12V input that way! I managed to bust several DUE that way.
I am now thinking of V5 and a simple 48pin VCU box. That would be pretty cool and complete VCU!
https://www.aliexpress.com/item/3291424 ... Xbbbr&mp=1

Do you have an idea of additional functions? Please by all means share...

Lately i am having some strange events. Disable signal comes online all of its own! This trips notaus button contacts as i use it to disable driving while connected to EVSE. Luckily Lebowski code is written so it can restart into spinning motor, but it is still shocking to feet the car trip out at 140km/h!!! I need to investigate this further. Could this be linked to my watchdog code or is it some EMI playing with DUE.
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 Mar 12, 2022 8:37 pm Toms code? As it SimpBMS? That is a brave preposition.
Yes take a look at this:
https://github.com/damienmaguire/Tesla- ... rgerV4.ino

This code is for a Tesla charger and has a portion of code to pull in EVSE relay and detect charge current dictated by the EVSE. Perhaps this code can work on your shield for that same purpose?
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 Mar 12, 2022 8:37 pm Toms code? As it SimpBMS? That is a brave preposition. Well CAN transciever for one. Then ULN driver for outputs and relays of course.
Arber, could you please take a look at this schematic. Is it possible to modify your shield so it would be according to the schematic? How would you suggest to do it? In this case I think Tom's code would work.
Attachments
20220315_221308.png
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 Mar 15, 2022 8:18 pm
arber333 wrote: ↑Sat Mar 12, 2022 8:37 pm Toms code? As it SimpBMS? That is a brave preposition. Well CAN transciever for one. Then ULN driver for outputs and relays of course.
Arber, could you please take a look at this schematic. Is it possible to modify your shield so it would be according to the schematic? How would you suggest to do it? In this case I think Tom's code would work.
Why would you want to complicate things. I explicitely setup one Nmos to fire on PWM signal. The best thing would be just to count the millis between pulses to get the Cp duty. That was my plan.

If you can prove it works i can implement it on my rev5 later... i just need to get a good casing here to make a model...
Something similar: https://www.aliexpress.com/item/1005002 ... 1802R1TJ3s
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 Mar 15, 2022 9:29 pm
900 wrote: ↑Tue Mar 15, 2022 8:18 pm
arber333 wrote: ↑Sat Mar 12, 2022 8:37 pm Toms code? As it SimpBMS? That is a brave preposition. Well CAN transciever for one. Then ULN driver for outputs and relays of course.
Arber, could you please take a look at this schematic. Is it possible to modify your shield so it would be according to the schematic? How would you suggest to do it? In this case I think Tom's code would work.
Why would you want to complicate things. I explicitely setup one Nmos to fire on PWM signal. The best thing would be just to count the millis between pulses to get the Cp duty. That was my plan.
evMacGyver wrote: ↑Mon Jan 31, 2022 4:08 pm Toms code on SimpBMS or at least TeslaBMSV2 does work quite nice for CP duty detection, just see the interrupt code. You need to change calculation polarity as shield board uses NPN or NFET for grounding IO pin. Additional optocoupler decade of 35ms needs to be removed.
Did you see my previous post, current circuit on this board does work, relay and nmos for CP, I've tested and proof it already. This does 'waste' a relay for CP, FET doing that would be nice.

V5 ideas for my personal needs would be that another CAN transceiver could be used for LIN transceiver with remote wakeup function, now I'm using separate board for this. Another would be two 0-5V analog outputs which I've done using opamp board. Also few more AD channels with resistor dividers. Aanyway these are just my current working modifications. Casing with proper connector is a really good idea!
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: ↑Sat Mar 19, 2022 12:44 pm
Did you see my previous post, current circuit on this board does work, relay and nmos for CP, I've tested and proof it already. This does 'waste' a relay for CP, FET doing that would be nice.

V5 ideas for my personal needs would be that another CAN transceiver could be used for LIN transceiver with remote wakeup function, now I'm using separate board for this. Another would be two 0-5V analog outputs which I've done using opamp board. Also few more AD channels with resistor dividers. Aanyway these are just my current working modifications. Casing with proper connector is a really good idea!
Hm...
You could already remove the relay and just connect CP resistor contact to relay (coil) trigger. It is part of the ULN2003 ladder so it will allways show GND.
But then you will be short of the second relay contact which i use to start the charger coolant pump. basicaly i connect another 12V relay in front of the pump which i turn on via this circuit. That relay brings 12V to coolant pump separately from the ignition circuit. That way i can have coolant circulating while car is on the EVSE.

I will see what i can make for V5. Seriously i am thinking of making it as a VCU with inputs/outputs to connect to outside relays and sensors. That way it will fit in one of the aliexpress boxes with 48pin connectors.
Post Reply