Problems reading a bcd switch...newbie
Archiver
Posts: 46,084
Sounds like your input pins are either floating if the respective
switches are open, or connected to +5V if the switches are closed. A
Stamp's input pins will most often read as logical 1's if left
floating ("floating" = connected to nothing...not driven/pulled to a
physical high or low). I think this explains why you see 1's no
matter what in the first instance you describe.
You may want to try the following. Connect your switch pins to your
Stamp pins as you described, but connect each of the four inputs to
ground through (separate) 2.2k resistors. Connect your switch's pin
5 to +5V. With this configuration, an open switch will be pulled
low and read as a logical zero, and a closed switch will be high and
read as a logical 1.
Steve
switches are open, or connected to +5V if the switches are closed. A
Stamp's input pins will most often read as logical 1's if left
floating ("floating" = connected to nothing...not driven/pulled to a
physical high or low). I think this explains why you see 1's no
matter what in the first instance you describe.
You may want to try the following. Connect your switch pins to your
Stamp pins as you described, but connect each of the four inputs to
ground through (separate) 2.2k resistors. Connect your switch's pin
5 to +5V. With this configuration, an open switch will be pulled
low and read as a logical zero, and a closed switch will be high and
read as a logical 1.
Steve
Comments
output on the screen.
The bcd switch has 5 pins: "inc"
Pin 1 = binary 1 Pins 1-4 are hooked up to pins 8-11 on the bs2.
pin 2 = binary 2
pin 3 = binary 4
pin 4 = binary 8
pin 5 = vdd+5 or ground ???? ----Through a 2.2k resistor---
I thought if I hooked up pin 5 to vdd ,+5V,and pins 1-4 of the bcd
switch to pins 8-11 of the bs2 and ran the code below things would be
wonderful,not so.
a var nib
start:
a = inc
debug bin a
pause 1000
debug cls
goto start
What happens when I hook up pin 5 to vdd I get : 1111 no matter
what number I have the switch set at.
When I hook up pin 5 to vss, ground,it gets better but it is
inverted. example: bcd at 1----1110
2----1101
3----1100
4----1011 etc..
Could somebody take my hand on this one. Thank you!!
>I am trying to hook up a bcd switch to a bs2 and simply display the
>output on the screen.
>
> The bcd switch has 5 pins: "inc"
>Pin 1 = binary 1 Pins 1-4 are hooked up to pins 8-11 on the bs2.
>pin 2 = binary 2
>pin 3 = binary 4
>pin 4 = binary 8
>pin 5 = vdd+5 or ground ???? ----Through a 2.2k resistor---
>
> I thought if I hooked up pin 5 to vdd ,+5V,and pins 1-4 of the bcd
>switch to pins 8-11 of the bs2 and ran the code below things would be
>wonderful,not so.
>
> a var nib
>start:
> a = inc
> debug bin a
> pause 1000
> debug cls
>goto start
>
> What happens when I hook up pin 5 to vdd I get : 1111 no matter
>what number I have the switch set at.
> When I hook up pin 5 to vss, ground,it gets better but it is
>inverted. example: bcd at 1----1110
> 2----1101
> 3----1100
> 4----1011 etc..
>
>Could somebody take my hand on this one. Thank you!!
>
Check the specs on the switch and see if it's providing the complement. If not,
see Pages 237, 238 of the BS-2 Manual, and use "ABS a". The BS-2 is expanding
what is sees as a negative number to a 16-bit word (internal workspace) and then
truncating the result.
Hope that clarifys it for you.
Regards,
Bruce Bates