Made the circuit attached only with no diode and a 2N3904 transistor. Using the example code "Fade" as well as a few of my own but the multiple fans I've tried all refuse to spin.
Circuit works at 5 V instead of 12 with LED's...5 volts wont turn the fan anyway (not without a push)
Tried upping the voltage and Amp on my power supply...no luck
Tried rotating transistor so Emitter was collector and collector was emitter...fan turned constantly at full speed, unsure why...
Fans all work when connected to regular power supply...they are all the 3 wire variety wit red+black, then yellow for measuring RPM (i think?)
I've kept at it but no success. I forgot about coding for now and focused on the circuit. I just used a optocoupler and a 9V battery. Whether or not the optocoupler has 5V coming from the arduino the fan wont spin...it spins beautifully when when connected to the battery.
Will be checking the thread frequently, please help
How big is the fan. 120mm? Could draw ~200mA. Bit much for a 2N3904.
Saturating the transistor for 200mA requires 10mA base current.
The opto and the resistor will limit base current to only 1mA...
If you don't saturate the transistor, it will get hot.
Can't you share grounds, dump the opto, and drive the base directly from a PWM pin.
analogWrite(fan, 1023); // Looks like an Uno clone. 100% PWM is 255, not 1023
Leo..
If you jumper pins 4 and 5 of the opto together, does the fan run?
What is the voltage across the two 220R resistors when the fan is supposed to be running?
Here is a useful trick, put an LED in series with the opto LED, change the series resistor by recalculating your LED current for 10mA, the extra external LED will act as an fan on/off indicator and not consume any extra current.
(In this case be good to help circuit debugging)
Fans all work when connected to regular power supply...they are all the 3 wire variety wit red+black, then yellow for measuring RPM
You have BLDC fans they do not like running at half or 3/4 rated voltage, they have built in speed control circuity, to keep fan speed constant, varying the supply voltage to change speed is just a unstable/unpredictable response from the fan control circuit.
Use digitalWrite instead of analogWrite and it will work properly.
Chill_Polins:
I'll try just using Pin9 for the base...It wasn't working earlier, I'll try again when I get back to the workshop tomorrow.
You might already have blown the transistor with all your experiments.
Never connect a transistor backward.
Always use a current limiting resistor between PWM pin and base.
Calculate base current for ~1/20 of the collector current. 470ohm is a good start.
So +fan to +12volt supply, -fan to collector. Add a diode across the fan.
-12volt supply (ground) to emitter and Arduino ground.
PWM pin via ~470ohm resistor to base.
analogWrite(fan, 255); // sets PWM to 100%
analogWrite(fan, 128); // sets PWM and fan power (not speed) to 50%
Leo..
I see that the 5V gate signal and the negative from the 12V supply need to share groundsFOR SOME REASON..wanted to separate circuit with optocoupler but that would require a second 5V supply independent of the Arduino...not interested.
Hi,
The reason that the two supplies, 5V for the gate and 12V for the fan, need to have their gnd/neg connected together is because the MOSFET is controlled by a voltage between the gate and source, the fan current needs to go through the source to drain circuit.
So both voltages need to have their gnd or neg connected to the source.
interesting, in my first post I attached a picture of a circuit with an octocoupler. However it gave no details on where to connect pin 6 of the IC...is this connected to the 12V source I'm controlling.
Chill_Polins:
interesting, in my first post I attached a picture of a circuit with an octocoupler. However it gave no details on where to connect pin 6 of the IC...is this connected to the 12V source I'm controlling.
It's typically not connected to anything. The most basic use would be to use it to tweak the output of the optocoupler by giving it a weak pullup or down.
interesting, in my first post I attached a picture of a circuit with an octocoupler. However it gave no details on where to connect pin 6 of the IC...is this connected to the 12V source I'm controlling.
The only reason your original circuit didn't work is that both the optocoupler and the fan transistor are not being driven adequately.
Although the transfer ratio for the CNY75 is quite low, it increases with more current driven through the led. Calculating the required resistor for 20mA, we get (5-1.25)/0.020 = 187.5Ω Also, the 10K base resistor for the BD135 is far to high.
A simple solution would be to use 220Ω for the optocoupler and 470Ω for the transistor.
The range of control for analogWrite (PWM) is 0-255.
When testing the fan, if you slowly increase the duty cycle, you may find that the fan will start at 40% then speed up properly as the duty cycle reaches 100%.
If you if you slowly decrease the duty cycle, you may find that the fan will slow down normally and stop at 10%.
To get the extra control range and start the fan from a stopped condition, just give a 200ms boost of 255 (full power) just before entering your first required value.
dlloyd:
Also, the 10K base resistor for the BD135 is far to high.
A simple solution would be to use 220Ω for the optocoupler and 470Ω for the transistor.
Yes, I noticed that - expecting a transistor to switch with a 10k base resistor seems
commonplace for some reason - it isn't going to work. Perhaps people confuse darlingtons
with single BJTs.