View Single Post
Old 05-25-2009, 09:48 PM   #1414 (permalink)
EcoModding Lurker
Join Date: Apr 2009
Location: Maine
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Originally Posted by MPaulHolmes View Post
I think I need to sample the current during each pwm period, which is kind of bad because it eats up so much of the system resources. That's 2/3 of all computing time gone! But I guess it's worth it. Throttle is only needed at maybe 1kHz frequency or perhaps 500Hz. Maybe inside that ISR, I could take turns with current and throttle? Maybe skip a current sample every 16 times, to allow time for throttle? And then every 32000 times or so, skip both current and throttle to take temperature? Then, there should be 1/3 of the processing time avalailable for "other things..." Duh Duh Duhhhhhhh!

If I do throttle and temp outside, maybe that would be fine! Maybe just set a flag inside the ISR that says "timeToReadThrottle", and then I get to it when I get to it? I would have to disable the interrupts when I got to the throttle conversion moment so nothing weird would happen, but that's OK! I might try that! heck ya dude! You can't teach that, it's instinct! hahaha!

Human response time isn't exactly all that quick compared to your micro-controller, so a few more milliseconds of process time between throttle reads should not be a problem or even noticeable up to about 50 milliseconds.

I forgot if you have hardware over current protection or if it is all in the software? If in software you will need that read every cycle to protect your power section. but if this is done in hardware and you are only reading for current to throttle position control, then I think that you could probably do something like take a sample every fourth cycle or so,( lengthen the number of cycles between current reads until it starts to feel like the controller is beginning to lose track, and then shorten it up a bit.

What I am curious about is if you can still keep your read point synchronized on the peek of current the cycle, if you are only taking samples every 4rth - 8th - whatever the code is set for. I do believe that keeping it on peek will be necessary.

If keeping it on peek is not possible, one workaround might be to use a hardware filter to smooth out the output of your current detection circuit going to your micro-controller read pin for the current; filtering only needs to be strong enough to cover your PWM frequency and no more. ( also be particularly careful not to filter or dampen the output to the current limiting circit. )
"Experience is something you get right after you need it !"
  Reply With Quote