Author Topic: Why does a button keep blowing up my Sparks?  (Read 8272 times)

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Why does a button keep blowing up my Sparks?
« on: April 04, 2014, 01:15:03 pm »
I'm using the I2C LCD shield and real time clock shield on my Spark to make an away message for my desk. The code works flawlessly and there don't seem to be any issues with the shields. But every time I try to get a push button incorporated I wind up with a dead Spark. One still shows a power light when plugged into USB, the other nothing but will power up if I use external power. I tried hooking USB data to pins 3 and 4 on both but they're not showing up. So I'm writing them off, one will become an ATTiny programmer and the other one is spare parts I guess.

So. Before I buy a third Spark for this project I'd like to get my wiring sorted out so I can stop killing these things.

This is the circuit pulled from the comments in a sketch:
* Place a push button on your board
* Put a 1K resistor between one pin on the button and ground
* Place a jumper between pin 5 and a point between the button and resistor
* Place a jumper between 5V and the other side of the button

or

                1k
GND____/\/\/\______/__5v
                        |
                     Pin 5

If I swap out a couple libraries and run it on my UNO (same button wiring) the whole thing runs like a sewing machine.

I'm running a 2012 MBP running OS 10.9.2.

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: Why does a button keep blowing up my Sparks?
« Reply #1 on: April 04, 2014, 06:35:42 pm »
Did you set the pinMode to INPUT in your sketch? It should default to that (I think), but it never hurts to be explicit.

Also, you aren't using a separate power supply than from the Digispark itself, are you? All power in your circuit from the same source?

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #2 on: April 04, 2014, 07:01:07 pm »
Yes. The pin is set to input and the whole setup is powered via USB. I didn't start messing around with external power until things borked. Then I tried it just to go through my options. Tried external power only at first, then added the wires for USB + and -.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Why does a button keep blowing up my Sparks?
« Reply #3 on: April 04, 2014, 11:01:30 pm »
Does it break right away or only after you press the button?

This is all indicative of a short.

I'd use a 10k resistor - but that isn't the issue or problem.

When you say it works with the same wiring on an UNO - do you mean exactly the same as in you just switch which board you plug it into? Or are you remaking the circuit when you tried it on the UNO?

Can you share the model number, link to, or anything else about the button being used?

And what did you assemble this circuit in - breadboard?

The last two I ask because some buttons with four pins have two sets of connected pins - and they aren't always in the order you'd expect - so I've shorted things out before by hooking to the pins on the wrong sides or having them attached because of the breadboard, etc.

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #4 on: April 04, 2014, 11:22:15 pm »
Quote
Does it break right away or only after you press the button?
It seems to bork during the loading of the sketch. Should I not have loaded it with the shields on?

Quote
I'd use a 10k resistor - but that isn't the issue or problem.
Resistor was 10k (bad at reading stripes)

Quote
When you say it works with the same wiring on an UNO - do you mean exactly the same as in you just switch which board you plug it into? Or are you remaking the circuit when you tried it on the UNO?
I changed the libraries for the UNO but the code stayed exactly the same. Used the same pin numbers on the UNO.
On the Spark I had the real time clock and LCD I2C shield on with stackable headers and the button components plugged into the topmost layer. I simply pulled those components and moved them to the appropriate pins on the UNO. For the LCD I used four lengths of hook up wire to get from GND, VCC, SDA and SCL to the jumper harness that was provided with the shield.

I didn't incorporate the clock in the UNO setup but there was no indication that there was anything wrong with it. Before I added the button to the Spark I used the clock and LCD to run the sample sketch and I saw the time on the screen. From that I ruled out that I hadn't gotten solder anywhere that I shouldn't be and that section was fine. I tucked the button components in and tried to reload the sketch I had written and it failed to complete.

Quote
Can you share the model number, link to, or anything else about the button being used?
It's a Radio Shack panel mount N/O pushbutton. Two terminals.

Quote
And what did you assemble this circuit in - breadboard?
Short lengths of insulated hook up wire.

Thanks for the responses. I'm two weeks into the whole scene and I expected to blow some stuff up. It's nice to get some direct help instead of scanning thousands of posts for a similar problem.


digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Why does a button keep blowing up my Sparks?
« Reply #5 on: April 04, 2014, 11:37:36 pm »
If nothing was connected to 3 and 4 then it wasn't anything to do with USB/uploading the sketch - BUT - that points to it being short in the wiring regardless of the button state. I'm thinking this must be some disconnect here (on my end or yours) with how this is being wired - because nothing you've said sounds wrong.

Do you have a multimeter that you could check the connectivity/ohms with between 5v and gnd when all is hooked up (but no power applied)?

Can you take a photo of it all hooked up the spark?

