ATMEGA 32u4 + USB lypo charging + Voltage regulator = Strange Stuff! - Page 1
Forum section: electronics / projects

author: fax8
author_rank: Contributor
timestamp: November 07, 2012, 07:33:19 pm
content: Hi everyone,I'm trying to debug a project I designed, since I'm seeing some weird effects... I attach the schematics of the project.So, it is mostly based uponSparkfun's Fio v3 board.. I added sensors and bluetooth module and kind of transformed the Fio v3 into a prototyping board for remote controller.. that was the point of the project.Btw, I'm trying to understand a couple of weird effects I'm seeing and I hope you'll be able to help me. The board has an USB port, a 110mAh lypo battery, anMCP73831lypo battery charger an ATMEGA32u4 connected to the USB port and a 3.3v MIC5219 regulator to provide power to the microcontroller.Here are the stange things happening:Only battery connected with SW102 closed, I read VBAT=4.12V, VCC=3.3V, VUSB=0V .. this is perfectly fine..Battery and USB connected with SW102 closed, VBAT=4.12, VCC=3.3, VUSB=5.12V .. this also looks fine..Battery and USB connected with SW102open, VBAT=4.12V,VCC=1.7V, VUSB=5.12V .. This is problem 1Battery disconnected and USB connected with SW102open, VBAT=4.33V,VCC=1.6V, VUSB=5.12V ... problem 2Battery disconnected and USB connected with SW102closed,VBAT=2.92V, VCC=2.66V, VUSB=5.12V .. microcontroller crazy (resets) .. this is problem 3.Ok, so.. my understanding of these problems is this:Problem 1 and 2 are basically the same.. my guess is that since my SW102 doesn't cut out VUSB from the USB port, then the ATMEGA 32u4 is somehow powering up from that and somehow a 1.7V arrives into the VCC rail.. I had a look at the datasheet but found nothing specific about this. My solution would be to use a dual slide switch which would also cut out the VUSB voltage.Problem 3.. I'm not entirely sure.. the MCP73831 does seem to be able to work without a battery connected.. however, datasheet seems to be a big vague on this.. my best bet would be that it is not able to provide enough current or voltage to the VCC rail and then the microcontroller is not able to properly work.. My guess is that I will have to use another charger chip or simply require the user to always have a battery connected. But, I would appreciate your view on this one and possible solutions.What do you guys think? Suggestions, ideas?Thanks for any kind of help,Fabiop.s.: yes,the transistors resitors are wrong.. I fixed them in the prototype.

author: SeanB
author_rank: Super Contributor
timestamp: November 07, 2012, 07:55:47 pm
content: The charge controller ideally should be the only thing connected to the battery, as it does both the charging and low voltage cutout. But at 500mA ( as you have it) the motors probably will not work well. You will have to choose a battery manager that has a higher discharge capacity, or that uses an external pass mosfet or has an internal switch that can handle 1A or more to the load. Running it without a battery will not make it happy, as it will be trying to recondition a non existent cell always by giving a low charge to bring it up to 3V before it switches to a higher charge current. This is the oscillation of the micro. You should run the voltage regulator for the micro from the usb and not from the battery.I am going to use the same ( in the teeny tiny package as well) dead bugged to some heatsinking as a charge controller soon.

author: jeroen74
author_rank: Frequent Contributor
timestamp: November 07, 2012, 08:06:44 pm
content: There are LiPo chargers that can handle both a load and charging at the same time. Like the LTC4098. The 1.7V is probably due current flowing into the protection diodes that's on each pin of the AVR, and that indirectly feeds the VCC rail.

author: PA0PBZ
author_rank: Super Contributor
timestamp: November 07, 2012, 08:31:18 pm
content: Disconnect UVCC (pin 2), see the datasheet page 256.

author: fax8
author_rank: Contributor
timestamp: November 13, 2012, 12:16:41 pm
content: Thanks guys for your help, I really appreciate it.I'm trying to come out with a solution which should fix all the issues elegantly, without massive changes in the circuit. I tried to lookup for lypo chargers allowing for both battery and load to be connected there but I've only been able to find ICs which require many additional components and make the circuit much more complex.So, I decided to keep the same ICs in the bugged design above but using p-channel mosfet as power selection to the main voltage regulator. The idea is to use one p mosfet to connect the battery to the VCC regulator when there isn't any power coming from USB (USB disconnected) and instead to connect the USB power to the VCC regulator when USB is connected, when USB is connected the lypo charger should also be enabled but in this way only the battery would be connected to it since the main load would be connected to the VUSB.I attach the schematics here, I hope you guys could have a look at it and tell me what you think. Thanks a lot. Fabio

author: fax8
author_rank: Contributor
timestamp: November 15, 2012, 02:13:03 pm
content: Nobody can help checking the above schematics?

