Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Friends, help to find out the bug of this charger

Status
Not open for further replies.
Only a guess - is R1 connected to the input side of the regulator?

Try breaking the problem down into steps.

1. Remove the ATmega32, it will work at maximum voltage if it is removed so at least you can check the regulating side without damaging the chip.

2. Temporarily ground the adjust pin and check you get about 1.25V at its output pin, this will check it is regulating.

3. Temporarily connect (ATmega removed!) JP4 pin 1 to +5V and check that again you get a low voltage out.

4. Temporarily connect JP4 pin 2 to +5V and see if R3 allows you to adjust the output voltage.

5. Keep calm and let me know the results of these checks.

Brian.
 

Brian,
i am out of the city now. having the
eid vacation... will start on it very soon with a calm mind... this time, it be a messy appoach, but will help to solve i hope

Meanwhile, happy Eid.

Mishu~~
 

Dear Brian,
How are you?? After the vacation, just now i returned and started working. At the very first I found a BIG problem... "Wrong Package Selection". I used 2N2222A as CAD where soldered 2N2222. One was npn switching (cad) but in practical it is pnp switching. and it might make the whole thing mess. Since all the components are soldered on the pcb, i'm gonna desolder all and re solder them all in another pcb (I have to make another pcb now) and then i'll tell you...

mean while, i checked the part of adc. that's still not working... even after removing from the main ckt. Next step i'll do for pcb is just a single ADC reading and display in lcd. the first lesson of ADC. let's check what happens there... (Infact i am also worried about the amp part... can you check again for me if the amp part is oky now?? dafinitely the last schematic. And only change in the current schematic is just the transistors... replaced by 2n2222 (NOT 2n2222A). that's all...

I'll let you know update...

Mishu~

Added after 2 minutes:

about the diodes in base of Q1-3, i'll use a jumper there to avoid them....
 

I'm fine thanks, I had a bad day but it's almost over.

The 2N2222 and 2N2222A are both NPN which is what you should be using so I'm a little confused where the problem is.

I can't see anything obviously wrong with the ADC circuit. I am assuming you are running the LM741 from both positive and negative supplies so it should be OK. There are better amplifiers, the 741 has been around for 30 years but it should still do the job reasonably well.

The only thing that might be worth adding is 5.1V Zener diodes between the ATmega ADC inputs and ground. At the moment, it might be possible to put more than 5V or a negative voltage on the ADC inputs. A Zener will help to protect the IC.

Brian.
 

Brian,
Thanks for reply...
I am using a voltage devider for measuring the batt terminal voltage. the rule is using a voltage devider that scale downs 20v to 5v. so in bascom code, i just do the math to scale the 2V to up to 4 times as 8V. it works fine so far.... (i just checked and also solved the adc reading problem... there was a code mistake... logically it though should not be... but well, it is working now...)

the batt temr voltage i can read. also it can read the current. I now have to check the amp for a fine tune. and ohhh i'm expeciencing one thing... very unstable reading... if i use a digital multimeter to read a dc volt, and at the same time the adc, then adc gives results with +/- 250mV with cont. swing. i'm lookin for a stable reading...

and i have checked the datasheet of 2n2222 and 2n2222A. There is a different pinout of them (i found) like the base is middle pin and first pin... this way it is making trouble... let's check as i also have checked my other schematics with pcbs those are working perfectly.... i think i should make another pcb and try once again...

Added after 3 minutes:

opps.. forgot... dafinitely using 741 with ICL7660 as negative supply....

Added after 1 minutes:

and so far i guess... to bias a pnp, i need voltage more than .7v at the base right???
 

You need around 0.65 to 0.7 volts to turn most transistors on.

I'm still confused where your PNP transistors are. All the transistors should be NPN and both 2N2222 and 2N2222A are NPN. I agree the pin layout is different between metal and plastic packages but the transistors themselves are basically the same.

If you are re-designing the PCB, make provision for adding a fixed resistor in the collector of Q2 and Q3 as well as the variable one. You can always link out the fixed one if necessary.

Brian.
 

