Shop OBEX P1 Docs P2 Docs Learn Events
FT232RL eeprom and PWREN#. — Parallax Forums

FT232RL eeprom and PWREN#.

Tracy AllenTracy Allen Posts: 6,664
edited 2014-08-07 11:27 in Propeller 1
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?

Comments

  • RaymanRayman Posts: 14,646
    edited 2014-06-23 16:29
    I used to use MPROG to raise current level. But, then I saw that nobody else did and it always worked anyway, so I stopped.
    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.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-06-23 16:40
    The PWREN# circuit recommended by FTDI for the FT232RL is not very good as a soft-start solution, due in part to a start-up glitch on that pin. Take a look at the schematic for the MoBoStamp-pe (#28300) for how I solved the problem. Here's more info: http://forums.parallax.com/showthread.php/100196

    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
  • RaymanRayman Posts: 14,646
    edited 2014-06-23 17:41
    The datasheet now says we should have a pullup on pwren#. I think I have seen this startup glitch also. But, I don't think it's been a problem for me. Maybe because that glitch is faster then the Prop boot time?
  • David CarrierDavid Carrier Posts: 294
    edited 2014-06-23 18:37
    Tracy,
    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.
    <?xml version="1.0" encoding="utf-16"?>
    <FT_EEPROM>
      <Chip_Details>
        <Type>FT X Series</Type>
      </Chip_Details>
      <USB_Device_Descriptor>
        <VID_PID>0</VID_PID>
        <idVendor>0403</idVendor>
        <idProduct>6015</idProduct>
        <bcdUSB>USB 2.0</bcdUSB>
      </USB_Device_Descriptor>
      <USB_Config_Descriptor>
        <bmAttributes>
          <RemoteWakeupEnabled>true</RemoteWakeupEnabled>
          <SelfPowered>false</SelfPowered>
          <BusPowered>true</BusPowered>
        </bmAttributes>
        <IOpullDown>false</IOpullDown>
        <MaxPower>500</MaxPower>
      </USB_Config_Descriptor>
      <USB_String_Descriptors>
        <Manufacturer>Parallax Inc</Manufacturer>
        <Product_Description>Propeller QuickStart</Product_Description>
        <SerialNumber_Enabled>true</SerialNumber_Enabled>
        <SerialNumber />
        <SerialNumberPrefix>DA</SerialNumberPrefix>
        <SerialNumber_AutoGenerate>true</SerialNumber_AutoGenerate>
      </USB_String_Descriptors>
      <Hardware_Specific>
        <USB_Suspend_VBus>false</USB_Suspend_VBus>
        <RS485_Echo_Suppress>false</RS485_Echo_Suppress>
        <Port_A>
          <Hardware>
            <Device>FT230X/FT231X/FT234X (UART)</Device>
          </Hardware>
          <Driver>
            <D2XX>false</D2XX>
            <VCP>true</VCP>
          </Driver>
        </Port_A>
        <Battery_Charge_Detect>
          <Enable>true</Enable>
          <Power_Enable>false</Power_Enable>
          <Deactivate_Sleep>false</Deactivate_Sleep>
        </Battery_Charge_Detect>
        <Invert_RS232_Signals>
          <TXD>false</TXD>
          <RXD>false</RXD>
          <RTS>false</RTS>
          <CTS>false</CTS>
          <DTR>false</DTR>
          <DSR>false</DSR>
          <DCD>false</DCD>
          <RI>false</RI>
        </Invert_RS232_Signals>
        <CBUS_Signals>
          <C0>BCD_Charger#</C0>
          <C1>RXLED#</C1>
          <C2>TXLED#</C2>
          <C3>PWREN#</C3>
        </CBUS_Signals>
        <IO_Pins>
          <DBUS>
            <SlowSlew>false</SlowSlew>
            <Schmitt>false</Schmitt>
            <Drive>4mA</Drive>
          </DBUS>
          <CBUS>
            <SlowSlew>false</SlowSlew>
            <Schmitt>false</Schmitt>
            <Drive>4mA</Drive>
          </CBUS>
        </IO_Pins>
      </Hardware_Specific>
    </FT_EEPROM>
    
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-06-23 22:06
    I've used the FT232RL on self-powered and low-powered projects, but this is the first time I'll be asking it to supply more than the 100mA. I'm not familiar with the FT231X, but it sounds like a good bet, not the least due to the smaller SSOP20 package.

    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.
  • RaymanRayman Posts: 14,646
    edited 2014-06-24 02:55
    I think the point at which PC/Mac complain about USB power is above 500 mA...

    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:

    Lipo_charger.png
    538 x 303 - 5K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-06-24 13:05
    Ray, that is the same circuit I have, except using the pin-equivalent Linear Tech LTC4054-4.2. I do like Linear Tech products and sometimes extra features and care with the specifications, but I don't like paying the 7x premium price. I'll certainly look into the Microchip part. It is the charge current programming resistor on pin 5 that I want to control with PWREN# and BCD_charger# from the FTxxxxx. That is the same on either chip. Icharge = 1000 / Rprog.
    And floating or reattaching that pin puts it in shutdown or initiates a charging cycle respectively.
  • RaymanRayman Posts: 14,646
    edited 2014-06-24 15:43
    I'm still thinking about the simplest way to integrate a LiPo battery in my setup...

    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-06-24 18:59
    I'm running the Prop and other circuits at 3V, so that they can run off the LiPo via a low-dropout linear regulator even when the LiPo is down to 3.1V. Below that, I'd like to shut down and lock out the battery until the charger is reconnected. Right now I have a Seiko battery protection IC on the board, but I'm not happy with it because it doesn't lock out the battery until it drops below 2.7V.

    I verified Phil's measurements from the earlier thread, about the glitch.
    FT232_wpren_glitch.png

    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.
    640 x 480 - 8K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-06-24 19:52
    Tracy,

    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
  • RaymanRayman Posts: 14,646
    edited 2014-06-25 06:17
    I'd like to find a power supervisor chip to make things better... There are just so many options...

    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...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-06-25 08:11
    Good call Phil. Something like the MCP102 should work, with ~1µA quiescent current, totem pole output, and 3.08V threshold. It is active low, so for battery detection it could drive an N-mosfet in the (-) leg of the LiPo so that the battery is locked out when it drops below that threshold. This has nothing to do with PWREN#, except that the charger would feed the positive terminal of the battery, in a way such that the battery can be unlocked for charging. The reverse current into the charger IC adds a couple of µA to the lockout drain.

    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.
  • RaymanRayman Posts: 14,646
    edited 2014-06-25 08:46
    The system I'm thinking about has several ICs, so just holding the prop in reset may not stop power usage...

    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...
  • David CarrierDavid Carrier Posts: 294
    edited 2014-06-25 17:19
    Tracy,
    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-06-26 08:48
    Thanks David, that is very informative. It will take a while to absorb the ramifications. I take it the BCD_charger# pin on the FT232X it ties to the presence of the short circuit (<200Ω) across the D+/- lines.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-07-07 13:08
    I've reworked the board to use the FT231X instead of the FT232R. Nice and compact. The app note from FTDIchip was helpful, AN_175 "battery charging over USB with FTEX devices". It goes into a lot more detail about the pin states. Figure 6 there shows the battery charging connection that allows several charge levels using 3 of the FT231X pins, and that is what I'm aiming for. Here is a tentative schematic..
    USB_chrg.png

    Shooting for 90mA before enumeration, 400mA after, and 600mA from a dedicated charging port and near zero in suspend.
    580 x 433 - 44K
  • RaymanRayman Posts: 14,646
    edited 2014-07-07 15:03
    Thanks for sharing that. I may switch to that, but first I'm going to try the LTC4090-5. One benefit I hope to get is very fast charging using wall adapter power and regular charging using USB. Also it controls the total USB current, not just battery charging current. This could be an all around good solution if the LTC4090-5 works even with no battery attached...

    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...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-07-07 16:57
    Table 5.2 in the FT231X data sheet summarizes its ESD protection, but I don't see an equivalent table for the FT232R. Are you referring to the pair of resistors in series with the USB inputs? Those are internal on the '232R but need to be provided externally on the '231X. They provide line impedance matching and a bit of protection.

    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.
  • RaymanRayman Posts: 14,646
    edited 2014-08-07 11:27
    Hope Tracy is having better luck than me... I started laying out the LTC4090 and realized the pad spacing on the DFN package is tiny. Also it takes a lot of extra components to make it work. But the real problem is that I don't trust my assembly procedure enough for power traces going to a DFN with tiny pad spacings where I can't visually inspect for shorts or opens :(

    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...
Sign In or Register to comment.