author: free_electron
author_rank: Super Contributor
timestamp: November 15, 2012, 03:18:08 pm
content: What is it with all these schematics floating around on the internet that are nothing more than a bunch of netlabels glued on a pin. Haven't you guys ever heard of wires ? Busses ?How the hell are we to know what is connected where. You dont even take the time to place a stub of wire underneath a netname , assuming it will connect. And in other locations you have wires crossing netnames. That may create unwanted connections ! There may be a big fat short or unwanted connection in your schematics to begin with and you would not be able to tell.Clean up that schematic , connect pins and parts with wires instead of scattering netnames everywhere. A pcb design begins with a clean, properly annotated , documented schematic. Not with a bunch of netnames placed close to some pins.

author: PA0PBZ
author_rank: Super Contributor
timestamp: November 15, 2012, 03:24:07 pm
content: I totally agree, a schematic should read as a story, not as a book where you have to go back to the index each time to find where the next sentence is.

author: jeroen74
author_rank: Frequent Contributor
timestamp: November 15, 2012, 03:35:10 pm
content: I totally agree. Labels do have their place of course, but at least group and connect them together with bus wires. And use logical groups like all the connections to a LCD module, or a group of buttons.

author: free_electron
author_rank: Super Contributor
timestamp: November 15, 2012, 04:25:17 pm
content: check power_flag at pin1 of u 103. plug in usb , close sw102 : vusb now lands on +batt ...this is the kind of errors that is avoided by drawing CLEAN schematics !

author: free_electron
author_rank: Super Contributor
timestamp: November 15, 2012, 04:40:33 pm
content: attached some comments on the schematic.

author: amyk
author_rank: Super Contributor
timestamp: November 15, 2012, 05:01:49 pm
content: Quote from: free_electron on November 15, 2012, 03:18:08 pmI've noticed this "loose parts with labelled pins" trend in "professionally" drawn schematics too, i.e. for laptops and such. I think most of it is just because they're just lazy and/or don't want to "waste time" routing the wires between the parts, although in some cases like a 600+ ball BGA it's probably acceptable. I'd use net labels only for main power rails or other nets with very many parts connected to them.

author: free_electron
author_rank: Super Contributor
timestamp: November 15, 2012, 05:08:21 pm
content: And a 'DaveCad' style intro Drawing EFFECTIVE schematics

author: free_electron
author_rank: Super Contributor
timestamp: November 15, 2012, 05:14:08 pm
content: Quote from: amyk on November 15, 2012, 05:01:49 pmThose are most likely synthesized schematics .... there are tools where you can describe mass interconnects in tabular form. The tool then synthesizes a 'schematic' but it is actually driven from a table. We do that for bulk interconnects between a cu and memories for example. it's a simple excel spreadsheet. : Net name in column subsequent columns have pin nunbers with the designator as header row.very effective for huge busses. a script then spits out schematic symbols and crosslinks it with netnames. totally unreadable , but fully correct.pinswaps are simple : fix the table and hit 'generate' : faster than doing this on 50 pages of schematics.but that is NOT the case in this post ... this post is a typical hard-whino style schematic. made by programmers who think that a loose assortment of parts with a pile of netnames is a schematic. And then you end up with crap. like a netnode somehwere it is not supposed to be giving a big fat short if you do something. simply because there is no clean way to follow the current flows.another thing that makes me 'growl' : ic symbols drawn with the pins in numerical order. Please make a 'variant' of the ic symbol to fit your schematic. Most (decent, and worhty of the designation 'schematic design tool' ) tools allow you to have variants in the library.open lib , pick part -> add variant -. reposition pins so you don't have 347 crossing wires in your schematic. then place that variant.if its a single opamp it becomes a triangle with 5 pins : vp , vm + - outif its a thing like a dual opamp : create 3 parts : 2 opamps and a 'power' partu1a : + - outu1b : + - outu1c : vp vm <- power railsthat way you can shove those out of the way and you dont need to worry if you do a swap between u1a and u1b to move the connectionswhen creating a symbol : take care to define pin direction and types as well. i too violate this rule too often... the ERC checker can trap floating input and shorted outputs if you feed it correct info. We have oodles of compute power and automated rule checking and then deliberately choose to circumvent and defeat it to define all pins of a component as 'passive'. and people wonder why autorouters create mess.. how is this poor router to know what is the driving node and what is the receiving node. if you define something as output and it is connected to 3 parts defined as input then the router already has a bit of info knowing where the signal originates. of you then tell it : daisy chain routing or star routing it will create the correct route pattern.A PCB begines with a correct, readable , clean , annotated schematic. if the tool allows you to place directives for PCB then PLACE them in the schematic. it avoids questions during routing. is this differential ? is this critical ? is this flight-time critical ? does this need length balancing ? it's all there , in the schematic , defined at design time, and it will get pushed to PCB as design rules. If you dare step 1 mil out of line while routing, the realtime DRC checker is going to be snarling and growling at you .