BS2 output problems..
Hi there..
I just want to tell you that I was trying to use the basic stamp in my project. all what I needed to do is that I have 8 bits input (2 out of 8 are going to be high each time) and for each input I want to set up different pin high.
I wrote a code for it but somehow pin 9 (which should be an output pin) is always high. attached you can find my code after I changed it and made it one input pin high only and pin 9 stayed always high.
on my schematic I have pin 3 and 23 grounded and 5 V on pin 21.
Thanks for any help....
I just want to tell you that I was trying to use the basic stamp in my project. all what I needed to do is that I have 8 bits input (2 out of 8 are going to be high each time) and for each input I want to set up different pin high.
I wrote a code for it but somehow pin 9 (which should be an output pin) is always high. attached you can find my code after I changed it and made it one input pin high only and pin 9 stayed always high.
on my schematic I have pin 3 and 23 grounded and 5 V on pin 21.
Thanks for any help....
Comments
Let me welcome you to the Parallax Forum
How are you·hooking these·INPUT PINS·up
Do you ·have 10 k ohm resistor to VSS pin· to the INPUT pin
And
·Do you have·a 220 ohm resistor·from·to the switch to VDD·and from the switch to the Basic Stamp PIN
·THIS IS A MUST if do not have your set up this way it will not work
Also you need to do this to each INPUT PIN the same
If you are using a optic sensor like a 4N25 then you do it like this· you may not need 24 volts on the input side
your resistors will be lower for five volt would be ·about· 1 kohm or so· but the side that hook to the Basic
Stamp would be the same·
The name of the file is misleading 24 Volt Power Supply.jpg·· but it show how to hook up a optic sensor like the 4N25·
One more thing the resistor that dose not have a value is 10 k ohm
I hope that this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 12/7/2008 4:03:10 AM GMT
Looking at your code, if no input (p0 through p7) is high, then none of your IF statements will branch, and you will fall into the code you label "nine:", and pin 9 will always be high because you put it high for 1/2 second, then put it low and instantly go to MAIN and quickly put it high again. Actually it will have dropped with your LOW 9 statement, but you set it high again very quickly.
I'm guessing that what sam_sam_sam was trying to say is correct, and that your input circuits are not working as you expect them to. Have you actually measured the volages at your inputs (p0 through p7)?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
The logic would be, if the LED was on the output would be LOW, otherwise it would be high. If you need it to be active high in the code you can read it inverted by putting a ~ in front of the pin constant.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thank You for point this out to me VCC should have been VSS I wrote the wrong label
Typically the emitter would go to ground (Vss) and the collector would be pulled high by a 10K resistor. The collector would also be connected to an I/O pin via a 220 series resistor for protection.
Thank You pointing this out to me as well
The logic would be, if the LED was on the output would be LOW, otherwise it would be high. If you need it to be active high in the code you can read it inverted by putting a ~ in front of the pin constant.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
IF LeftIn = 0 THEN ‘ LOW when input is active
becomes
IF ~LeftIn = 1 THEN ‘ HIGH when input is active
Another benefit to handling things like this in code is that you can handle certain unforseen changes to hardware.· Once I connected a keypad on a customer board and for whatever reason the connector would not fit in the normal manner.· It ended up being reversed making all my connections backward.· But in code it is so easy go from SHIFT-LEFT to SHIFT-RIGHT when scanning.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering