04192015, 01:50 AM

#7041 (permalink)

EcoModding Lurker
Join Date: Apr 2015
Location: USA
Posts: 12
Thanks: 5
Thanked 4 Times in 3 Posts

Yep power section is built. I used the entire board just for the little DC motor. RTD explorer said 7 amps max on the current feedback.



Today



Other popular topics in this forum...



04192015, 02:02 AM

#7042 (permalink)

PLUGnGO
Join Date: Sep 2012
Location: Olympia Wa
Posts: 131
Thanks: 73
Thanked 75 Times in 52 Posts

Quote:
Originally Posted by Articus
Yep power section is built. I used the entire board just for the little DC motor. RTD explorer said 7 amps max on the current feedback.

Congrats! Photos?
(Sorry I've no help on your current limiting question)



04192015, 02:14 AM

#7043 (permalink)

EcoModding Lurker
Join Date: Apr 2015
Location: USA
Posts: 12
Thanks: 5
Thanked 4 Times in 3 Posts

Quote:
Originally Posted by jedsmd
Congrats! Photos?
(Sorry I've no help on your current limiting question)

Thanks and of course . I made 2 of them, here is the first:
I'm waiting on an order from Mouser for the VR1 trim pot on the second one because I lost the ones I originally ordered



04192015, 02:20 AM

#7044 (permalink)

PLUGnGO
Join Date: Sep 2012
Location: Olympia Wa
Posts: 131
Thanks: 73
Thanked 75 Times in 52 Posts

Nice, what are you putting these into?



04192015, 09:21 PM

#7045 (permalink)

PaulH
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831
Thanks: 1,367
Thanked 1,115 Times in 730 Posts

Depending on the motor, it may not be using 7 amps. Also, there would be very little resolution, since it's a LEM Hass 300s. There are 128 ticks of the A/D for each 300 amps. So, around 2 amps per tick of the A/D. Figure +/1 tick of resolution, and it can only resolve +/ 2 amps. My guess is that the motor is using less than 7 motor amps, and so the PWM just ramps to 100% trying to see 7 motor amps.



04222015, 02:31 AM

#7046 (permalink)

Dreamer
Join Date: Nov 2013
Location: Australia
Posts: 350
Thanks: 95
Thanked 210 Times in 150 Posts

Quote:
Originally Posted by MPaulHolmes
Depending on the motor, it may not be using 7 amps. Also, there would be very little resolution, since it's a LEM Hass 300s. There are 128 ticks of the A/D for each 300 amps. So, around 2 amps per tick of the A/D. Figure +/1 tick of resolution, and it can only resolve +/ 2 amps. My guess is that the motor is using less than 7 motor amps, and so the PWM just ramps to 100% trying to see 7 motor amps.

Since it is low current and just for testing with a small motor. How about taking the LEM 300 off of the copper bar and running a wire from the copper bar, looping through the LEM several times (not sure how many) and then to the motor? Thereby increasing the magnetic field measured by the LEM. Effectively reducing the LEM to say a LEM 20 rather than an LEM 300.



The Following User Says Thank You to Astro For This Useful Post:


04222015, 07:55 AM

#7047 (permalink)

PaulH
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831
Thanks: 1,367
Thanked 1,115 Times in 730 Posts

That works very well to do that. Good idea!



05072015, 11:18 AM

#7048 (permalink)

EcoModding Lurker
Join Date: Nov 2012
Location: West
Posts: 7
Thanks: 1
Thanked 3 Times in 3 Posts

I'm totally confused by the "PI" loop in the Cougar11B code. Can someone please help me see where I've made a mistake:
In config you have:
Kp ( from the example in the code, this is 1 or 2)
Ki ( from the example in the code somewhere between 20 and 160)
In config_pi:
v1 =Kp<<10
pi.K1=v1 (so ~2000)
pi.k2=Kipi.K1 (so ~ 1800)
In the main loop:
pi.error_new = current_ref  current_fb;
pi.pwm += (pi.K1 * pi.error_new) + (pi.K2 * pi.error_old);
drop the pi. and substitute for K2 (watch the i's and 1's):
pwm += (K1 * error_new) + ((KiK1) * error_old);
pwm += (K1 * error_new) + (Ki * error_old)  (K1 * error_old);
pwm += (K1 * (error_new  error_old)) + (Ki * error_old);
finally :
pi.error_old = pi.error_new;
I can't see an integral term in there. Normally you'd have something like
pi.total_error += pi.error_new;
but the code is just setting new to old, not accumulating.
The first term appears to be a differential term. If so, what's running is a PD controller, but the proportional term (Ki) is acting on the last error, not the current error.
Substituting some imaginary values:
pi.pwm += (2000*10) 1800*50;
pi.pwm += 20000  90000 = 70000;
the final signal is pi.pwm >> 16 so the output would change by 254, not unreasonable.
Empirically, the loop is stable, so I feel I must be missing something  PD is not unstable.



The Following User Says Thank You to artc For This Useful Post:


05072015, 12:06 PM

#7049 (permalink)

PaulH
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,831
Thanks: 1,367
Thanked 1,115 Times in 730 Posts

I didn't do the PI loop the traditional way. I did it like this:
Let P and I be the constants. error(t) is the error between the desired current, and the actual current. pwm(t) is the duty at time t.
pwm(t) = P*error(t) + I*INTEGRAL(error(TAU)), where the integral goes from 0 to t, hence the dummy variable TAU (remember that in calculus? hehe. They always use TAU! What's up with that?).
Differentiate both sides:
(2) d (pwm)/dt = P*d(error)/dt + I*error(t), by the Fundamental Theorem of Calculus. (The one where differentiating the integral leaves the function)
Now, I approximated d(error)/dt and d(pwm)/dt by finding the slope of two points for a small time interval, like 0.001, which was my throttle sampling rate back in the day, and substitute it into equation (2).
So, d(error)/dt IS REPLACED WITH (errorNew  errorOld)/deltaT. (remember the difference quotient. We just aren't letting h > 0. Just using small h)
Also, d(pwm)/dt IS REPLACED WITH deltaPWM/deltaT.
Also, replace error(t) with errorOld. (You could use either errorOld or errorNew if you wanted I think).
So, after substituting, Equation (2) becomes:
(2b) deltaPWM/deltaT = P*(errorNew  errorOld)/deltaT + I*errorOld
Now, multiply both sides by deltaT:
(3) deltaPWM = P*(errorNew  errorOld) + I*deltaT*errorOld
Now, distribute P, and get all the errorOld stuff together:
(4) deltaPWM = P*errorNew  P*errorOld + I*deltaT*errorOld
(5) deltaPWM = P*errorNew + (I*deltaT  P)*errorOld
So, kp = P, and ki = I*deltaT  P. kp and ki are constants, because I, P, and deltaT are constant.



The Following User Says Thank You to MPaulHolmes For This Useful Post:


05072015, 02:52 PM

#7050 (permalink)

EcoModding Lurker
Join Date: Nov 2012
Location: West
Posts: 7
Thanks: 1
Thanked 3 Times in 3 Posts

Quote:
Originally Posted by MPaulHolmes
I didn't do the PI loop the traditional way.

No argument from me there
You're right in that you're calculating deltaPWM rather than PWM so there's an additional differentiation that comes into play.
Quote:
Originally Posted by MPaulHolmes
(5) deltaPWM = P*errorNew + (I*deltaT  P)*errorOld

(As a PI equation that seem intuitively horribly wrong, but I can' see a problem in the mathematics).
What bothers me about (5) is that somewhere I'm missing an inversion (possibly U5C?). With a "direct" drive I think that lower pwm, lower OCR1A would lead to an increased current which would imply a negative proportional term. However, I think that output of that loop increases with increasing error.



