Hi, I'm working on a PID algorithm that controls a computer fan by watching its blades go past an IR reflective sensor.
I'm finding that my divide is very computationally expensive and taking about 74uS which is about 600 clock cycles.
uint16_t bladeFrequency = F_CPU / clocksSinceLastBlade; // clocksSinceLastBlade is a uint32_t and varies from 35,000 to 700,000 in general use
There are plenty of articles written about efficiently dividing with constant denominator, but none that I can find addressing a constant numerator.
I was wondering if you guys have any suggestions on how I can tackle this more efficiently? It doesn't need to be entirely accurate.