3
\$\begingroup\$

I am trying to use a microcontroller (specifically attiny85) to "fake" a computer fan on a computer motherboard. For the computer to recognize a fan, the tachometer pin on the motherboard must be pulled low twice per revolution of the fan. Thus, I am generating a square wave of arbitrary frequency with the microcontroller and I want to use a transistor to pull the tach pin low whenever the microcontroller output is high. GND is shared by the microcontroller and the computer. The tach pin normally sits at approximately 2.5 v when not pulled down. I currently have the following circuit:

enter image description here

When this is hooked up, it seems to shutdown the microcontroller, and resets when I unhook any of the connections on the transistor. Can anyone tell me what I am doing wrong?

\$\endgroup\$
4
  • \$\begingroup\$ Add a 10k resistor in series with the square wave so that it doesn't over-drive the base too much. \$\endgroup\$
    – user57037
    Commented May 8, 2020 at 23:24
  • \$\begingroup\$ Make sure that the tach input is high when the 2N2222 is not connected. In other words, make sure it is pulled high somehow on the motherboard. \$\endgroup\$
    – user57037
    Commented May 8, 2020 at 23:26
  • \$\begingroup\$ If I may ask, why are you trying to fake the fan? This can be dangerous and you may end up burning out whatever part that fan was trying to control (CPU, GPU etc) \$\endgroup\$ Commented May 9, 2020 at 12:10
  • \$\begingroup\$ Doesn't Attiny have open-drain mode of GPIOs? \$\endgroup\$
    – fraxinus
    Commented May 9, 2020 at 16:26

1 Answer 1

9
\$\begingroup\$

Three problems:

Transistor base current

You are murdering the transistor base. The connection between the base and emitter can be treated much like a diode. When you connect 5 V directly to it, you essentially short-circuit the CPU output pin and a huge amount of current will flow.

In your case it will be limited by the attiny's output current limit, which is only supposed to be used in "emergencies" like this. The circuit will still draw a lot of current through the CPU power supply pin, likely lower it intermittently to a voltage that is too low to function or trigger the brown out detection that reset the CPU.

All of this can be solved with a simple resistor:

schematic

simulate this circuit – Schematic created using CircuitLab

This limits the current to about 0.5 mA, which should be enough to drive your transistor in this case. Decrease it to something like 4.7k or 2k if it doesn't work, but it should.

CPU resetting

You may have too little decoupling capacitance on the CPU voltage input. Make sure there's at least 1 µF of capacitance between GND and VCC near the CPU VCC input pin, and this kinds of CPU resets should be less common.

Tachometer pull-up

You may need a 10k pull-up from the tachometer input to the fan +12 V supply. Right now you are measuring around 2.5 volts which suggests that it is may be floating. I'm not sure if it is necessary in this case, but try that if you can't get this to work. I'm getting some conflicting information when searching for details about this input, a comment by Spehro Pefhany suggests that this may even be harmful, and I agree. The pull-up should not be necessary.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you. Adding the resistor on the base of the transistor seemed to do the trick. No more resetting. As far as the pull-up on the tach input, the motherboard is supposed to have a pull-up built in, so I will leave it. It seems to work ok. \$\endgroup\$
    – matdogg
    Commented May 9, 2020 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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