Shop OBEX P1 Docs P2 Docs Learn Events
Wanting to detect no sound from a computers sound card to trigger a pin on the — Parallax Forums

Wanting to detect no sound from a computers sound card to trigger a pin on the

DigitalDjDigitalDj Posts: 207
edited 2006-10-26 01:55 in General Discussion
Hello Guys,
I am wanting to detect no sound on a computers sound card when no music is playing so i can trigger a pin on the SX28 or 48. By doing this i can tell the SX what i want it to do at that point. I am wanting to control lighted buttons as a attraction method for my jukebox.

So what i need is a circuit that can detect the absence of the sound and trigger the pin high or low. The SX would have to be programmed with a delay once the pin is triggered so it doesn't get triggered by just a simple break in the music. I didn't want to have to do this by software because i want sequences programmed in the SX and not be controlled by the computer.

Thanks for any ideas!
Kevin
·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)


Post Edited (DigitalDj) : 10/14/2006 7:06:19 PM GMT

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2006-10-16 17:43
    Kevin,

    What comes to mind that might just do what you want is a VOX circuit. VOX stands for Voice Operated Trans(X)mit. People who use handheld radios for communication often like these circuits because they allow them to simply start talking without having to press a button to start the transmitter when they want to communicate. Basically the circuit detects a certain level of sound and then switches on the transmitter for as long as the sound level persists plus some delay that allows for slight pauses or periods of lower volume.

    This sounds like it should do exactly what you desire because the circuit will change its output state based upon whether or not it has detected any (loud enough) sounds recently. Such a circuit can be found at www.rason.org/Projects/basicvox/basicvox.htm, though there are many, many others around. You may want to search for "VOX circuit".

    You should be able to connect the PTT ("Push To Talk" - radio jargon) connection in the circuit I referenced directly to an SX pin configured for input since the transistor is simply pulling the connection to ground.

    I hope this helps or at least gives you an idea where to look.

    - Sparks
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-16 18:04
    The VOX circuit that Sparks mentioned is essentially an amplifier, a rectifier/filter, and a transistor switch that's intended to connect to a microphone level input. Your sound card probably has a line level output (maybe 1V max) or a headphone output. In both cases, you will need less amplification. You may just need the diode and filter capacitor. It all depends on the output circuitry of your sound card.
  • BeanBean Posts: 8,129
    edited 2006-10-16 18:20
    Kevin,
    If you use the built-in comparitor, you can probably must rectify the speaker output(diode), filter it with a cap, and connect it to the comparitor input through a resistor (10K ?).

    Then adjust the other input to the comparitor to the threshold level.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    Don't mistake experience for intelligence. And vis-vera.
    ·
  • DigitalDjDigitalDj Posts: 207
    edited 2006-10-17 02:30
    The Vox circuits definately and interesting idea i hadn't thought of.

    I probably wouldn't want to go over 5 volts on the pins of the SX which i don't think will be a problem. The bad thing i can think of is rectifying the audio out of the sound card would maybe be ok but filtering it will have an effect on the sound quaility unless i use a audio transformer to isolate the circuit.

    Bean,

    Have you ever programmed anything similar to this with the comparitors?

    Thanks,

    Kevin


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
    The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
    Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)


    Post Edited (DigitalDj) : 10/17/2006 2:37:28 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-17 04:13
    DigitalDJ,
    I was going to suggest an audio transformer originally. Pick up either an 8 ohm to maybe 300-1000 ohm transformer or a 1:1 transformer if you've got a line output and use a bridge rectifier to feed a small filter capacitor. Decide on the time constant you want for the reaction time for sound on or sound off and pick a resistor to put across the capacitor to discharge it based on the time constant. Connect the negative side to ground and use a 10K to 100K resistor between the positive side and the SX pin. The SX will see a high any time the rectified voltage is above roughly 1.4V (without using the comparator). If you want, you could put a volume control somewhere in the circuit to set the trigger level.
    Mike
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-10-17 07:36
    Kevin,

    I would not worry about the sound quality when rectifying and filtering the audio signal as long as you take care that the load attached to the soundcard's line out is not too low. Using a tranformer does not reduce the load when you use a 1:1 transformer.

    I like Bean's idea using the comparator, as this seems to me the solution requiring a minimum of external components - see the attached schematic. I only estimated the component values, so some experimenting might be in order but using a relatively large resistor in series with the audio signal makes sure that the sound card almost does not "see" this circuit, i.e. there is a minimum load only.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
    1178 x 758 - 72K
  • DigitalDjDigitalDj Posts: 207
    edited 2006-10-18 01:52
    The sound that will be coming out of the sound card will also be going to an amp so that's why i didn't won't to risk the chance of changing the sound quality. Correct me if i'm wrong but using the diode inline with the audio and then having the capacitor after it then the diode should decouple it from the line correct?

    I will try theseideas and see what i come up with! I am waiting on my SX48 board. I may need help on programming the comparators which i can do with my SX28 f it is not to different from the 48. I went with the 48 because i needed more outputs to control.

    Thanks for the ideas guys!

    Kevin



    Bean,

    I·still have a simple led program you helped me with, if i need to repost this i can if·you want to help and show me how to use the comparators.

    Thanks,

    Kevin



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
    The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
    Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-10-18 07:35
    Kevin,

    in the schematic I have suggested, decoupling is done by the resistor in series with the audio signal, and not with the diode.

    Using the comparator is pretty easy:

    ; Configuring the comparator
    mode $08 ; access CMP_B
    mov w, #%01000000
    mov !rb, w ;enable comparator, do not enable comp. output at rb.0

    ; Insert a delay to allow comparator to respond

    ; Reading the comparator (same as above)
    mode $08 ; access CMP_B
    mov w, #%01000000
    mov !rb, w ;enable comparator, do not enable comp. output at rb.0, and copy comp. result into w

    ; When bit 0 in w is set (w = 1), the voltage at rb.2 is greater than the voltage at rb.1

    When you don't neet port pin rb.0 for other purposes, you could enable the comparator output (write %00000000 to !rb instead of %01000000). You then can directly check the state of rb.0 for the current comparator result, i.e. you don't need to execute the second

    mode $08 ; access CMP_B
    mov w, #%01000000
    mov !rb, w ;enable comparator, do not enable comp. output at rb.0, and copy comp. result into w

    in a loop for reading the result.

    Assuming the potentiometer is set correctly, the comparator status would be 1 for no audio, and 0 for audio. You can always exchange the rb.1 and rb.2 pins if you like an inverted result, i.e. 1 for audio, and 0 for no audio.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • DigitalDjDigitalDj Posts: 207
    edited 2006-10-19 00:58
    How much voltage do you suppose i need to come up with off the audio line to make this work?

    Is there any differences that i need to change when going from the SX28 to the 48 from a simple SX28 program?

    I will give this a try thanks!

    Thanks,

    Kevin




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
    The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
    Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)


    Post Edited (DigitalDj) : 10/19/2006 1:02:27 AM GMT
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-10-19 09:14
    Kevin,

    IMO, the detection should work with a relatively low level on the audio line, as the comparator reacts on the voltage difference between the rb.1 and rb.2 pins. Let's assume, you adjust the potentiometer for 0.5V between Vss and rb.2, the comparator output will change its state when the rectified and filtered audio signal betwwen Vss and rb.1 exceeds 0.5V by some Millivolts. The SX28 data sheet specifies the typical minumum input offset voltage as +-10mV for an input voltage in the range from 0.4V to Vdd-1.5V. So when the rectified and filtered audio signal at rb.1 is 0.5V or more, you are in good shape. Use the potentiometer to adjust the minimum audio level that shall be interpreted as valid audio signal.

    When using an SX48, there are some differences concerning the MODE register (besides other differences). Instead of

    mode $08

    in my previous example, you need to use the instructions

    mov w, $18
    mov m, w

    instead.

    Are you planning to write your application in assembly, or in SX/B? When using SX/B, the compiler will handle the differences between the SX28 and the SX48. As I'm not too experienced in SX/B, maybe someone else can bail in with a demonstration how to deal with the comparator in an SX/B application.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • DigitalDjDigitalDj Posts: 207
    edited 2006-10-21 01:28
    Gunther,

    Yes i would like to do it in SXB!

    Thanks,

    Kevin



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
    The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
    Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)
  • DigitalDjDigitalDj Posts: 207
    edited 2006-10-26 01:46
    Can someone show me how·working with the comparotors·is done in SX Basic like Gunther did in assembly?

    You know what screw it since Parallax can't put out a book on SX/B i'll just learn Assembly, I should have done it a long time ago. Gunthers book seems very informative. Thanks for the book that comes with the SX Experimenter Board·Gunther

    Kevin




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Education And Experience Teaches Knowledge Not Arrogance ! (Unknown)
    The Only Stupid Question Is The One Not Asked ! (Unknown, of coarse this is something that i would say)
    Do Not Burn The Bridge That Has Brought You Forth You May·Need To Journey Back ! (Chinese)


    Post Edited (DigitalDj) : 10/26/2006 1:52:53 AM GMT
  • BeanBean Posts: 8,129
    edited 2006-10-26 01:55
    Did you try the SX/B help file ?
    Reference->Compare->Example (in upper right corner)

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
Sign In or Register to comment.