Quick question re: the BS2SX and audio
Chris
Posts: 2
hello!
Hi everybody! Have a quick question. I recently picked up the bs2sx and have been working on a small audio project and I've run into an issue. Basically I have an electret microphone that is running through an LM386 which then runs into an ADC0831 then to the Stamp and back out to a relay. What I am attempting to do is convert audio to digital and then use the digital values as part of an equation for switching a relay on and off. I've got it all working, however I've run into a snag. The only delay feature that I know of in stamp is
and this pauses the programs operation. This is problematic in that it causes the entire program to stop, which is a problem because the mic tracking ceases as well. So, what I need is a means of continuing to allow the program to run, while sending a delayed on/off out from an output pin. I guess what I'm looking for is a multi-tasking solution, or a function that works as a delay on a pin rather then a pause in the program. is this possible, is there a function or equation that will allow the stamp to continue viewing the digital data while sending an on/delay/off to another pin? I guess what I could do is run it out to a 555 and just have the digital info equate to the resistance change needed for the 555. help?
chris
Hi everybody! Have a quick question. I recently picked up the bs2sx and have been working on a small audio project and I've run into an issue. Basically I have an electret microphone that is running through an LM386 which then runs into an ADC0831 then to the Stamp and back out to a relay. What I am attempting to do is convert audio to digital and then use the digital values as part of an equation for switching a relay on and off. I've got it all working, however I've run into a snag. The only delay feature that I know of in stamp is
pause (number)
and this pauses the programs operation. This is problematic in that it causes the entire program to stop, which is a problem because the mic tracking ceases as well. So, what I need is a means of continuing to allow the program to run, while sending a delayed on/off out from an output pin. I guess what I'm looking for is a multi-tasking solution, or a function that works as a delay on a pin rather then a pause in the program. is this possible, is there a function or equation that will allow the stamp to continue viewing the digital data while sending an on/delay/off to another pin? I guess what I could do is run it out to a 555 and just have the digital info equate to the resistance change needed for the 555. help?
chris
Comments
Having said that, you can code a loop with a short 'PAUSE', increment a counter, and then do something every Nth time through the loop.
so:
DO
· GOSUB ReadMic
· IF (Stuff) THEN
··· ' Change Relay
· ENDIF
· Counter = Counter + 1
· IF Counter = 1000 THEN
··· Toggle LEDPin
····Counter = 0
· ENDIF
· PAUSE 1 ' Pause only ONE millisecond here, then go around again.
LOOP