About 2n2222 and 2n2222A, I also know the same... one is low freq and another one is high freq. again i found that 2n2222A is a metal package and the middle pin is the base (pin#1). But i designed CAD with this one and choosed the TO92 where the pin 1 is the first pin and pin 2 is base (middle pin). there is the problem. when the cad generated with auto route, it assumed pin 1 (base) as the pin1 of the plastic package instead of the metal package. I changed my mind in a bit different way... remove the Qs and put them on a prototype board (vero board) using wires. This will help me to work out for the time being without the re make of the pcb/re designing the pcb. Just solder the proper wire to proper pin.

I'll do so later on when i'll make some other type of chargers based on this project. (Because in near future i will need charger for 24V-36V battery bank with around 25A for a backup PSU project for my server rack.)

about the fixed resistors, may i know the reason?? I can add them on direct pcb if needed... but well, next time i will keep that provision ofcourse...

Mishu~
 

I suggested the fixed resistors because at the moment, the variable resistors will allow you to set the voltage down to about 1.5V which is far lower than you would normally want. It also means that to set the voltage to charge the battery, the control will be 'almost' at one end of it's travel. If you can add a fixed resistor it should allow you to restrict the adjustment range so it only covers the voltages you need and it will also make the control less sensitive, and hence easier to set.

Brian.
 

Brian,
Is there any special difference between 2n2222a and pn2222a except pin diagrams and signal ability?? i'm using pn2222a. Seems same like 2n2222a.

Added after 59 minutes:

still not working... tried in your prescribed way...

doing a little check with 317... then i can make sure that the IC is not ok or ok... even swapped the pins with 1 with 3 and then another 220 burned that is for 3sec holdoff... the ckt is not liking the 220ohm resistors....

Added after 38 minutes:

nothing nothing nothing.... just nothing...
 

I checked the data sheets and the PN and 2N versions are almost identical so that isn't the problem.

Even if we assume the regulator is completely short circuited, the power dissipated in R1 could only be (assuming 15V before the regulator) 15*15/220 = 1.02W so it might get very hot but you wouldn't see fireworks, and that's assuming the control circuit is shorted as well.

It points to something being wrong in your construction I'm afraid. Without seeing it, all I can do is make some guesses and suggestions where to start looking:

Do these tests with the power OFF and battery disconnected!

1. Measure the resistance from the LM338 ADJ pin to ground, it should be more than 5KΩ

2. Measure the resistance between the input and output pins of the LM338. It is difficult to predict what it should be, and it may take a while to settle as the reservoir capacitors charge but it should be >500Ω.

3. The metal case, or metal mounting tab is connected to the output of the regulator, check it isn't shorted to anything else.

4. Check R1 is connected between the output and ADJ pins of the regulator and not from the output pin to ground.

5. Check D1 is wired the cathode to the rectifiers and not reversed. The schematic is correct.

6. If all the above seem OK, connect the ADJ pin directly to ground and power it up again. The voltage across R1 should be about 1.25V and certainly not more than 2V.

Let me know the results.

Brian.
 

i'm reading your last post... meanwhile, sharing...

i used 18v transformer. after all the connection, even the mega32 removed (the controller board unavailable), it is just showing 26V. using 317, same... just the 220ohm gets heated.. but not burned.... but 338 makes it burned...

i'm adding the whole thing togather including pcb. also the amp is not working and batt terminal voltage is working fine but current monitoring part is not working... vary unstable or false reading... and if shorted with GND, then shows zero...

mishu~
 

i'll make the whole pcb again... because this pcb has became a mess... but planning to work very slow... if this time it fails, i'll avoid this method and will look for another method...
 

Nice PCB !

When you say the current reading is unstable but is zero with the input grounded, between which points are you applying the ground connection?

The symptoms suggest there is a high impedance at the measurement point but there should be a 0.22Ω resistor to ground from there.

Brian.
 

betwixt said:
Nice PCB !

The symptoms suggest there is a high impedance at the measurement point but there should be a 0.22Ω resistor to ground from there.

?????? means?????

well, i just used the connector pin (jp6,7) for this test... not the pin...

Added after 1 minutes:

also did a little change in code.... 10 values and then average them... hope it will help... but if the values are not ghost values

Added after 2 minutes:

voltage part is workig beautiful... only the current part.... and planning to use without the amp also... let's check... lateron, i'll add the amp...

i dont understand... i made several 317 psus with VRs... in variable range (tunable) but this time it is not working... only difference is previously i used single pot for variable settings and now fixed settings driven by uC. complicated....
 

Sorry, I am not explaining clearly.

When you measure the charging current all you are doing is reading the voltage across the 0.22Ω resistor. Using Ohms law, you should drop 0.22 Volts per Amp of current and by using this voltage your software can calculate how many Amps were flowing.

For example, if 1 Amp flows, the resistor will have 0.22V across it, if the current was 3 Amps you would read three times as much, 0.66V.

The ATmega32 has a 10-bit ADC so you can get 1024 different values out of it from zero to ARef (pin 32 voltage which in your schematic is 5V) giving 0x3FF. Assuming you are using ARef and not the internal reference, this means that at the maximum 5A current, the voltage across the resistor will be (5x0.22) = 1.1V which uses less than one quarter of the ADC range. Looking at it the other way around, each change of one digit in the ADC reading equates to just over 22mA of current.

The purpose of the 741 is to amplify the voltage dropped across the resistor so more of the ADC range is used and therefore each step in reading is made smaller. This also makes the in-built inaccuracy of the ADC appear smaller which is good. The drawback is that any noise in the system, including ripple from the rectifiers is also amplified and the sample point of the ADC could catch a peak or dip in the noise, giving random readings.

Two things come to mind - the noise really could be so much that the reading fluctuates or, the ADC is not sampling properly. You say that shorting the input to ground results in an ADC reading of zero, do you mean you shorted out the 0.22Ω resistor at the input to the amplifier or you shorted out the ADC pin on the ATmega?

If shorting out the resistor made the ADC read zero, something is wrong with the resistor or you are reading a voltage drop somewhere else in the wiring. If it only went to zero when pin 20 of the ATmega was grounded, there is noise in the amplifier stage.

I would suggest trying this:

1. Change the amplifier for a better one, I suggest either a TL071 or TL081. These have better performance, lower noise and are direct drop-in replacements.

2. If idea 1 doesn't work, rather than averaging lots of readings, try adding a delay between selecting the ADC channel and taking the measurement. The ATmega only has one ADC and you are switching it between different measurement pins, try selecting the current measurement pin, waiting for 1mS then measuring to see if settling time is the problem.

3. Involves hardware, add a 470Ω resistor in line with the ADC measurement pin on the ATmega and add a capacitor of 100nF from the pin to ground as close as possible to the IC itself. This will electrically filter some of the noise and should help to average out rapid voltage changes.

Let me know the outcome.

Brian.
 

Dear Brian,
about adc zero reading, i think there is lots of noise in the line and thus adc is not getting stable. no matter if i remove it from .22ohm or not. even when disconnected from .22ohm, it sometimes giving paranoid readings... false readings and after shorting the adc pin to gnd, it gets 0.

Since making the pcb again, well, strange things happened while i was working with the adc part. I have taken out the controller board and powered and loaded the firmwire made for the job. then i added a lm35 and took the output using meter. it was 310mV for my room temp. and i directly fed it to the adc of current measurement and got a clean reading for the same... since i made the software for .3mV 3V, it is showing me that 3A is the current. Also fed 5v as batt terminal voltage (dummy) and i'm getting a less 3.something (i'll check with the pot for the voltage devider for scaling 20v down to 5v). so for now i'm assuming that the current readings are okey...

