NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » P-MOSFET

February 04, 2011
by kvjohnso
kvjohnso's Avatar

If I had a little 9V circuit with a few LEDS and wanted to use a MOSFET to control it, wouldn't I have to use a p-channel MOSFET if I'm only sending +5V to my MOSFET's gate since the gate would be less positive than then the source pin?

Thanks,

Ken

February 04, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Kvjohnso,

If you are looking too put the MOSFET on the positive rail, then yes, you would need a p-mosfet. My suggestion is to use an n-mosfet (which are included with the USB NerdKit) and put it on the low side of the LEDs, to "sink" the current down when the voltage at the gate goes high. It would be quite similar to driving a motor off a 9V power supply like we do in our motors and microcontrollers video. Hope that helps.

Humberto

February 04, 2011
by kvjohnso
kvjohnso's Avatar

Thank you. Sorry, but what do you mean by the low side of the LED?

Ken

February 04, 2011
by Rick_S
Rick_S's Avatar

The low side of the LED is the - side or the cathode. The anode would be the + or high side.

Rick

February 04, 2011
by kvjohnso
kvjohnso's Avatar

Thanks for writing back Rick. I guess I don't know what I'm doing. I'm trying to use pin 24 of the MCU from the led_light project to trigger the gate of my MOSFET to control a 9V batter and two led circuit. I'm really missing some key concept with the MOSFET.

I just have a 9V batter lighting up two LEDS and I wanted to cut the circuit and insert the MOFSET's source and drain.

I have zero clue what I'm doing wrong - or doing :).

Thanks,

Ken

February 04, 2011
by kvjohnso
kvjohnso's Avatar

Here's what I've done so far. Any ideas what's wrong (or right :) ) ?

alt image text

February 04, 2011
by mongo
mongo's Avatar

You might want to tie the negative of both power sources together. The signal is probably making it out but there appears to be no return path.

February 04, 2011
by kvjohnso
kvjohnso's Avatar

Thanks for the reply but it didn't seem to work. The LEDs are just staying on even though the meter shows that +5 volts is only coming from the MCU in 10 second intervals (on 10 sec off 10 sec).

Thanks again,

Ken

February 04, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Ken, you’re on the right track. I did have this all written out but I think pictures work better: The resistor is just the first one I grabbed, I think it's a 1M ohm resistor so its there just to show where it would go. The MOSFET is a 2N7000, exactly what comes in the Nerd Kit.

pic 1 pic 2 pic 3 pic 4

I hope this helps

Chris B.

February 05, 2011
by kvjohnso
kvjohnso's Avatar

This really helped. Thank you so much. The pictures were perfect.

I replaced the LED with a 9V relay and now the relay "clicks-on" but it won't turn off after I send the "off" signal from the MCU. It will only turn off if I pull the mosfet out (bad idea I know) or undo the relay's 9v source..

Any ideas? Sorry for the trouble.

alt image text

February 11, 2011
by BobaMosfet
BobaMosfet's Avatar

kvjohnso-

What is the part number(s) on the solenoid, so we can look at a datasheet?

BM

February 13, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Kvjohnso Here’s what I see:

1.It looks like you are using one 9V battery for your nerd kit and another for your relay. Not entirely necessary but it will prolong your battery life.

2.If you are using the MOSFETs that came with your kit, it appears you have everything wired to the GND of the circuit.

3.I noticed the two batteries do not have their respective GNDs tied together.

4.It also appears that you have the 9V of one battery tied to the GND (blue rail) of the circuit.

Here is what I would do:

1.on the battery at the bottom of the picture, match the colors to one another (RED to RED and BLACK to BLACK)

To test this, tie the middle pin of the MOSFET to 5V(Don't forget to disconenct the MCU first). The relay should energize until you disconnect the 5V. Whenever I use a MOSFET, I try to involve an LED so I am sure the MOSFET is working correctly. Basically what I just typed is already shown in the pictures above, just substitute the relay for the LED.

DISCLAIMER: I may be WAY off base and if I am, I’m hoping someone smarter than me can correct my error :-)

Chris B. n3ueaEMTP

