0
\$\begingroup\$

This is my first microcontroller project. Goal is to keep relay on for specified amount of time with pause and resume feature.
I am using ports as follows:

  • P1 to drive LCD 16x2 display.
  • P0 and P2 to supply a binary no, countdown time, using dip switches.
  • P3.0(10th pin on ic) controls relay. It stays high from start signal till count reaches zero. There is an optoisolator in between microcontroller and the relay.

The problem is that when I turn on the power or use reset pin, the relay flicks for a brief moment. First instruction in my code is to set the pin P3.0 low, but still it gives output high for short period. Power on reset is done using 10k res and 10uF cap.

If I use RC delay circuit then it will delay pause and resume operations as well.

Is there any setting/flag to keep Port 3 low by default?
One option is to supply power to relay(high voltage side) after starting microcontroller. Is there a better way to handle this?

\$\endgroup\$
2
  • \$\begingroup\$ " There is an optoisolator in between microcontroller and the relay." - Any reason you can't make the optoisolator input active low? \$\endgroup\$ Commented Jul 9, 2021 at 8:01
  • \$\begingroup\$ The optocoupler, relay and high voltage part is a separate module. I'll change microcontroller side to yield high when pin P3.0 is low. \$\endgroup\$
    – the Hutt
    Commented Jul 9, 2021 at 8:24

1 Answer 1

0
\$\begingroup\$

In my opinion, the pin's default state is pull-up. I think that you could solve your problem if you add a buffer between the pin and relay.

The buffer should have a port to enable/disable it's output. I think that 74HC125 might be proper. This buffer outputs when the enable pin is low.

If you connect your MCU pin to the enable pin, the buffer will not output.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ With 8051 designs I would make the active level as low - this means adding inversion. \$\endgroup\$
    – Kartman
    Commented Jul 9, 2021 at 7:21

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.