[SOLVED] MOSFET-P first use :) OR Relay

Hello, I am building a robot that i can leave at my house and control over the internet. The robot works and i am focusing on the home station now. I am working incrementally to understand what i do because i am quite new to electronic.

Today the goal is that when the robot is connected to the home station, the Arduino and motors get power from the home station and not the nimh battery (lipo on my diagram -_-). Here is the diagram of my robot ( i didn't draw servo / ipod 5v alimentation that is of no interest here)

|500x233

Here are my question :

1) Contrary to the diagram, i think q1 component should be a MOSFET-P, right? [EDIT] fixed 2) How to choose this MOSFET-P? It should cut of when 12v is applied. and close the battery circuit when there is 0v 3)Because it will create a sudden change in tension, shouldn't i have a condo (how to choose the size) after it? Maybe just put the 10uf after it instead of before? 4)I think i must put a resistor on the gate of the mosfet, if so, why and how to choose it?

Last but not least, for information after i made this, when i am connected to home, i will start a nimh recharge circuit on the battery.

Please be indulgent, i was not very active in my electronic class :(

[EDIT] given the message below, maybe te SPDT relay is a better choice for my circuit

A good example of this kind of circuit is in the Arduino itself. It selects USB power or external power depending on which one is higher. The Due has a particularly good example because it has 2 USB ports to work with. Open up the Arduino schematics and have a look.

An N type MOSFET looks right. You want it to be "on" when the 12V input is low, don't you? You might have source and drain backwards there try to redraw the schematic without that line crossing on top of the transistor symbol.

It doesn't look too good to me. It definitely won't do this:- "It should cut off when 12v is applied. and close the battery circuit when there is 0v" (At least not in the way I think you want.)

Draw it properly, without the ambiguous wire crossing. (Flip the MOSFET so that it's gate is downwards, then draw the "Home supply" at the bottom instead of top, with it's ground pointing down.) There's a fault either way, but that will allow us to detemine which fault is the real one.

And tell us - is the "home" supply only for control, (which is what your above statement indicates), or is this supposed to be a circuit where one or the other supply powers the unit? Re-reading, I guess it's the latter - one supply or the other.

It's really best to put a 'blob' on all joins, and 'jumpers' where wires cross. This eliminates any ambiguity. You're right about one thing - a P-channel MOSFET is more than likely what you need, but I won't commit myself until you clarify the points I've already raised.

My biggest concerns are:- 1. If your wire crossing near the MOSFET 'doesn't' connect, how does the regulator get power from the battery? 2. If that crossing 'does' connect, the source & gate of the MOSFET are shorted together. 3. As you mentioned, I think you need a P-channel MOSFET AND some circuit mods to fix 1. / 2. above.

@ oldSteve The crossing near the MOFSET does connect. Then it is true that source & gate are short circuited ! some problems avoided :) Maybe i should put a diode from gate to source to avoid current going up from the battery to the gate ?

Something like that |500x244

@Morgan S i will look this exemple which sounds like a good start!

[EDIT] To clarify, the robot behave much like a roomba or the robot that cur your grass. When it is wandering, it uses the battery and when it is charging at the home station, the electronic uses the the current from the home not the battery to maximize battery life.

Corrected to P mosfet

glub0x:
@ oldSteve
The crossing near the MOFSET does connect.
Then it is true that source & gate are short circuited ! some problems avoided :slight_smile:
Maybe i should put a diode from gate to source to avoid current going up from the battery to the gate ?

Something like that

@Morgan S i will look this exemple which sounds like a good start!

First draw it properly as asked, using a P-channel MOSFET, then think about the cure. (Draw it in pencil, so you can modify it.)

I’m exhausted and it’s very late here, (early morning actually), so I can’t spend any more time helping right now, I’m afraid. I’m sure that someone will get on board and give you a hand. At least I helped to get you started on the right track. (And don’t ignore the possibility of using a relay, either.)
Good luck.

But if it's docked to the charger then you don't care about running the battery down. Most battery chargers (with some rare exceptions) can charge properly with an Arduino permanently attached to the battery.

I read the diagram as saying that crossing didn't connect. It's easier to read with dots on the junctions but you should still never show a straight cross like this as it's confusing. If you need to join two vertical wires to a horizontal one, split them so there are two T joins instead of one + join.

Before going to bed, I just scribbled up the relay version of what you want. (It’s attachedbelow). Possibly the simplest way to go. :slight_smile:

And MorganS, an N-channel MOSFET was never going to work in this circuit as glubOx envisioned it.

Home or Battery Switchover.JPG

Thanks a lot i'll have a look to the relay For now i have 0 idea what a relay does so i'll educate myself a bit :)

[EDIT] I have corrected the crossing in my original post aswell as the 2nd one

glub0x:
Thanks a lot i’ll have a look to the relay
For now i have 0 idea what a relay does so i’ll educate myself a bit :slight_smile:

The relay is a 12VDC SPDT relay, (Single Pole Double Throw). You’ll easily find a small 12VDC SPDT relay from most suppliers. If you go that way, choose one with a contact current rating to suit your motors plus a little. Do a Google image search on SPDT relays for more info.

