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.

Battery Charger PWM

Status
Not open for further replies.

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
    test_364.gif
    5 KB · Views: 2,618
2camjohn said:
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.

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?.
 
2camjohn said:
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.

Many thanks
John

What are you assigning to the TMR2 and PR2 registers? Do you have that pin set as an output?
 
Nigel Goodwin said:
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?.

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.
 
2camjohn said:
Jay.slovak said:
Could you use 12F683 or 16F628 instead of 12F675? They both have HW PWM, which would simplify things a lot.

I cant use the '628 because I need an ADC.
The 12F683 looks like an awesome chip, but it isnt supported by my compiler :(
Or try 16F88. What Compiler are you using?
 
2camjohn said:
I have tried changing my duty cycle but it makes no difference.

I think instead of using PWM I will make several const current sources for the different modes of charge and switch them on and off as needed.

Thanks for the help anyway, shame we coudnt get this one sorted :? :( :(

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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top