Zombieverter PWM setup for dummies

Topics relating to the ZombieVerter VCU
Post Reply
User avatar
J0hannes
Posts: 121
Joined: Sat Nov 11, 2023 10:29 am
Location: Finland
Has thanked: 16 times
Been thanked: 144 times

Zombieverter PWM setup for dummies

Post by J0hannes »

Ok, so I'm looking at testing pump speed control with Tim3 and got confused and lonely trying to understand how these parameters actually work.

- PWM Control
100 Tim3_Presc 1 72000 719 Only used if CP Spoof and GS450h Oil pump output is not used
101 Tim3_Period 1 100000 7200 Only used if CP Spoof and GS450h Oil pump output is not used
102 Tim3_1_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used
103 Tim3_2_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used
104 Tim3_3_OC 1 100000 3600 Only used if CP Spoof and GS450h Oil pump output is not used

Soo after some searching this was closest to an explanation I was able to find, but really left me wondering.
royhen99 wrote: Thu Jan 30, 2025 10:18 pm Really easy to get the correct frequency. The clock is 72MHz so need total division of 36000000, e.g. 9000 x 4000.
set Tim3_Presc to 8999, and Tim3_Period to 3999. Duty cycle is controlled with Tim3_x_OC, where x is 1 to 3. 1000 gives 25% duty cycle, 2000 gives 50%, 3000 75% etc.
Dug through some STM32 application notes (AN4019, AN4776) and stared at Zombieverter source code and maybe I got this :idea:

So If I understand it correctly, this royhen99 example is setting a 2Hz update period for Tesla pump, correct?

Looking at the application notes got me thinking about how to go through this so it would be understandable.

We want to have 2Hz PWM frequency, which can be used to calculate the needed params TIM3_Presc and Tim3_Period
  • Prescaler is used to set counter clock frequency, this is arbitrary, but you'll probably want the counter to run at kHz level say 100kHz.
    System core clock for STM32 used in Zombieverter is 72MHz
    Tim3_presc = (System core clock/counter frequency)-1 --> (72 000 000 / 100 000)-1 = 719
  • PWM Period can now be calculated
    Tim3_Period = (Counter frequency / PWM period)-1 --> (100 000/ 2)-1 = 49999
  • Now we can decide the duty % and apply. Lets try 30%
    Tim3_X_OC = duty % * PWM period --> 0,3* 50 000 = 15000
  • The the duty % adjustment for PWM outputs work if they aren't assigned for another use (i.e. CP spoof)
    Tim3_1_OC = duty % on PWM 1
    Tim3_2_OC = duty % on PWM 2
    Tim3_3_OC = duty % on PWM 3
On royhen99 example counter clock is 8kHz, but otherwise the math works.

Did I get this right? :)
User avatar
tom91
Posts: 2443
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 213 times
Been thanked: 599 times

Re: Zombieverter PWM settup for dummies

Post by tom91 »

J0hannes wrote: Tue May 20, 2025 9:05 pm Did I get this right?
get a scope out and verify it ;) or even just an okay multimeter. I struggled to do the math until Roy suggested how to set it up and thats now how the Zombie is setup.
J0hannes wrote: Tue May 20, 2025 9:05 pm The the duty % adjustment for PWM outputs work if they aren't assigned for another use (i.e. CP spoof)
No, if any PWM output is used for a dedicated output the frequency (so divider and period) for all 3 are fixed. But yes you can adjust pwm duty

To get 1kHz it currently does:

Code: Select all

timer_set_period(TIM3, 3999);
        timer_set_oc_value(TIM3, TIM_OC1, 1);//No duty set here
        timer_set_oc_value(TIM3, TIM_OC2, 1);//No duty set here
        timer_set_oc_value(TIM3, TIM_OC3, 1);//No duty set here
        timer_set_prescaler(TIM3,17);
So duty is %x40 to set it.
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
peakPWR
Posts: 26
Joined: Tue Dec 17, 2024 6:49 am
Has thanked: 5 times
Been thanked: 6 times

Re: Nissan Leaf (and Tesla) coolant pumps

Post by peakPWR »

here's the wiki page for reference: https://openinverter.org/wiki/Tesla_Mod ... olant_Pump

Alibro wrote: Thu Jun 26, 2025 10:10 pm If you have a Zombieverter VCU I believe it can output the PWM required. I've not tried it yet but will report back when I do.
I would like to run these pumps from zombie too. Where to start in the SW and how to integrate? Zombie IO (without temp set points) or hard coding temp logic like X °C / °F = 60% Duty Cycle ?
User avatar
tom91
Posts: 2443
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 213 times
Been thanked: 599 times

Re: Zombieverter PWM setup for dummies

Post by tom91 »

First try can be just to use the PWM outputs and its parameters to get the 2hz output and then tweak the duty cycle to see if it works.

No need for any code changes to run a fixed PWM duty and frequency, if you do not configure any PWM functions
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
peakPWR
Posts: 26
Joined: Tue Dec 17, 2024 6:49 am
Has thanked: 5 times
Been thanked: 6 times

Re: Zombieverter PWM setup for dummies

Post by peakPWR »

Sounds good. I'll try that out and report if successful.
Shouldn't be a problem if 2Hz is possible.

What would be the "right" way (or position in code) to implement a temperature set point feature?

I know I asked a lot of those questions lately but I really want to learn about the OI environment so one day I can start to contribute code to it. Hope you don't mind ....
User avatar
tom91
Posts: 2443
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 213 times
Been thanked: 599 times

Re: Zombieverter PWM setup for dummies

Post by tom91 »

Write code for it, you can make it as interactive and configurable as you want. Have a look at functions/parameters that do something similar.

"easy example"
Param Output Function: CoolingFan
Param: FanTemp

So many options, for testing don't worry about it. just do it manually.
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
peakPWR
Posts: 26
Joined: Tue Dec 17, 2024 6:49 am
Has thanked: 5 times
Been thanked: 6 times

Re: Zombieverter PWM setup for dummies

Post by peakPWR »

tom91 wrote: Tue Jul 08, 2025 1:53 pm Have a look at functions/parameters that do something similar.
"easy example"
Param Output Function: CoolingFan
Param: FanTemp
That's something I can work with. Thank you for the explanation.
User avatar
Gregski
Posts: 2753
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 505 times
Been thanked: 957 times
Contact:

Re: Zombieverter PWM setup for dummies

Post by Gregski »

removed
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Gregski
Posts: 2753
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 505 times
Been thanked: 957 times
Contact:

Re: Zombieverter PWM setup for dummies

Post by Gregski »

removed
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Gregski
Posts: 2753
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 505 times
Been thanked: 957 times
Contact:

Re: Zombieverter PWM setup for dummies

Post by Gregski »

removed
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
tom91
Posts: 2443
Joined: Fri Mar 01, 2019 9:15 pm
Location: Bristol
Has thanked: 213 times
Been thanked: 599 times

Re: Zombieverter PWM setup for dummies

Post by tom91 »

Gregski wrote: Thu Jul 10, 2025 2:22 pm Hey Greg, we get it that you are working within the TOYOTA/Lexus Eco System, so what's up with the Nissan Altima pump?
Please create a specific topic for this, keep this topic clean and focused.
Creator of SimpBMS
Founder Volt Influx https://www.voltinflux.com/
Webstore: https://citini.com/
Post Reply