Attiny13 reset when light switch is pressed on the wall please help - Page 1
Forum section: electronics / general

author: Chriss
author_rank: Frequent Contributor
timestamp: February 27, 2016, 07:04:48 pm
content: Hi!I have a small project made with Attiny13 uC.Project description:The whole project is right now on my bread board.I use the internal oscillator of the uC because I don't need a precise timing.A simple switch is for switching on PortB1A LED is on PortB2If the switch is pressed then after 30sec the LED goes on.All this stuff is working.Problem 1:When I leave the project running, which is powering from my lab power supply andI press my light switch on the wall of my working room the uC will reset.Sometime it will reset when I power of my room light but in most of time the resethappens when I power on the light.What I tried:Several options with filter caps. with coils, put the power source to battery powering through the LM7805 ic configured asit is described in the datasheet of the manufacturer.Also tried with 100nF and around that on the gnd pind and the vcc pin but with no luck... :-(Problem 2:When I attach the switch on a long cable like 15 meter the uC sometime sens a switch pulse even if the switch is not pressed.I think it is because of the long cable, the cable acts like an antenna and conduct some voltage.I solved this problem on programming level but, I'm not sure is that a good idea?I would assume if somebody have a clue how to solve this on hardware level.Thank you for any ideas and advice...

author: georges80
author_rank: Frequent Contributor
timestamp: February 27, 2016, 07:09:24 pm
content: Bypass caps on the power?Brown out programmed?Do NOT run long leads to inputs of microcontrollers etc unless you want them to die due to static/rfi etc. You need conditioning circuitry for sensor/switch connections that have wires more than a few inches away.What you have in your 'schematic' is conceptual, you now need to add everything that makes it actually work...cheers,george.

author: Chriss
author_rank: Frequent Contributor
timestamp: February 27, 2016, 07:20:45 pm
content: I put bypass caps on the power in different capacitance from 1uF to 3300uF and nothing helped me about the wall swich problem.Brown out not programmed, I will give a try.I know my "schematic" is conceptual, I would just show the very fundamental wiring of my circuit.I think about to put a relay which would be switched if the switch is pressed on the long wire and the relay working contact should trigger the input pin on the uC.Would that bee fine to protect the uC?I mean, the coil is energized through the switch on the long wire and the wire and the switch is galvanic separated from the uC input pin.Another Idea comes to me to use an optocupler to separate the long wire from the uC.Thans for watching my writingGeorge.Cheers,Chris.

author: georges80
author_rank: Frequent Contributor
timestamp: February 27, 2016, 07:27:05 pm
content: Remove your long wire and put the switch right next to the tiny13. Does it still reset due to the wall switch?Opto is one option, another is just to take the switch into a transistor 'buffer' to isolate from nasties. I'd also put a schmitt to clean up pulses. Consider the signal could bounce, what does your software do if it gets noise pulses on the switch input?Smaller value ceramics a good for filtering. 0.1uF in parallel with say 4.7uF would be good. Put them right near the +/- pins of the tiny13.Don't leave floating pins on your tiny13. The pins you don't use you should be pulled up (weak internal pullups enabled) or driven as outputs to a known level.You really haven't left the RESET# pin floating have you?cheers,george.

author: Chriss
author_rank: Frequent Contributor
timestamp: February 27, 2016, 07:55:39 pm
content: Even without long wire the uC reset.All other unused pins are driven as output.For the bouncing of switch I use the debouncing routine of the programming language and if there areseveral bouncing signals in 30ms the software will not pay attention and would not power on the LED.I checked in several situation my debouncing routine and that works fine in my working room where I can simulatethe electronic smog only with my wall light switch. :-)But, I will modify my circuit to something as you advised.The reset pin is connected to the VCC through 10k resistor. I forgot to draw on the "schematic"... sorry, my mistake...ThanksChris.

author: georges80
author_rank: Frequent Contributor
timestamp: February 27, 2016, 09:14:24 pm
content: Disconnect your power supply and run your circuit from a battery... Still resets due to light switch?cheers,george.

author: Chriss
author_rank: Frequent Contributor
timestamp: February 27, 2016, 11:48:03 pm
content: Yes, it still reset even on a battery power...I did as you told and that helped me.I put two caps 4.7uF/450v on the VCC and GND close as possible it was to the pins of uC.First I tried 4.7uF/100v but the result on the scope was better with the same cap but 450v.When I put in parallel with this caps the ceramic caps 0.1uF then I have the same resetting situation.I even tried with a lot of other values and combinations of caps but without result.The only way how I got the uC not resetting was as I described.The brown out fuse didn't solved my problem also.Now, I hope this solved in long term meaning my resetting problem.I will tomorrow playing with the "long wire" problem.Anyway, thanks for the suggestion and that really brought me to a good result.My best regards.Chris.

author: georges80
author_rank: Frequent Contributor
timestamp: February 27, 2016, 11:58:45 pm
content: How is this 'board' put together? It it some christmas tree style construction? Built on one of those prototype boards? Picture?Running on battery and still resetting means you have some glitch/spike getting into the power or reset. Be interesting to catch the resetting condition and look at the MCUSR to see what caused it to reset (I presume the tiny13 show you the reset cause in that register?). You can save it in eeprom and then check it with a programmer.Are you using interrupts? Got ISR routines defined for all the interrupt sources?There is some noise/spike occurring that you need to resolve. Certainly long wire for the switch will not be helping. I presume it's a twin conductor so you have the ground wire running all the way to the switch to loop back to the switch sense input.cheers,george.

author: Chriss
author_rank: Frequent Contributor
timestamp: February 28, 2016, 01:23:06 am
content: Actually, as I figured out why my uC reset is, because of two problems:1. Whenever that "long wire" was attached it acts like an antenna2. I monitored the power line with my scope, when I removed the probe from the power source the scope tipthen no more resetting.I'm not worried because the "long wire" I will redesign the unit to work wit that "long wire" as we talked about, butwhat is going on with my scope probe? It behaves like an antenna too and collected the energy from the sparkingwall switch or maybe from the neon tubes.

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: February 28, 2016, 01:49:15 am
content: Quote from: Chriss on February 28, 2016, 01:23:06 amAny piece of wire is an antenna. Your scope is a sensitive device with high input impedance so it will pick up anything within its bandwidth - mains hum, local radio stations, spark-gap transmitters (your wall switch) -everything!