I have a double Fly wheel with quad optical shaft encoders (red encoders) and i wanted to get the speed in mph. its 4 motors 2 on each side with a 49:3 compound gear ratio (84-36/84-12) how would i code it on easy C or what would be the calculations??
What is your reason for wanting the speed in mph? I think it would be a lot easier if you got the speed in ticks per second, or RPM and did everything from there. Are you planning to get the speed and use it in some kind of velocity control program such as TBH or PID?
It would be interesting to find out the actual speed of the motors in terms that can be understood.
You would first have to find the circumference of your wheel. For us 4" x 3.14 = 12.56inches. This is your distance traveled per rotation of your wheel.
Your unit of speed right now is probably something like, ticks /20 milliseconds. Use the data from your code to get this speed and calculate your RPM or rotations /minute. There are 360 ticks per ENCODER revolution. Remember to include the gearing between your encoder and your flywheel.
Put circumference in and get (12.56inches * rotations) /minute.
Then calculate MPH or miles/ hour.
Just a bunch of conversions.
You can do all this with basic algebra, it is just sometimes hard to visualize throughout the multiple steps.
Probably not efficient to us MPH in your code. Just use raw data.
@007aj077 i rather use ticks per mins but cant find or figure out the code. and i want it on the lcd for the feeder to know exactly when to input
I’m not the coder but it is pretty simple.
Speed is distance / time right? So…
while(true)
{
wait (20); //time
encoder = speed;//send current encoder value to the speed variable
encoder = 0;
}
Hope I didn’t miss anything. This kind of thing should give you speed every .02 second. This is obviously pseudo code. The time might want to be raise to about 50 if you are not getting outputs large enough.
ill try that and get the results back to u in about 30 mins im making hardware changes right now to support a lift @Cyber brains