Electronics > Beginners

Switch power to load using 2 GPIO pins, 5V and 12V

(1/2) > >>

dindondee:
Hello everyone,

I'd like to control a buzzer with two volume levels(voltages) using GPIOs. I have 3.3V, 5V and 12V rails available and the MCU is connected to the 3.3V rail. Does this circuit work for this? My idea is to use 2 MOSFETs, one for the 5V and another for the 12V rails and place pullup resistors on the gates of the MOSFETs from the GPIOs to ensure they are on when needed. Then a program ensures the 2 GPIOs can never be on at the same time, just one at a time.



Is this safe/legal? I know that I will need P-channel MOSFETS, here's a schematic of my thought process and I hope you can correct or tender suggestions with better solutions. Thank you very much!

Ian.M:
No.  You need to level shift each gate drive as it needs to get all the way up to the respective supply rail to fully shut-off a P-MOSFET, so M2 will be hard on all the time (with min. -8.7V Vgs).  Also the body diode of M1 wont block voltages above 5V (the rail feeding its source), so it will dump the 12V from M2 (less one diode drop) onto your 5V rail, letting out the magic smoke from the rest of your circuit.

To fix the level shifting issue, use low Vgs threshold N-MOSFETs to drive the P-MOSFET gates, with a pullup resistor to the P-MOSFET's supply rail.  To fix the reverse conduction through M1 (via its body diode), add a schottky diode in series with M1's drain.

Does your buzzer actually work properly with 1K in series with it?

dindondee:

--- Quote from: Ian.M on June 27, 2022, 06:24:59 pm ---Does your buzzer actually work properly with 1K in series with it?

--- End quote ---

No, this is just an example. I am yet to adjust for current yet.

Is this circuit a better interpretation of what you suggest?

Ian.M:
The level shifting looks sane, and as a whole it will probably work, but to be certain it doesn't do anything odd at the moment of GPIO18 switch-off, due to stored gate charge in M1 from its source being dragged up to ~11V via its body diode, I'd put D1 in series with M1 drain, not M1 source where you have it.

Caution: if the buzzer is electro-mechanical add a diode in parallel with it, cathode positive to suppress any back-EMF.

Zero999:
Why not use a single IO pin, with an emitter follower with a filter and PWM to adjust the volume?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod