Pin comparision
NosePicker
Posts: 54
I have a small project where I want to know anytime one of my input pins changes from high to low or low to high.
Which pins I used is not important so if it will be easier to use different pins I can.
However if I understand this right it looks like it will be best to use pins 0 - 7.
Can someone look at the following code and tell me if that will work?
The assumption is the line (LastValue = INL) will assign a value not a pointer.
' {$STAMP BS2}
' {$PBASIC 2.5}
' Sets pins 0 - 7 as input
DIRL = 0
LastValue VAR Byte
' INL = the byte for the combined pins 0 - 7
LastValue = INL
MainLoop:
· IF (INL <> LastValue) THEN
··· LastValue = INL
··· DEBUG DEC LastValue
· ENDIF
· PAUSE 5
· GOTO MainLoop
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
Which pins I used is not important so if it will be easier to use different pins I can.
However if I understand this right it looks like it will be best to use pins 0 - 7.
Can someone look at the following code and tell me if that will work?
The assumption is the line (LastValue = INL) will assign a value not a pointer.
' {$STAMP BS2}
' {$PBASIC 2.5}
' Sets pins 0 - 7 as input
DIRL = 0
LastValue VAR Byte
' INL = the byte for the combined pins 0 - 7
LastValue = INL
MainLoop:
· IF (INL <> LastValue) THEN
··· LastValue = INL
··· DEBUG DEC LastValue
· ENDIF
· PAUSE 5
· GOTO MainLoop
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Does anyone know where I can get those from?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
It's an op-amp, not a comparator specifically.· But, anyway.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
I searched digikey and they have so many different models. Do I just need to read the datasheet for all of them to figure out which will do what I need?
I will need 7 separate (? detections) so it looks like 2 quads should do the trick.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
http://www.radioshack.com/product/index.jsp?productId=2062593&cp=
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Any chance this range of voltages is actually the result of PWM and different duty rates?
Using a small inductor and a 220 ohm resistor I am able to create a voltage spike by taking the input pin LOW-Output and then changing it back to input. A voltage spike (attached scope output) shows a 2.6V spike when fed 950mV.· The stamp however (attached program) is not fast enough to catch the spike as it is only above the 1.4V threshold for 200ns.· A microchip with an interrupt on pin change for example could detect this short of a pulse. Then again, perhaps the stamp could detect it using pulsin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
I also thought the LM339 would do it but I purchased some and after reading the datasheet and testing with them on my breadboard, it appears when the comparator detects a difference in the voltage for the + and - input, it simply connects the output pin to ground. So to try this, I connected an LED and 220ohm res from my +5v supply to the output pin of the comparator. I then connected a 12v battery + and - to the input pins. And the LED would turn off and on as I would connect and disconnect the + side of the battery.
So would I have to basically replace the LED with the stamp pin?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
IMHO your best option is to use a voltage divider to reduce your input signal from 12 volts down to less than 5. Then your comparator and all your circuitry will operate at stamp voltage and everything is easier. Can you do that?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Yes I can but we are losing sight of what I am really trying to accomplish. I was just using the 12v battery to test something. My real situation is connecting a device that will produce anywhere from 4v down to about 1v which is below the threshold of the stamp to detect. (Read my 3rd post from the top) Because the voltage drops below the threshold is why I am trying to use either a comparator or the Op Amp to detect the signal.
But for my "test" you are right I need the input to be = or < the supply voltage.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
It looks like you are creating a voltage divider.
Considering the input voltage from the device is guaranteed to be between say 4v and 0.8v when on and 0v when off would I need those resistors still?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks
NosePicker