Leaf Gen2 DC Voltage Sense

Nissan Leaf/e-NV200 drive stack topics
Post Reply
User avatar
nickyivyca
Posts: 15
Joined: Thu Jul 06, 2023 4:45 pm
Location: California
Has thanked: 2 times
Been thanked: 8 times

Leaf Gen2 DC Voltage Sense

Post by nickyivyca »

I noticed the DC input voltage as measured at my Gen2 Leaf was pretty off from the full pack estimate reported by my BMS. (I have this version of the control board) I noticed when I got an overvoltage fault right after precharging. 345 was measured at 368.5, 332 was 351, 305 was 313. I did some google sheets math on these trying to back out what the as-measured ADC counts would be, based on the code and the original udcofs and udcgain, and then try to estimate new udcofs and udcgain. I was getting a negative udcofs which was not possible to enter in the interface, so I figured I might be doing something wrong.

I did some measurements with a DC power supply and my multimeter comparing to what the reading was in the web interface. It seemed there is a nonlinearity in the voltage sense:
image.png
I repeated the calculations with the data I took, optimizing for the 250-350V range where my pack sits. Still got a negative udcofs. I built my own version of stm32-sine foc with the ability to set a negative udcofs (just changing in param_prj.h) and now I am getting much more accurate readings. Has anyone seen anything similar with their Gen2 Leaf boards?

Calculations here
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1025 times
Contact:

Re: Leaf Gen2 DC Voltage Sense

Post by johu »

Yes it is the same problem on all Leafs. I'm not sure where the non-linearity is introduced. I couldn't be bothered to tune it as I have very liberal udcmin and udcmax, power limiting is accomplished with the BMS limits forwarded to idcmin and idcmax.
I could allow negative udcofs for anyone inclined to tune it.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
nickyivyca
Posts: 15
Joined: Thu Jul 06, 2023 4:45 pm
Location: California
Has thanked: 2 times
Been thanked: 8 times

Re: Leaf Gen2 DC Voltage Sense

Post by nickyivyca »

Is the UDC measurement only used for those limits or is it used for more direct motor control stuff? If it is used for motor control stuff then it would make sense to me to have it as accurate as possible across the full range. Or maybe it doesn't matter much?

One of the reasons I did this was to get the best results in the inverter-log based motor parameter estimation since it uses udc as a term. I also may want to tune in the min and max voltages for derating to enforce no regenning above 4.2v/cell and no discharge below 3.0v/cell (assuming the pack stays balanced) rather than programming my BMS to send those values.

So I am inclined to tune it, but I do also have my custom build already ¯\_(ツ)_/¯
User avatar
johu
Site Admin
Posts: 5791
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1025 times
Contact:

Re: Leaf Gen2 DC Voltage Sense

Post by johu »

It's just used for these limit and precharge control (udcsw)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Leaf Gen2 DC Voltage Sense

Post by Pete9008 »

nickyivyca wrote: Thu Jul 20, 2023 6:19 am Is the UDC measurement only used for those limits or is it used for more direct motor control stuff? If it is used for motor control stuff then it would make sense to me to have it as accurate as possible across the full range. Or maybe it doesn't matter much?

One of the reasons I did this was to get the best results in the inverter-log based motor parameter estimation since it uses udc as a term. I also may want to tune in the min and max voltages for derating to enforce no regenning above 4.2v/cell and no discharge below 3.0v/cell (assuming the pack stays balanced) rather than programming my BMS to send those values.

So I am inclined to tune it, but I do also have my custom build already ¯\_(ツ)_/¯
Udc was mainly included in the calculator to cater for large changes in voltage (peoples pack voltage could potentially vary quite a lot!). It's quite likely there is still significant (say 5-10%) error in some of the measurements due to udc errors but being realistic it's still a lot better than the other options :)

You're right that we should be making more use of it though. At the moment the uq and ud control loops actually control the pwm, not the voltage, this means that as the battery voltage changes so do the effective loop gains. Effectively the loop gains change by up to 30% between minimum and maximum pack voltage; it's possible that this exaggerates the loss of power on a lower pack voltage. This is another thing I'm thinking of changing in the future but tbh can't see the point until a car is running with much better logging than is currently available. The OI FOC control is still fairly basic and there is still a lot of scope for developing it.

On the Leaf udc I'm guessing the engineers used a linear opto-coupler but without feedback linearisation so it's never going to be perfect (there is also a reasonable scope for error in the OI ADC reference). I'd tune it for best accuracy in the normal battery voltage range (even if a negative offset is needed) and even then accept that it's only going to be accurate to within a few volts. In terms of discharge/regen limits it's probably safer to use the min/max cell voltage from the BMS rather than an average value.
Post Reply