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 05-21-2009, 12:39 PM   #1341 (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 12 Times in 9 Posts
Let us know what your starting system parameters are before you start trying to tune it. I'd like to know the frequency of your sampling the current and throttle and how they are filtered (rolling average? details on that). I'd also like to know your PI loop frequency. It is a good idea as well to decide on an intended response, for example, 5% overshoot, 1 second 90% response, 1.1 seconds to 2% error.

My digital control systems text book is at home burried in the "to be sorted" pile of boxes, but I'm sure you could get some starting values by looking at digital control system theory online with using the parameters listed above.

Edit - is it also possible for you two rig up 3 push-buttons with resisters that would give you 5%, 20% and 50% throttle? These would let you datalog or scope the various responses.

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 05-21-2009, 06:47 PM   #1342 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,367
Thanked 1,115 Times in 730 Posts
My main problem is I'm working with 16 bits, and that's it. All the documentation I've read uses 32 bits for the fixed point math. I guess I can use fake 32 bits, like the upper half in one variable and lower half in another. Man, that's annoying.
__________________
kits and boards
  Reply With Quote
Old 05-21-2009, 07:47 PM   #1343 (permalink)
Crowd Estimator
 
Join Date: May 2009
Location: Maine
Posts: 11

Molly - '94 Toyota Electric Tercel
Thanks: 0
Thanked 0 Times in 0 Posts
Controller software

Paul (and everyone else anxiously awaiting),

I just got the controller software posted to the wiki. Sorry for the delay, I've a bit busy the last few days.

[ReVolt - EcoModder Link to Wiki]
  Reply With Quote
Old 05-21-2009, 08:20 PM   #1344 (permalink)
EcoModding Lurker
 
Join Date: Apr 2009
Location: Melbourne, Australia
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Great work Zero, now to fill out some of those blank spots .

Keep up the hard work Paul, i for 1 is waiting for it pass alpha testing!
  Reply With Quote
Old 05-21-2009, 08:49 PM   #1345 (permalink)
EcoModding Lurker
 
Join Date: May 2009
Location: Bremerton, Wa
Posts: 41

That Big Gray Thing - '82 Mercury Capri
90 day: 19.33 mpg (US)
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to wolfraven
Yeah, I'm waiting for it to pass some of the testing as well...because I hadn't been seriously planning an EV conversion of any sort until I started reading through this, and the conversions here...then I started crunching numbers... It'd be cheaper even with a premade non-Open Source controller...but then, I wouldn't be able to make the racers at work sad w/o putting in MUCH more money than I'm willing to
  Reply With Quote
Old 05-22-2009, 12:09 AM   #1346 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,367
Thanked 1,115 Times in 730 Posts
Oops, I think I found a problem with the PI loop. hehe. I'm integrating, but I forgot a little thing I like to call delta_t. My delta_t is 1/1000 of a second. That could affect things. Leaving that out made my integration correction off by a factor of 1000. my bad. Actually, when I first tried it, I was doing the sampling much faster, so the correction was more like off by 15000 or who knows what! I had just tried to convert some guy's suggestions from the EV Tech list, and he hadn't mentioned that I was integrating, and his explanation had a few errors, and I just blindly followed it. But I decided to read up on it, and it's way easier when you can just look at the math yourself! Man! So you CAN use Reimann sums in real life! What's that all about!

What if I did a slightly different version of a PI loop, where instead of integrating from t = 0, I only go back like maybe 128 samples or whatever, and do that running average thing again with the errors, and then multiply by delta_t and my 'I' constant? Would that cause issues with convergence? I don't think so. I'm going to try that. I guess the errors can be negative, so maybe I'll just have a running total instead, and multiply that by 'I' constant and delta_t.

Man, I'm not going to lie, "my kingdom for 32 bits"
__________________
kits and boards

Last edited by MPaulHolmes; 05-22-2009 at 12:38 AM..
  Reply With Quote
Old 05-22-2009, 05:58 AM   #1347 (permalink)
EcoModding Lurker
 
Join Date: May 2009
Location: Bucharest,RO and Copenhagen,DK
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
I've added to the svn the wiki version of the software. It's up to Paul to decide who will be given "write" access to the repository. For now, our main developer has yet to master the art of svn

/trunk - Open ReVolt - Trac
  Reply With Quote
Old 05-22-2009, 06:32 AM   #1348 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location:
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 267 Times in 210 Posts
Yay, I get to critique someone elses code!
but I wont, looks reasonable to me
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 05-22-2009 at 06:38 AM..
  Reply With Quote
Old 05-22-2009, 10:08 AM   #1349 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,367
Thanked 1,115 Times in 730 Posts
Oh snapping turtle, I can do it on an 8 bit chip now! ya! I'm going to test it out!
__________________
kits and boards
  Reply With Quote
Old 05-22-2009, 11:46 AM   #1350 (permalink)
PaulH
 
MPaulHolmes's Avatar
 
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831

Michael's Electric Beetle - '71 Volkswagen Superbeetle 500000
Thanks: 1,367
Thanked 1,115 Times in 730 Posts
Hey! It works! Super fancy. Here's the math:

You start with:

pwm(t) = P*e(t) + I*INTEGRAL(e(TAU)), where the integral goes from 0 to t.

Differentiate both sides:

......d (pwm).......P*d e(t)
(2) -------- = ---------- + I*e(t), by the F.T.C.!!!
.........dt.................dt

Let's approximate d(e)/dt and d(pwm)/dt by finding the slope of two points for a small time interval, like 0.001, which is my throttle sampling rate, and substitute it into equation (2). Also, use the old value for e(t). I probably could use errorNew too. I haven't tried that though.

(pwmNew - pwmOld)/deltaT = P*(errorNew - errorOld)/deltaT + I*errorOld

Now, multiply both sides by deltaT:

pwmNew - pwmOld = P*(errorNew - errorOld) + I*deltaT*errorOld

Now, solve for pwmNew:

(3) pwmNew = pwmOld + P*(errorNew - errorOld) + I*deltaT*errorOld
/////////////////////////////////////////////////////////////////////////////
So, we need good values for P and I. What I did was change the range of pwmDutyFine to [0, 32000] or so. However, I end up shifting it down so that it's in the range [0, 512], and that gives me the resolution to play with P and I. Letting P = 1 in equation (3) above really is letting P = 1/64, since pwmDutyFine gets shifted down from 32000 to 500 or whatever. I let 'I' be some other number. haha! I still need to fine tune the values. Here's the code:

errorNew = _throttlePos - _current;
pwmDutyFine += (errorNew - ((7*errorOld) >> 3));

errorOld = errorNew;
// under absurd worst case, pwmDutyFine could grow by close to 1000
if (pwmDutyFine > 31740)
pwmDutyFine = 31740;
else if (pwmDutyFine < 0)
pwmDutyFine = 0;

// Round the result.
if ((pwmDutyFine % 64) >= 32) {
pwmDuty = (pwmDutyFine >> 6) + 1;
}
else {
pwmDuty = pwmDutyFine >> 6;
}
OCR1A = pwmDuty;

__________________
kits and boards
  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 3471 06-01-2020 10:53 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 - 2020, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com