I'm running a dc motor using PIC16 family microprocessor. I connect it to my pc, I can send a command to run the motor in certain speed or stop.
It works for small motor (3V, 100 mA). But the moment I use bigger motor (3V, 300 mA), I can only I send 1 command e.g. run fast. After that, the pic refused to process the next command. Even when I turned off the device and turned it on again, the motor still running the last command. It seems like memory hardening or something like that.
I'm not sure what happened - Could it be a kickback current from motor caused the instability? I'm using TIP120 as motor driver. - I have put capacitors, diodes around the motor driver. But didn't help.
Can someone help me?
I appreciate your thoughts.
Answer
Federico Russo said it well: "decoupling, decoupling, decoupling". ICs like microcontrollers require smooth power supplies, that is without disturbances. Small negative spikes may cause a reset or cause your software to go bananas. Positive spikes may do the same, and even damage the part. You definitely want to get rid of those disturbances. There are two ways to attack the problem, and the best way is to apply both.
First consider the cause of the disturbances. This is often difficult to find out, but in our case it's definitely the motor. Place capacitors between the power supply and ground, close to the motor's connection pins. Have an electrolytic capacitor of \$100\mu F\$ (actual value depends on the motor current, but this is a good start), and place a \$1\mu F\$ ceramic capacitor parallel to it. The latter is needed because the elco is not good at high frequencies, and there the ceramic takes over.
This is the first step. It's not just necessary to solve our problem, it also reduces EMI (ElectroMagnetic Interference). There are regulations about the level of EMI you may create.
Then we go to the microcontroller. The power supply will not necessarily be clean yet, there may be other noise sources. Here we do the same: place capacitors on the power pins, between \$V_{DD}\$ and ground, as close as possible to the pins. The microcontroller doesn't use high current, so we won't need the \$100\mu F\$ elco. Usually a \$100nF\$ ceramic will do. To calm your nerves :-) you may add a \$1\mu F\$.
What else? Some other pins may also be sensitive to noise. Look at the reset pin. It's no good ensuring that your power supply is clean if the microcontroller would reset due to spikes on the reset pin. So also a cap between reset and ground, again as close as possible to the pin. \$100nF\$ is fine.
No comments:
Post a Comment