When power is not applied to the relay coil, the battery is automatically in-circuit. (Normally closed contact)
When power is applied to the relay coil, the contacts switch, disconnecting the battery and connecting the ‘home’ supply via the ‘normally open’ contact. (Much like a SPDT switch, but controlled by a voltage on the coil instead of by throwing a switch manually.)

Now it’s bed for me…ZZZZZZZZZZZZZZZZZ

So, relai looks good as it is intuitive to me!
it’s a really simple but clever mechanism !
SIDE NOTES: the downsides :
– it has a life expectancy of X cycles.
– It is more expensive than the mofset. ( 1,6 € against 0,5€ no problem here)
– heavier i think

So if i understand things right i should take something like Song Chuan 899-1CFC E 12

coil is 12v 400ohm so when the robot goes back home and close the tension, the coil will turn on on and switch to power from the home instead of battery.
Most of the relay can handle high current compared to the <1A that my robot eat … I am not sure how much this one handle in DC but i am sure it will do.

Now has it is mechanical i guess i should put a condo after the relay so the Arduino doesn’t power down right?
If needed, the condo (C3?) can be on the 5v rail instead of the 12v as, the motor can turn off for 10ms, no problem.
How to choose his capacity knowing that i have some servo on the 5v rail?

Also i added some diode to the motor, this is missing in my robot now :frowning:

I will redraw with the relay

The MOSFET circuit just needs a resistor from the gate to local ground so that the MOSFET will actually switch at all. Disconnecting the connection to the gate would otherwise leave it floating around which is very bad.

Any standard p-channel MOSFET with a low enough on resistance would work - the resistor turns it on unless the external power is applied in which case it turns off immediate. Some thought about switching spikes would be needed still I think.

The relay circuit will drop power completely for perhaps 10ms, not a sensible idea.

You could just have two diodes, one for the battery and one for the external supply - so long as the external supply voltage is higher the diodes do all the work (but will dissipate some power, schottky diodes are best).

MarkT: The MOSFET circuit just needs a resistor from the gate to local ground so that the MOSFET will actually switch at all.

Close, but also a diode to stop the MOSFET's internal diode from conducting back, overcharging the battery.

Any standard p-channel MOSFET with a low enough on resistance would work - the resistor turns it on unless the external power is applied in which case it turns off immediate(ly).

Almost right, although a series diode is also necessary to stop the 'home' voltage conducting back through the MOSFET's internal diode, overcharging the battery. I was too tired last night, (this morning really), to think about it and didn't want to make a mistake in my logic. 'Standard' is the keyword here, too. I wouldn't use a logic-level MOSFET in this circuit, in case the 'home' voltage was a bit low, turning on the MOSFET when it should be off. (See my point lower down - the LiPo voltage could easily be higher than the 'home' voltage.)

Some thought about switching spikes would be needed still I think.

Yep, hopefully a 1000uF capacitor will do the trick. Smaller would probably work, but that size should (hopefully) guarantee it. Possibly a small, (lower ESR), capacitor across it as well, if it still spikes at all.

The relay circuit will drop power completely for perhaps 10ms, not a sensible idea.

Just like the MOSFET circuit, a capacitor would be needed, but it would have to be larger, to replace the supply for >=20mS.

You could just have two diodes, one for the battery and one for the external supply - so long as the external supply voltage is higher the diodes do all the work (but will dissipate some power, schottky diodes are best).

No, not a good idea IMO. The home voltage is the same as the battery, according to the OP. In fact, a 12V LiPo could easily be a fair bit higher - 14V-15V straight after charging.

Edit: I don't think I've overlooked anything, but if I have, please mention it. (I just got up and am half-asleep still. :) )

glub0x:
So, relai looks good as it is intuitive to me!
it’s a really simple but clever mechanism !
SIDE NOTES: the downsides :
– it has a life expectancy of X cycles.
– It is more expensive than the mofset. ( 1,6 € against 0,5€ no problem here)
– heavier i think
So if i understand things right i should take something like Song Chuan 899-1CFC E 12

Yes, this would do, but see my new (P-channel) MOSFET circuit first, (attached below). It is the better option.

coil is 12v 400ohm so when the robot goes back home and close the tension, the coil will turn on on and switch to power from the home instead of battery.
Most of the relay can handle high current compared to the <1A that my robot eat … I am not sure how much this one handle in DC but i am sure it will do.

Yes, this would do, but see my new (P-channel) MOSFET circuit first, (attached below). It is the better option.

Now has it is mechanical i guess i should put a condo after the relay so the Arduino doesn’t power down right?
If needed, the condo (C3?) can be on the 5v rail instead of the 12v as, the motor can turn off for 10ms, no problem.
How to choose his capacity knowing that i have some servo on the 5v rail?

It’s still better to put the condo, (capacitor), on the 12V rail. If it is only on the 5V rail, the rapid switch-off then switch-on of the motor board could put a spike on the 5V rail, resetting the Arduino.
Also, as mentioned by Mark, a capacitor is still a good idea with the MOSFET circuit, to absorb any switching spike.

