Possible Problems with basic stamp
morris4019
Posts: 145
I'm trying to test to make sure that i did not blow any of my pins while i was testing a program for a stepper motor. I'm wondering what resistor you guys think i should put in between 9v for the stamp to see a logic 1 or 0. You know what i mean, I'm trying to write a small program that I can test the pins as inputs to make sure everything is aok. I have one rail (the rail with the stamp connected running 9v, letting the onboard voltage regulator take care of it), and the other rail i have a 7805 with 5v regulated. I figured I could get away with running a jumper from pos to pin 0 (or whatever pin i was testing) through a resistor to get a logic 1 or 0 you know. But what size should it be?
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
Comments
Thank you
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
' {$STAMP BS2}
' {$PBASIC 2.5}
top:
IF (IN0=0) THEN DEBUGzero
IF (IN0=1) THEN DEBUGone
GOTO top
DEBUGzero:
DEBUG HOME, "Pin 0= 0"
GOTO top
DEBUGone:
DEBUG HOME, "Pin 0= 1"
GOTO top
The debug window just stays at "Pin 0 = 1"... ????
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
' {$STAMP BS2}
' {$PBASIC 2.5}
DIRA=$F 'Make the first 4 pins outputs
INPUT 15 ' Make pin 15 an input for which direction we are going to run.
delay CON 50 'Set a constant for time delay. (1/2 second)
index VAR Byte 'Index is used for our counter.
pattern VAR Byte 'Pattern is used for the particular pattern were on.
direction VAR Bit 'Set a variable for which direction we are moving.
top:
IF (IN15=0) THEN
direction=0
ELSEIF (IN15=1) THEN
direction=1
ENDIF
IF (direction=1) THEN
FOR index = 0 TO 7
LOOKUP index, [noparse][[/noparse]%0001, %0011, %0010, %0110, %0100, %1100, %1000, %1001], pattern
OUTA=pattern
PAUSE delay
NEXT
ELSEIF (direction=0) THEN
FOR index = 0 TO 7
LOOKUP index, [noparse][[/noparse]%0001, %0011, %0010, %0110, %0100, %1100, %1000, %1001], pattern
OUTA=pattern
PAUSE delay
NEXT
ENDIF
GOTO top
I will take a picture of my breadboard to show you how i have hooked up everything. It will be on here in just a few minutes.
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
Post Edited (morris4019) : 5/7/2009 10:05:44 PM GMT
Did you realise that the Basic Stamp inputs "float" unless they are tied to +5v or to Gnd via a resistor?
Because if you don't have a set condition for the program, you can't really read a different condition.
If you are testing variable which is logical, has only possible values 0 or 1, than IF statement needs only one evaluation:
IF value = 1 THEN·· ' explicit test·for 1
·· statement(s)
ELSE··················· ' implied "test" for 0
·· statement(s)
ENDIF
It does kind of make sense though, because this is why i am thinking i have a problem. Now mind you, i have no problems doing basically anything, except when it comes to inputs. If i have nothing connected to an input pin, when you would think it gets no signal, it randomly seems to get some sort of signal, which blinks the light every once in awhile. Thats why i was thinking that my stamp may be messed up.
But how else should i connect a switch? I will be using just a small push button switch, and a 9v battery.
Also, vaclav_sal, thanks for the tip. I have originally wrote it that way, but when i was getting unexpected results I went more specific and thought that way i could rule out code.
Thanks everyone.
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]
You should also think about changing the IN15 command to the (better) BUTTON command which will debounce the switch.
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
======
······ I'll try everything once [noparse]:)[/noparse]