PWM in PIC16F873A


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94

    Default PWM in PIC16F873A

    Hi, I want to make a circuit that charge a lead acid battery in the day with solar cell and in the night it turning on and off some LED's. This pulse should work all the night when my program measure the battery voltage so i have to use the PWM mode. if the battery voltage is getting low i should decrease the duty cycle to 45,40 or 30% for battery saving. I want to turning on the LED's every one second (one second on and one second off), so i need a 0.5Hz frequency with 50% duty cycle. How can i use the PWM to make this pulse? can i use HPWM instruction in pisbasic pro? ( i want to write my program in picbasic pro). i read in the help of the picbasic pro that the lowest frequency at 4MHz is 245Hz so how can i make 0.5Hz pulse? (you can see this: http://www.electro-tech-online.com/m...ic16f873a.html)

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    You can make a .5 hertz pulse using a timer with interrupts. Here is an example. http://darreltaylor.com/DT_INTS-14/blinky.html

  3. #3
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    yes, i can do this with timer and interrupt but first of all i want to know how can i do this with pwm mode? i want to make pulses and at the same time my program should measure the battery voltage with ADC and etc.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    With PWM,

    The Cycle time of PWM is dependent upon the oscillator frequency. If a
    4MHz oscillator is used, each Cycle is about 5ms long.
    So, you could get there either HPWM or PWM by running your chip at about 1/25 of a megahertz for PWM or about 1/100 of a megahertz for HPWM. So the only valid option I know is interrupts.
    Last edited by ScaleRobotics; - 26th January 2011 at 22:16.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts