Arduino Forum

Using Arduino => Motors, Mechanics, and Power => Topic started by: SouthernAtHeart on Jan 14, 2013, 03:40 am

Title: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 14, 2013, 03:40 am
5 volt system.
An atmega328P-AU, DS3234, & h-bridge (Si9986)

My atmega will be sleeping, waiting for the interrupt from the DS3234 timer.  DS3234 will have Vcc cut off from an Arduino pin, so it runs on Vbatt. But if I'm reading the datasheet correctly on the Si9886, it uses 300 uA in standby mode.
To achieve a low quiescent current, I think I'll need to power down this H-Bridge.
http://www.vishay.com/docs/70007/si9986.pdf (http://www.vishay.com/docs/70007/si9986.pdf)

  I found one user said they like this MOSFET. The DMN3404L
http://www.mouser.com/ProductDetail/Diodes-Inc/DMN3404L-7/?qs=oUsD4qhOtFw9qrJFkpbwKg%3d%3d (http://www.mouser.com/ProductDetail/Diodes-Inc/DMN3404L-7/?qs=oUsD4qhOtFw9qrJFkpbwKg%3d%3d)

I don't understand enough about FETs to be certain this is a good selection.  Can someone please confirm this?  My H-Bridge will be switching a 6 volt motor, .5 amp, max current.  My atmega will be running on 3 cells (4.5 volts).

I've included an image of how I assume I power down the h bridge.
Many thanks.

