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:

Arduino DUE VCU with analog and CAN control

Post by arber333 »

I am posting here so not to clutter the original Chademo VCU thread

I cant get the ISA shunt just yet and in my EV it is a bit redundant because i already have SOC and Voltage measurement/display in a closed system.
What i need is a capable conventional charger controler with CAN bus and chademo charging capability.

Isaac, what if i used an ISO124P opamp with isolated supply and feed its signal to VCU on throttle input? I think this would be a linear input easily setup in a code. Would you be willing to input that possibility in your code? If Throttle would be pulled to GND priority would go to ISA shunt and data through CAN bus whereas if there would be voltage on throttle line you could use it to determine HV voltage. Since current is not so important we could get by with only voltage? Or i can still make a use of 5V LEM sensor with another input?

I am thinking of using chademo VCU as AC charger and DCDC controler also and i need to know inputs that i could use.

tnx
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

I can add that possibility. It would just go in a different version of the code, so there would be no need to pull Throttle to ground.

I would prefer to have both current and voltage sensing, taking the current sensing out complicates the protocol (means I need to change more than just the sensors).
I'll look at the code and make the necessary changes.
Calibration will need to be done by editing the code, I'd rather not add more serial configuration parameters.

-Isaac
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 »

Isaac96 wrote: Thu Oct 29, 2020 4:10 pm I can add that possibility. It would just go in a different version of the code, so there would be no need to pull Throttle to ground.

I would prefer to have both current and voltage sensing, taking the current sensing out complicates the protocol (means I need to change more than just the sensors).
I'll look at the code and make the necessary changes.
Calibration will need to be done by editing the code, I'd rather not add more serial configuration parameters.

-Isaac
Ok so for voltage sensing we need two parameters like with Johannes Vgain and Voffset
For current sensor we need A/mV parameter and a "zero point" parameter which determines at what mV means 0A.
If tere is any other parameter please let me know.

I will definitely try to use this VCU for my chargers control. I will need some more I/Os.
Lets do some gap analysis...
I/Os that are needed on VCU for Chademo
- 12V power ON signal on pin 2? Does this mean we cant use VCU for anything while driving?
- Contactors relay output on pin 4
- Output on Pin 3
- Chademo inputs pin 5 and 6

So what analog I/Os you intend to use with Chademoi?
- Voltage signal on the Throttle1 signal pin 15
- Amp flow signal on the Throttle2 signal pin 16

I/Os that i will need for AC charger control
- DCDC Enable input 12V - pin 8
- DCDC Enable output 12V - pin 7 if i could cheat a bit?
- Charger PP sensing input with internal pullup - pulled to GND ???
- Disable output to immobilize the car when EVSE is connected (also applicable for chademo) ???
- Relay output for Water pump to cool down chargers ???
For Last outputs a signal output driving DPDT relay could be used...

Damn! Not enough inputs...
Any ideas?

EDIT: I started to work on Damiens V1 Leaf VCU board to add more outputs and inputs without changing JLC design.
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

The Chademo code is just for quick charging, nothing else. I'm not going to add any other things, you are welcome to add extra features but that will not go into the published code.

Analog inputs are your choice, just be sure that they don't interfere with the existing inputs. Also you should consult the schematic of the VCU and see what the voltage dividers etc. look like, some of the other inputs needed a resistor or two removed to work properly.
I'll add the necessary parameters to the code once we've got the inputs selected.

-Isaac
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 »

Isaac96 wrote: Thu Oct 29, 2020 10:07 pm The Chademo code is just for quick charging, nothing else. I'm not going to add any other things, you are welcome to add extra features but that will not go into the published code.

Analog inputs are your choice, just be sure that they don't interfere with the existing inputs. Also you should consult the schematic of the VCU and see what the voltage dividers etc. look like, some of the other inputs needed a resistor or two removed to work properly.
I'll add the necessary parameters to the code once we've got the inputs selected.

-Isaac
OK, i will just use Leaf VCU for Chademo for now. I will use the same inputs as you prescribed in your design.
Now lets focus on analog inputs of current and voltage.
I intend to use ISO124 isolated opamp to signal voltage reference from 0 - 5V. I will post schematic a little bit later.
This will be an add on PCB powered from cars 12V and it will put out 0 - 5V signal. Basicaly the same as any throttle. Also current sensor will put out the same 0 - 5V analog signal.

I have here various 2 channel automotive sensors. Channel 1 we cant use because it only goes up to 20A.
DHAB S/44, zero voltage is at 3.08V, sensitivity of channel 2 at 6.15mV/A
DHAB S/51, zero voltage is at 3.24V sensitivity of channel 2 at 5.48mV/A
DHAB S/124, zero voltage is at 2.5V sensitivity of channel 2 at 4mV/A
Last sensor channel 1 could actually be used as it works up to 75A, Zero voltage at 2.5V, sensitivity at 26.7mV/A

