noob... basic pushbutton input to light LED... problem
maxx233
Posts: 11
So I'm going through the "what's a microcontroller" tutorial, and ch3 (digital input) has a circuit to push the little button and have the stamp read the input signal and flash an LED as long as the button's depressed. Mine doesn't work After fiddling for an hour I've figured out that when I turn the board off, then back on... it'll pretty much work for up to 8 seconds or so. It will indeed actually flash the LED as it's supposed to. But then it stops. And it won't work again after that until I reset the board. And if I reset the board, but then write the same program to it again, it won't work even if I haven't tried it yet since the last reset. At this point I'm pretty sure my programming logic works, since it does blink immediately after reset when I push the button. Why does it stop working/never works after writing to the board? I don't want to keep trying if I'm missing something stupid and jack up my stamp, but receiving input is kinda pivotal and all [noparse];)[/noparse] So I figure I'll put it down for tonight and ask you fine folks. Any help is much appreciated, thanks!
maxx
maxx
Comments
I'm not getting the LED blinking, and and I'm only showing 0s in the debug window except for briefly & sporatically after powering the board on and trying it - it'll show 1s (with a couple 0s mixed in), and the light will blink for a while.
I have it plugged in with a wall wart, so no batteries.
I had it all plugged in on an offboard protoboard originally for easy working, and after posting I feared that might have been the culprit somehow. So I took it all apart and put it on the onboard proto area exactly as in the book, to no avail. It seemed like it was working better, but it was just because I'd turned it off while plugging it all back in, so when I turned it back on it worked for a while.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I'll try it, but even the debug window shows no input, so I don't think it's a matter of just not seeing the light or anything unforetunately
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I'll post a pic (hopefully it shows up!) I took last night and never posted it because I thought it'd just be confusing (plus to further confuse things, now I've moved everything onboard to match the book exactly, just to rule that factor out) It's hard to see what's going on, but basically there's three long jumpers (black, red, green) from the board to an external proto board where I put the switch, just for ease & space. So hopefully you can see the circuit (and hopefully I didn't screw it up!) Like I said, now I've moved it all onboard to reduce problem factors, but still no go.
Franklin, I see what you mean now about reducing the blink rate - like maybe it was just blinking so fast it was overtaxing the regulator? In the exercise before this one I had it blinking at 1 to 50 milliseconds on a for next counter, so it has blinked faster before and worked, but it's worth a shot - I'll try reducing the pause when I get home just to verify. I've been in IT for a long time, specifically programming for the last year or so, and at this point I'm getting the distinct feeling that I screwed something incredibly simple up - or there's a problem with the board
The LED has a polarity and the book (WAM?) shows how to tell which end is which. It won't light if it's hooked up backwards.
Try this
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
HIGH 14
PAUSE 1000
LOW 14
PAUSE 1000
LOOP
This will help with a wiring issue or a reset problem with the stamp.The LED should blink on and off @ around 1Hz (over and over)
When I have trouble with something complicated, Its usually something simple that helps me fix it.
__________$WMc%________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
AND NOW... the stamp sees every input as being true! Finally to prove this I'm running this code:
With *nothing* connected to the onboard proto area it's showing all 3 inputs as 1 in the debug window. What on earth?!? I mean, I suppose I could just switch my programming logic so that if IN3 = 0 then blink the light instead if IN3 = 1... but... obviously something's wrong This newbie can't catch a break, what's goin on??
Unused (open) pins are undefined.
Used input must be tied to + - pull up or - pull down potential via a resistor. 10 kOhms is fine.
Your input pin3·should always read 0 (connected thru·pull down resistor of 10 KOhms to ground) if your button is not active.
If·it reads anything else especially at random - you are missing this pulldown resitor.
If you run
Do
DEBUG BIN ? INS··
pause 1000
loop
You will see·all the inputs at once·and the "open" ones will almost always read 1. ( Unless you are using pull up resistors as mentioned above)
·
·
·
Hardware rule #2
The on board regulator is only for the board. It is temperature protected (to a degree) and will shut down when overloaded. ( this is where your several seconds of correct operation is comming from). Or let out the smoke in worst case!
·
Your LED may draw more current than the regulator (especially the older bargain type one) can handle ( about 50 ma) and will make the regulator to shut down. And when it recovers it will ---·reset the processor and start over...
·
Feed all external components via a separate supply - not via on board regulator.
·
Anywho, long story short - I'm sending it back, they're going to test it and conclude once and for all that I'm either an idiot, or the unit is bad. ((crosses fingers for bad unit)) [noparse];)[/noparse]
In the photo on page 81 show Vdd and the the 220 ohm on·one side of the switch ·and the 10k is on the Vss·of the switch and
·In the wiring diagram it show the 10 k and the 220 ohm on the Vss side· of the switch and Vdd on the other side of switch
The one in the photo would make the INPUT HIGH when the switch is not pushed on a·NO switch and would not be LOW unless the button was pushed
I have not· try-ed this set up to see how it really works but I will try it and see what happens the one in the photo
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Try this - disconnect both·LED and your switch.
Connect·10kOhm resistor from IN3 to ground. Run the test I suggested without any other devices.
Does IN3 reads 0 always? If yes than add your limiting resistor in series with this pull down resistor. Run the test again. Should have same result - IN3 reads 0.
Now connect your switch to the junction of limiting resistor and pull down resistor.
With the switch open you should read same – 0 on IN3. Now connect the other side of the switch to +.· Operate the switch and you should read 1 on IN 3.
Ignore any other inputs or change the debug to read IN3 only.
Remove the PAUSE from the test program!
I actually ended up getting the inverted input state working. Or rather, it started working properly just as randomly as it stopped working properly. Now all the inputs do show 0 as they should. But there's additional problems now/still: when I write a program to the stamp that deals with inputs at all, I have to power cycle the board before it will ever register the inputs. power cycle, not reset, etc. And it still stops working after a short while.
But I did run through you whole suggestion, and everything is wired right - just to be sure, so thanks for that. At this point I'm pretty much resigned to an official ruling I think. Or rather, I will be when I package it back up and stick it in the mail in a bit.
Thanks all, will post the outcome once I hear back from parallax!
I had an older long unused module and it would periodically quit. You have mentioned some intermittent behavior when you move you hand over. Also cold solder joints are possibility since it works for few seconds. Good luck.
·