I have an ATtiny85 switching an NPN transistor, which will in turn switch on a relay that will run a motor. Everything is run off a 3.7V 18650 Li-Ion battery, but I have since moved over to a variable power supply with same problem:
Without the motor, the relay switches fine, ATtiny85 will switch the relay on for one second, and then off for one second, and repeat, and the oscilloscope (connected to relay output and GND) and clicks are showing correct behaviour for the relay.
When I connect the motor, the relay still clicks, but the oscilloscope is showing zero voltage. Seems like relay tries to switch, but doesn't. I connected an LED to Pin0 of the ATtiny85, and it flashes instead of staying on for one second and going off for 2 second.
Seems to me that the problem could be:
- The ATtiny85 is resetting because not enough current going through. This doesn't make sense because I've switched over to a bench power supply and same thing happens, voltage is still the same.
- Some sort of feedback from the motor? The motor runs fine if I connect it directly to battery so I don't think power is an issue.
Some additional information:
- Relay switches on for 1 second then off for 1 second. I am not doing PWM, but just have this on/off behaviour for testing.
- This is the motor: 3V-12V water pump motor
- Power supply is set at 3.9V with 2A current available. Increasing it to something like 5V still doesn't work.
EDIT: Although the answers all helped me figure out my problem, I chose the one that helped me the most. Found that it wasn't back-emf or your standard type of decoupling required. The motor was dropping the voltage down hard and no capacitor was going to fix it (already had these in place), although these are common issues.
More findings here