I need to measure the duty cycle of PWM Pulse of a parallel port running at 5hz, with a duty cycle going from 0.1% to 100%, with a resolution of AT LEAST 0.1% or 1,000 steps (preferably .01% - 10,000 steps !).
The output will feed either a D/A Convertor or create a high frequency PWM to create a very stable control voltage to control a 0-10,000 rpm motor controller with a control voltage of 0 - 10v dc. I cannot feed the existing 5hz pulse directly to the controller as because of the low 5hz frequency, it is just not stable enough, even with a R/C network. The R/R Network also adds in a delay when changing speeds which is unacceptable.
I will also need to measure the ACTUAL motor speed of the motor and feed it back into the PIC on another pin and adjust the output speed (control voltage) when a load slows the motor down.
The pulse width varies from 200 us to 200,000 us, the duty cycle calculation is:
TotalPulse = LoPulse + HiPulse
DutyCycle = (LoPulse * 1000) / TotalPulse
However, I now know that the PIC can only handle integers and values less than 65,535 and the above calculation cannot be done because it results in a fraction.
If I multiply the LowPulse * 1000 then the value of LoPulse at 100% Duty Cycle is 2000000 which is too large for the PIC to handle.
Any suggestions ???
Thanx
PeterC
Bookmarks