FT232RL eeprom and PWREN#.
Tracy Allen
Posts: 6,664
I'm working on a device that won't itself draw much operating current from USB, but it wants about 250mA to charge a Li-ion battery that runs the device when not connected to USB. That exceeds the initial 100mA USB limit. The docs suggest that I should use the MPROG.exe utility to program 250mA into the Max Bus Power setting of the FT232RL eeprom. And I should wire the PWREN# pin to enable the charger, which will happen once enumeration is complete and the host allows it. I see the example circuits from FTDI, and Parallax uses such a circuit to enable power to the #32910 activity board. Is that pretty much it? I don't see an example specifically related to battery charging.
I'm wondering if anyone here has fiddled with those parameters and the MPROG utility and might have pointers on what is important and what not. Also, has anyone experienced grief from installing MPROG.exe?
I'm wondering if anyone here has fiddled with those parameters and the MPROG utility and might have pointers on what is important and what not. Also, has anyone experienced grief from installing MPROG.exe?
Comments
Never had a problem since...
In fact, I think in most cases you could get away with drawing straight from +5V, without using enumeration.
But, it's probably safer to do it the hard way...
Also, I vaguely recall something about an even higher current rating that newer USB chips can negotiate for battery charging. FT232RL doesn't have that though.
Your other -- perhaps better -- option would be to use one of FTDI's more recent devices. And take a look at the schematics for the Propeller ActivityBoard.
Finally, be sure to consider using LVC buffers on the serial lines to prevent powering up the FTDI chip from P30/31 and causing errant resets.
Parallax's David Carrier is probably your best source for the most current FTDI tricks'n'traps.
-Phil
The best part to use as a reference design for the FT231X circuit is the Propeller QuickStart. Below is a copy of the XML file of the settings that we use with FT_PROG. You'll notice that MaxPower is set to 500. You may want to set it lower, if you know that your power usage not exceed a lower value. (This will allow your device to work on an underpowered hub, if there is enough power available from the root hub.) We set the C0 pin to BCD_Charger# and C3 to PWREN#. When the FT231X is connected to a USB charger, it will drive C0 low. When it has innumerated on a USB port and the allotted power is available, it will drive C3 low. Please be aware that C0 can switch between floating a driving high while the FT231X is enumerating. This can cause glitching on the supply lines if it is not accounted for. As shown in the Propeller QuickStart schematic, we pull the output of the CBUS pins to the FT231X's power input pin and also run the signal through an RC filtier with the capacitor connected to the same power input pin. This ensurse that the output stays off until signalled to turn on, as the capacitor will not charge until the FT231X drives C3 or C0 low.
You can use the XML file listed below with FT_PROG by coppying the text and saving it to a file with an XML extension. When you have enumerated a device in FT_PROG, you can right click on it, click "Apply Template", select the XML file you created, make any modifications you need, then program the new settings into the device. Be sure to change the Manufacturer and Product_Description strings to match your product.
David Carrier
Parallax Inc.
David, I see FT-PROG has replaced MPROG for configuring the FTDI devices. MPROG and the FT232R do not support the <Battery_Charge_Detect> options. Just to be sure, let me ask about the meaning of USB charger as opposed to a USB port. I'm guessing that a USB charger is simply a 5V source of power with no capabilities of enumeration, and the simple presence of that power will cause your C0 BCD_charger# pin to go low. After enumeration, both pins go low. Still, they glitch at start-up and need to be filtered if it matters. Is that a fair rephrasing?
Another minor question, the quickstart and the #32910 activity board both use the FT231X, but the circuits for current limiting are quite different. The activity board uses the TPS2552DVB "current limited power distribution switch" rather than the pmosfet. One shown to be preferable to the other?
My circuit really need only control the battery charger, because the rest can coast along at milliamps. The Prop (running at low power) could I think monitor PWREN# and BCD_Charger# directly and throttle the charger until one or the other goes low.
Phil and Ray, thanks for the comments and links. That 2008 thread is quite informative. USB ports do seem to be tolerant of more than 100mA. Maybe the chips and designers don't check that carefully to fit to the standard. My Mac laptop does definitely reach a point though, sadly experienced, where it shuts down a port and complains bitterly about the excess.
As a point of reference, I've made a LiPo "shield" for Propeller Platform that charges a 1000 mAh battery while also powering a 4.3" touchscreen with total current draw of ~400 mA.
Here's the battery charge circuit:
And floating or reattaching that pin puts it in shutdown or initiates a charging cycle respectively.
Perhaps there's a simple way to have the charger supplied by +5V and let the LiPo generate 3.3V through a buck/boost converter that can be shut down by the FTDI chip.
I verified Phil's measurements from the earlier thread, about the glitch.
Channel 2 is the input USB power, being applied. Channel 1 is the PWREN# output from the FT232R. Trace A zooms in on the first glitch pulse, about 13ms long.
I'm a huge fan of three-terminal supervisor chips for apps where you need a comparator output for a fixed voltage threshold. They're simple and cheap, and they come in a wide range of trigger points and hold delays. Maybe one will work for your battery lock-out circuit. The one 'feature" you have to accommodate is that they're powered by the voltage they're monitoring. So look carefully at the datasheet specs for the minimum operating voltage.
-Phil
Was just looking at the LTC4090 and it seems pretty reasonable. I don't think it prevents the battery from being drained though.
Perhaps there's some way of using Phil's three-terminal supervisor chip to disable it when the battery is low...
This starts to get expensive and big and complicated though...
Real battery protection ICs have a feature that prevents charging of a near dead LiPo. Don't want a fire. The charger (LT4054 or MCP73831) may handle that okay though, with the trickle charging feature.
Ray, the LTC4090 does not have a lockout feature. One can purchase the LiPo with the protection board built-on, or buy the protection board separately. However, for a single LiPo cell that does not need the cell-balancing, it would seem better to build the protection onto the application board. I've used the LT4071 which does have the lockout transistor on-chip, or the LTC4070 which has a control pin for one. The LT4071 reduces the locked battery drain to nanoamps. Those are low-current parallel chargers though, meant for energy harvesting less than 100mA.
Maybe I could use the LTC4090 to control USB power and battery charging and high voltage input buck.
Add an MCP102 hooked to a 3.3 V LDO with shutdown pin. That seems to cover all the bases...
Actually, maybe Tracy's way with N-mosfet in series with battery, controlled by MCP102, is better...
Or, maybe I'll just forget all this and have the Prop monitor the battery voltage and shut everything down if it gets low.
This is maybe easiest since I already have a touchscreen chip with a battery voltage monitor input...
Check out the description of the USB Battery Charging Specification on Wikipedia. The charger signals that it is a charger by connecting D+ and D- with a less than 200 ohm resistor.
The QuickStart doesn't have any over current protection. It disables current draw until the device is enumerated, but it is up to the end user to make sure they do not draw too much current. The Propeller Activity Board and Propeller Board of Education, on the other hand, have over-current protection. The TPS2552DVB power distribution switch also disables current draw until the device is enumerated, but it adds over-current protection.
Regarding others' discussions of USB ports supplying more power than expected, USB specifications allow a root hub to provide more power than requested and requires the port to supply 20% more power than requested. They may also limit current for a bank of USB ports instead of a single port, so it may take a few amps to get an over-current condition on a root hub.
— David Carrier
Parallax Inc.
Shooting for 90mA before enumeration, 400mA after, and 600mA from a dedicated charging port and near zero in suspend.
I might switch to FT231X one day. Last time I looked the datasheet called for external ESD protection. Did they take that away? Or, did you figure out that we don't really need it? The FT232R says it has internal ESD protection...
Update: Just looked at FT231X datasheet again and I see that USB data lines need a RC filter...
That's better that I remember...
Still, when working with 0805 parts, I lose a lot of the size advantage due to the need for these 4 extra parts...
The LTC4090 is a swiss army knife of functions in its 22 pin DFN--It makes my LTC4054 in 5 pin sot23 looks like a pointed stick in comparison. Even with 22 pins it would save board space over having to cover all of its power path options from scratch. I'll be interested to hear how it works if you get a chance to follow up.
The LTC4054 is a linear charger so even with good heat sink its maximum current is 800mA. I'll be running the project directly from the battery, probably no more than a 1.8 Ah Li-poly. The project itself draws less than 10mA on the average.
So, I'm back to thinking about the MCP73831. Problem for me is that it doesn't have "load sharing".
But, I found this page that describes how to implement that based on an app note (AN1149) with just a few parts:
http://blog.zakkemble.co.uk/a-lithium-battery-charger-with-load-sharing/
So, that's my new plan...