Also i added some diode to the motor, this is missing in my robot now :frowning:

Good. :slight_smile:

So, I have redrawn the relay circuit, with a capacitor, and also added the MOSFET circuit, which should be fine.
The capacitor on the MOSFET circuit could probably be smaller - you might want to experiment there.

I haven’t specified a particular type of P-channel MOSFET, but any ‘standard’ one will do. You want one with a Vgs threshold of more than about 6V, to ensure that it doesn’t turn on from a fully charged battery when ‘home’ is connected. * Do not use a ‘logic-level’ MOSFET with a 2V to 4V gate-source threshold voltage.
Anyway, both circuits are drawn in the attached file, so you can choose which you want to use. The MOSFET ciircuit is best. :wink:

Ok thanks for the diagram, i bought the relai and i will buy the MOSFET, this is an educational project for me so i am happy to play :)

The MOSFET is hard to choose as the documentation is very confusing to me ... Would this one do IRLML6402? VDS -20 IDA 3,7 A? ( my motors+servo+screen hardly eat 1A )

Other option for me would be IRFR9120N but looks overkill ...

Here is the new diagram I removed the 10uf it is useless with the 1000uf in paralell right? I added the switch to makes things clearer

|500x250

glub0x: Ok thanks for the diagram, i bought the relai and i will buy the MOSFET, this is an educational project for me so i am happy to play :)

The MOSFET is hard to choose as the documentation is very confusing to me ... Would this one do IRLML6402? VDS -20 IDA 3,7 A? ( my motors+servo+screen hardly eat 1A )

Other option for me would be IRFR9120N but looks overkill ...

Here is the new diagram I removed the 10uf it is useless with the 1000uf in paralell right? I added the switch to makes things clearer

|500x250

I'm a bit cinfused. So don't you want the 'home' supply to also power your robot? You need to clarify this. I thought that you did, and drew the circuit accordingly, but I see that in your diagram the 'home' supply doesn't power it at all. Is this an error? Once you clarify this point, I can answer your other questions.

Yes there is a mistake in the diagram!

|500x238

glub0x: Yes there is a mistake in the diagram!

Oh good. I was getting a little confused when I saw your earlier diagram. Now I'll reply to your earlier post.

Now, I'm very sorry, but I've been thinking a bit more about the MOSFET problem, and to be honest, I'm not sure that any MOSFET will really be 100% suitable.

Because the battery voltage could be about 14V to 15V, while the 'home' voltage will only be 12V, there is a fair chance that the MOSFET will never switch off fully. The 'home' supply can only provide 12V to the MOSFET's gate, while the source will be at the battery voltage. That means that the home voltage will leave a Vgs of up to 3V, partially turning the MOSFET on. Even a standard MOSFET could be a problem. The 12V 'home' voltage can only be guaranteed to turn off the MOSFET when the battery is partially discharged, down to 13V or less. If the 'home' voltage was 15V, there would be no problem.

So, after all of this messing around, I would recommend that you use the relay circuit. It will definitely do what you want.

Again, sorry for the waste of time. :(

Ok that is interesting reading and definitely not a waste of time. The lipo that is actually on the robot waiting to be replaced by the nimh goes up to 13,5V so there will be a problem here.

What you are saying probably mean that i will need a 14v DC adaptor or maybe even 16V to be on the safe side. Do not forget that the next step is to use this DC current to recharge the battery, how can a 12V charger charge a 12v battery ? that sounds problematic.

After checking 14v would be no problem for my components.

Here is the new diag |500x251

So before buying, would the IRLML6402 do as MOSFET in that case?

I did a correction to the motor pluging but this is of no importance here.

glub0x: Ok that is interesting reading and definitely not a waste of time. The lipo that is actually on the robot waiting to be replaced by the nimh goes up to 13,5V so there will be a problem here.

What you are saying probably mean that i will need a 14v DC adaptor or maybe even 16V to be on the safe side. Do not forget that the next step is to use this DC current to recharge the battery, how can a 12V charger charge a 12v battery ? that sounds problematic.

After checking 14v would be no problem for my components.

Here is the new diag |500x251

So before buying, would the IRLML6402 do as MOSFET in that case?

I did a correction to the motor pluging but this is of no importance here.

As long as the 'home' voltage is >= the battery voltage, you'll have no problems and that MOSFET will do the job.

You say "Do not forget that the next step is to use this DC current to recharge the battery" How could I forget, or even know, something that you never mentioned? I can only go by what you say, not by what you are thinking. :)

14V for the 'home' supply will probably not be high enough to fully charge your NiMH battery, if it is a 10-cell, 12V NiMH battery. You'll need 15V at the very least. What type of charger do you plan?

And a point to note is that you cannot run the motors in reverse with your circuit, only forwards.

I did mentioned it in the first post!
Regarding the motors, i corrected the plan.

Thanks for your help this problem is solved, i have no doubt i ll get what i want now i am just waiting for the MOSFET & relai to experiment :slight_smile:
Next step is here http://forum.arduino.cc/index.php?topic=356188.0 !