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
    5 KB · Views: 2,622

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

Yes the pin is set as an output, it works fine when powering an LED.

There isnt a TMR2 register on the chip im using 12f675 (well I cant see one anyway).

Thanks for the help,
John
 
Could you use 12F683 or 16F628 instead of 12F675? They both have HW PWM, which would simplify things a lot.
 
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
 
Here is the schematic.
The NPNs are ZTX451s.

RLIMIT is 0.82ohm 6W resistor.

The reg for the constant current source is an LM317T

The battery is connected to the header on the schematic (output to intboard)

Thanks for all the help so far...
john
 

Attachments

  • test55.gif
    16.9 KB · Views: 2,059
Or try 16F88. What Compiler are you using?
 
The 88 is a bit big for my needs. I want to stay with an 8 pin chip ideally.

I am using the PIC simulator IDE from oshonsoft.
 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…