0
\$\begingroup\$

I'm having trouble with the power signal out of my Rocker Switch (https://www.sparkfun.com/products/8837 for reference).

My PIC18F4550 + 16x2 character LCD screen project was running fine until I added a Rocker switch to break the +5V line. Now, 50% of the times the LCD screen backlight will turn ON, but no message will display. This does not happen when I leave the Rocker switch in it's bridging position and plug/unplug the DC barrel jack directly (which has much fewer bouncing problems due to it's mechanism).

I do have a Power ON timer configured in my PIC program, which should give me around 60ms before going into the program, but apparently it isn't enough. It's also worth noting that whenever I press the Rocker switch VERY SLOWLY, I don't get the problem (thus, pointing to bouncing problem again).

Concept: +5V Line with switch

Do you guys think it's a debouncing problem? How do you recommend me tackling this? Hopefully, if it's indeed a bouncing problem, we can fix it with caps and resistors only.

PS: The TO_PIC line on the picture not only goes to the PIC voltage pins, but it also goes to a LD33V Chip

Bit more complete circuit: With the voltage regulator

\$\endgroup\$
1
\$\begingroup\$

As Debounce you can add a cap. But a little better is an RC Lowpass, because a cap alone causes big currents when turning on which could harm your switch (mostly only if the cap is a little bigger).

If you need a fast changing Signal then you can put a schmitt trigger after the lowpass and an unloading resistor parallel to the capacitor. This is a luxus version, but more proper than just a cap.

If it's a hobby project try it with a cap but if the switch needs to last long time try the other one with the low pass.

\$\endgroup\$
1
  • \$\begingroup\$ I'm not sure why I didn't think about filters lol, it might be that I'm used to thinking about them in a more "signals" environment. I'll try it and let you know. Thanks \$\endgroup\$ – Sebastian Rivas Aug 5 '15 at 1:46
0
\$\begingroup\$

Hook up a scope to your circuit so you can determine the magnitude and duration of the bounce. You then have a couple of options. The simplest might be to use a switch with better characteristics. Otherwise (if timing is not ns critical and you can edit the PIC code) get your PIC to sample the pin at a slower rate and average the readings. Eg if the sample rate is 5ms and the average of the last 5 samples is low, assume low.

\$\endgroup\$
2
  • \$\begingroup\$ Well that would be a software debounce, but I'm not entirely sure you can do that with the Vdd pin right? And that's the point of that Switch, it's not I/O \$\endgroup\$ – Sebastian Rivas Aug 4 '15 at 0:06
  • \$\begingroup\$ Ahh you are spot on I didn't process the second schematic properly. In that case a cap would absorb the bounce. Do you have a scope to measure it? if so try a few cap values and see which ones are most effective. \$\endgroup\$ – BenG Aug 4 '15 at 0:11

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.