Shop OBEX P1 Docs P2 Docs Learn Events
Quick question re: the BS2SX and audio — Parallax Forums

Quick question re: the BS2SX and audio

ChrisChris Posts: 2
edited 2004-12-15 17:13 in BASIC Stamp
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
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

  • ChrisChris Posts: 2
    edited 2004-12-15 17:09
    other question, can the sx2 execute pwm out while taking in digital info? I.E Pin 1-2 are taking in a varying voltage and translating it into 0-255 values. Then these are read and spit into an equations which says, if value = x then send high5 or low5 out with Ydelay.
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-15 17:13
    First of all, the SX and the BS2SX are two different beasts. The BS2sx is primarily a BS2, and should be talked about in that forum.

    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
Sign In or Register to comment.