Reading Voltages
SN96
Posts: 318
I have the BS2px and I was wondering if the CONFIG command would allow me to· trigger a·program routine when the voltage changes from 1.6v to 2.5v? I do not need to measure the voltage, just cause my program to react to the change. I built a sound sensor that has an output wire that normally puts out ~1.6v but when a sound is detected, the wire puts out ~2.2v. TTL logic threshold is logic low @ 1.4v and logic high @ above 1.4v my circuit is normally outputing 1.6v.
Whats the best way to react to voltage changes?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Whats the best way to react to voltage changes?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Comments
It depends a lot on what else the program has to be doing, while waiting for the sound trigger. It could sit and watch the result of the comparison, or it could do other stuff and come around occasionally.
Also look at the POLLIN command. This provides another way to detect the sound trigger, but you would have to shift the 1.6 to 2.5 volt signal down by about 0.6 volts, so that it would span the 1.4 volt trigger point of any Stamp input. The POLLing commands can be configured to latch an input event (hold on to a brief event even while the program is off doing something else), and it can be configured to trigger while the Stamp is in a low power SLEEP mode or to trigger very rapidly to the event.
I'm not sure exactly how the COMPARE interacts with the POLLing, but I believe that if you enable the p0 output from a compare, that can be used as an input to POLLing.
There is ordinary polling too, available on any Stamp on any pin. Just look at the input to be above or below the threshold, but the program has to be there to catch it or have some external means to stretch external events.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I will try the compare command by feeding one pin 5v and the other pin the sensor output and use the difference as the trigger.
I will also look in to the POLL command and see if that will work for me also.
I got this to work using a Basic Atom Pro, which has a built in AD converter but I think I fried the AD converter some how. The AD pin is rated for 5v and my circuit only puts out 2.5v so I don't know what happened. Below is a video using the Atom MCU but I also have the BS2px I can try.
http://www.youtube.com/watch?v=23s_LwDYKiQ&fmt=6
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Here is the simple code:
' {$STAMP BS2px}
' {$PBASIC 2.5}
DO
IF IN3 < 1 THEN
DEBUG "it works" '<
Can be replaced with any set of instructions
PAUSE 1200 '<---- Allow time for the pin to return to a high state
ENDIF
LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Note: Because the voltage drop across the PN junction is proportional to the current across the PN junction, you might need two diodes in series to get an adequate drop. Just about any generic Si diode should work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.