Hi all,
Hope you can help me again.
My circuit:
- Breadboard arduino running at 8MHZ
- Atmega328p running on 3V from battery
- WS2812B's running on battery boosted to 5V
- Led data is levelshifted to 5V by SN74LVC1T45
I've been trying to get current consumption of WS2812B leds down when not needed by adding a p-channel mosfet on their supply side. I expected the leds to shut down when the LEDFET pin (see image) was left floating by setting its PINMODE to INPUT (I expected the gate would be pulled up to 5V by the 10K resistor).
Unfortunately I'm seeing 3.8V on the gate when doing this, the MOSFET is still conducting and the RGB leds do not shutdown...
Any help is much appreciated, please ket me know if you need more info 
please ket me know if you need more info
Specify the MOSFET. Post the code, using code tags.
You MUST NOT apply more than Vcc+0.5 V to an input, and it appears you are violating that.
jremington:
Specify the MOSFET. Post the code, using code tags.
Hi, thanks for your quick reply!
Mosfet is FDV304P, broken out.
Code (stripped out Fastled code):
#define LEDFET_PIN 5
void setup() {
}
void loop() {
// Turn on P channel MOSFET: Set ledfet pin to output and 0V
pinMode(LEDFET_PIN, OUTPUT);
digitalWrite( LEDFET_PIN, LOW );
delay(2000);
// Turn off P channel MOSFET: Set ledfet pin to high impedance
pinMode(LEDFET_PIN, INPUT);
delay(2000);
}
You MUST NOT apply more than Vcc+0.5 V to an input, and it appears you are violating that.
This sounds like its the problem, what would happen if I put 5V on a 3V atmega328P input pin? What would make that pin go to 3.8V?
EDIT: Reading up on max input voltage, am I seeing 3.8V because the protection diode on the input pin is kicking in?
// Turn off P channel MOSFET: Set ledfet pin to high impedance
pinMode(LEDFET_PIN, INPUT);
Don't do that, just set the output high to turn it off.
Maybe you didn't get what jremington was telling you. You are putting 5V to pin 9 through R9. As the Arduino is only being powered by 3V3 then you are overvolting the pin. Maybe it is already damaged.
what would happen if I put 5V on a 3V atmega328P input pin?
You stand a good chance of burning out the pin or worse.
The 3.8V is probably explained by the voltage drop across the 10K gate resistor, due to current flowing from Vcc into the pin (and rest of the chip, due to the diode to Vcc).
This is a bad design and should be revised immediately. Most people use an NPN transistor (with a suitable base resistor) to switch the gate of a high side P-channel FET.
Grumpy_Mike:
// Turn off P channel MOSFET: Set ledfet pin to high impedance
pinMode(LEDFET_PIN, INPUT);
Don't do that, just set the output high to turn it off.
Maybe you didn't get what jremington was telling you. You are putting 5V to pin 9 through R9. As the Arduino is only being powered by 3V3 then you are overvolting the pin. Maybe it is already damaged.
Hi, thanks for you input, I get what he was saying, I put my code as I used it before asking the question on the forum. Thereby probably frying something, if I try putting the LEDFET pin to HIGH instead of INPUT I am still getting 3.8V.
if I try putting the LEDFET pin to HIGH instead of INPUT I am still getting 3.8V.
You cannot apply a voltage greater than Vcc+0.5 V to an output, either. The 10K limits the current, so you may not have damaged the MCU.
Ok, thanks very much for your help
, I will have to look into other means of switching...
jremington:
This is a bad design and should be revised immediately. Most people use an NPN transistor (with a suitable base resistor) to switch the gate of a high side P-channel FET.
Thanks, this seems to be the solution. Found this circuit on PJRC Teensy site:
