user69394: I have a Arduino which I would like to use to control a 12v PWM fan for speed control.
I know about the 0-3.3v to 0-5v logic level shifter, is there a similar option for 0-5v to 0-12v? Or is there a circuit using a IC that I need to make?
Thanks in advance for your help.

user-1: Use MAX232
Advantages of MAX232:

It has low rise/fall times. A good PWM needs to be sharp. Since MAX232 is designed for serial port communications, i.e., TTL to RS232 and RS232 to TTL, it has to perform reliably. Reliability ensures low rise/fall times.

It operates at low currents. The OP suggested that the fan only needs a PWM to drive, i.e., it has its internal current amplifiers.

It is cheap. Engineering solutions require to be no more expensive than it has to be, and MAX232 is half the price of L298.


Shortcomings of MAX232:

Since the computer serial port is used much less, the primary use of MAX232 is over. Therefore, it is not in all hobby kits and it might be harder to find MAX232. Mostly older engineers who used to play with PIC16F877A before ardunios become popular remembers such ICs.

Shortcomings of L298:

L298 is a current amplifier, not a voltage booster. Using it for a purpose other than its primary purpose is suboptimal.

L298 has a huge current output. It might exceed the threshold currents of the fan, and cause malfunction. It is very unwise to connect a 1A rated L298 to 0.5 mA rated signal pin.

L298 has a weird pin diagram. It has a ZIP package rather than the regular DIP to allow attachment of heatsinks, which increases the size of the circuit.

L298 has high rise/fall times. Its purpose is to generate large currents, not PWMs. Therefore, its rated rise/fall times are not only high, but also unreliable.

L298 requires four high current rated Schottky diodes. The cost of these diodes will be more than that of the L298 and they are very large, resulting in a much larger circuit area.


Do you really want to use an H-Bridge? Use L293D.

L293D is still a current amplifier but not an overkill like L298. Its current output is four times as low as L298 so chance of malfunction is reduced.

L293D has a DIP layout. Most hobby electronics application uses DIP sockets to mount the ICs later on and you can do it with L293D.

L293D has the flybacks diodes internally. So you neither need to buy nor place them on your circuit.


Do you want to design your own circuit? Use a gate/base recharge/discharge transistor.
Basically, all transistors have a gate/base capacitor which needs to be charged before the transistor switches to ON and discharged before it switches to OFF. Power amplifiers normally do not care about the rise/fall times, with a notable exception that comes to my mind is musical amplifiers.
What about a discharge resistor?
Replacing discharge transistor with a simple resistor works but it would increase your drain from the PWM source. It has a simplicity vs performance trade-off.
Commenting about relays
Relays usually have a higher switching time because their input module consists of a diode and output module consists of a transistor, i.e., you have add their reaction times together. This results in distortion in the PWM output. Furthermore, there is no need to use SSR in a low power operation, an opto-isolater would suffice.
Final comment about designing circuits
Circuits have many trade-offs. Cost, availability, complexity, size, performance are just to name a few. A good design needs to take everything into account. To rate my above suggestions:

MAX232: Cheap, simple, small, good performance, not available
L298: Expensive, complex, large, low performance, available
L293D: Cheap, simple, small, mediocre performance, available
Simple transistor: Cheap, simple, small, mediocre performance, available
Modified transistor with base recharge/discharge: Expensive, complex, large, good performance, available

So, I would rate L298 as the worst possible solution that actually works.

user53: As far as I can tell the Arduino does not have open collector outputs, so you can mimic one as follows. The following inverts the Arduino output signal, so some adjustment is needed there when generating the PWM signal.
Excuse the rather gross schematic. I can't find any scaling parameters.
The particular resistors values are not terribly important, mainly to limit current.

simulate this circuit – Schematic created using CircuitLab

user69378: I advice you to learn about basics of how to connect external components to MCU.
Anwser to your question is simple transistor amplifier... So you can use bipolar transistor (NPN/PNP) or MOSFET... MOSFETs is better for switching like your case, switching via PWM.
If you switching inductive load with MOSFET like motors or coils, don't forget add antiparallel flyback diode. Otherwise your MOSFET will burn out.

If you need switching with higher frequency or load with more voltage or power I advice to use push-pull logic to drive mosfet gate.
Something like this:


69394: <p>I have a Arduino which I would like to use to control a 12v PWM fan for speed control.</p>
<p>I know about the 0-3.3v to 0-5v logic level shifter, is there a similar option for 0-5v to 0-12v? Or is there a circuit using a IC that I need to make?</p>
<p>Thanks in advance for your help.</p>
 -1: <p><strong>Use MAX232</strong></p>
