### Chris Calver from Team C2 discusses how you can test the speed of your flywheels to see if you are getting as much speed as the calculations would lead you to believe:

VEX give a specification for the motor which when coupled with our known gear ratio allows us to calculate a theoretical maximum flywheel speed. However, if the motor is not powerful enough to drive the gearbox at that speed, the flywheels will never achieve the theoretical maximum.

There are a few ways that we can measure the actual flywheel speed.

- Physically count the number of revolutions over a known period of time
- Write a program to count the number of motor rotations over a known period of time (e.g. 1 minute)

Firstly, let's look at option 1, physically counting the rotations. Before we start, we need to have a look at the specification for the motors themselves.

On the VEX IQ website, VEX quote the “Free Speed” as 120rpm (revolutions per minute).

This means that when there is no load for the motor to turn, it should spin 120 full turns every minute. We can check how close our motors are to this specification using a really simple test.

Firstly, I fitted the two motors from our launcher to a plate so that they are side my side. I then added a small shaft and put a large 60-tooth gear on each shaft. I then marked one tooth on each gear with some white correction fluid so that it is easy to see and used a standoff as a stationary marker on the plate.

Next, I ran a really simple program that turns both motors on to 100% so they are running at full speed. Because the motors don't turn that fast, I can see every time the white tooth on the gear passed the standoff marker. It's slow enough so that I can count every time it goes past.

I need to know how many times it goes past the marker in 1 minute – this will give me how many revolutions per minute (rpm) the motor has done. However, I don't want to sit and count it for 1 minute so I will count it for 30 seconds and then multiply the answer by 2 to give me the rpm value.

Check out the video to see this in action.

In 30 seconds, I counted 59rpm which multiplied by 2 (to give a full minute) is 118 so pretty close to specification, especially if we take into account that I may have made an error of 1 or 2 whilst counting.

### Stroboscopes

My gear ratio on the flywheel is 1:9 – for every 1 turn of the motor, the flywheel turns 9 times. This means if our motor runs at the theoretical maximum 120rpm, the flywheel turns at 1080rpm, or 18 times per second. This is going to be too fast to count so we need another way to measure it – a stroboscope.

A stroboscope is an instrument which is specifically designed to measure the speed of rotation of an object without having to be physically in contact with it. It works by pulsing a bright light at a known frequency. Check this video out to see exactly how this works:

I don't have a stroboscope. You may have one in your school but if not we can make one using some equipment that you probably do have. For this, we need a function generator (or frequency generator) that is capable of producing a square wave. We also need a bright white LED and a dark room. I have put one white mark on each flywheel which will be the reference markers. See mine in action in the video. It's not perfect, but it does the job!

### Using ROBOTC to calculate flywheel speed

Finally, I wrote a little program in ROBOTC to calculate how fast the motors are turning. It then multiplies the motor rpm by the gear ratio to tell us how fast the flywheels are turning.

Each VEX IQ Smart Motor has a built-in encoder that can tell us how many degrees the motor has moved. This program works by accelerating the flywheels to full speed. Once the flywheels have reached full speed, it then resets the motor encoders to zero and waits for 10 seconds. At the end of the 10 seconds, the encoder values are stored in a variable and the flywheels are switched off.

We then divide the encoder value by 360 to turn the value into degrees into number of rotations. This number is then multiplied by 6 to give us a full minutes worth of rotations and therefore rpm (revolutions per minute).

Finally, we can multiply by the gear ratio to give us the flywheel speed. In this case, we multiply by 9.

You can download the ROBOTC program from here.

#pragma config(Motor, motor4, rightDrive, tmotorVexIQ, PIDContro

#pragma config(Motor, motor5, rightLauncher, tmotorVexIQ, PIDContro

#pragma config(Motor, motor6, intake, tmotorVexIQ, PIDContro

#pragma config(Motor, motor7, launcherLoad, tmotorVexIQ, PIDContro

#pragma config(Motor, motor11, leftLauncher, tmotorVexIQ, PIDContro

#pragma config(Motor, motor12, leftDrive, tmotorVexIQ, PIDContro

//*!!Code automatically generated by 'ROBOTC' configuration wizard

task main()

{

//set up some variables to store the motor and flywheel RPM

int launcherSpeed = 0;

int leftLauncherRPM = 0;

int rightLauncherRPM = 0;

int leftLauncherFlywheelRPM = 0;

int rightLauncherFlywheelRPM = 0;

int gearRatio = 9; // stores the gear ratio (i.e. 9 = 1:9)

displayCenteredTextLine(1, "Winding up...."); //display a message on line 1

//start the launchers

//this for loop accelerates the flywheel slowly over a period of

//5 seconds (i.e it loops 100 times and pauses for 50ms each time)

//It starts at zero and gradually increases the speed to 100

for(launcherSpeed = 0; launcherSpeed
<=99; launcherSpeed++)

{

setMotorSpeed(leftLauncher, launcherSpeed);

setMotorSpeed(rightLauncher, launcherSpeed);

wait1Msec(50);

}

setMotorSpeed(leftLauncher, 100);

setMotorSpeed(rightLauncher, 100);

//wait 3 seconds to allow to stabilise and make sure the flywheels are

//running smoothly at full speed

wait1Msec(3000);

eraseDisplay(); //clear the display

displayCenteredTextLine(1, "Starting RPM count"); //show a message on line 1

//reset the launcher encoders to zero

resetMotorEncoder(leftLauncher);

resetMotorEncoder(rightLauncher);

//..then wait ten seconds before taking the new encoder reading

wait1Msec(10000);

//get the motor encoder values (in degrees) and divide by 360 to work out

//the total number of rotations since the encoders were reset.

//Then multiply by 6 to get number of revolutions in a minute (rpm)

//as we only recorded the values after 10 seconds of rotation

leftLauncherRPM = (getMotorEncoder(leftLauncher)/360) * 6;

rightLauncherRPM = (getMotorEncoder(rightLauncher)/360) * 6;

//caculate the flywheel speed by multiplying motor speed by gear ratio

leftLauncherFlywheelRPM = leftLauncherRPM * gearRatio;

rightLauncherFlywheelRPM = rightLauncherRPM * gearRatio;

//display the results on the screen

eraseDisplay();

displayTextLine(2, "SIDE MOTOR FLYWHEEL");

displayTextLine(3, "Left %d %d", leftLauncherRPM, leftLauncherFlywheel

displayTextLine(4, "Right %d %d", rightLauncherRPM, rightLauncherFlywhe

//..and decelerate the flywheels over a period of 5 seconds

for(launcherSpeed = 100; launcherSpeed >0; launcherSpeed--)

{

setMotorSpeed(leftLauncher, launcherSpeed);

setMotorSpeed(rightLauncher, launcherSpeed);

wait1Msec(50);

}

setMotorSpeed(leftLauncher, 0);

setMotorSpeed(rightLauncher, 0);

while(true)

{

//program gets trapped in this while loop at the end

//so we can see the results on the screen

//This will generate a warning in ROBOTC as it is an

//infinite loop with no instructions. You can ignore

//the warning and just hit X on the Brain to end the

//program.

}

}