Maker Pro
Maker Pro

dual power: battery or regulator

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
I'll order, mockup and test all, in fact. The way you pointed me the problems is really exciting :)
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Hello all,

I'm back with mockup. Half successfull:
- Batt is 3.6v
- External is 3.3v

Relay is given 3ms switch time. It draws around 60mA.

a 50uF /16v capacitor can't absorb the switch time: it seems the 60mA are still eaten (bounces ?), and i endup in a brown out reset. The MCU restart quickly, so i only see this at oscilloscope.

Steve, do you have any advices ? What do you think if i mockup the MOSFET driven schematic ? This would not make an huge current draw to my capacitor.

JC
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
Try a bigger capacitor and post images of what you're seeing the power rail do.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
The power rail drops from 3.3 to 1.5 and go back to 3.6v, in roughly 5ms

So the MCU is going in brown out.

Let's be clear: i have around 20mA - mainly from LED - when battery power (Vbb) and 100mA when externally powered.

C1 is 4.7uF, but even with 50uF the powerless gap is nearly identical: the power outage last perhaps 1ms less, but this point is bugging me. i'm wondering if i have bounces or something that would draw 100mA when my relay is powered on the capacitor.

I should be able to reduce the MCU running current drastically, but i will not reduce the current in the relay. So if the switch is somehow involved by the relay current draw, well, it will never succeed :) This is why i ask you what you are thinking about this.

