Potnom not completely float

Post Reply
User avatar
manny
Posts: 165
Joined: Sun Jan 23, 2022 4:15 pm
Location: Netherlands
Has thanked: 38 times
Been thanked: 125 times

Potnom not completely float

Post by manny »

While driving my Saxo at low speed/power I sometimes feel the small surge or dip in power.
When looking on the web interface at the Iq current I can see a corresponding rise or fall in current.
After adding potnom to the chart they matched perfectly.

Potnom was changing with discrete steps. To verify this I tested this on my test setup.
potnom_5.32.M-foc.PNG
After tracing through the code I found this:

Code: Select all

float Throttle::DigitsToPercent(int potval, int potidx)
{
   if (potidx > 1) return 0;
   if (potmax[potidx] == potmin[potidx]) return 100.0f;

   return (100 * (potval - potmin[potidx])) / (potmax[potidx] - potmin[potidx]);
}
the 100 should be 100.0f I think. After this I took a look at the Zombie code:

Code: Select all

float Throttle::NormalizeThrottle(int potval, int potIdx)
{
    if(potIdx < 0 || potIdx > 1)
        return 0.0f;

    if(potmin[potIdx] == potmax[potIdx])
        return 0.0f;


    return 100.0f * ((float)(potval - potmin[potIdx]) / (float)(potmax[potIdx] - potmin[potIdx]));
}
When I changed the code I got this
potnom_mod.PNG
Second point.
The second "if" returns the opposite value 0 VS 100. 0 seems logical to me but maybe there is a reason?
[DRIVING] Citroen Saxo electrique
  • Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
  • PSA battery (50kWh)
  • Foccci and MG ZS charger 6.6kW
  • Zombie VCU
User avatar
tom91
Posts: 2754
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 264 times
Been thanked: 717 times

Re: Potnom not completely float

Post by tom91 »

You want to raise a push request or shall I?
manny wrote: Wed Aug 13, 2025 4:55 pm econd point.
The second "if" returns the opposite value 0 VS 100. 0 seems logical to me but maybe there is a reason?
What do you mean? The second if returns 0 if potmin is equal to potmax.
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
User avatar
manny
Posts: 165
Joined: Sun Jan 23, 2022 4:15 pm
Location: Netherlands
Has thanked: 38 times
Been thanked: 125 times

Re: Potnom not completely float

Post by manny »

on the OI code

Code: Select all

   if (potmax[potidx] == potmin[potidx]) return 100.0f;
so if potmin and potmax are equal the potnom is 100%

0% seems safer.
[DRIVING] Citroen Saxo electrique
  • Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
  • PSA battery (50kWh)
  • Foccci and MG ZS charger 6.6kW
  • Zombie VCU
User avatar
tom91
Posts: 2754
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 264 times
Been thanked: 717 times

Re: Potnom not completely float

Post by tom91 »

wait all of this is already in the Zombie, doh.

https://github.com/damienmaguire/Stm32- ... e.cpp#L116

I got confused, so you are on about the SMT32_Sine/FOC specfics.
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
User avatar
manny
Posts: 165
Joined: Sun Jan 23, 2022 4:15 pm
Location: Netherlands
Has thanked: 38 times
Been thanked: 125 times

Re: Potnom not completely float

Post by manny »

Yes. The Zombie implementation seems correct to me.
[DRIVING] Citroen Saxo electrique
  • Volvo ERAD motor, XC90 inverter/DCDC (custom OI board)
  • PSA battery (50kWh)
  • Foccci and MG ZS charger 6.6kW
  • Zombie VCU
Post Reply