2
\$\begingroup\$

I want to use the digital output of an Arduino Nano to switch the VPP pin of an AT89C1051 between 12 V and 5 V, for programming.

The tolerances for 5 V are 3.5-5.5 V and for 12 V the tolerances are 11.5-12.5 V. The maximum current for programming is 250 μA. I have designed the following circuit] using a single NPN, and a current source to simulate the AT89C1051.

circuit

Simulation

Simulation using resistor instead of current source

Simulation with a RST switch for 0 V

Both the on (5 V) and off (12 V) state use the 12 V power source, the 470 Ω serving as a voltage divider for the on state. I'm avoiding diodes in the 12 V path to avoid voltage drop.

Varying the current source from 0-250 μA at either the on (5 V) or off (12 V) state, everything seems to be within spec. But given the circuit is very simple compared to anything else I could find and that I am not an expert, I'd like to have a second opinion on this.

Also I'm assuming the transistor I have (2N2222) will behave close enough to Falstad's NPN. According to figure 3 in the datasheet, at ~7 mA in Ic at ~25 °C I should expect 150 hFE in the transistor, which reduces the on state to around 4 V (still fine).

Figure 3

\$\endgroup\$
0

1 Answer 1

2
\$\begingroup\$

There’s two problems with your circuit.

  • It assumes a fixed load for 12V mode

That's not going to be the case with this part during its programming cycle: the varying draw will cause your voltage to shift due to the varying IR drop.

  • RST needs to be controlled in sequence at the beginning and end of the programming cycle

The programming sequence starts with RST low, then 5V, then alternating between 5V and 12V, then to 5V, then low before powering off. To accomplish this you really need to switch properly between GND, 5V and 12V as stated in the data sheet Programming Algorithm.

Below are a couple of ideas to do that (simulate them here)

enter image description here

The upper sim uses FETs, the lower one uses bipolar transistors and a diode.

I should also mention that I just used a 47k ohm load (about 250uA at 12V) to model the minimum pull-down value in the IC.

At any rate, the circuits work as follows:

  • In non-PGM mode (Vpp Enable = L) the RST/Vpp pin is controlled by a 3-5V signal Reset.
  • During PGM mode (Vpp Enable = H) the RST/Vpp pin is pulled up solidly to 12V, irrespective of the current on RST/Vpp.

The chip RST/Vpp pin has a weak internal pulldown, so the second circuit will work too even if RST is low. Still, for the lower, BJT-based sim I added a separate pull-down for the RST pin to reduce the possibility of noise pickup.

Big picture: programming fixtures deserve careful, robust design, which strictly follows the programming sequence specified by the manufacturer. This is no place to cut corners just to save a 2-cent transistor.

\$\endgroup\$
8
  • \$\begingroup\$ I'm not assuming a fixed load: I'm using the current source (not meter) to vary the current draw, which is equivalent to varying the load. You can set the load to any value in the range 0 - 250 μA (maximum comes from the datasheet) and see that everything is within tolerances for either switch states. In the original post you can click the "following circuit" to open the simulation, and vary the current with the slider at the sidebar. \$\endgroup\$
    – nicbn
    Nov 14 at 23:05
  • \$\begingroup\$ You would model the load as a resistance, not a current sink. At any rate, your circuit isn't handling the case where RST needs to be low for the device to run. \$\endgroup\$ Nov 14 at 23:20
  • \$\begingroup\$ I edited the post to contain a simulation with a resistor instead of current source as well, you can see it's the same. The current source/sink acts as a resistor in order to keep the voltage drop. I also included a simulation that handles RST by pulling the output to ground. \$\endgroup\$
    – nicbn
    Nov 14 at 23:42
  • \$\begingroup\$ About the suggested circuits: I like the second one. When the load is infinite (no current) the voltage always goes to 12 V so I'd add a 1 MΩ pulldown just to be sure. I'd still like to know if the first one I suggested is ok, just because I don't have MOSFETs ATM to work with. But I might switch to your circuit next time I order components, as it draws less current and provides pretty much exactly 12 V (5 V still has some wobble but it's still fine). \$\endgroup\$
    – nicbn
    Nov 14 at 23:56
  • \$\begingroup\$ The RST pin has an internal pull-down, but it's highly variable (up to 330k). I suggest about 47k or so for an external pull-down. The first circuit works, but yes it's more complicated. That's why I did the second, with the diode, as a simplification. \$\endgroup\$ Nov 15 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.