First of all, to protect your MCU it's a good idea to use a 33 ohm resistor between your PWM pin and the Gate of the MOSFET or transistor.
While the PWM pin should be either HIGH
or LOW
, there could be situations where your Gate pin can have nothing as input, for example when the MCU is powered off. Therefore it's also a good idea to use a pull-down resistor between GND
and the Gate pin. This ensures that your MOSFET stays off if the MCU is not connect or is powered off.
I would say a 10k ohm or even a 1k ohm would suffice, it depends on the amount of noise and power consuption. Use the 1k ohm on higher-noise environments.
For the sake of your MOSFET protection, unless your current load is higher than the MOSFET's current take or the transistor's Icc, you don't need to worry about it if you are only using it to control LEDs or even lamps. Most MOSFETs can flow up to 3 Amps of current, while normal transistors' aren't that much. Use a current meter to check how much current your device consumes at the highest level (e. g. when all parts of it are turned on at the hgighest level and speed.)
However, you should also consider an extra protection if your device has any kind of a Electromagnetic Coil inside it, like the Solenoids, Motors and Relays.
This is because the coils generate a reverse voltage spike when the power is switched off, which could damage your MOSFET or transistor. This is a side effect called Inductance.
To prevent this, a diode is usually used know as the flyback diode or the kickback diode. It is generally a normal diode which is conncected reverse-biased in the circuit near the consumer device, which allows the reversed current to be looped inside the diode and the device, thus allowing the current to be drained. Wikipedia has a nice article around it.
As for your case, you are planning to use a motor, which has a coil inside it, so try to put a diode near the motor and away from the MOSFET (if possible) to drain the unwanted reverse current.
If you can't put it on the consumer device, at least use it on your PCB along with the MOSFET, it's better than nothing.
I would say a 1N4007 could suffice here, just remember to put it backwards in the circuit (Anode
goes to the Drain
pin of the MOSFET and Cathode
goes to the VIN
of your device. Unlike resistors, diodes must be used in the correct direction.)
Please be sure that you are supplying enough current to your circuit. It's also a good idea to use a 220 μF cap to regulate the 5V
input of your ATTiny.
As for the protection against short circuits, you could either:
a) limit the current with a resistor
b) use a resettable fuse.
Obviously, limiting the current here would be a stupid idea, so you could use a resettable fuse to prevent flowing too much current into the circuit.
A Resettable fuse (or PTC) is a device which blocks too much current from flowing until you remove the load and break the circuit; In this case shorting the circuit will flow all of its current through it!
The PTC's discussion goes beyond to the answer of your questions, so try looking it up on Google.
Have a great fun playing with the electronics.
Hope I've helped you!
Best Answer
If you are making a signal generator, then the 50 ohms in the output is a good start. With a 20Vp-p sinewave and the output shorted the resistor will disipate about 1W so firstly choose this resistor to have the power rating but, what op-amp operating at maybe 30MHz can deliver 1W? Probably none so it might be worth adding a push-pull stage made from PNP and NPN emitter followers.
Because they are emitter followers and, because they can be biased (with a little care) to be on the verge of conduction (it's called class AB) taking the op-amp feedback from the output of the push-pull circuit may work OK. Be aware that it can be easy to cause ringing and oscillations so layout is a little critical but methinks you have learned this so far (did you relay the DDS and get it working better?).
The transistors should have an \$H_{FE}\$ that remains above 1 at 1GHz or higher.
Basically, my idea is to build a little power into the final drive stage and use a +1W 50 ohm resistor on the output. Be also aware that the full 20Vp-p may not be attainable using this method - maybe you can increase the power supply levels a little. Also, your choice of op-amp is worth disclosing.