Battery Charger PWM

2camjohn

Member
I am adding a PWM battery charger to one of my circuits, im having some trouble getting the PWM to work.

Attached is the relevent parts of the circuit, in order to make the current source high, the transistor needs to be switched off.
I have run a variety of test programs to ensure everything works circuit wise.


I have done the PWM in software, I have chosen a duty cycle of 100us, the problem is, whenever I run the PWM even at 90%, the io pin remains high (over 3V) which keeps the transistor on meaning my constant current source is always off.

(running the PWM at 100% does turn the current source on and all works fine)

I think maybe my duty cycle is too small, but before I completely rewrite my PWM code I thought I would check with you good people first.


Any ideas?




Many thanks
John
 

Attachments

  • test_364.gif
    5 KB · Views: 2,676

You've not posted the circuit of the constant current section?, which is likely to be the most likely part at fault.

What you have posted shows the PIC and the constant current source sharing the same power rail - 5V isn't much to feed your constant current source from!.

Also, have you used a scope to see what's happening?, and are you using hardware or software PWM?.
 

What are you assigning to the TMR2 and PR2 registers? Do you have that pin set as an output?
 

I'll do a schematic of the whole thing shortly.

Sorry the constant current source is run off 12V, not 5V as in my crappy diagram.

I dont have a scope Im afraid.

Im using software PWM.
 
Or try 16F88. What Compiler are you using?
 

Your problem may be that your PWM isn't working at all?, that's where a scope would come in useful. However, you could always connect the output from the PIC to the input of an audio amplifier (via an attenuator), and listen for the tone to prove it's doing something.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…