Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PWM in PIC16F873A

Status
Not open for further replies.

amindzo

Member
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?
 
i knew that but i want to measure the battery voltage all the time and change the duty cycle depending on the battery voltage so i can't change the resistor and capacitor values in different situations and also when i use microcontroller for measuring and charging the battery it doesn't cost saving to use another circuit for making pulses. i want to produce this circuit in big scale so cost is very important , even one resistor is important in the price in big scale.
 
Why do you need a microcontroller when cost is important? You could use 2 transistors as a multivibrator to flash the LED (like in cheap Chinese dummy cameras with a flashing led). Then find an easy analog way to reduce the duty cycle as the battery voltage falls, which should be easy enough.

Do you have any experience designing a large quantity product? The PIC you have chosein is extremely expensive, especially compared to a solution that uses two 3 cent transistors to do the same job.
 
i want to make a smart battery charger, i want to charge a 12v, 14Ah lead acid battery with solar cell so i think it would be easier to design this circuit with microcontroller but this is the experimental one and then i will find a cheaper microcontroller for my application. so for making this smart battery charger it's better to use a microcontroller and also making pulses with that. i should turn on and off 150 LED with variable duty cycle. my application is making LED traffic sign and in next stages i want to use some sensors to send some information about weather so it seems that using microcontroller is necessary.
 
Last edited:
I apologise because my reply sounded harsh, I was not intending to be harsh or insulting.

However my point is still valid. You stated that;
i want to produce this circuit in big scale so cost is very important , even one resistor is important in the price in big scale.

If you are making a large expensive solar powered traffic sign with 150 LEDs that is a very different application. I doubt that the cost of one resistor will matter that much.

At this point it may be wise to join forces with someone who is experienced with microcontrollers who can do that part of the product for you, or to take some time off and learn the microcontroller skills you need to come back later and make the product.

To answer your question, you can use many systems to make PWM with a PIC, it depends on what features the PIC has (if it has a PWM module) and how good you are at doing PWM in programming alone.
 
i haven't try pwm but i won't have problem with that because every time i wanted to do something new with microcontroller, i'd do that. every time i read datasheets, books and use internet searches to do my job. with studying i found that if i want to use the pwm mode , i have limitations to make frequency. so i think it's better to use timer (timer1 or timer 2) and interrupts to make 0.5Hz frequency. the program does other works like measuring the battery voltage or charging the battery and when the timer interrupt happen the program goes to interrupt routine program to make a pin high or low ( 1 second high and 1 second low). i have another idea to reduce the power consumption because in LED traffic signs with solar cell, power consumption is very important, because if the weather is cloudy the solar cell can't charge the battery very well and in my province we have more rainy days in contrast with other provinces in my country. so i want the battery work for 6 nights without charging. ( this the problem that other LED traffic signs have). so my idea is that when i make a pin high to turn on the LED's for 1 second with timer and interrupts i use pwm mode too. so when the interrupts happen i make a frequency with pwm mode to turn on and off the LED's with high frequency in 1 second that the eyes can't see that. the LED's turn on and off with high frequency that eyes can't see that but i have power saving. so 1 second with high frequency LED's are on and in next 1 seconds they are off.
I made an LED traffic sign with PIC16F84 and NE555 ASTABLE with 60% duty cycle and it works for 3 nights with 12 hour working in each night and i want to improve my design by using another micro like PIC16F873A and pwm mode, because i need ADC to measuring the battery and solar cell voltages and charging the battery and i also need a circuit to turning on and off the LED's so i need a microcontroller to have all these things together and in the future i will add some sensors so i think PIC16F873A is a good choice
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top