Go Back   EcoModder Forum > EcoModding > Fossil Fuel Free > Open ReVolt: open source DC motor controller
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 03-23-2009, 12:50 PM   #621 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
OK I'm back from my final today! I did some thinking and programming on paper! ya! Good idea Matt!

New control loop:

// iFeedback should be in 0 to 128, since that's all the resolution I have!
// Make sure iRef (from GetThrottlePos()) is also in the range 0 to 128,
// so you would need an extra step of shifting it. how annoying. maybe fix that.
// You want pwmDuty to be in 0 to 255.
// iFeedback in [0,128]
// iError in [0,128]
// pwmDuty in [0,255]
// iSum in [0,255]
// K1 in [0,1]
// K2 in [0,1]
// Start with K2 = 0.
//


void SetCurrent(void) {
iSum = 0;
do {
iFeedback = GetCurrent();
iError = iRef - iFeedback;
pwmDuty = K1*iErr + iSum;
OCR1A = pwmDuty;
iSum += K2*iErr;
if (iSum < 0)
iSum = 0;
} while (iFeedback != iRef);
}


void SetThrottle(void) {
iRef = GetThrottlePos();

GetTemperature();
//////////////////////////////////////////
// limit iRef based on temperature here //
//////////////////////////////////////////

SetCurrent(); // Sets the current to iRef.
}


That makes a lot of sense (throttle proportional to current only). I was just thinking that if there was a failure of the hall effect current sensor, that I would lose control of the car, and I don't know how failure proof those things are. But that wouldn't matter, would it?

Let's say you have a failure of the current sensor. It fails, being stuck reading an erroneous 499 amps. The PI loop would go forever (never exiting), and pwm duty would be driven to 0%, right, desperately (do computers get desperate?) trying to make the current drop. In that case, the car stops. So what! That's fine.

Now let's say you have a failure of the current sensor where it's stuck reading an erroneous 0 amps. Then if the throttle is even at 1%, the loop will drive the PWM duty all the way to 100%, trying desperately (hehe) to get the current to be 1% of 499 amps. This would be bad. But if the throttle was 0%, then the car would stop. OK. I think that's an acceptable risk. If the current sensor fails, just remove foot from gas pedal. Not catastrophic.

Now I need to tune the PI loop, to find the just right K1 and K2 values in the range of 0 to 1. Hey, I get to use fixed point math! I used to do that when making video games on my piece of crap 386 computer! ya!

__________________
kits and boards
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 03-23-2009, 01:05 PM   #622 (permalink)
Master EcoModder
 
Join Date: Jun 2008
Location: London, Ontario
Posts: 1,096

2k2Prot5 - '02 Mazda Protege5
90 day: 33.82 mpg (US)
Thanks: 0
Thanked 17 Times in 14 Posts
Paul, you sly devil... you're getting good at this stuff!

Second fail case - Hall stuck at 0. If you are already moving and the hall is stuck at 0, then it will try to push up the current. Then you realize th ings are bad and you drop throttle. Throttle and current will both be 0, so the PWM will NOT CHANGE from where it is! So yes, you ARE going to be rocktting down the road strapped to an electric death machine. I recommend a simple "if throttle = 0, kill it", but that might be harsh on the electronics.

Use excel to choose your values for you. Decide your settling time and overshoot this way. There is, unfortunately, an unknown variable which makes this a little more tricky than it looks. The rate of change of current with respect to PWM duty is NOT constant. At higher rpm, the rate of change of current with respect to pwm duty is lower than it is at low RPM. A properly designed state space version of this controller would alleviate that and you'd get good response across the board.

Be sure to run that calculation on a timer interrupt! You do not want to do this in the main loop.
  Reply With Quote
Old 03-23-2009, 01:09 PM   #623 (permalink)
Master EcoModder
 
Join Date: Jun 2008
Location: London, Ontario
Posts: 1,096

2k2Prot5 - '02 Mazda Protege5
90 day: 33.82 mpg (US)
Thanks: 0
Thanked 17 Times in 14 Posts
Wait a tick... i just noticed that it is all happening in a while loop. Don't do that. Use static variables and just keep calling the function at a standard interval like 0.5ms or something... maybe faster if you can.
  Reply With Quote
Old 03-23-2009, 01:22 PM   #624 (permalink)
EV test pilot
 
bennelson's Avatar
 
Join Date: Jan 2008
Location: Oconomowoc, WI, USA
Posts: 4,435

Electric Cycle - '81 Kawasaki KZ440
90 day: 334.6 mpg (US)

S10 - '95 Chevy S10
90 day: 30.48 mpg (US)

Electro-Metro - '96 Ben Nelson's "Electro-Metro"
90 day: 129.81 mpg (US)

The Wife's Car - Plug-in Prius - '04 Toyota Prius
90 day: 78.16 mpg (US)
Thanks: 17
Thanked 663 Times in 388 Posts
Quote:
Originally Posted by MazdaMatt View Post
you ARE going to be rocktting down the road strapped to an electric death machine.
That's it.

