Can anyone help me with some coding?
I want to power a 12v halogen bulb from a 14.8v li-ion battery pack and regulate the supply voltage using pwm. Amongst other things my aim is to flatten out the battery discharge curve to provide a longer run time.
For the sake of simplicity assume that the required regulated output voltage is going to be set at 12v. I may change this value at some point e.g. 6v for dipped beam.
My circuit is pretty straight forward. So far I have a high effiecency mosfet driven by the picaxe pwm output to switch the power to the lamp. This part is working and I can light my bulb and start it by ramping the pwm from 0v to provide a soft start feature.
I am currently missing the feedback loop both in terms of the physical ciruit design and the code. My intention is to measure the voltage at the lamp using the ADC input of my picaxe via a potential divider to ensure the input voltage remains within the range the ADC function can handle. There are a couple things I need help with.
1) Since I need to measure the average voltage seen at the bulb and not the pulse voltage I need to smooth it out before it's fed into the ADC input. I assume I do this with a capacitor in parallel to the resistor in the potential divider I'll be taking my measurement from. Is this correct and if so how do I choose the correct value for the capacitor?
An now the tricky bit...
2) Any pointers on the code I should use to calculate the pwm duty cycle and period on the fly from the measured feedback voltage.
BTW I'm currently using a 08M.
Any help, much appreciated.
Thanks
I want to power a 12v halogen bulb from a 14.8v li-ion battery pack and regulate the supply voltage using pwm. Amongst other things my aim is to flatten out the battery discharge curve to provide a longer run time.
For the sake of simplicity assume that the required regulated output voltage is going to be set at 12v. I may change this value at some point e.g. 6v for dipped beam.
My circuit is pretty straight forward. So far I have a high effiecency mosfet driven by the picaxe pwm output to switch the power to the lamp. This part is working and I can light my bulb and start it by ramping the pwm from 0v to provide a soft start feature.
I am currently missing the feedback loop both in terms of the physical ciruit design and the code. My intention is to measure the voltage at the lamp using the ADC input of my picaxe via a potential divider to ensure the input voltage remains within the range the ADC function can handle. There are a couple things I need help with.
1) Since I need to measure the average voltage seen at the bulb and not the pulse voltage I need to smooth it out before it's fed into the ADC input. I assume I do this with a capacitor in parallel to the resistor in the potential divider I'll be taking my measurement from. Is this correct and if so how do I choose the correct value for the capacitor?
An now the tricky bit...
2) Any pointers on the code I should use to calculate the pwm duty cycle and period on the fly from the measured feedback voltage.
BTW I'm currently using a 08M.
Any help, much appreciated.
Thanks