Also i have "normal" single channel 5V 200A Tamura sensors L31S200S05FS. Zero voltage is at 2.5V.
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 »

Hi Isaac

I was thinking. Since i already have Eltek and Outlander chargers in my car i could just use their CAN line reporting.
I have one line in a car that is dedicated to DCDC control while car is operating and charger control while car is on the EVSE.
Now if i could get voltage reports from one of the chargers i could recalculate it for chademo reporting instead of ISO124. One less isolation barrier required that way.
Sou could i safely "falsify" current report and use actual voltage report with existing VCU then?

Problem is Eltek doesnt go CAN without AC present. So that is that :(.
I still need to check for Outlander CAN msg, if i remember correctly it starts to output its data as soon as you show it 12V on one of the connectors.

I will still prepare one ISO124 interface with one LEM sensor, maybe someone will use it because it will be cheaper than ISA shunt, who knows.
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

Hmm... Falsifying current report is technically okay, though of course it violates the spec. I can add a codepath for that in a specific version, not to be generally published.

Seems like many people like the ISA because it doesn't have noise issues and can report so many detailed measurements; the amp-hour counting is one of the best features IMO.

-Isaac
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 »

Isaac96 wrote: Tue Nov 10, 2020 12:16 am Hmm... Falsifying current report is technically okay, though of course it violates the spec. I can add a codepath for that in a specific version, not to be generally published.

Seems like many people like the ISA because it doesn't have noise issues and can report so many detailed measurements; the amp-hour counting is one of the best features IMO.

-Isaac
Yes i dont feel like i would run indefinitely on false reading. Strictly for testing my setup. But i absolutely want voltage reading in there.
I am interested in using ISO124 because i know it is really accurate and robust and it doesnt need other amps down the line.

I am allready using one of the most accurate SOC meters i ever dealt with. It uses dV, dT and coloumb measurement for SOC. It has a memory function in case of brownout and i suspect a kind of RTC too. EV Display V4. I got it from Cleanpowerauto just after they closed. Dimitri sent me one of the last boards. I guess it was too good a product to stay alive... You just set it up and it works without touching it. From 2013...
Normaly for the period IoT or CAN connectivity is missing.

Hm on the other hand... i have EV Display transmitting serial signal each second. Could i just use it with existing hardware? Heh, maybe i could put a simple arduino uC on it and CAN bus transciever to code out that signal to a certain CAN message? Or could i just connect serial cable directly to Chademo gizmo and it would read serial?
There will be continuous stream of data packets with 1 second time interval between packets. Each
data packet is an ASCII string of 45 characters, containing 10 data fields. Each field starts with label
character and follows by decimal numeric data of constant length, padded by leading zeroes. Each string
is terminated by return and new line characters, bytes 0x0D and 0x0A.

Example of Data packet:
B1H00000V000F000S000D0A00000W000000T000R00000

Data packet fields:
B – Battery address, typically 1, in multi-battery systems this will represent battery order – 1 digit long
H - AmpHours remaining, in 0.1Ah resolution, i.e. 123 = 12.3Ah – 5 digits long
V – Volts, in 1V resolution for HV systems or 0.1V for LV systems, i.e. 123 = 12.3V – 3 digits long
F - Fuel Gauge, in percent, i.e. 100 = 100% – 3 digits long
S - SoC percent, in percent, i.e. 100 = 100% – 3 digits long
D – Current direction, 1 – charging, 0 – discharging – 1 digit long
A - Amps instant, in 0.1A resolution, i.e. 123 = 12.3Amp – 5 digits long
W - Watts instant, in 1W resolution, i.e. 20000 = 20000W – 6 digits long
T – Temperature, in degrees, units depends on setup parameter – 3 digits long
R – Reserved for future use – 5 digits long

Serial Port parameters:
Baud Rate – 9600
Data bits – 8
Stop bits -1
Parity - none
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

EV display to CAN would probably work best and be the smoothest integration, especially if you want to match the ISA message ID's.
Does the VCU even have a serial port available? I suppose the ESP8266 port would work. But 9600 is very slow, that might cause issues with the rest of the system. 45 bytes is about 50 milliseconds at that speed.. ouch.
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 »

Well i know now i can get CAN info on pack voltage from Mitsubishi charger which i keep on even when car is off. This allows me to see pack voltage at 2V precision. Would that be good enough for CAN? Telegram 0x389 states BD = 189 * 2 = 378V.

I am now trying to get more info from EV Display. But i realized this action is only productive for me. I wanted to make a simple dual sensor board for the rest of community. I better get started...
Isaac96 shall we...?
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

Sure thing.
Just to be sure I'm doing the right thing:
We want pure analog inputs for current and voltage, with center points and scaling factors configurable.
These can only be configured by editing the code (no way am I adding any more serial configuration parameters).
This will be a separate version.
Which inputs should I be reading for these sensors?
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 »

Isaac96 wrote: Sun Dec 06, 2020 7:17 pm Sure thing.
Just to be sure I'm doing the right thing:
We want pure analog inputs for current and voltage, with center points and scaling factors configurable.
These can only be configured by editing the code (no way am I adding any more serial configuration parameters).
This will be a separate version.
Which inputs should I be reading for these sensors?
Yes on the first part!
I prefer editable in code. That way a person learns about the process also.

Like you said we need to use throttle inputs which are still free. Lets make Throttle1 voltage input A0 and Throttle2 current input A1.
Since sensors are on 5V level i will make inputs 0 to 5V signal.
Voltage sensor will start at 0,5V for actual 0Vdc and 5V somewhere at 500Vdc. Will have to experiment with resistor divider on the opamp.
But A0 will read 0 to 3V3V?

Current sensor will show 0V to 5V signal with 0A somewhere at 2.5V for start. I would like to have the 0 point adjustable within code. Maybe a comment inline there? Probably Due needs 3V3 signal and so A1 0 point will be at 1.65V?

TNX
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

There are voltage dividers on the inputs already. So a 0-5v signal is converted down to a 0-2.5v. (1:2 scaling for some extra safety headroom).
Certainly, a zero point in the code.
The Due's analog inputs run from 0 to 4096 (10 bits) so using a raw value makes sense - 2048 would equal an input of 1.65v on the chip itself, and an actual voltage of 3.3 before the divider.
Then a simple scaling factor.
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 »

Hi Isaac

I am working with my "transportable" CHADEMO version so i am able to test this on the fly in whatever DIY car i am able to find out here.
This means i can test it with various voltages and setups.

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?

My idea is to just install everyting in a box with only DC lines out and some LV 12V supply and signal lines from the host car. Mostly BMS and CAN lines with 12V and GND. That means my CHADEMO VCU would be rather self sufficient inside that box.

tnx

A
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Chademo VCU with analog charging control

Post by Isaac96 »

The current sensor only needs to be on the CHAdeMO lines. Of course, that won't let you monitor things like KWh in and out overall, but it will still work for charging.

External CHAdeMO box sounds great, just be sure to keep the car's plug covered!

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

Arduino DUE VCU with analog and CAN control

Post by arber333 »

I am revisiting this thread since i have built a VCU shield for Arduino Due. A form of control unit which is capable of running several digital/analog inputs vs CAN and digital or PWM outputs. Such VCU is good for experimenting with CAN systems and integrating them together.
In my case i intend to use it to drive Outlander motor, inverter, charger, DCDC and heater with one board.
Untill now i have 4 revisions, while i am actively using rev3 in my Pug.

Main points with latest V4.1.
I have corrected the issue with CAN chip 3V3 power supply.
I added B2P-VH header for CAN1 output which is more robust header. It will hold 3.96mm pitch connectors with wires up to 1mm2.
I have routed 12V power to relay contacts and provided solder points to connect either to GND or 12V. Also i power relais with 12V. This releases poor Arduino 5V regulator which had difficulties to cope with increased demand from 5V relay.
I added 3 mosfets to PWM outputs and connected them to 12V. So now i can directly connect PWM signal to drive chargers, DCDCs or car fans with that signal.
I also eliminated position for 12V regulator as a diode can perform some voltage aleviation as long as we use ordinary 3A diode. Pleaase let me know if someone has other suggestion.

I will update design with rev. 4.1 and post it on github opensource here: https://github.com/arber333/Arduino-Due-CAN-shield
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Chademo VCU with analog charging control

Post by 900 »

arber333 wrote: Wed Jul 14, 2021 12:21 pm Pleaase let me know if someone has other suggestion.
Thanks Arber for all the changes. Yes I meant to incorporate the PWM and amplifier to be able to run pwm controlled chargers etc directly. So you've now changed the relays from 5 v to 12 v? Good best not overload the Due. What is the purpose of IC8 chip?
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Arduino DUE VCU with analog and CAN control

Post by arber333 »

900 wrote: Wed Jul 14, 2021 8:42 pm
Thanks Arber for all the changes. Yes I meant to incorporate the PWM and amplifier to be able to run pwm controlled chargers etc directly. So you've now changed the relays from 5 v to 12 v? Good best not overload the Due. What is the purpose of IC8 chip?
IC8 chip is the ULN2003 darlington driver which is there to drive relays and amplify several digital outputs. It was not meant to drive hardware PWM since it is only NPN drive, but you could use it with suitable 12V pullup and generating software PWM.
My idea was to use hardware PWM ports since they run on interrupts.
And darlington is not very good at amplifying square signal. Mosfet is much better at that. I choose SOT23 chips because you can use Nchannel or Pchannel mosfets and it will just change PWM polarity.
I corrected some typos that happened to 4.1 version. I will not make another version. I will just repost the new one.

I am also thinking of making another shield to be put on top of the first one which would add LIN bus or SW CAN functionality. But would sacrifice CAN1 for that. It could add additional digital inputs and outputs to be used. Any ideas?

EDIT: does anyone know how to reliably read PWM duty? I mean directly on DUE chip.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Arduino DUE VCU with analog and CAN control

Post by arber333 »

Let me tell more about the board.
I must say i solved the problem with DUE 5V regulator brownout. I simply wired everything important to 12V plain with 3V3 and 5V remaining for logic and AD sensing only. I learned to use flags and state machine with it and it still has way more capacity CAN wise.
I setup current V4 to also serve as chademo interface triggering relais with UL2008 chip pins.
There are 3x analog input interfaces setup. One is meant for throttle, second for regen signal and last one is simply input and GND.
There are 4x Nmos transistors wired to PWM pins. They are meant for signalling PWM to a charger and other systems in a car. It is widely used control to drive pumps and fans.
A single PWM pin is reserved for input and that has its own transistor to amplify a CP signal and read it directly on DUE.
There are serial pins available for connection as well as I2C pins.
Of course EEPROM chip spot is available.
2x CAN bus transcievers
Also there is still a lot of digital pins available at the rear end of the board. I could make an addon board that would express more of digital I/Os for various applications.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Arduino DUE VCU with analog and CAN control

Post by arber333 »

OK! I have tested the board with PWM signal to Volt gen2 DCDC and it works! I tested it with PWM to D6 pin from a library here https://github.com/arber333/DuePWM

I also tested other pins.
I will probably make another 4.2 mod, which will be final revision as i see from the library shield works with pins from D2 to D6. Library only works from D6 to D13. So i will have to change my PWM signals more towards higher pins.
As i have several other PWM pins wired to transistors they should be used with different library.
900
Posts: 55
Joined: Fri Jun 25, 2021 11:10 am

Re: Chademo VCU with analog control

Post by 900 »

arber333 wrote: Mon Oct 04, 2021 7:31 am I will probably make another 4.2 mod, which will be final revision
Hi, I am very interested in it's use as a VCU to control an inverter and also to control 3 sets of contactors - precharge and main contactors and another contactor to send HV to dcdc converter when ignition is turned on. I plan to trigger contactor closing off certain CAN messages that comes in. Do I need 3 relays on the shield for that do you think? For contactor control I would have contactor signal positive always wired to 12 V and I would be switching grounds on with relays on your shield. Does this sound right? 😊 Those relays are now controlled off 12 V volt directly right?
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Arduino DUE VCU with analog and CAN control

Post by arber333 »

900 wrote: Mon Oct 04, 2021 7:57 am
arber333 wrote: Mon Oct 04, 2021 7:31 am I will probably make another 4.2 mod, which will be final revision
Hi, I am very interested in it's use as a VCU to control an inverter and also to control 3 sets of contactors - precharge and main contactors and another contactor to send HV to dcdc converter when ignition is turned on. I plan to trigger contactor closing off certain CAN messages that comes in. Do I need 3 relays on the shield for that do you think? For contactor control I would have contactor signal positive always wired to 12 V and I would be switching grounds on with relays on your shield. Does this sound right? 😊 Those relays are now controlled off 12 V volt directly right?
This shield uses ULN2008 chip with 7 transistors. Two are used for Cp relay and Enable relay which can each drive 2 devices each. Onboard there is also connector with 5 pins. Each pin can sink 0.5A for driving relays etc... So you can decide how to drive those. You could also pair up those pins for 1A capacity.
Also i built in two relays so you can choose to connect 12V or GND to relay common contact in order to have different options.
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 posted new document on my github with 4.1 schematic in pdf.
https://github.com/arber333/Arduino-Due ... ematic.pdf
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 »

Are you still using sn65hvd234's in your design if so where are you getting them from?
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: Arduino DUE VCU with analog and CAN control

Post by arber333 »

rstevens81 wrote: Thu Oct 21, 2021 7:30 pm Are you still using sn65hvd234's in your design if so where are you getting them from?
Huh? I have like 4 of them left from the last order. I thought i need to get some for experimenting with can. Dont tell me they too are unobtanium. I use them because they work good with 3v3 DUE signals. Many can transcievers like 5V better.
Post Reply