I am controlling motor speed by using PIC16F877A and L298, but motors give Back EMF which can burn the microcontroller. To avoid back emf, I have 3 options:

  1. Diode.
  2. Darlington pair.
  3. Optocoupler.

What would be the preferred method, in your opinion, keeping into consideration the respective problem? A practical example would be very helpful for me. Thanks

  • \$\begingroup\$ In the L298 datasheet you have the flyback diodes. \$\endgroup\$
    – R Djorane
    Commented Jan 15, 2016 at 12:41
  • \$\begingroup\$ Thanks for reply but motors having current more than 2 amps burnt the microcontroller due to back emf. \$\endgroup\$ Commented Jan 15, 2016 at 13:31
  • \$\begingroup\$ Did you use the same schematic in figure 6 from the L298 datasheet? \$\endgroup\$
    – R Djorane
    Commented Jan 15, 2016 at 13:45
  • 1
    \$\begingroup\$ You can't get rid of back EMF in motors, except by stalling them. And back-EMF is ALWAYS less than the power supply voltage (unless something else is driving the shaft above normal speed). So your problem is more likely to be inductive transients (which can be hundreds of volts). See flyback diodes, R-C snubbers, power supply decoupling. \$\endgroup\$
    – user16324
    Commented Jan 15, 2016 at 14:13
  • \$\begingroup\$ @codo, since your comment solved the OP's problem, maybe just put it as an answer. \$\endgroup\$
    – user57037
    Commented Jan 20, 2016 at 4:32

1 Answer 1


You need to use flyback diodes to protect from large inductive currents on motor startup and shutdown. I used the following circuit with the L293B, you have to adopt it for the 298, but the basic principle and arrangement of the diodes is the same.

enter image description here

The flyback diodes provide a path for the current generated by the back-EMF (stored in the motor's magnetic field) when the motor is switched off/turned on. You can read more on flyback diodes on Wikipedia. Also, take care to use Schottky diodes (a special type of diodes) which are much faster than the generic rectifier diodes. I used SB260 (60V, 2A) but you may need to use something larger, depending on the current and voltage. Allow for a significant voltage overhead above your operating voltage, because these inductive voltage spikes can be big. The resistors R1 to R6 are there for current overload protection for the microcontroller, they are not strictly necessary, but can save your ucontroller if you screw up something.


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.