I'm going to send a signal from a 24v machine, to my Pico. Obviously that voltage would destroy my MCU immediately so I need to run it through an optocoupler or a mosfet before going to the gpio. I'm unsure which to use.
I will be powering my Pico from the 24v machine through an L7805 voltage regulator. Since they will have a common ground, I'm not sure if an optocoupler would give me the electrical isolation protection I would need. A mosfet seems like it would work but would require 2 resistors for a voltage divider and they seem to be a bit more expensive.
The opto will isolate the +24V when the resistor is added. I have done this many of times but that was before built in pull up resistors in processors. The 24V ground will be connected via the 5V ground, they are the same.
Hi,
Have you checked how much current the Pico will need and anything else on the 5V supply?
Linear regulating from 24V to 5V is not efficient and you need to calculate the power dissipated in the 7805, and work out if it needs a heatsink.
A DC-DC converter may be better, more efficient and cooler to run.
Tom...
PS. Good that you have read the specs and put bypass caps on the 7805.
If you don't need isolation why not just have a potential divider straight to the Pico input? I look after a clock that has a 24v contact driving an electromagnet. There's a snubber across the contact 1k parallel with 220nF; then a 1k shunt, 8k2 series, 1k2 shunt and a 1N4148 to protect against negative spikes (observe polarity of diode). This drives a 3v3 input on a Due, has been doing so for years with no issue.
100K and 10K would give you 2.18V at the GPIO, which might be high enough to register as high. If not, 100K and 15K would work.
If your 24V signal was actually at ground when not asserted, you could enable the internal pullup resistor on the I/O, and use a single diode for the connection.
Yeah, I guess. Although - it's 100K, and there's no doubt a protection diode on the GPIO. So maybe just the resistors would be good enough for the girls I date.
I do like the idea of the voltage divider straight to the GPIO on the pico. I would need a divider anyway for a transistor. I could just forgo the transistor.