0
\$\begingroup\$

Circuit to activate a relay

Hello, I have a small circuit which is used to activate a relay. Whenever 15V supply is applied, it should turn on the relay. Since the current is so small, a tiny MCU is programmed in such a way that when pin 2(analog pin) reads a voltage greater than 3V it will send high output via pin 5(PWM output) which activates the relay and if its less than that pin 5 will be low thus turning off the relay. MCU gets a constant 5V supply. This circuit was working fine when tested in a breadboard. However when tested in a PCB, the relay is flickering continuously whenever pin2 reads high voltage and for the low voltage it stays off. I am not sure what i am missing here.

Also if there is any other easy way i could turn on the relay without using MCU, i would appreciate it.

Thank you.

\$\endgroup\$
  • 4
    \$\begingroup\$ You should use a resistive divider on PB2, not just a series resistor. Turning the relay directly from the MCUs I/O is a bad idea. Why not power a relay directly from the voltage source? (if on-on/off-off is the correlation you want) \$\endgroup\$ – Wesley Lee Jun 7 '17 at 17:05
  • 5
    \$\begingroup\$ Assuming your pin out has the capability to drive your relay ....You urgently need a diode across the relay or you will damage your MCU pin. \$\endgroup\$ – Jack Creasey Jun 7 '17 at 17:14
  • 2
    \$\begingroup\$ Please add all the component values and ratings to your schematic: R1, K1? As @WesleyLee said, why drive the relay directly from an I/O pin. You need a clamp diode across the relay (anode to GND, cathode to relay V+). (Were you imagining using the internal I/O pin diode to clamp the relay coil? Don't - it hasn't got the current capability.) \$\endgroup\$ – TonyM Jun 7 '17 at 17:15
0
\$\begingroup\$

You are probably picking up noise in your ADC line. Try bypassing the input with a 0.1 uF capacitor. Add a 10 uF in parallel if more filtering is needed. If the leads to the 15 volt supply are a couple inches or more in length, twist them together to minimixe noise pickup. A 0.1 uF cap on the uP VCC pin to ground is also advised.

You need a voltage dropping cicuit from your 15 volt line to your uP. Try a 4.7 k to ground and 10 k in series with that to the 15 volt supply. Put the uP ADC input at the junction of the two resistors. This will give you about 4.8 volts when the 15 volt supply is up.

Finally, make certain your uP output pin is capable of driving the relay. If not, you need to add an NPN or FET driver.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.