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-25-2009, 08:30 AM   #1391 (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
Just doing my post-weekend catchup read. Good work again, Paul. I'm glad that you're getting things sorted out now that you're using a few extra bits.

FYI, there are a few ways that interrupts can act if they overrun.
1. A new interrupt can interrupt the currently interrupting interrupt. Whe that one is done, it returns to the first one to complete it. If it gets interrupted before it is done, the same thing happens, if this continues we have a stack overflow and the cpu goes crazy.
2. A new interrupt can be completely ignored because the first one is not done.
3. A new interrupt can be queued up to run after the first. Only one can be queued up, so if you take too long, or repeatedly take a little too long, then you'll skip one.

It all depends on how you have set up your interrupt handlers and masks. Ideally, though... you arrange the code so that in the worst case, you aren't using the full available time... the system has to do other things too, remember.

Do you have your ADC reading and/or filtering happening during interrupts as well, or polled?

  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 05-25-2009, 08:57 AM   #1392 (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
Quote:
Originally Posted by MazdaMatt View Post
...Do you have your ADC reading and/or filtering happening during interrupts as well, or polled?
If it still looks anything like the svn code:
/trunk/HighVoltageControllerIMPROVED_ECOM.C - Open ReVolt - Trac

everything is done in a timer interrupt, which might be a problem. Could use a lower priority interrupt for updating some of the variables (i.e. temperature). And any variables updated in an interrupt "thread" should be declared volatile.

Paul, did you measure how long that isr takes to complete in worst case?
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 05-25-2009, 09:04 AM   #1393 (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
Another thought - is it really necessary to control the current at 16kHz? Could you back it off to 8kHz or 4kHz? Your current and throttle values are being fed through rolling average filters, so it isn't like you're actually responding to "this cycle's" current reading.

A question about AtMegas in general - can you easily erase and rewrite flash sectors on the fly? On the Coldfire, if I wanted to store some user settings, i could just drop them into the program flash - just need tomake sure that the compiler is avoiding that section of flash.
  Reply With Quote
Old 05-25-2009, 09:53 AM   #1394 (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
The megas have eprom built in
http://atmel.com/dyn/resources/prod_...ts/doc2486.pdf

You can overwrite flash too, but that affects reliability IMHO. Best to use the eprom so writes that go wonky dont overwrite code.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote
Old 05-25-2009, 09:56 AM   #1395 (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
Cool. That could definately be used for some mild datalogging.
  Reply With Quote
Old 05-25-2009, 10:28 AM   #1396 (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 Adam, I might have to wait until tomorrow to reproduce it. We are having a big party, and all my "gCode" is on the backs of old credit card bills in the garage and in a couple different notebooks that can't find right now.

Matt, that's a good idea about lowering the frequency at which I check the current. Sampling at 4 KHz would allow for plenty of time during worst case to have everything inside a single interrupt. I could definitely move the temperature measurement outside, but I've never done multiple interrupts at different priorities. I need to look that up. I did a couple different timer interrupts once but that's about it. I didn't know what had what priority.

I haven't been sampling the throttle, because it was pretty clean, but there is a bit of a wiggle to the throttle signal too because the A/D conversions are happening pretty fast. So, maybe I could do the same thing with the throttle too, but maybe only 4 or 8 averages? If I had plenty of time, I could do

I guess the only thing I would lose would be the coveted current measure at the same point on the waveform each time. Maybe not though. I need to try some things. I'm pretty new to microcontroller interrupt handling.

EDIT: The general interrupt control register looks promising! I need to read more. Actually I should be doing other things! haha!
__________________
kits and boards

Last edited by MPaulHolmes; 05-25-2009 at 10:34 AM..
  Reply With Quote
Old 05-25-2009, 10:37 AM   #1397 (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
Wait wait... you misread... Keep sampling the current at every waveform and keep doing the rolling average thing. What i meant was, can you do the PI thing at 4 or 8kHz? Adjust your PWM duty every 2 or 4 pwm cycles. You are reacting on every single cycle to a value that is averaged out over the last X cycles.

If you find that the throttle is being read smoothly, then don't bother filtering it. I would assume that you already have a filter capacitor on the throttle, that should be fine.
  Reply With Quote
Old 05-25-2009, 10:42 AM   #1398 (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
I'm doing the PI thing at 1kHz right now, but inside the interrupt that's being called at 16 kHz. I do a quick test of:

if (ISRCounter % 16 == 0)
do PI stuff...

if (ISRCounter % 32000 == 0)
do temperature stuff.


So, most of the time, I'm only doing some quick things related to current.
__________________
kits and boards
  Reply With Quote
Old 05-25-2009, 10:44 AM   #1399 (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
I'm sorry... i thought that i read above that you were doing PI at 16Khz... ignore this entire line of questioning. My bad.

edit - i highly recommend putting each of those if( blah % x) into its own timer interrupt. Arrange the priorities correctly and you'll never overrun an interrupt time.
  Reply With Quote
Old 05-25-2009, 10:49 AM   #1400 (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
Paul, I looked at the base timing of the ISR (calling it within AVR studio) of the svn version, and a typical call looked like about 1225 cycles, or 80us @ 16mhz. Plenty of room there if the interrupt is happening @~1000 Hz, but not the latest code and optimized for size (not even sure what compiler I'm using).

__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  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