switch problems

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have a switch connected to a atmega32, one end of the switch to ground the other to a Mc pin. The switch is a normal domestic switch, but the wiring runs along with the normal household wiring(about 10-15 mts length).

I am having problems with its behaviour. sometimes a press/release is not registered. i have 4 such circuits. 2 are giving me problems while the other 2 are angles! all switche wiring are the same length and run parallel to each other sharing a common ground.

I have used a debounce routine.. the switch works fine otherwise in test conditions(less than 1 mtr length wiring)

what do u think i should do? apply an external pullup resistor such as 1k?

let me know!

Rodney

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
apply an external pullup resistor such as 1k?

Yes, but 10k should be enough.
Have you tried to change a non-working switch with a working to find out if switches or wiring/noise causes your problem?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A pullup resistor would be a start. Standard lighting switches are meant to switch reasonable currents not microamps! Other issues might be induction from other mains cables is you're running close and parallel with them. In which case you'll need to run more current through the switch circuit and filter the signal. You'll alos wnat to have some surge protection in there as well to protect against induced lightning surges and spikes induced from the mains wiring. A 1K resistor will cause 5ma to flow in a 5V circuit, hopefully your switch will appreciate this a little more.
My recommendation:
1k resistor pullup to 5V. 22K reistor in series, 10nF cap to ground, SA5.0 transzorb to ground then to port pin. This should go a long way to improving the situation.