I AM buying that parachute for my car...
__________________


300mpg.org Learn how to BUILD YOUR OWN ELECTRIC CAR CHEAP
My YouTube Videos
  Reply With Quote
Old 03-23-2009, 01:24 PM   #625 (permalink)
Master EcoModder
 
Join Date: Jun 2008
Location: London, Ontario
Posts: 1,096

2k2Prot5 - '02 Mazda Protege5
90 day: 33.82 mpg (US)
Thanks: 0
Thanked 17 Times in 14 Posts
Good luck, ben
  Reply With Quote
Old 03-23-2009, 01:38 PM   #626 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,368
Thanked 1,202 Times in 765 Posts
Quote:
Originally Posted by MazdaMatt View Post
Throttle and current will both be 0, so the PWM will NOT CHANGE from where it is!
...
I recommend a simple "if throttle = 0, kill it", but that might be harsh on the electronics.
Yikes, good point. I didn't catch that. But instead of rebooting the computer from a coding error, we have to reboot Ben. haha! CLEAR! ZAP!!! haha! Just kidding Ben. It will be very safe when I ship it to you, but you will have that emergency disconnect nearby, right?

Excellent idea about excel! Thanks!
__________________
kits and boards
  Reply With Quote
Old 03-23-2009, 01:38 PM   #627 (permalink)
EcoModding Lurker
 
Join Date: Feb 2009
Location: rochester ny
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Just wanted to Say hi and Congratulate everyone on their excellent work. I have been a long time lurker on this thread and I am very impressed with what you guys have been able to accomplish. Keep up the good work and I will be putting my order in for a pre milled power section if you offer them!

-Copertop
  Reply With Quote
Old 03-23-2009, 02:20 PM   #628 (permalink)
MAD Modder
 
Join Date: May 2008
Location: NorCal
Posts: 70
Thanks: 0
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by MPaulHolmes View Post
Yikes, good point. I didn't catch that. But instead of rebooting the computer from a coding error, we have to reboot Ben. haha! CLEAR! ZAP!!! haha! Just kidding Ben. It will be very safe when I ship it to you, but you will have that emergency disconnect nearby, right?

Excellent idea about excel! Thanks!
Is he going to use something like this?

Plasma Boy Racing Photos :: Emergency Disconnect!

Should be easy to build and handle plenty of amps (pun intended?)

Looks amazing, must read from 3-4 pages back and get caught up, a lot happened this weekend while I was out of town
  Reply With Quote
Old 03-23-2009, 05:08 PM   #629 (permalink)
EcoModding Apprentice
 
Join Date: Sep 2008
Location: Upstate NY
Posts: 190

GreenMile - '00 Mazda Protege ES
90 day: 34.45 mpg (US)
Thanks: 0
Thanked 5 Times in 3 Posts
Just curious, this controller is capable of 144 volts and 500 amps for a total of 72 kw's? If that's the case that's incredibly impressive amount of capacity. More then capable of driving a vehicle with large electric motors for greater acceleration.

I was also wondering which program you were using as your C++ editor?
__________________
http://benw385.vox.com/
'Blog' on the open source electric motorcycle project.

Please come visit and comment!
  Reply With Quote
Old 03-23-2009, 05:56 PM   #630 (permalink)
EV test pilot
 
bennelson's Avatar
 
Join Date: Jan 2008
Location: Oconomowoc, WI, USA
Posts: 4,435

Electric Cycle - '81 Kawasaki KZ440
90 day: 334.6 mpg (US)

S10 - '95 Chevy S10
90 day: 30.48 mpg (US)

Electro-Metro - '96 Ben Nelson's "Electro-Metro"
90 day: 129.81 mpg (US)

The Wife's Car - Plug-in Prius - '04 Toyota Prius
90 day: 78.16 mpg (US)
Thanks: 17
Thanked 663 Times in 388 Posts
Quote:
Originally Posted by Blue Bomber Man View Post
this controller is capable of 144 volts and 500 amps for a total of 72 kw's?
yep.

That comes pretty close to 100 ELECTRIC HP.

You DO know how much better electric horsepowers are than gasoline horsepowers, right?

Dang, I DO gotta instal the parachute!

__________________


300mpg.org Learn how to BUILD YOUR OWN ELECTRIC CAR CHEAP
My YouTube Videos
  Reply With Quote
Reply  Post New Thread


Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paul and Sabrina's Cheap 3 Phase Inverter (AC Controller) with Field Oriented Control MPaulHolmes Fossil Fuel Free 3480 05-04-2022 05:43 PM
Paul & Sabrina's Cheap EV Conversion MPaulHolmes Fossil Fuel Free 542 11-12-2016 09:09 PM
Three Dirt Cheap DIY Electric Cars - Part 5 SVOboy EcoModder Blog Discussion 0 12-12-2008 04:10 PM



Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com