<div dir="ltr">Murray,<div> I was reading over my response and noted an error:</div><div><b>What I said:</b></div><div>However, the electrical power in the motor's winding is Power = current^2 * voltage. In this case (3.6 A) ^2 * Voltage, where for VEX system is 7.2 V. or ~93 watts. This is why stalled motors often fail within seconds.</div><div><br></div><div><b>What I should have said:</b> <b><br></b></div><div>However, the electrical power in the motor's winding is Power = current * voltage. In this case (3.6 A) * Voltage, where for VEX system is 7.2 V. or ~26 watts. This is why stalled motors often fail within seconds. </div><div><br></div><div>Sorry for the confusion.</div><div><br></div><div>Regards,</div><div>Doug P. <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 21, 2020 at 10:58 AM <a href="mailto:secretary@dprg.org">secretary@dprg.org</a> <<a href="mailto:secretary@dprg.org">secretary@dprg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Murray,<div> I am a bit confused by your message. I think that you are confusing power and torque. You might find this link useful: <a href="http://www.epi-eng.com/piston_engine_technology/power_and_torque.htm" target="_blank">http://www.epi-eng.com/piston_engine_technology/power_and_torque.htm</a> . </div><div><br></div><div> Take this scenario, your robot without encoder feedback is moving on a level floor at a given speed, then it comes to a ramp and as it goes up the ramp it slows down. In this case the robot's motors are being supplied a set voltage. In a DC motor, the speed will drop as more load is placed on it for a given voltage. This is because at a given voltage only a specific current will be supplied to the motor.
Torque is directly proportional to motor current.
Typically what you want is when the robot reaches the ramp you want the speed not to drop. This means that you need to increase motor torque. You want the robot motors to provide more current going up the ramp. This means that you have to increase the voltage to the motors.</div><div><br></div><div>Below is the performance curves for a VEX robotics 393 motor (used to be their main motor). To get the different data points on this curve they are changing the load and the voltage. At stall, the motor is pulling 3.6 A, has a speed of 0 RPM. The motor's mechanical power is 0, because motor mechanical Power = (torque * speed) / constant_based_on_units. However, the electrical power in the motor's winding is Power = current^2 * voltage. In this case (3.6 A) ^2 * Voltage, where for VEX system is 7.2 V. or ~93 watts. This is why stalled motors often fail within seconds.</div><div><br></div><div><div><img src="cid:ii_k9a1lp700" alt="image.png" width="562" height="391"><br></div></div><div><br></div><div>Now take this scenario, your robot with encoder feedback is moving on a level floor at a given speed set by your PID (or P, or PI, or PD) controller, then it comes to the ramp. If you have a P controller the speed will change to a certain level as the controller increases the voltage (and thus the current and torque) to some value that is lower than your level speed but higher than it would be without any feedback. The reason that it doesn't maintain perfect speed control is because as the feedback value comes close to the desired (reference) value, a P controller loses its ability to change the output, in a sense it runs out of steam the closer it gets. So for a P controller there will always have an offset from the desired speed set by your reference signal. Often this is all you need. If you have a PI controller, the I portion of the controller will allow your output to match your reference setting at the expense of adding more instability (however, it maintains response even as speed approaches reference). For most robots this is usually all you need. Adding a D component (i.e., PID vs PI) can add response with reduced oscillations in output if done right, but is adds a level of trickiness to the tuning. I often use only a P, or PI controller, in my robot depending on what I am doing. I often wrap a velocity PI inside of a heading P controller. In the case of a line following robot, a PD controller is often used. What the D does is add response to rapid changes. The robot will not run at the reference setting with PD, for that can only be done with an I component in the controller. Note that both I and D have a dt component, you must keep loop time constant or adjust for varying it. Also, please note that the above is somewhat general, people with more knowledge may have a better understanding than me. I hope others will jump in and correct me where I have gone off base.</div><div><br></div><div>Regards,</div><div>Doug P.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 20, 2020 at 11:27 PM Murray Altheim via DPRGlist <<a href="mailto:dprglist@lists.dprg.org" target="_blank">dprglist@lists.dprg.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
Over the past week I've spent many an hour working on my Python-<br>
based PID controller, which is using a ThunderBorg motor controller<br>
under the hood to drive a quartet (left-right pairs) of OSEPP motors.<br>
<br>
I've kinda got something working, at least the PD part of it seems<br>
functional, but there's a big gaping hole where a certain part of<br>
the implementation is concerned: prior to PID I was "successfully"<br>
driving the robot based on an encoder-based velocity measurement,<br>
but there was no PID, and my recent attempts to create a PID<br>
controller using velocity have failed.<br>
<br>
I believe this is due to the fact that I was attempting to use the<br>
velocity measurement as the PID input to set the motor power. As I<br>
think David noted in his YouTube video, there isn't a direct relationship<br>
between motor power and velocity so this was bound to fail. I like<br>
fail as much as the next person, but success is nice too.<br>
<br>
So with that in mind I've gone back to a power-based PID controller,<br>
knowing I still have a certain mountain to climb.<br>
<br>
The question I now have is: how to add a velocity-based control to<br>
my robot? Do I come up with some mathematical relationship between<br>
velocity and motor power, or do I create a velocity-based PID<br>
controller **over top** of the power-based PID controller, i.e.,<br>
two layers of PID control?<br>
<br>
Much-simplified pseudo-code:<br>
<br>
KP = some_constant<br>
KI = some_constant<br>
KD = some_constant<br>
<br>
target_power = 0.5<br>
<br>
while True:<br>
current_power = motor.get_power()<br>
error = target_power - current_power<br>
<br>
k_diff = KP * error<br>
i_diff = KI * sum_errors<br>
d_diff = KD * last_error<br>
<br>
output = k_diff + i_diff + d_diff<br>
slewed_output = slew(output)<br>
new_power = current_power + slewed_output<br>
set_motor_power(new_power)<br>
<br>
last_error = error<br>
sum_errors += error<br>
<br>
So would I incorporate velocity into the above somehow, or build<br>
Yet Another PID controller for velocity (using roughly the same<br>
structure as above, but solely dealing with velocity) that calls<br>
the above power-based PID controller?<br>
<br>
I thought perhaps we could discuss this in tomorrow's Robot Builders<br>
Night Virtual get together... but an email discuss is also welcome,<br>
thanks!<br>
<br>
Cheers,<br>
<br>
Murray<br>
<br>
...........................................................................<br>
Murray Altheim <murray18 at altheim dot com> = = ===<br>
<a href="http://www.altheim.com/murray/" rel="noreferrer" target="_blank">http://www.altheim.com/murray/</a> === ===<br>
= = ===<br>
In the evening<br>
The rice leaves in the garden<br>
Rustle in the autumn wind<br>
That blows through my reed hut.<br>
-- Minamoto no Tsunenobu<br>
<br>
_______________________________________________<br>
DPRGlist mailing list<br>
<a href="mailto:DPRGlist@lists.dprg.org" target="_blank">DPRGlist@lists.dprg.org</a><br>
<a href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org" rel="noreferrer" target="_blank">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a><br>
</blockquote></div>
</blockquote></div>