piotrb5e3 / AT89C2051_programmer

Python & Arduino-based AT89C2051 programmer
GNU General Public License v3.0
22 stars 7 forks source link

Question about optocoupler #3

Open tfry-git opened 5 years ago

tfry-git commented 5 years ago

So I bought an AT89C2501-based diy clock for my kid to solder, and ... it isn't working. What a great excuse for looking into the hows of a new MCU! It looks like I'm probably going to build your programmer (and thanks for sharing!), but two questions about the optocoupler:

1) You write that an optocoupler with mosfet output is best, but I don't have that in my box. In an earlier description, you seem to have used an EL817. Will that sort of work, and what issues should I expect?

2) Why are you using an optocoupler at all? AFAIU, the problem is that you need to feed 12V, 5V, and 0V to AT89_RST. But the ground level is still the same as that of the Arduino, so why not just use a plain transistor (mosfet), to feed in the 12V? Also, why not just a plain diode between A0 and AT89_RST to protect A0 from the 12V?

tfry-git commented 5 years ago

Ok, never mind question number 2. I see now that the ground level is not "the same as that of the Arduino", but either 0V or 5V, depending on A0. D'oh!

Still looking for your insight on question number 1, though.

piotrb5e3 commented 5 years ago

AD1. A transistor-output optocoupler should also work. I used what I had laying around. AD2. The ground level is the same - see 12V terminal connections. I used an optocoupler to make the design simpler, but a PNP BJT or a P-channel MOSFET could also work. Schematic idea: Arduino drives an NPN that shorts the gate of the PNP to the ground to enable 12V. You can't drive a high-side PNP enabling a voltage >VCC directly from an Arduino - it will be always-on through the pin overvoltage protection diode. This version also requires careful placement of resistors to limit the base current.

tfry-git commented 5 years ago

Thanks for your answer!

As usual, I got side-tracked, but I do plan on getting back to this. Here's my circuit idea, using two 2N7000s: http://tinyurl.com/y7dv6otj (for simplicity, I added switches connected to 12V for toggling the gates, but of course these would be connected to arduino outputs in reality.

The AT89_RST-pin is high impedance, right? Then this design should allow to get by with very few common parts. Unfortunately, it reverses the current logic, so I'd have to change the code, too. I'll keep you posted on how it goes...

steveschnepp commented 1 month ago

I used 2 npn and 3 leds. https://blog.pwkf.org/2022/08/27/simple-at89c2051-programmer.html