Last thing, i have ordered and learned what is a MOSFET. Basically, were is the current sink on ie a 2N7002 ? I am not able to find it on its own DS ( http://www.farnell.com/datasheets/660093.pdf ) ?

Here is the schematic (actually no schottky, i'll add them later, i guess this have no impact). Thank you :)
 

Attachments

  • sch.png
    sch.png
    9.4 KB · Views: 113

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
My calculation is that at 20mA, the 50uF capacitor will fall to 1.3V in 5ms. That's pretty close to what you're seeing I assume.

My calculations were done on the basis that the current draw was 60uA, approximately 300 times less than you're telling me now.

I would expect that 1000uF should work better.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Another important thing: when Vee is connected, the MCU is powering a LED (permanently) and disable it when Vbb is connected.

I think when i'm switching back to Vbb, the LED is still powered, and will be unpowered on my next cycle - i have100ms cycle... - so the time the led is powered it creates a significant current sink. This is a really decent reason !

You know what ? I'll isolate the Vbb/Vee/relay stuff and test with a 20k (200uA load) resistive load. Thus i could eliminate the bounces and others problems i'm not able to see.

The time for the capa energie is t=RC right so a 20k load should last around 100ms, right ? Or t = RC would only be for capacitor charging through a resistor and not when the load is parallel to the capacitor ? Is there any better formulae ? I don't understand everything on wikipedia related to this.

Warming my oscilloscope, thank you !
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Sorry to bug you again. I'm also wondering if the capacitor (C1 in my case):

- could discharge through the Vbb circuit once the relay is powered off (because, for now, i have not schottky) ?
- what is the charge resistance for the C1 capacitor ? Is the charging time instantaneous (or nearly) in regard of mecanical bounces on the SPDT ?

*Scratch his head*
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
- could discharge through the Vbb circuit once the relay is powered off (because, for now, i have not schottky) ?

Yep. But since you mentioned that, I assumed that you were only looking at the switch-on delay.

Also the diode across the relay will slow the opening of the relay contacts.

Is the charging time instantaneous (or nearly) in regard of mecanical bounces on the SPDT ?

Assume it is.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
Another important thing: when Vee is connected, the MCU is powering a LED (permanently) and disable it when Vbb is connected.

I think when i'm switching back to Vbb, the LED is still powered, and will be unpowered on my next cycle - i have100ms cycle... - so the time the led is powered it creates a significant current sink. This is a really decent reason !

It may be better to power the LED from the Vee supply -- the same as the relay -- so it is not drawing from the capacitor.

Without the diode, I'm not sure how you are detecting the external supply, but it is quite reasonable to continue doing so.

You could also connect the power to an interrupt pin or poll it faster so you can react faster to a power switching event.

The time for the capa energie is t=RC right so a 20k load should last around 100ms, right ? Or t = RC would only be for capacitor charging through a resistor and not when the load is parallel to the capacitor ? Is there any better formulae ? I don't understand everything on wikipedia related to this.

In 1 RC time, the capacitor will discharge by about 63%. That's *way* too much in this application.

We're only wanting a very small voltage drop, so we can consider the current drawn to be constant and the rate at which the voltage falls is then linear.

For a constant current i amps and a capacitance C farads. and a voltage drop v volts (think 0.1 or so for this), then the time taken (t, in seconds) is t=(Cv)/i

So for a 0.1V drop on a 1000uF capacitor with 20mA, t = (1000e-6 *.1) / 20e-3 = 0.005 (and that's 5ms)

Note that this is the time from when the relay drops out. At the moment, the capacitor discharges to the voltage where the relay drops out (it might be 2V) and then the slower discharge starts. The schottky diode eliminates the load of the capacitor driving the relay.

Warming my oscilloscope, thank you !

Good idea, it's always good to be able to see what's going on.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Hello Steve,

The relay is a no-go. Even with a 1000uF, i have a brown out reset.

For now i have successfully tested the MOSFET one. I use a type N, i assume type P on your schematic is a typo, or perhaps i misunderstand the design ? I see it this way:
- when Ve (power pack) is down, the gate is to GND and S to G is closed so device is powered with Vb, while schottky does not allow any current return
- when Ve is high, the gate is set to 5v so SG is open, and the power flows through Schottky

Am i missing some points ?

Anyhow it work flawlessly but:
- Vb should be 3.6 and is 2.9v measured
- Ve should be 3.3 and is 3.1v measured

I'm using a 1N5817 schottky and BS270 N-MOSFET.
Vdiode is 0.245mv when Ve on and 2.9v when Ve is off.

Thank you !
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
The relay is a no-go. Even with a 1000uF, i have a brown out reset.

Without the diode it will continue to do that with any value of capacitance.

I'll answer the other questions later.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
Yeah, it looks like I drew the mosfet backwards. Source and drain are reversed.
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Without the diode it will continue to do that with any value of capacitance.

I'll answer the other questions later.

Ok, ty for the tip. I'll try with the first relay schematic 'just for' and diodes.. and try to understand why :(
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
I have definitively a glitch with the relay. I have implemented the above design (2x schottky, 1 relay SPDT, 1 flywheel) and a capacitor.

I go through a 13mA load (single resistor 220ohms).
Ve = 3.3; Vb = 3.6, Ve is powering the load.

Without capacitor, i have a clean cut of 1ms, then Batt is powering device. Same when powering Ve, i see the switch time (<50ns) of the relay. Clean, very clean.

With capacitor, i have slow discharge always ending at 1.3v whatever is the capacitor (1000uF or 4.7uF).

The only way i have a clean discharge is when i'm putting a normal (not tryed with Schottky) diode on Vout before capacitor (K is on cap+, while A is on Vout. Thus, i have an excellent switch time, a slight discharge, everything is as expected.

Can you explain me why i have to add this diode ? Do the relay is acting as a // capacitance or anything else ?
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
Re,

Here is the working schema with relay. In fact as soon as i put schottky on Ve psu, i have troubles.

Now trying to achieve MOS controlled switch.

Can you comment it, please ?
 

Attachments

  • Relay-Switch-Alim.png
    Relay-Switch-Alim.png
    7 KB · Views: 97

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
As I have tried to tell you before. Without diode D1, the capacitor is being used to hold the relay in after you disconnect the external power source.

The diode prevents this from happening, powering *only* the load.

Also, I'm going to have to review that circuit with the mosfet. I was thinking about it last night and I'm not confident I have it right.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,505
Joined
Jan 21, 2010
Messages
25,505
Yeah, it looks like I drew the mosfet backwards. Source and drain are reversed.

No, it's drawn correctly. And it is a P channel mosfet.

The gate resistor turns the mosfet on (by increasing Vgs to -3.3V) when the external power supply is not connected.

The external power supply turns the mosfet off (by reducing Vgs to about -0.3V)

The problem you might have is that a very flat battery could be "charged" through D1 and the body diode. This will happen when the battery voltage falls to about 2.5V.

Replacing the mosfet with an N channel mosfet will work in a limited way, but mostly due to the action of the body diode. The mosfet will never get turned on. The body diode explains the low voltage you see without power. The schottky diode will drop about 0.2V, the body diode about 0.7 (and that's exactly what you're seeing)
 

johnny_cash

Aug 13, 2013
39
Joined
Aug 13, 2013
Messages
39
As I have tried to tell you before. Without diode D1, the capacitor is being used to hold the relay in after you disconnect the external power source.

The diode prevents this from happening, powering *only* the load.

I'm ashamed i wasn't able to see this. Really. It's obvious, but you had to point it precisely to make me understand this point.

I have tryed a MOSFET design, but i ordered N Mosfet thus it is not working actually, a P is mandatory for 0v gate. For now i have sticked to the relay above schematic, but yes i'm sure i'll improve it to a MOSFET based design. Basically the questions i have is the polarization of S, D: voltage on Vgs, Vgd, Vds, if applicable.
 
Top