(https://www.dropbox.com/s/efa2xz6b0he77ce/Photo%20Jan%2012%2C%2010%2041%2029%20PM.png)
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: larryd on Jan 14, 2013, 07:24 am
Looks OK.
You could also use a small, sensitive DIP 5Volt relay.
http://www.frys.com/product/6401152
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: MarkT on Jan 14, 2013, 11:46 am
Not sure you can do that - the Si9886 requires all its inputs be no lower than -0.3V w.r.t. its ground terminal - you are
proposing low-side switching of the Si9886 - its ground will then rise to Vbat, so that Arduino ground will appear as
-Vbatt.  If any of the Arduino pins connected to it are driven LOW, or if the Arduino is powered down you'll fry the
H-bridge inputs.

The normal approach is high-side switching - what is Vbatt?  If its also 5V then a logic-level p-channel MOSFET could be used to
switch the H-bridge (if higher you'd need an small n-channel MOSFET as a level-shifter to drive the p-channel gate.

What state will the Arduino be in when sleeping - can it drive an output HIGH or LOW then?

BTW the H-bridge has a standby current drain of about 75uA, not 300uA - see the graphs in the datasheet.  The
300uA figure is across all supply voltages and temperatures.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 14, 2013, 06:21 pm

Not sure you can do that - the Si9886 requires all its inputs be no lower than -0.3V w.r.t. its ground terminal - you are
proposing low-side switching of the Si9886 - its ground will then rise to Vbat, so that Arduino ground will appear as
-Vbatt.  If any of the Arduino pins connected to it are driven LOW, or if the Arduino is powered down you'll fry the
H-bridge inputs.

The normal approach is high-side switching - what is Vbatt?  If its also 5V then a logic-level p-channel MOSFET could be used to
switch the H-bridge (if higher you'd need an small n-channel MOSFET as a level-shifter to drive the p-channel gate.

What state will the Arduino be in when sleeping - can it drive an output HIGH or LOW then?

BTW the H-bridge has a standby current drain of about 75uA, not 300uA - see the graphs in the datasheet.  The
300uA figure is across all supply voltages and temperatures.


Thanks. I wondered about that issue of switching the gnd. The P channel counterpart to that MOSFET is this: http://www.mouser.com/ProductDetail/Diodes-Inc/DMP2305U-7/?qs=oUsD4qhOtFyFQmlG8wLVjw%3d%3d (http://www.mouser.com/ProductDetail/Diodes-Inc/DMP2305U-7/?qs=oUsD4qhOtFyFQmlG8wLVjw%3d%3d)
I could switch Vcc of the H bridge with this I think. Would that upset the Si9986?
From what I understand from Nick G's tutorial on low power modes, you can set the Arduino pins high or low before powering it down.
Vbatt will be 3 volt from a lithium cell.

The best alternative would be an H-bridge that uses low quiescent current, but I don't know how you'd even go about searching for one.


Edit: Vbatt is just referring to the coin cell supply for the DS3234, and it not connected to the Arduino.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 14, 2013, 08:55 pm
Quote
The best alternative would be an H-bridge that uses low quiescent current, but I don't know how you'd even go about searching for one.

I looked through several other h bridge data sheets for low quiescent current without lick. I hoping cutting the supply Vcc using the above mentioned N channel MOSFET will work?
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 15, 2013, 08:38 pm

5 volt system.
An atmega328P-AU, DS3234, & h-bridge (Si9986)

My atmega will be sleeping, waiting for the interrupt from the DS3234 timer.  DS3234 will have Vcc cut off from an Arduino pin, so it runs on Vbatt. But if I'm reading the datasheet correctly on the Si9886, it uses 300 uA in standby mode.


300uA maximum, but more like 65uA typical @ Vdd=5V judging from page 3 of the datasheet.

Low-side switching to turn the power supply to the H-bridge off using an N-channel mosfet is OK provided you set INA and INB high first. Similarly, turn the mosfet on before you set the pins driving INA and INB to be outputs. It's slightly better to put the 10K resistor to ground on the other side of the 330 ohm resistor unless there is a connector involved, that way the mosfet gate gets the full ~5V drive from the atmega328p instead of ~97% of it.
Title: Solid state relay
Post by: SouthernAtHeart on Jan 15, 2013, 10:38 pm
http://www.digikey.com/product-detail/en/CPC1002NTR/CLA230DKR-ND/1212884 (http://www.digikey.com/product-detail/en/CPC1002NTR/CLA230DKR-ND/1212884)

...would this solid state DC relay be a better choice to power down an H-bridge?  I didn't seem anything in the datasheet that would indicate I couldn't switch the high side, which sounds safer than turning everything on/off high/low in the right order as suggested to switch the low side...
Seems this only has 1uA of current when off?

Thanks for taking a look at this. This does seem a good solution to me, I'll be anxious to get some feedback on this relay.

...and if there's a better more obvious way to cut power to an H-bridge so my project can run on just a few uA, don't hesitate to tell me I'm missing something. I thought of trying to skip the h bridge but couldn't come up with a way to run a 200-500mA motor in both directions.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 15, 2013, 11:19 pm
If you switch the high side of the H-bridge, you will still have to make sure you set the outputs correctly (i.e. low) before you power it down. So switching the high side instead of the low side doesn't gain anything.

Using an SSR is overkill, you don't need isolation in this case.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 16, 2013, 12:33 am
Quote
Low-side switching to turn the power supply to the H-bridge off using an N-channel mosfet is OK provided you set INA and INB high first. Similarly, turn the mosfet on before you set the pins driving INA and INB to be outputs.


Ok, if I switch the low side, I won't need the extra MOSFET driver transistor, just this setup in the attached picture. But then to do all that I've quoted you here. ...can I do this if I'm turning on power, running the motor a few seconds, turning off power, rinse repeat twice a day?
Can you list the order of proper startup/ shutdown?  The way I see it if I set INA/B high first, then shut down the MOSFET, won't I leave them high until after I power it up again?  But you said to turn on the MOSFET before setting INA/B as outputs, but they'll already be outputs, & set to high.  ???

I don't mind using a P channel, or using extra components, I just want to do it properly-what ever is the best most acceptable way of turning off power so as to bring my total quiescent current down to just a few uA. From all that I've read, it seems a P channel is more commonly used to switch the high side, but I did notice those P channel circuits all have a pull up resister, and that in itself will draw more current than I want. 
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 16, 2013, 09:41 am
If your H-bridge and the Arduino are running from the same +5V supply, then you can switch either the high side or the low side of the H-bridge. You can use either a logic-level P-channel mosfet to switch the high side, or a logic-level N-channel mosfet to switch the low side. The P-channel mosfet needs a pullup resistor between gate and +5V to hold it off while the system is powering up; the N-channel mosfet needs a pulldown resistor to ground for the same reason. In both cases, when the mosfet is off, there is no voltage across the resistor, so no associated current drain.

If your H-bridge uses a different +5V (or higher) power supply from the one powering the Arduino, then you must use high-side switching, with a P-channel mosfet and an NPN BJT or similar to level-shift the mosfet gate drive. The usual level shifting circuit consumes no power when the mosfet is off.

I suggest you include 1K resistors between INA, INB and the corresponding Arduino pins, to protect the chips in the event of you getting the sequence wrong.

Here is my suggested operating sequence:

1. Low side switching with N-channel mosfet (output pin high to turn mosfet on)

Initialise:
    digitalWrite LOW to mosfet control
    mosfet control pinMode to OUTPUT
    digitalWrite HIGH to INA, INB
    INA, INB pinMode to OUTPUT (both will be set HIGH because of the previous command)

Power up:
    INA, INB should both already be HIGH
    Mosfet control HIGH to enable power to H-bridge

Power down:
    INA, INB HIGH
    Mosfet control LOW to power down H-bridge

2. High side switching, direct connection to P-channel mosfet (output pin low to turn mosfet on)

Initialise:
   digitalWrite HIGH to mosfet control
   mosfet control pinMode to OUTPUT
   DigitalWrite LOW to INA, INB
   INA, INB pinMode to OUTPUT

Power up:
   INA, INB should already be LOW
   Mosfet control LOW

Power down:
   INA, INB LOW
   Mosfet control HIGH.

3. High side switching with level shift: as (2) but reverse mosfet control pin HIGH/LOW.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 16, 2013, 04:08 pm
Thanks dc42,
I really would like to understand this stuff better. So my scenario is #3, since my motor voltage is 6 volts and my Arduino voltage is 4.5 volts.
This photo is what I've found from another thread. Is this correct?  I've read that the pull up resistor on the MOSFET's gate is needed to turn it off. But the continuous current drain across that 10K resistor will defeat the purpose of attaining ultra low quiescent current.  My motor voltage is 6 volts, so across 10K, that'd be a 600 uA, no?
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 16, 2013, 05:04 pm
That circuit is OK, although personally I would reduce the value of the pullup resistor to +6V to 2k2 or 4K7, at the expense of slightly increased current consumption when the H-bridge is powered up. This resistor will only draw current when the transistor is turned on and the H-bridge is powered up, so it doesn't defeat the purpose of switching the H-bridge supply.

As you have a little under 6V gate drive available, you will need to use a logic level P-channel mosfet.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 17, 2013, 05:45 am
Ok, I think I got it!  Here's a photo of what I've got, and the components.  Oh, I don't have it...  I just discovered the 2N3904  transistor doesnt come in SMD at Digikey. What would a good NPN transistor be to turn on/off my MOSFET?  I have some BSS138W-7-F in stock. Would they be a good choice?  If not ill be ordering from Digkey anyway.
and does the P channel mosfet look appropriate?

BSS1338 transistor: (I guess it's not a transistor, but an NPN MOSFET)
http://www.diodes.com/datasheets/ds30206.pdf (http://www.diodes.com/datasheets/ds30206.pdf)


The P channel MOSFET (DMP2305U)
http://www.diodes.com/datasheets/ds31737.pdf (http://www.diodes.com/datasheets/ds31737.pdf)

H-Bridge
http://www.vishay.com/docs/70007/si9986.pdf (http://www.vishay.com/docs/70007/si9986.pdf)
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 17, 2013, 09:48 am
Looks OK to me. The Vgs rating of that P-channel mosfet is only 8V, uncomfortablly close to the 6V drive it is getting, so it is probably better to spit the 2K2 resistor into 2 x 1K and drive the gate from the junction of the two. Alternatively, pick a mosfet with a higher Vgs rating but designed for 5V gate drive, such as TSM2313CX.

For the transistor, use either a bipolar NPN transistor such as BC817 and omit the 10K resistor to ground, or a small signal mosfet such as your BSS138W and omit the 10K series resistor..
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 17, 2013, 09:49 am
PS - don't forget to add some good decoupling capacitors between the source terminal of the P-channel mosfet and the ground connection of the H-bridge.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 17, 2013, 11:23 pm
Quote
Alternatively, pick a mosfet with a higher Vgs rating but designed for 5V gate drive, such as TSM2313CX.

...still looking for something at Digikey. I can't get the one you mentioned  at Digikey, and at Mouser it's a non stocked item which you've gotta order 15000 of…
Digikey's filtering system doesn't  have the criteria of Vgs, so I'm having trouble selecting one. Once I find something I'll post my updated schematic.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 18, 2013, 12:16 am
Perhaps PMV48XP then?
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jan 18, 2013, 02:34 am

Perhaps PMV48XP then?


Thanks!  Here's what I came up with...
Is R1 needed? I usually put something like that to make sure the motor is off while the Arduino boots up.
So nothing is needed between the Arduino pin and the gate of the BS1338?
Sure appritiate all the help!

I'll be glad to go this route rather than just a relay.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jan 18, 2013, 09:17 am
R1 is worth including. Its purpose is to ensure the mosfet is kept off when the system is powered up but the Arduino pin has not yet been configured as an output. It isn't needed if the pin feeds a BJT, but then you need a series resistor instead.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 25, 2013, 11:33 am
Quote
Looks OK to me. The Vgs rating of that P-channel mosfet is only 8V, uncomfortablly close to the 6V drive it is getting, so it is probably better to spit the 2K2 resistor into 2 x 1K and drive the gate from the junction of the two. Alternatively, pick a mosfet with a higher Vgs rating but designed for 5V gate drive, such as TSM2313CX.


I have changed from a 6 volt motor supply to a 9 volt supply, (and tapping off 4.5v for the 328 chip), but I don't understand this Vgs thing, so will this schematic still work to turn on/off Vcc to my motor driver chip?
Will I still need to have the 2k2 resister split into 2 1k resistors?  I don't understand thus part.
Thanks.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 25, 2013, 01:05 pm
Running from 9V, you definitely need R1, R2 to be 2 x 1K. However, your schematic is wrong. They need to be in series, not in parallel, and the gate drive to the P-channel mosfet needs to be taken from the junction of the two.

I would connect the 100nF capacitor to the source terminal of the P-channel mosfet instead of the drain terminal, and put a much larger electrolytic capacitor (e.g. 1000uF) in parallel with it. Position the P-channel mosfet and capacitors close to the 9986, and keep the traces connecting these 4 components short.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 26, 2013, 08:13 pm
OK!  I think I've got it.  I made the schematic on eagle, trying to make it all clear so I could get a second opinion on it.  If you could note that it looks okay, and that the mosfet are connected to the correct gates.  I've included datasheets for the components...
thanks again,


BSS138W N Channel Mosfet:
http://www.diodes.com/datasheets/ds30206.pdf (http://www.diodes.com/datasheets/ds30206.pdf)

PMV48XP P Channel Moseft:
http://www.nxp.com/documents/data_sheet/PMV48XP.pdf (http://www.nxp.com/documents/data_sheet/PMV48XP.pdf)

Si9986 H-Bridge
http://www.vishay.com/docs/70007/si9986.pdf (http://www.vishay.com/docs/70007/si9986.pdf)
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 26, 2013, 11:58 pm
As I tried to make clear in my previous reply, I think you should omit C3. Otherwise, every time you turn on the P-channel mosfet, there will be a large surge of current through the mosfet as C1 charges. If you do decide to keep C3, then you can omit C1 but I think you should also deliberately slow down the turn-on speed of the P-channel mosfet by connecting a capacitor of about 10nF in parallel with R2.

You will need to make sure that the 2 input signals to the 9986 are low before you turn off the P-channel mosfet, and remain low until after you have turned it on.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 12:11 am
I will just omit C3. I didn't realize it was a problem. I added C1 thinking that was what you meant to do. C3 is just what I put next to all chips I use as a decoupling cap. I didn't know it was interfering with the P channel MOSFET. Thanks for explaining that. I kinda understand it now.
I'll be sure to turn the h bridge signals off before turning off the P channel.
Thanks!
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 12:38 am
On the same project, I need to turn off the Vcc to the DS3234 RTC chip. If I should start a new thread for that let me know.
The 3 chips in my project are:
Atmega328P-AU (first time to boot load the SMD variant)
si9986 H-Bridge
DS3234 RTC

Vcc for the Atmega328 & DS3234 is 4.5v (3 C cells)
...trying to last a year on batteries, I will power down the Atmega328P, and have the alarm from the DS3234 interrupt wake it up. But if the DS3234 has Vcc it uses a lot of current. If I turn Vcc off, it uses only 1-2 uA from Vbatt (a coin cell battery).
So I need to "disconnect" Vcc from the DS3234. Would this same technique I used on the si9986 work?
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 27, 2013, 09:23 am

I will just omit C3. I didn't realize it was a problem. I added C1 thinking that was what you meant to do. C3 is just what I put next to all chips I use as a decoupling cap. I didn't know it was interfering with the P channel MOSFET. Thanks for explaining that. I kinda understand it now.
I'll be sure to turn the h bridge signals off before turning off the P channel.
Thanks!


Just bear in mind that C1 is effectively the decoupling cap for the H-bridge, so it should be close to the chip and the traces between it, the chip and the P-channel mosfet should be kept short. If you are making a PCB, then I suggest you make a space for C1 anyway (and a capacitor in parallel with R2), just in case there are any problems with noise pickup when the mosfet is off.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 27, 2013, 09:29 am

On the same project, I need to turn off the Vcc to the DS3234 RTC chip. If I should start a new thread for that let me know.
The 3 chips in my project are:
Atmega328P-AU (first time to boot load the SMD variant)
si9986 H-Bridge
DS3234 RTC

Vcc for the Atmega328 & DS3234 is 4.5v (3 C cells)
...trying to last a year on batteries, I will power down the Atmega328P, and have the alarm from the DS3234 interrupt wake it up. But if the DS3234 has Vcc it uses a lot of current. If I turn Vcc off, it uses only 1-2 uA from Vbatt (a coin cell battery).
So I need to "disconnect" Vcc from the DS3234. Would this same technique I used on the si9986 work?


The DS3234 takes less than 1mA. Power it from an Arduino output pin (possibly the same one that is controlling the power to the H-bridge), through a 150 ohm resistor, and put a decoupling capacitor between its Vcc and ground. Make sure you drive the 3 SPI control signals to it LOW before you power it off.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 10:54 am
Thanks!  I should've known that. In all the details of powering down the H bridge. I forgot.
I'll post my complete schematic here in a few days.
Trying to check anything that might draw current I thought about the 10K pull-up resistor on pin 1 of the Arduino. 5v through a 10K resistor = 500 uA. But maybe there's a lot more resistance in the Arduino chip when I put it to sleep?
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 27, 2013, 11:00 am
The pullup on the reset pin won't draw any current, unless something else pulls the pin low.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 11:08 am
Ok, thanks.
Title: Adding a 16x2 LCD in low quiescent mode
Post by: SouthernAtHeart on Mar 27, 2013, 06:08 pm
Adding a 16x2 LCD in low quiescent mode

I got the RTC DS3234 added into my schematic.  One more thing I'm going to need is an LCD screen to enable the user to set the date/time.
For all the more it'll be used (probably once in 10 years if the coin cell last as long as they say they do), I won't even bother with the back light.  And data sheets I've looked at are showing Vcc for LCDs to only be 1-2 mA, so I can power that from a digital pin, too.  Would a 150 ohm resistor be good between the I/O pin and the Vcc on the LCD?

What about the 6 I/O pins controlling the LCD?  I know they're a kind of communication lines, but I just use a liquid crystal library to control them.  I'll likely be losing some current through them?  After the user is done setting the time, I could disconnect the LCD, only I don't see a LCD.end() function only the LCD.begin().  Will the be any power consumption from this connection?
thanks.
PS. I've read some threads about powering off the backlight, but what I need to do is power off the whole LCD.
Title: Re: Adding a 16x2 LCD in low quiescent mode
Post by: dc42 on Mar 27, 2013, 06:47 pm

One more thing I'm going to need is an LCD screen to enable the user to set the date/time.
For all the more it'll be used (probably once in 10 years if the coin cell last as long as they say they do), I won't even bother with the back light.


Then get a reflective mode LCD display, otherwise you may find the LCD display very hard to read without the backlight.


And data sheets I've looked at are showing Vcc for LCDs to only be 1-2 mA, so I can power that from a digital pin, too.  Would a 150 ohm resistor be good between the I/O pin and the Vcc on the LCD?


Yes, that's what I do.


What about the 6 I/O pins controlling the LCD?  I know they're a kind of communication lines, but I just use a liquid crystal library to control them.  I'll likely be losing some current through them?  After the user is done setting the time, I could disconnect the LCD, only I don't see a LCD.end() function only the LCD.begin().  Will the be any power consumption from this connection?


You need to drive all the pins connected to the LCD low before turning off its power, then they won't draw any current.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 06:53 pm
Quote
You need to drive all the pins connected to the LCD low before turning off its power, then they won't draw any current.


They will already be set from the LCD.begin() function.  What will I need to do to turn them low, just digitalWrite(pin, LOW)?
Or will I first need to use pinMode(pin, OUTPUT)?
thanks.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 27, 2013, 07:20 pm

What will I need to do to turn them low, just digitalWrite(pin, LOW)?


Yes. BTW there is a problem with the LiquidCrystal library: it makes a call to the begin() function in the LiquidCrystal constructor (a very silly thing to do IMO, and completely unnecessary because you should call begin() in setup). So you should preferably patch the LiquidCrystal library source file to remove this call, to avoid feeding power through the I/O connections before you power up the LCD.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 27, 2013, 09:42 pm


What will I need to do to turn them low, just digitalWrite(pin, LOW)?


Yes. BTW there is a problem with the LiquidCrystal library: it makes a call to the begin() function in the LiquidCrystal constructor (a very silly thing to do IMO, and completely unnecessary because you should call begin() in setup). So you should preferably patch the LiquidCrystal library source file to remove this call, to avoid feeding power through the I/O connections before you power up the LCD.

Is there an updated library that fixes this?  I don't know anything about working with or editing libraries.

Edit:  ill search around about this. I should've done so before asking more about it.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 28, 2013, 03:22 am
Quote
Yes. BTW there is a problem with the LiquidCrystal library: it makes a call to the begin() function in the LiquidCrystal constructor

Searched for 20 minutes, but couldn't come up with any more info about this. Is this something that I need to address?
Quote
avoid feeding power through the I/O connections before you power up the LCD

Will this matter?  If so, I assume you mean I should edit one of the text files on my Mac?  Under /Applications/Arduino.app/Contents/Resources/Java/libraries/LiquidCrystal I found 2 files that look like something you might mean to edit?  These came with the Arduino IDE, if something's not right with one of them I'm surprised I couldn't find anything about it around here.
Please advise.


also, here is my completed schematic for the H-bridge shutdown.  I tried to tidy it up a bit, and I think I understood where to add/remove the caps, but if you could check it out, I'd sure appreciate it.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 28, 2013, 09:49 am
You only need C9 if you also have the other 0.1uF capacitor between Vdd of the 9986 and ground.

To fix the LiquidCrystal library to allow for the LCD not being powered up permanently, edit the LiquidCrystal.cpp file, commenting out the call to begin() at the end of the init() function.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 28, 2013, 03:43 pm
Very good!  I found the begin() statement and commented it out.  

I reckon I should use the backlight for my LCD, then.  I searched and found this schematic that turns is on and off.  I cuts the NEG side, but I reckon the POS side isn't connected to the LCD's POS, so it won't back feed into it when I power off the LCD's chip.  Not sure about the value of R7.  Running from 4.5v, I may not need a very high resistor?

One thing I don't know/understand.  When I power down this circuit by a LOW arduino pin, there won't be any current left flowing in the BSS1338 mosfet, then will there? See the attached clip from the BSS1338 data sheet. Does that mean there'll be .5 uA current loss all the time?  Accord Nick Gammon's arduino power page, I can get the Atmega down to .335nA, so the current in the BSS1338 is considerable.  I reckon the one controlling my H-bridge will add another .5uA.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Mar 28, 2013, 04:10 pm

I reckon I should use the backlight for my LCD, then.  I searched and found this schematic that turns is on and off.  I cuts the NEG side, but I reckon the POS side isn't connected to the LCD's POS, so it won't back feed into it when I power off the LCD's chip.  Not sure about the value of R7.  Running from 4.5v, I may not need a very high resistor?


Depending on the LCD display, you may not need any resistor at all, because some displays have the series resistor built-in.


One thing I don't know/understand.  When I power down this circuit by a LOW arduino pin, there won't be any current left flowing in the BSS1338 mosfet, then will there? See the attached clip from the BSS1338 data sheet. Does that mean there'll be .5 uA current loss all the time?


0.5uA is the maximum, it may typically be much lower. For example, the datasheet for 2N7002 says 0.01uA typical, 1uA maximum @ 25C.


I reckon the one controlling my H-bridge will add another .5uA.


Don't forget the P-channel mosfet, that will have some zero gate voltage drain current too.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Mar 28, 2013, 07:28 pm
Thanks for all1. I think that's pretty well it on the hardware end of the project. Will get some actual readings from the motor with its load attached, and see what amperage I'm using.  Then will make the final decision on whether to use AA or C cells. Will report back.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: SouthernAtHeart on Jun 06, 2013, 05:54 am

Running from 9V, you definitely need R1, R2 to be 2 x 1K. However, your schematic is wrong. They need to be in series, not in parallel, and the gate drive to the P-channel mosfet needs to be taken from the junction of the two.

I would connect the 100nF capacitor to the source terminal of the P-channel mosfet instead of the drain terminal, and put a much larger electrolytic capacitor (e.g. 1000uF) in parallel with it. Position the P-channel mosfet and capacitors close to the 9986, and keep the traces connecting these 4 components short.


I'm finishing up my board to send off to the fab house.  Everything on this board is very small, except that 1000uF CAP.  Is that correct, a 1000uF size?  Just checking, thanks.


Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jun 07, 2013, 09:45 am
1000uF was just a suggestion. You can use a lower value, but the ripple current rating should be at least half the maximum motor current. Maybe something like http://uk.farnell.com/rubycon/10tzv470m8x10-5/capacitor-smd-470uf-10v/dp/1281858RL (http://uk.farnell.com/rubycon/10tzv470m8x10-5/capacitor-smd-470uf-10v/dp/1281858RL). The purpose of the capacitor is to reduce noise on the power and ground lines when you PWM the motor.
Title: Re: Adding a 16x2 LCD in low quiescent mode
Post by: SouthernAtHeart on Jun 29, 2013, 04:12 am
You need to drive all the pins connected to the LCD low before turning off its power, then they won't draw any current.

Here is a test code I made to be sure I'm properly powering up/down my LCD.  How does it look?  I don't want to test it on my LCD in case it's wrong and I mess up my LCD.

Code: [Select]
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A7,A0,A2,A3,A4,A5);
int LCDpins[] = {
 A7, A0, A2, A3, A4, A5};
int LCDpower = 4; //pin controlling LCD power
unsigned long LCDtimer;  //counter

void setup() {
 //don't use LCD.begin() here, correct?
 pinMode(LCDpower, OUTPUT);  //set pin as output
 digitalWrite(LCDpower, LOW); //maybe not needed?
}

void loop() {
 if (millis() - LCDtimer > 10000) {  //every 10 seconds
   LCDtimer = millis();  //update counter
   display_something();  //activate the LCD
 }
 //do other stuff...
 delay(100);

}

void display_something() {
 digitalWrite(LCDpower, HIGH); //power up the LCD
 lcd.begin(16, 2); //start the LCD
 lcd.clear(); //clear the screen
 lcd.print(millis());  //print the time
 delay(2000); //give user time to read it
 for (int i = 0; i < 6; i++) {
   digitalWrite(LCDpins[i], LOW);
 }
 digitalWrite(LCDpower, LOW);  //power down the LCD
}

Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jun 29, 2013, 07:07 am
That looks ok to me. You may need to insert a delay between powering up the lcd and making the begin() call.
Title: Changing to an OLED
Post by: SouthernAtHeart on Jul 09, 2013, 04:53 am
Well, DC42, after getting my first version board back from the fab house, I discovered a few design mistakes, so I'm going to redo it.  I couldn't get the LCD to work, but I'm pretty sure it was something more to do with the LCD, rather than the schematic.  The LCD was this tiny one like the one pictured with a FCP connector, and I'd never used one like it before.  I've recently learned about these little OLED displays like adafruit sells, and want to switch to them on my next attempt at a board. (see link).  The OLED display uses very little current, so I'm guessing I can control it's power directly from a digital pin?
Quote
The power requirements depend a little on how much of the display is lit but on average the display uses about 20mA from the 3.3V supply
Seems I read somewhere else that with all the pixels lit one used 50ma.  I'll just be using it for text, not graphics, so I won't have anywhere near all the pixels used.
It may be a little while before I resume this project, I'll be gone a few weeks, but here a picture of the schematic I'm guessing will work for powering up/down the OLED from the Atmega328's D4 pin.  Would the I2C pull-ups get connected to D4 as well?
http://learn.adafruit.com/monochrome-oled-breakouts/overview (http://learn.adafruit.com/monochrome-oled-breakouts/overview)

Thanks for taking a look at this.
Title: Re: SMD MOSFET to power down my SMD H-Bridge
Post by: dc42 on Jul 09, 2013, 09:24 am
Sorry, I've never worked with OLED displays. However, as its current consumption is so high, you can't safely drive it from an Arduino pin. Use another P-channel mosfet, although this time you can switch it directly from the Arduino instead of using an additional transistor for level shifting.

PS - don't from the data you posted, looks like the oled display is a 3.3V device, So you'll be switching 3.3V to it, not 5V. The I2C pullup resistors should be connected to the Vcc pin of the display.