If it ends up being something wrong with one of our shields or anything like that I'll be happy to replace them - first I'd love to figure out what's going wrong, because by all means it doesn't sound like it should be shorting it out and I've used lots of buttons on pin 5.

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #6 on: April 05, 2014, 10:40:17 am »
I'm at a gig until sometime on Monday but when I get back to my bench I'll get all the readings I can from both fried sparks and send along some pics.

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #7 on: April 07, 2014, 11:49:16 am »
OK. I put the original stack back together. Spark, then clock module, then I2C shield with screen connected. I loaded the clock sketch from the wiki and the time showed up on the screen and advanced every second. The button was not attached at that time. Then I added the button and tried to upload my own sketch for my away message display and it failed to complete. I tried a couple more times to load it as the power LED was still on, causing me to think it was an alignment or communication issue. After a few tries I stripped the shields off and tried to load a blink sketch and had no luck.

In the picture you can see the resistor jumping from ground to pin 5 and the leads for the button on 5v and a point between pin 5 and the resistor. Originally I had some electrical tape around the terminals on the switch and also around the resistor.



So next I swapped out a couple libraries and uploaded the sketch to my UNO where the same switch and resistor worked flawlessly. Originally I was just using the pins on the UNO but I've got a couple different things going at the moment so in this picture you see it with the breadboard. The clock module isn't included but I've got no reason to think it's faulty. The resistor is just peeking out from behind the black wire next to the I2C connector.


I'm not sure what the deal is. I'll happily buy another one and give it one more go. I was planning on writing this project up as an Instructable. Future projects I've got in mind are going to need more memory, pins, etc so I'll be using pro minis and whatnot but the Spark is a great intro to the world of dev boards and I want to do my part to help publicize it.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Why does a button keep blowing up my Sparks?
« Reply #8 on: April 07, 2014, 01:54:53 pm »
Two more questions - and then I'll duplicate this on a Digispark here to see what is going on:

1) Did you ever try with just the button and no shields?

2) Is the resistor going to the VIN or 5V pin?

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #9 on: April 07, 2014, 02:35:02 pm »
I haven't ever used a button with only a Spark.

It wasn't until I got an LCD connected to my first one that I started using a button. That rig borked while running on an iPod charger. I thought something might have come into contact with a screwdriver on the work bench.

With the second one I was much more careful about watching for possible shorts. I made sure there was nothing around the ports on the computer and put tape on the flying lead elements.

Sorry it's not clear in the picture. I'm on the 5v pin.

evanstoddard

  • Newbie
  • *
  • Posts: 1
Re: Why does a button keep blowing up my Sparks?
« Reply #10 on: April 07, 2014, 04:04:12 pm »
I work with SkinnyMac in the real world... He can verify that... I had the same setup and the same issue occurred and now mine is dead.

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #11 on: April 09, 2014, 11:09:37 am »
I measure .5 ohms between 5v and GND with the whole stack hooked up. Both Sparks read the same.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Why does a button keep blowing up my Sparks?
« Reply #12 on: April 10, 2014, 03:10:38 am »
Sorry haven't been in one place long enough to try this with the same stack - I will try to get to it tomorrow.

That is definitely a short - can you try removing the button from the stack and see what the resistance between 5v and gnd is then?

SkinnyMac

  • Newbie
  • *
  • Posts: 10
  • Audio Engineer
Re: Why does a button keep blowing up my Sparks?
« Reply #13 on: April 10, 2014, 01:38:10 pm »
Derp. Those were the readings without the button or the screen attached. Let me start over. I just sat down and did a complete set. Once again for the record this is a 10k resistor from GND to Pin 5, normally open button between 5v and Pin5. Readings were similar enough on the two Sparks that it's not worth typing them twice.

Button|GND to P5|GND to 5v
Open9.9k.2ohm
Closed.2ohm.2ohm
Removed.4ohmopen

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Why does a button keep blowing up my Sparks?
« Reply #14 on: April 13, 2014, 07:02:52 am »
TLDR: add a 5.5v zenner diode between the digital pin on the spark and ground, and a resistor in serial from the pin to the switch.. so switch goes 5v, switch, then splits through a resistor to ground and a resistor to digital input, which then connects over to ground through the zenner diode (placed facing the opposite way to a normal diode - the painted on circle should face towards the digital input)

I bet this is your problem:

when you start or stop pressing the button, it connects or disconnects the little circuit through the resistor, and those relatively long wires to the switch have a small inductive capacity. When the switch is connected and power runs through it, the wires charge up, and when the switch disconnects, it's metal plates very slowly (in electron timescales) move apart.. picometers, then nanometers, eventually as much as a milimeter or two.. and along the way, it creates a spark gap. The inductive property of the wire tries to continue moving the same amount of current, and the only way to do that is to swap amps for volts, so the voltage on the wire rises up.. 5v, 6v, 10, 20, 100... maybe hundreds of volts.. enough to spark across the gap, which requires higher and higher voltages as it widens, sending jolts through the entire system easily enough to fry the digispark. Usually this isn't a problem - usually the linear regulator on the spark seems to do a decent job of making sure the spark isn't powered over 5v, so excess voltage bleeds out through the clamping diodes in the attiny85 and get thrown away as heat in the linear regulator. if the voltages involved were high enough through, I bet this wouldn't work. Zenner Diode should solve it through.

I've fried heaps of stuff from a similar situation - using unreliable connectors to connect things over 1m wires.. the connectors (audio jacks in this case) would make tiny sparkgaps as they moved slightly, and those tiny sparks would fry the attiny chip.