PIC and MOSFET in switch mode

Discussion in 'Embedded Systems and Microcontrollers' started by french_guy, Apr 16, 2009.

  1. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Hello

    I'm using a PIC and want to make a prototype to discahrge 1 Nimh cell (1.5V at full load) thru a 0,5 Ohm/10Watt resistor
    I would like to use a Mosfet to switch ON and OFF the discharge
    Is the attached drawing OK?
    Can I use a IRF1104 (I have some of them available)? Is it going to be in switch mode with 5V only?

    Thanks
     
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,670
    897
    The IRF1104 is designed for 10V at its gate. It will not turn on completely at 5V from the PIC and will get very hot. See Figure 3 in the IRF1104 datasheet.

    Look for a logic-level mosfet that you can get in your area.

    John

    Edit: I also put a small resistor between the mosfet gate and PIC to limit the current to the maximum allowed per pin (probably 25 mA). That resistor slows down turn on a little, but protects the PIC.
     
  3. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    What would be an "easy to find" logic level MOSFET?
    With the right MOSFET, is my drawing OK?

    Thanks
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    International Rectifier has a "help find the right MOSFET" guide. I'd suggest looking under motor control applications.

    If this is also going to be a battery charger, to check efficiency of batteries from AH Measured to AH Charged, time taken, internal resistance, and other parameters, I'd suggest an H-Bridge drive, using a "MOSFET Driver IC" (also on IR's site) to boost the gate voltage for best switching. Might also add in a temperature sensor (both charge and discharge) and the Delta V algorithm (for optimal charging).

    The IRL series MOSFETS have a logic level input, but do not switch as quickly or handle as much current as their counterparts driven with a MOSFET Driver. See the thread titled "MOSFETS" for more info.
     
  5. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,670
    897
    I think the schematic is fine, if you add a gate resistor as suggested.

    As for the mosfet, you can search DigiKey's paper catalog for logic- level mosfets or electronic catalog and filter for low Vgs. Unfortunately, the electronic version doesn't include the term logic level. Mouser has similar parametric searches. The key thing to look for is a value for Rds(on) with a gate voltage of 5V or lower (it is often at 4.5V).

    There are lots of possibilities and not knowing where you are or what sources you have, it is impossible to recommend something that would be easy to find. If you can get International Rectifier products, its part numbers for logic-level often include an L in the number. For example, the IRFZ44 and IRLZ44 are similar, but the latter is logic level.

    John
     
  6. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Thanks for your comments...
    I won’t use this as a charger…I already have one
    Actually, I bought 2 x 7.2 Ni-Mh battery packs (4200mAh) few months ago, but I didn’t use them until now
    And after a couple of charge/discharge, I can only get something around 2500mAh for capacity
    So I dismantle one of the pack, and I’m trying to balance cell per cell (charge and discharge) and I’ll see what
    I can get after a couple of cycles
    The use of the PIC is more for fun (I have a Comfile PICBASIC PB-3H + Proto Board PNP3) and I thought it
    could be interesting to use it for this little project
    I think I won’t be able to find a logic-level MOSFET in my area (I only have Radioshack available)
    What do you think about that drawing?
     
  7. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Read This post by SgtWookie, which shows two MOSFET Drivers, and the simulated switching. Your application may not need that amount of performance, however.

    As long as RDSon of the MOSFET is a few milliohms at Vgs of 10 volts or so, the driver you show will work, adding a higher current boost would allow for faster switching (over about 100kHz). If using a lower frequency PWM, the single transisor shouldn't cause any major problems. Remember to use a good heatsink on the MOSFET.

    You may want to reduce the base resistor value depending on the transistor type to increase current and switching speed.
     
  8. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Actually, I plan to have the mosfet ON as long as the voltage of the cell is higher than 0.85V
    When the voltage of the cell will equal 0.85V, I’ll set the output of the PIC to 5V, then the MOSFET will be OFF
    and the discharge will stop
    There is not PWM in that driver…..
    May be I missed something???

    Thanks
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    My apologies, I assumed (shame on me!) That you were using PWM for a constant current drain to measure capacity.

    In your case, the turn on time isn't as much of an issue as the RDSon.

    You will want to choose an N-Channel that has the lowest RDSon for the available drive voltage and current.

    These two would fit that bill:

    FDA8440 $1.88 Each. RDS(on) = 1.46mΩ (Typ.)@ VGS = 10V, ID = 80A
    Datasheet

    Logic Level, simiilar to above - FDI8442 $5.06 ea.
    Typ rDS(on) = 2.3mΩ at VGS = 10V, ID = 80A
    Datasheet
     
  10. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Hummmm……Datasheet of IRF1104 says Rds=9mΩ @Vgs=10V, Id=60A
    Will this still be OK?
    Furthermore, I’m very interested in what you said about PWM to control the current, and then have the possibility
    to measure, under a constant drain current, the real capacity of my battery
    How would you do that? Same driver, but I’ll have to generate PWM out of the PIC to adjust the current?

    Thanks
     
  11. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    As long as you are under 0.01Ω (10mΩ), the heat dissipated by the MOSFET will be very limited relative to the current sense resistor.

    For a measurement, you would need two ADCs on the PIC, one sensing voltage across the sense resistor, and another to measure the battery voltage for cutoff at 0.9V, which is the Manufacturer average recommended min per cell alone, 1V while in packs.

    Set up the PWM For current drain, usually to simulate operating conditions of the cell, in an RC Car, a 10 second high current draw, followed by 3 seconds of low current, followed by a high current burst.

    The current/PWM would be set by the voltage drop across the sense resistor to be constant as the battery voltage drops. The battery voltage is measured after 5 second "rest periods", and if it is < 0.9V after a rest, or drops below 0.7V during a draw, the internal resistance is too high for the current being drawn.

    Summing the discrete measurements, V*I, over the discharge cycle would give you a rough estimate of capacity, as well as internal resistance, which is calculated by current divided voltage on the battery, rather than the sense resistor.

    For this application, 20kHz or so switching would be needed for constant current, and a 20Mhz clocked PIC can accomplish these tasks in addition to driving an LCD if the PIC has the ADC and ECCP modules in hardware.

    This means the MOSFETS shown above would need a harder driving circuit. The gate capacitance is the imporant parameter for switching, and RDSon is the important parameter for Dissipation. Vthreshold is sort of "meaningless" in a switching application, as it alone does not state the voltage required for the MOSFET to be fully turned on. Thus, the reason to use the voltage given with the RDSon specification.

    I hope that made sense... I believe there is source code on the net in C for a 16F877 for this application, I've seen it somewhere, anyway, that would give you a good head start as well.

    Needless to say, the Capacity will be quite a bit lower than what is printed on the battery, as that is from a C/10 discharge constant.
     
  12. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Wow…Looks like you’ve already worked on that topic!!!
    What should be the sensor resistance value (Ohm and Watt)?
    And what do you mean by a harder driving circuit?
    My main problem is that I’m using a COMFILE PICBASIC PB-3B, which has an interpreted Basic and is not that fast.
    It does have 2 outputs to generate PWM signals, but frequency is only 1.22KHz!!!
    I should have somewhere a Compiled Basic, which should be faster…some thing I should try

    Thanks
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    1Khz would work, though measuring the voltage (Does the Protoboard have ADC?) would require a diode and small capacitor to hold the level long enough for sampling.

    The "Harder Driving" circuit is explained in the link to SgtWookie's post above, essentially, more current than can be provided with a single transistor and resistor, needed to overcome the capacitance of the junction. However, at 1Khz, there are MOSFETs that would work with this as well. In the datasheets linked with the Digi-Key parts, there are graphs that show efficiency related to frequency.

    I'd suggest getting you original idea working, even if it isn't the "end goal", since you learn a lot as you go. Once you have a basic switch through fixed resistor drain, add in ADC Sampling of the voltage below the resistor to keep the current somewhat constant by varying the duty cycle of the PWM applied to the MOSFET. With only a resistor, less current is drawn as the charge in the battery is depleted.

    A constant current drain will give easier math, and mimic the actual application, as electronic speed controllers use a somewhat constant current when driving the motor at a certain speed through PWM.

    The best way to make a matched pack is to use a battery analyzer, could be as low cost as a Triton Jr. to cycle each cell 3-5 times, after going through a couple dozen cells, you have enough for two matched packs.

    This is NOT for Li-Ion! (Just for others reading...)

    A Sense resistor should be smaller than the combined RDSon of the MOSFET, and the cell's internal resistance. Usually 0.5 ohms, as you have above. A 5Amp drain would work for a starting point, which is about 2C of a Sub-C battery.
     
    Last edited: Apr 16, 2009
  14. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    All right...I'll make some tests, and let you know

    Thanks for your help, I appreciate
     
  15. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    Hello
    I went to my local Radioshack yesterday, and I found a 741 op amp.
    I was thinking about this driver to open/close the MOSFET
    What do you think?
    Gain is set to 2, and R3 is a pull-down resistor
    Let me know

    Thanks
     
  16. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    741s aren't that good of op-amps, a TL082 (Also a RadShack item) would be a much better choice. The 741 output isn't "Rail to Rail". I would suggest the single transistor driver you posted above over a either one, due to current ability.

    The problem with a small signal type op-amp driver is limited current. There is an effective capacitor at the gate of the MOSFET that needs to be charged, around 10nF is listed in the datasheet above. The actual "value" is not directly measureable, and varies widely, check the datasheet for your device for value, often in nanoCoulombs. Voltage at a low current charges a capacitor slowly, just like an RC Network.

    Dedicated MOSFET Driver ICs, such as the LM5112 can source 3 amps and sink 7 Amps, with a typical operating frequency of 100kHz, in the same package size as a 741 Op Amp.

    Zetex has a couple Application Notes and And Here - Nicely written which go in depth with schematics and formulas for building your own driver with BJTs.
     
  17. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    OK…I'll use the NPN driver
    Should I put a pull-up resistor (10KOhm) somewhere if I want to be sure that the transistor will be saturated (and then the MOSFET open) if the PIC is not powered for example (see drawing)

    Thanks
     
  18. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The MOSFET will conduct continually if the PIC is off in the schematic above. A PIC will source the full 5V supply voltage to turn on the transistor fine.

    The current to the MOSFET gate is limited by the 1k resistor to 1mA, you can try it out, especially with the low frequency, and at least get the original concept circuit of on until discharged, then disconnect. Measure the voltage of the battery with only a small current draw, around C/20, rather than the fast discharge resistor. With a 2A+ draw, the internal resistance of the battery will cause early discharge termination.
     
  19. french_guy

    Thread Starter Active Member

    Apr 16, 2009
    42
    0
    If the PIC’s output if Off, the transistor will be saturated with the 5V thru the pull-up 10k resistor, right? Then the gate of the MOSFET will be at 0V
    If the PIC’s output is at low (0V), the transistor is not saturated, and then Vgs is 12V….and the MOSFET closed
    Am I wrong?
    Do you recommend to do my balancing (discharge) under a low current (C/20) instead of the ~2.4 Amp?

    Thanks
     
  20. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Balancing cells is a bit tricky, as some that show the same capacity at C/20 will not match at 2C. This is the reason for the "advanced version" to alternate load rates to simulate actual use.

    Right now, I'd like to get the basic discharge working one step at a time. There won't be much that you'll be making and throwing away, code or hardware wise, only building in addition. It will make more sense to you and me for debugging that way.

    Apologies for the brain lapse on the inverting transistor, the pullup should work OK and not effect the PIC at all unless it is connected to one of the programming pins.
     
Loading...