<p><strong>Advantages of MAX232:</strong></p>
<ul>
<li><p>It has low rise/fall times. A good PWM needs to be sharp. Since MAX232 is designed for serial port communications, i.e., TTL to RS232 and RS232 to TTL, it has to perform reliably. Reliability ensures low rise/fall times.</p>
</li>
<li><p>It operates at low currents. The OP suggested that the fan only needs a PWM to drive, i.e., it has its internal current amplifiers.</p>
</li>
<li><p>It is cheap. Engineering solutions require to be no more expensive than it has to be, and MAX232 is half the price of L298.</p>
</li>
</ul>
<p><strong>Shortcomings of MAX232:</strong></p>
<ul>
<li>Since the computer serial port is used much less, the primary use of MAX232 is over. Therefore, it is not in all hobby kits and it might be harder to find MAX232. Mostly older engineers who used to play with PIC16F877A before ardunios become popular remembers such ICs.</li>
</ul>
<p><strong>Shortcomings of L298:</strong></p>
<ul>
<li><p><em>L298 is a current amplifier</em>, not a voltage booster. Using it for a purpose other than its primary purpose is <em>suboptimal</em>.</p>
</li>
<li><p><em>L298 has a huge current output</em>. It might exceed the threshold currents of the fan, and cause malfunction. It is very unwise to connect a 1A rated L298 to 0.5 mA rated signal pin.</p>
</li>
<li><p>L298 has a weird pin diagram. It has a ZIP package rather than the regular DIP to allow attachment of heatsinks, which increases the size of the circuit.</p>
</li>
<li><p>L298 has high rise/fall times. Its purpose is to generate large currents, not PWMs. Therefore, its rated rise/fall times are not only high, but also unreliable.</p>
</li>
<li><p>L298 requires four high current rated Schottky diodes. The cost of these diodes will be more than that of the L298 and they are very large, resulting in a much larger circuit area.</p>
</li>
</ul>
<p>Do you really want to use an H-Bridge? <strong>Use L293D</strong>.</p>
<ul>
<li><p>L293D is still a current amplifier but not an overkill like L298. Its current output is four times as low as L298 so chance of malfunction is reduced.</p>
</li>
<li><p>L293D has a DIP layout. Most hobby electronics application uses DIP sockets to mount the ICs later on and you can do it with L293D.</p>
</li>
<li><p>L293D has the flybacks diodes internally. So you neither need to buy nor place them on your circuit.</p>
</li>
</ul>
<p>Do you want to design your own circuit? <strong>Use a gate/base recharge/discharge transistor.</strong></p>
<p>Basically, all transistors have a gate/base capacitor which needs to be charged before the transistor switches to ON and discharged before it switches to OFF. Power amplifiers normally do not care about the rise/fall times, with a notable exception that comes to my mind is musical amplifiers.</p>
<p><strong>What about a discharge resistor?</strong></p>
<p>Replacing discharge transistor with a simple resistor works but it would increase your drain from the PWM source. It has a simplicity vs performance trade-off.</p>
<p><strong>Commenting about relays</strong></p>
<p>Relays usually have a higher switching time because their input module consists of a diode and output module consists of a transistor, i.e., you have add their reaction times together. This results in distortion in the PWM output. Furthermore, there is no need to use SSR in a low power operation, an opto-isolater would suffice.</p>
<p><strong>Final comment about designing circuits</strong></p>
<p>Circuits have many trade-offs. Cost, availability, complexity, size, performance are just to name a few. A good design needs to take everything into account. To rate my above suggestions:</p>
<ul>
<li>MAX232: Cheap, simple, small, good performance, <strong>not available</strong></li>
<li>L298: <strong>Expensive, complex, large, low performance</strong>, available</li>
<li>L293D: Cheap, simple, small, <strong>mediocre performance</strong>, available</li>
<li>Simple transistor: Cheap, simple, small, <strong>mediocre performance</strong>, available</li>
<li>Modified transistor with base recharge/discharge: <strong>Expensive, complex, large</strong>, good performance, available</li>
</ul>
<p>So, I would rate L298 as the worst possible solution that actually works.</p>
 53: <p>As far as I can tell the Arduino does not have open collector outputs, so you can mimic one as follows. The following inverts the Arduino output signal, so some adjustment is needed there when generating the PWM signal.</p>
<p>Excuse the rather gross schematic. I can't find any scaling parameters.</p>
<p>The particular resistors values are not terribly important, mainly to limit current.</p>

<p><img src="https://i.stack.imgur.com/EEBMi.png" alt="schematic" /></p>

<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fEEBMi.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
 69378: <p>I advice you to learn about basics of how to connect external components to MCU.
Anwser to your question is simple transistor amplifier... So you can use bipolar transistor (NPN/PNP) or MOSFET... MOSFETs is better for switching like your case, switching via PWM.</p>
<p>If you switching inductive load with MOSFET like motors or coils, don't forget add antiparallel flyback diode. Otherwise your MOSFET will burn out.
<a href="https://i.stack.imgur.com/kJkCp.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/kJkCp.jpg" alt="How to connect mosfet to arduino pin" /></a></p>
<p>If you need switching with higher frequency or load with more voltage or power I advice to use push-pull logic to drive mosfet gate.</p>
<p>Something like this:</p>
<p><a href="https://i.stack.imgur.com/HZJ3c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HZJ3c.png" alt="enter image description here" /></a></p>
