Hey all,
There should be (well with most BDC and BLDC motors) some sensor that relays the back-emf created by the windings back to the PIC.
On the PIC, the line should go to a ADC port which then checks it against a known (probably through trial and error) range of voltage-speed levels.
I believe there is another way to calculate this. If you are using PWM to control the motor, the duty cycle of the pulse directly relates to the amount of
voltage applied to the motor. The length of the duty cycle over the period (can be expressed as a fraction) times the input voltage to the motor
gives you the voltage the motor should be receiving. From there, the data sheet should provide a graph correlating speed and voltage.
Example: You create some PWM code that has some arbitrary period, lets say 10ms (make it easy on ourselves). Assume the output voltage on the line
is 12V (typical operating voltage for a motor). We want the motor to run at a third of its total speed.
( L(dcycle) / L(period) ) * V(motor in) = V(supplied to motor).
I could be wrong, Ill wait for someone more knowledge able to come around and correct me if I am
-Joshua