Dear sir thank u for reply.
My question is that i can get 10 bit resolution of PWM output to control motor speed.
I use following code.
CCP1CON = %00001100 ' Set CCP1 to PWM
T2CON = %00000111 ' Turn on Timer2, Prescale=4
PR2 = 249 ' Set PR2 to get 1KHz out
CCP1CON.4 = pid_out.0 ' Store duty to registers as
CCP1CON.5 = pid_out.1 ' a 10-bit word
CCPR1L = pid_out >> 2
It will give 10bit PWM output at 16MHz crystal.
Now spose pid_Error=+5 then spose after calculation
pid_Out=100
pid_out.15=0 'DIRECTION BIT
same result will be if pid_Error=-5 but
pid_out.15=1
With both errors final PWM resolution is same but how can I use direction bit to change PWM output to increase or decrease motor speed according to requirement.?
If there is any OFFSET which must be used ?
Bookmarks