February 15, 2011
by kvjohnso
kvjohnso's Avatar

Chris and Company. I was on travel for a bit so sorry about delay getting back to you all.

I took your advice and a "clue" from Chris and now everything is working.

The relay needs 9V to engage. I Liked your LED idea. A lot easier to trouble shoot. Thanks.

Question (again), if my DC power supply gave enough volts, how would I wire it to run both the MCU and the 9V relay.

Thanks again for all your help.

Ken

I cleaned it up a bit and here is the latest - that's 9V coming in from my DC power supply.

alt image text

February 16, 2011
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Ken,

I think that the reason that the relay coil won't turn off is that the MOSFET may be wired "backwards" -- with source and drain reversed. That is, I believe that the photos posted by n3ueaEMTP actually are actually showing the 2N7000 MOSFET in a configuration where it would be permanently on, and wouldn't be able to turn off.

Basically, you should have the 2N7000's "Source" pin to ground, the "Gate" pin to the microcontroller pin, and the "Drain" pin connecting to the "low side" of your load. The "high side" of your load would then connect to +9V or similar.

If source and drain terminals are inadvertently reversed, you'll find a undesired behavior which has to do with something called the MOSFET body diode, which is basically a built in diode which is simply a byproduct of how the MOSFET is manufactured. For an n-MOSFET body diode, anode = source, cathode = drain. Therefore, when the source terminal is at a higher voltage than the drain terminal, current will flow, regardless of the gate-source voltage.

However, looking closely at the most recent photo that you've posted, I think you've actually got it OK in that regard -- source terminal to ground. But the way that the second power supply and relay are connected do not look exactly right. Try this:

  • Remove all relay and 2nd power supply connections.
  • Connect the negative terminal of your power supply to the existing ground rail.
  • Connect the positive terminal of your power supply to one of the relay terminals.
  • Connect the 2nd relay terminal to the drain pin of the MOSFET.

If you then want to run everything from the same power supply, then you can simply remove the 9V battery and connect the positive supply of your power supply to the input of the 7805 voltage regulator.

Hope that helps!

Mike

February 16, 2011
by kvjohnso
kvjohnso's Avatar

Perfect. Once again, your help is incredible. It's working nicely.....

I do have one last question. I'm learning a lot of EE stuff these past few months thanks to everyone here. All the source code is great. However, I now know how to program the MCU and read data from the serial port, but one little part is missing...

Is there any NerdKit C examples on a standalone program to send signals via the USB/Serial cable? I'd like to be able to override the sensor that's controlling the MOSFET gate (PC4) from the command line. I've tried googling for some explanations but my search words weren't too successful :(.

Thanks again!!!!!!

Ken

March 26, 2011
by esoderberg
esoderberg's Avatar

I'm working on a similar problem. I'd like to run a 12v/5A linear actuator, controlled via PC1 and PC2. I just want to run it all the way to its limit switch with PC1 and then all the way to opposite limit switch with PC2. Just running in one direction seems easy enough, with an N channel transistor on the low side completing a circuit. But as I want to be able to reverse the direction, I need to control the high side as well. Below is the circuit I came up with. Any comments on whether or not it should work appreciated.

schematic

March 27, 2011
by esoderberg
esoderberg's Avatar

Does posting images hosted on Google docs work? Thought I followed the instructions on the above post for posting an image, and the image comes up if you right click open in new tab, but obviously shows as broken.

March 27, 2011
by esoderberg
esoderberg's Avatar

Well I suspect that one could direct link to a google doc, but I couldn't get it to work and just followed the recommended method.

schematic

March 27, 2011
by esoderberg
esoderberg's Avatar

A little off thread topic, but I finally figured out how to post an image hosted on Google Docs after several failed attempts seen above.

Upload and open image on Google Docs. Instead of copying the link that says "link to this page" on the right side of the screen, right click on the Download menu in the upper left. It will give you an option to "copy link address", the link you get this way works per NK instructions, the other "link to this page" does not.

Eric

Post a Reply

Please log in to post a reply.

Did you know that interrupts can cause problems if you're not careful about timing and memory access? Learn more...