View Single Post
Old 03-30-2009, 11:42 AM   #699 (permalink)
Roger Heuckeroth
EV Converter
 
Join Date: Mar 2009
Location: Saugerties, NY
Posts: 51
Thanks: 0
Thanked 1 Time in 1 Post
Paul,

If your simple code works, then great you’re done! There is no need for a fancy PI loop if everything is working nice and smooth. The question is will it work just as smooth for other motors and other voltages.

I believe Einstein was quoted saying something like “the simplest solution is the best solution, as long as it’s not too simple.”

I think frequency of your iterative loop plays a key role in how stable and smooth the controllers response is to accelerator pedal input. A physics teacher once told me if you have trouble understanding the dynamics of a multivariate problem take the variables to their limits and see what happens.

So, let’s look and the extremes. Say your loop takes just a nanosecond to increment the PWM duty cycle. Your foot calls for 10% current to the motor. The motor has inductance, so it can’t respond that fast. In 1024 nanoseconds the PWM duty is up to 100%. It stays there until the current sensor feedback tells it that 10% has been achieved. You lurch forward at full torque. Then blam, in another 1024 nanoseconds the PWM duty is back to 0. The response is to fast, and the controller goes from 100% to 0 to 100% and so on. It’s an unstable system that results in a really jerky ride.

Now let’s look at the other extreme. It takes a full second for the loop to make on 1/1024th increment. Your foot calls for power, but the controller says hold on there, let’s not rush this. You get really slow response and a sluggish EV.

So, somewhere in between there is an iterative frequency that gives just the right response without significant overshoot. You may have found the “sweet spot” already for your motor and voltage just by accident. It will be a bit different for an 11” motor at 144V, but maybe it will be fine.

If you find that you get a jerky start, just decrease the iterative frequency. If you want quicker response, increase the frequency. Could it be this simple? Maybe so.

What PID logic would essentially do is slow down the rate at which the increments or decrements occur as you get closer to the target current. So, if you want to get more complex, you could calculate the difference between the target current and the actual current and slow down the iterative frequency as feedback from the LEM sensor gets closer to the target current. Its been years since I have wrote code, but this doesn’t sound to hard. Just have a delay in the loop that is inversely proportional to the difference between the target and actual. Is this simpler than the code you were trying to make work in the rain?

Do you need this extra bit of code? Only way to find out is to experiment. Not only with your EV, but in others. That’s the beauty of an open source design. We can all work together to make this the best darn controller out there.

Roger
  Reply With Quote