Issue with MOSFET circuit

Hi everyone!

This is my very first post here in this forum and I hope I'm explaining my problem the right way and you guys can help me. (I apologize in advance for any language/grammar mistakes as English is not my first language.)

I'm currently learning about different electronics parts and I just can't find the mistake I made in my little project. (Of course there must be one, I just can't find it :frowning: )

Attached you'll find a picture of my breadboard and a schematic of the circuit.
The process should be as follows:

  • Pushing the button sends a signal to the Arduino input pin (no. 4) ("Button pressed") <- working fine!
  • The Arduino then sends a "HIGH" on the output pin (no. 8 ) which goes into the PC817 optocoupler <- working fine!
  • Now here the problems start: On the other side of the optocoupler I have an external 12V source that should switch the 5V (external source) circuit of the LED via a 30N06L MOSFET.

First of all, from my understanding, the 12V circuit should not work until I push the button and send 5V to the PC817. But I can constantly measure 12 V from the collector to the emitter. Only when I push the button, voltage drops to zero. Is there anything wrong or am I not understanding the opto correctly?

And then there's the problem (?) with the MOSFET:
No matter if I push the button or not, I constantly read 3,62V from Drain to Source (and -3,62V from Ground to Drain). What is happening here? Why doesn't the MOSFET react to the button? Up until the MOSFET I can measure the drop from 12V to 0V when I push the button. But the MOSFET itself doesn't react to anything. I already tried another MOSFET of the same type because I thought that maybe somehow I fried the other one, but the problem persists.

The LED is definitely working, because if I connect it directly to Ground it lights up correctly.

I tried googling, but apparently my mistake is so obvious that there was no need for a stupid question like that yet. :smiley:

I would be so grateful for any advice you can give me! Thanks a lot in advance!

Simz

The schematic is completely wrong.

You have the gate shorted to GND, plus you do not need a source resistor but you need a 10k gate resistor to GND.

The opto is drawn wrong.


As larryd said. Try this:

Hi!

Thank you so much for your reply!
(And I'm sorry, I didn't think of embedding the images, thank you!)

I shouldn't have used this free circuit drawing program, it lacks parts and features and I drew the MOSFET part wrong - SORRY! Here's the circuit as drawn by hand:

And the breadboard:

(In case the imgur links don't work I attached both images again.)

Is it still that wrong?

I swapped the 150R for a 10k with no success.
I'm very sorry to bother you all with my apparent lack of knowledge, but I would really like to understand what I'm doing wrong here. :frowning:

Thanks a lot for your help!

Simz

Ooooook, so after swapping the MOSFET again for a new one (because who knows, right) the LED flickered a little when I pushed the button (4 button presses) and now it's back to doing nothing again. Am I destroying MOSFET after MOSFET now? :smiley:

I feel like success is right around the corner and there's still a short somewhere (?) but I just don't see where exactly! :slight_smile:
I promise I'm going back to easier stuff after this, but I'd be so happy to learn where I went wrong!

Thank you all for your replies so far! :slight_smile:

Where the -'s of the 12V and 5V connected to? Assuming you have the +'s connected to the resistors shown.

Thank you both so much!

I removed the 330R and now the LED is permanently illuminated (yay! And as is expected because the 12V circuit is always closed, which I unfortunately still don't know how that's possible).

When I push the button now, voltage on the LED increases. I honestly expected the gate to open which would lead to the LED turning off.

The - of the 12V is floating as there is the GND of the 5V circuit that the opto is connected to. Is that wrong? Should they share a common ground? But wouldn't that defeat the purpose of the opto-MOSFET-circuit?

I'll attach the schematic that I tried to follow just for your information. (With only one channel though. The input board is working fine.)

I'm very sorry, I don't want to give up yet. :frowning:
I really appreciate all your comments/help!

Does anyone have that wonderful Fritzing program? ;D

Hi,
Do you have a DMM?

Tom... :slight_smile:

I guess you're being sarcastic, but in case you're not I downloaded Fritzing and recreated the schematic there:

Yes, I have one (it's pretty old and I don't know how reliable), which measurements do you need? So far I measured:

  • LED: 5V to cathode of the LED: 2.35V -> 2.67V when the button is pressed
  • MOSFET G to S: 1.10V -> 1.27V when the button is pressed
  • MOSFET D to S: 1.97V -> 1.78V when the button is pressed

Thanks in advance!

Hi
Can you measure these points with and without the button pressed.
Can you also post your test code?

Measure;
With neg probe on C
Between, A and C
Between, B and C

With neg probe on H
Between, D and H
Between, E and H
Between, F and H
Between G and H

Thanks.. Tom.. :slight_smile:

Please excuse this stupid question, I'd love to get to measuring right away, but which points do you mean exactly? :frowning:

Oh, and here is the code. It's very simple and just tells me if the button is pushed and therefore sending a signal.

const int buttonPin = 4;
const int outputPin = 8;
int buttonState = 0;


void setup() {
  pinMode(buttonPin, INPUT);
  digitalWrite(outputPin, LOW);
  pinMode(outputPin, OUTPUT); 
  Serial.begin(9600);
}

void loop() {

  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH)
  {
    Serial.println("Button pressed");
    digitalWrite(outputPin, HIGH);
  }
  else
  {
    Serial.println("off");
    digitalWrite(outputPin, LOW);
  }
  delay(500);
}

Hi,
Sorry this one.

Inet dropped out.

Tom... :slight_smile:

Thank you! :slight_smile:

With negative probe on C

Button NOT pressed Button pressed
Between A and C 0 V 4.80V
Between B and C 0 V 1.26V

So I guess there are some weird things happening with negative probe on H

Button NOT pressed Button pressed
Between D and H 11.56V 1.51V (and the LED is turning off as soon as I touch both points)
Between E and H 1.31V 1.51V
Between F and H 1.59V 1.72V
Between G and H 4.96V 4.96V (no change)

Thank you for taking some time out of your day and trying to help me! I really appreciate it! :slight_smile:

Simz

Hi,
Point D is your 12v power supply, it should not change in either state.
What is your 12V power supply and is its negative terminal connected to H?
Is your 5V supply negative connected to H?

Check that you do have the MOSFET connected correctly.

Tom... :slight_smile:

Hi,

Tom... :slight_smile:

OH MY GOD, it's working!!! :slight_smile: :slight_smile: :slight_smile:
Thank you so much, that was it! Both negative terminals of the 12V and the 5V power supply are now connected to H. I'm so stupid...

Thank you thank you thank you and I really learned a lot in the last 24 hours :slight_smile: