Atmega328 and a logic level mosfet p30n06le

Hello All,
I have a stand-alone atmega328 on a breadboard with my script and a momentary-on button switch that when I send 5v to the gate of the mosfet "HIGH" the drain goes to zero volts and when the momentary-on button is off I hace 12v on the mosfet drain. This is the opposite of what I want. How can I get 12v to the drain when I press the momentary on button and it has 5v to the gate.

Thank you

What is connected to the drain? What is connected to the source? Post a wiring diagram, here's a start.
Pch

I will take a SWAG but please send the schematic as requested. It sounds like a N-channel device and you are referencing the source for your Vgs measurements. What you want will not happen. The MOSFET will only sink current, If you want to source current you need to use a P-MOSFET. Assuming something on the drain to pull it up then logicly your circuit is working as it should. You can add some external hardware or invert your control signal from the microprocessor. Also define the load.

Actually, everything works, the low beams blink, and the high beams blink on demand,

except for my LED indicator light on the momentary-on switch, for the high beams, it is OFF when the high beams are on, and very dimly lit, when the high beams are on, Just the opposite of what it should be.

Here is my schematic, the low beams work, and the low beams blink when I press the momentary-on switch for the low beam, and the low beam indicator led works fine, it is always on and it blinks in step with the low beam lights,

The high beam led indicator on my momentary-on switch is the problem, when I give 5v to the gate of M2 my high beams turn ON, but my led indicator on the high beam momentary-on switch turns off, and if very dim.

When I toggle my momentary-on switch to off, the high beams turn off, but my led indicator on the momentary-on switch is ON full brightness.

You can see my bench power supply readings in the last two photos

Thank you,

high_beams_off_1
High_beams_on_1

Your schematic does not follow easy to read, standard conventions for the connections to a MOSFET. So it's really not clear from that, how you actually have it connected. The explanatory note you appended, only adds to the confusion.

Please have a look around at some MOSFET circuits, and re-draw your diagram in a standard way.

1 Like

Thank you for your reply, but I would not know how to draw it any other way to make what I did any clearer. I am a relative newbie to electronics.

That is why I suggested you go look at how it's done. You only need to look at a few simple circuits, and it's obvious.

1 Like

I just removed my momentary-on button with the led indicator and I replaced it with a standard momentary-on button without the led indicator and my circuit works. So the schematic I am showing works.

So the problem I have is with the led indicator on the other momentary-on switch.

Can you see where you would put the leads to the switch to make it work correctly? Sorry if I am not clear on your suggestion. I have looked at many circuits none with an led indicator I can find.

I can tell you that when I turn on the momentary-on switch for the high beams, the gate voltage goes to 42ma, and the drain goes to 10v, and when the momentary-on button is switched off, my gate voltage is 5v, and the drain is 6mv

A voltage can't be measured in mA.

I figured it out, as gilshultz pointed out, I needed P channel MOSFET with an NPN transistor, It works the only downside is the led indicator on the momentary-on switch that turns on the high beams is only getting 5v not 12 because of the fact that the hot side of the led part of the switch is connected to the base of the NPN transistor which gets 5v from the atmega328 pin.

Any ideas on how I can get 12v to the led indicator and still make it work correctly?

Thanks for any help

1 Like

I'd like to help, but your schematic is just too painful for me to work with. Sorry. It's nearly impossible to tell where the high beam switch is actually connected (for example).

https://electronics.stackexchange.com/questions/28251/rules-and-guidelines-for-drawing-good-schematics

here is the P-Channel_schematic, this solves problem only downside oly 5v to led 12v indicator led, how can I get 12v to it? and keep all else the same? Thanks sorry if I am being a pain.

I can't believe it I just realized I could connect the led indicator to 12v at the drain of the p channel MOSFET LOL, I am 100% now will send corrected schematic.

Thank you for your help, much appreciated

Here is the 100% fix
!

Thank you

No, that can never work reliably (or at all). There is no resistive load on the BJT collector. I wonder how you can present something like the 1V reference V1, and not explain. What is it modelling, and why is it there? LED D1 would explode in a shower of fragments if the MOSFET ever turned on, that is if the source were connected to a realistic voltage source like 12V. SW1 will never turn off the BJT. So it's ineffective.

Are you saying it will not work overtime? I followed this tutorial on youtube MOSFETs and How to Use Them - A Comprehensive Guide - YouTube

Currently, my circuit is working fine on the bench, the led on the momentary push-button switch that turns on my high beam fog lights, has the full 12v and it turns on when I turn on the high beams and it turns off when I turn off the high beams, everything blinks too at 100ms high beam and/or low beams. The led indicators blink too in sync with the fog lights as I wanted for feedback.

Please see the video and explain what is missing. What would you add to fix it, and where? Thanks

Just my two cents: I'm a fan of the IRFZ44N, and not only because i have a box full of them..
with a Uds of 3V and up it conducts with an Rds of several milliOhms.. It can handle roughly 50A, it costs almost nothing.. Ok, it has a TO-220 housing but you can file off the top if the current doesn't exceed 10A...
Actually no resistors neccesary but a 10k from gate to source and a 1k to the processor is "nice":wink:
The load can be connected from the Drain to the +V..
Kees

I'm saying it won't work for even a millisecond. I don't have time to sit around watching YouTube videos. I mix my attention here with my other work. It takes me only a few minutes or seconds to evaluate a simple circuit like that. A collector load is absolutely required for any BJT to work. If it's missing, it really can't work. Not reliably. It's possible that the circuit you have on your bench is not the one that you posted, or that the tiny gate current leakage from the MOSFET is making it appear to work, but be assured that the circuit you posted is a crock.

For some more detail... the resistor network on the base of the BJT can never turn the transistor off, because SW1 only closes the voltage divider, and the resulting 2.5V is still way over the Vbe 0.7V of the transistor.

The LED would explode because it has no current limiting resistor.

I can only conclude that you're not checking the schematics you post (thanks for the improvement, by the way) do not reflect the hardware that you actually have.

That makes it impossible to help you, because people here don't have your hardware and instead depend on reliable information from you.

Sorry, you sound so upset in your reply, I'm sure you know your stuff. I was hoping you would tell me what and where to place the component od components needed to make my circuit be satisfactory and safe. I just saw your resistive load on the BJT collector Can you explain to a novice what that would be? thank you

Can you tell a novice what component to get and where to place it in the circuit?

Thank you

Let's start with an accurate, complete, and verified schematic of the whole deal...