PDA

View Full Version : Voltage monitor and PWM control



StoneColdFuzzy
- 5th May 2009, 20:47
I'm going to try build a voltage monitor with the goal of changing PWM depending on the input voltage. I'll need the on board A/D and PWM and the end circuit will have to fit in a pretty small place, so I'm figuring on using the PIC12F683. I can fiddle around with the DIP version before I go surface mount. Is this a good IC for my application? I haven't ordered anything yet.

Here are my input voltages and calculated duty cycles.

Vin Duty
30 0.43
29 0.45
28 0.46
27 0.48
26 0.50
25 0.52
24 0.54
23 0.57
22 0.59
21 0.62
20 0.65
19 0.68
18 0.72
17 0.76
16 0.81
15 0.87
14 0.93
13 0.99


Am I on the right track?

Next, to tackle the PWM adjusting. Are there any similar projects that I can study? I searched and didn't find anything like what I'm doing or at least, simple enough for me to grasp.

~ Dave

bcd
- 9th May 2009, 01:22
OK, we might need a bit more info here.

Is the voltage you want to measure AC or DC ? What's the application - if its in a vehicle you will need to add some voltage spike protection to the sense inputs and power supply lines.

The 12F683 has a Hardware PWM output from memory so it is really easy to set the duty cycle to the required value and it will stay at that level until it is next changed - have a look in the manual for the HPWM command.

You will need a voltage divider circuit to allow you to get the full scale voltage into the A/D. Try doing a search on the forums, its been discussed before.

Bill.

StoneColdFuzzy
- 11th May 2009, 16:11
OK, we might need a bit more info here.

Is the voltage you want to measure AC or DC ? What's the application - if its in a vehicle you will need to add some voltage spike protection to the sense inputs and power supply lines.

The 12F683 has a Hardware PWM output from memory so it is really easy to set the duty cycle to the required value and it will stay at that level until it is next changed - have a look in the manual for the HPWM command.

You will need a voltage divider circuit to allow you to get the full scale voltage into the A/D. Try doing a search on the forums, its been discussed before.

Bill.

It's DC voltage and I'm OK with spike protection, a voltage divider and all of the rest the of the circuitry.

Through searches on the Internet and this forum and the data sheet, I did find out that the PIC12F683 will do the job, but I need help understanding the programming. I'd like to see a couple of similar projects that monitor voltage and then perform functions based on that voltage. In other words, I'd like to study the code, which has always been my shortcoming, especially with IF, greater than, less than, equal to, THEN, ENDIF and so forth.

Thanks.

~ Dave