I have a double flywheel with a 15:1 with 4 high speed motors and I wanted to create a program so that the flywheels run at a constant rate throughout the match so that the flywheel speed doesn’t depend on the battery on Easy C.

(I’m using 2 red optical shaft encoders).

For PID the concept is identical, it should basically just be a matter of porting the code over from the robotC PID controllers (although im not entirely sure about the specifics of programming with easyC).

Just remember this is basically what a PID loop boils down to:

error = targetVelocity - actualVelocity

Proportional = error * Kp

totalError += error

Intergral = totalError * Ki

Derivative = (error - lastError) * Kd

motorspeed = Proportional + Integral + Derivative;

Ok, I’ll try that and post my results.

How does one aqcuire the actual velocity and does it differs from target velocity? Also, in EasyC do I have to use the timer functions or the PID?

in order to determine velocity, what you need to do is this

encoders = 0;

wait1Msec(Time);

int distance = encoders;

velocity = (WheelDiameter*PI/360*12)*distance*(1000/Time);

what that line of code does is converts between encoder tic per time interval, to feet Per Second of the wheel edge

as for understanding how PID control works, here is a tutorial in RobotC, I cant really help you with EasyC, but maybe if you can get the ideas from the video you can port them to EasyC

oh and by the way, that line of code to get velocity only works if the encoders are on the same shaft as the wheel, if they are somewhere else in the gear chain you need to add another multiplier, for example, if you had a 1:21 gear ratio, and the encoders where on the same shaft as the motors, you would multiply that line of code by 21

you could also calculate it in RPM by going:

```
encoderCount1 = SensorValue
wait(waitTime)
encoderCount1 = SensorValue
// essentially difference/time (or how many ticks in the time frame divided
// by the time)
EncoderTicksPerMilisecond = (encoderCount2 - encoderCount1) / waitTime
// Because 1000 milliseconds in a second and 60 secs in a minute
EncoderTicksPerMinute = EncoderTicksPerMilisecond *1000 * 60
// Multiply by your gear ratio to get the speed of the flywheel.
// gear ratio is whatever it is to one e.g. 1:7 would be 7
FlywheelEncoderTicksPerMinute = EnocoderTicksPerMinute * gearRatio
// Because the red encoders have 360 ticks in a rotation
Velocity = FlywheelEncoderTicksPerMinute / 360
```

Note: that you could combine all these calculations into one calculation, I just did this for understandings sake.

This means the output is = x rotations per minute if we assume that a positive output means clockwise (or I guess right/east) and a negative output means anticlockwise (or I guess left/west).

How could i apply that in easy c

^