Joystick 269 free speed motor control linearization algorithm

This thread is some testing I did on 269 motor, which is basically the exact same theory in this thread: But in a different situation – free spinning 269 motor.

So we know that the relationship between the value assigned to a motor, which is the voltage at the port, and the free-spinning velocity of the motor, is positive but not linear. It is a concave up curve with a dead band of approximately ± 15, depending on your mechanics and motor choice.

What Jordan did was 5 second speed calculation for every motor value, which is good, but in my opinion still not precise enough. So, in my tesing, I feel like taking my time and really getting some good data. I did 3 seconds of acceleration plus 20 second interval average speed test, because I do realize that my motor gets fast and slow in every turn. So, all compiled together, starting from 15 to 127, took me about an hour to produce some fine data.

Posting the same stuff I did a few days ago, but in a much much higher resolution, encoder value over 20 seconds and scaled down to RPM:

I tried to do regression before, but excel gives a perfect 5th order regression but does not give me the extremely precise formula for it. All the numbers are rounded up and when it comes to 5th order regression, it’s a big deal and values get pathetically off. Plus, I do not want the cortex to make 5th order calculations with constants with 10 decimal places every loop.

So exactly the same as what Jordan did, I fixed the data in excel, mapped out what I can and estimated&filled in the rest, and here we go. I felt comfortable with the linearized control and it seems to give a lot more freedom to develop skills.

And the final algorithm for free spinning linearization of 296 motor:

int LinearizedMotorValue (float target)
	int estimationArray[114] = {0,15,15,15,16,16,16,16,16,16,17,17,17,18,
	float expected;
	if (target == 0)
		expected = 0;
	else if (target > 0 && target <= 113)
		expected = estimationArray[target+1];
	else if (target < 0 && target >= -113)
		expected = -estimationArray-target+1];
	else if (target > 113)
		expected = 127;
	else if (target < -113)
		expected = -127;
	return expected;

The max velocity in my test was consistently 113, so a completely linearized joystick control program looks like this:

motor[port2] = LinearizedMotorValue (113*vexRT[Ch3]/127);

So, this is it guys. I thought this would be a more general case for people who plan to do testing and programming with free spinning 296 motors, or maybe visualizing the speed reduction of drivetrain motors by comparing your data with this algorithm.

Today was my last day in lab, as I am graduating next week, and I am happy that I did everything I wanted to do as a high school VRC programmer, including this, PID velocity and rerun program. Will talk about the rerun program I did that’s inspired by Ruiqi Mao in another thread.

Excel data file: [

Codes attached below.

Cheers people,
pid test.c (18.2 KB)
high resolution graph.JPG

do you know if this curve will hold true for a 393 motor?

I have not tested it on my own, and I have no idea why I snatched a 269 motor when I decided to start this project… but Jpearman’s testing says yes, they are close.