well then i turned on my frs radio for a while and made a tx with .5w on gmrs ch1. it is in uhf. the ant of my set was within 2ft and the mega got hang. then after i stopped tx, it got reset. i also checked with a vhf 5w set and happened the same. seems that the ckt is very sensitive to RF emmission. So i need even shielding (if not for this project but later on, for ever... specially my inverter project). any ideas??

i'm a bit confused... so sharing with you... i've scaled 20V down to 5V. so at 20V, adc will get 5V. now when i'll take the reading, i'll multiply the adc value with 4.89 (my multiply factor) and then devide by 1000 (5000mV = 5V) and then multiply that by 4 (5x4=20) right???

Also planning to use without any amp since 22mV is okey with me... 22mV means 220mA. so if i can just measure minimum 300mA, then i can decide for float mode...
Mishu~
 

I'll look through your code tomorrow, it's late here and I need sleep (need LOTs of sleep!)

The problem of RF getting into circuits is very common and I have even worked on VERY VERY expensive (>$10M) military computer systems that crash when a mobile phone is used near them. You can completely screen the whole thing but you will find it much easier to place small capacitors (10pf - 20pf) between all pins of the ATmega and ground. Except of course the ones going to the crystal. Also, if you have long wires leaving the PCB, it might be worthwhile to loop them through ferrite rings to increase their inductance slightly.

I have never used the ATmega processors but I think I'm right in saying they have a built in ADC reference regulator. It might be work trying to use it instead of the main supply line. The lower reference voltage it provides will make small input voltages produce higher ADC readings.

Brian.
 

man... capasitor in each pin??? damn!!! that's gonna be a pcb... owwww...

there are wires of course (hdd connector connection from power board to controller board.)... you know what??? so many things are unavailable in retail market in bangladesh. anyway, i'll try my best to solve the rf problem using ferrite and screening. but before all, i have to make the power board again...

this time i'll not use the part of Q4 (i'll add it later). also the amp. since i can easily read the lm35 (though not precise due to 5v ref... it should be 2v ref. because 5v ref gives 4.8mV resolution.. but that's enough now)., i'll add the amp later. let's first see what is actually happemning...
 

You are lucky to have a market! The nearest place I can get parts is about 100Km away so I have to rely on the postal service. And the Post Office is on strike at the moment !

Brian.
 

off the topic though...

yes, i have the market here, where the shopkeepers are 420. (420 means cheat. 420 is a rule number in our local law against cheating)... but for only the components for repair job of CRT TV, old CD-Casset player,... cell phone repair(though when they work on power, the network also need to be repaired after that and then again after that the audio part and finally the cell phone becomes a new one after lots of replacements, those were collected from other sets..). Some items are here for some stupid students who claim themselves as super engineer (though they still needs hand to tight a screw). For their very very special ROBOTICS Project (where a CCTV cam mounted and a toy RC car is the basic part.) there are some stupid steppers and some very common uCs. though some of them are in low voltage version like I can found tons of mega32L here but not mega32. 32L can not handle higher xtals where i need precision result most of the times. The market is rich, full of garbage. not so far, though i have to ride (using my 150cc bike) through 30-45mins of traffic jam (sometimes more... when i have to finally use the pavement).

I prefer someone like digikey with postal service... i can go to 100miles using my bike if it is a free road just for the perfect item in a good price...


anyway, i was bit busy with my versity course registration for the new semester and now i'm gonna start it again (the project)... will dafinitely give you the update...

Mishu~~
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top