Timers

Submitted by Ana on

Hi I have a doubt in the servomotor with PIC tutorial because  don't know how the REG_value is calculated  and why TMR0 is 251 and this line of code 

on_time = (170-pot_value); can you explain to me please, THANKS

Here the variable pot value will vary from 0-40 based on the potentiometer value. So when the value is 0 we have to make a PWM with 0 duty cycle and when 40% we have to make a pwm with 100% duty cycle.

When the value of on_time is 170 a 100% duty cycle will be formed by the timer0 module and when 130 i.e (170-40) a 0% duty cycle will be formerd. To understand the concept better you can download the simulation file and try simulating the code by using different values for 170

  Joined August 16, 2016      1000
Tuesday at 12:29 AM