Trial and Error PID

So today I was trying to get the robot to move as straight as possible when going forward. I know you can do this with PID, but I don’t know how to do it yet. So instead, I changed the power given to each motor on the base to compensate for veering. After trial and error, I found that for the robot to move straight, one side (left) had to be at 85 power and the other side (right) had to be 127. Is this big of a difference normal?

Well you will find the motors have no speed change from 90 - 127. So this doesn’t actually sound unreasonable. Just for a quick test try changing the 127 to 95 and seeing if your results change at all ( I bet they wont).

Thank you! I didn’t know this until now.

Wait, what? The motors don’t go at a different speed until power 89?

Is the amount of stall torque different as well?

Tabor is saying the speed from 85-127 increases very marginally, while the probability of stalling is much higher. The motor changes speed from1-85, but at about that point there is little increase.

*The motor changes speed from 20-85

Is it 85 - 127 or 90 - 127 where the speed stays basically the same?

Read this historical and historic post. Notice the graphs.

What @LegoMindstormsmaniac found was that a power setting of 85 to 127, the actual delivered power does not increase much at all.

From just below the second presentation of the graph, in paragraph 9:

Because of @LegoMindstormsmaniac’s work, (which others have verified and reproduced periodically) we know you shouldn’t expect to see much if any change from 85 or so up to 127. We often round this to 90, just because it’s an easier number to work with.

Ah, I see. Thank you for the clarification!

So I understand what you’re saying, however I’m wondering is there an advantage to using the value 90 instead of 127 in your code? If 90 and 127 are the same speed anyways, does it matter what value you use as long as it’s between 90 and 127 if you want your robot to go full speed? I have heard someone on the forum say that competitive robots usually don’t go above 100 during competition play, and I’m wondering why it matters, if 100 or 90 or 127 is used, if they’re all the same speed?

I guess if you use 100 instead of 127, it takes longer for the motor to overload since it’s receiving less power, but it comes at the cost of less torque (only a little bit though, like 1 in-lb loss)?

I am not sure it actually gets less torque. People have been saying that here over and over without any evidence to back it up.

If the motor receives less power, then it produces less torque.

Do you have proof it receives less power?

I did a test a while back of the motor controller output on ports 2-9. Measured on an oscilloscope.

The signal being given to the motor has no change from ~85 to 127. This means the power, speed and torque are probably completely unchanged across that range.


  1. Only tested every 5 power
  2. Tested with tiny resistor instead of motor to remove back EMF, it is possible higher load on the motor controller produces unexpected effects.*

The only reason I have found to run 90 instead of 127 is that it heats the ptc less.

If you’re going to be in an engineering field, you should base decisions on facts and evidence.

There are at least two separate places in this thread that disprove your assertion that using 90 instead of 127 will heat the PTC device less.

It was really good of @tabor473 to provide a graph from his recent data-taking on this issue. If you don’t understand it, I’m sure he is more than willing to explain it.

If you disbelieve it, or think it doesn’t apply to your situation, you should be prepared to back up that thesis with data.

Yes, that is an important caveat to this discussion. There will be difference in how motor would behave under the load vs being run idle (where the only mechanical load is the friction in their internal components).

See this thread:

Also, using resistor instead of the motor, removes not only back EMF but also the ability of the motor to store additional energy in the inductive component of it windings.

There must be multiple causes for the control-value-vs-resulting-speed curve not being linear but, I believe, a lot of non-lineriarity comes from the interaction between the power capacitor inside the MC29 (C7 in the image below) and the motor’s inductive component.

When there is little or no external load, the supplied energy only needs to go toward overcoming internal motor resistance and friction, which is not much. So, when H-Bridge connects C7 cap to the motor windings it takes very little time to transfer energy from one (cap) to another (windings). Then when H-Bridge disconnects, C7 recharges from Cortex’s battery at a leisurely pace, while energy stored in the motor’s inductive components is being converted into mechanical energy. (Leaving out extra complexities due to triple winding of the brushed DC motor).

I wish I had equipment to test this while varying the value of C7 and/or dynamic load on the motor. NbN would have been a good year to do this test, with everybody having flywheel geartrains with varying degrees of friction as the mechanical load.

The more external load you put on the motor the flatter the curve should become. And it will reach max speed not around 90 but much higher. (Edit: see post below)

If I recall correctly, when we were tuning Flywheel PID for NbN robot, the output speed was changing all the way to the power level ~115 with our setup.