Shop OBEX P1 Docs P2 Docs Learn Events
Sound Switch — Parallax Forums

Sound Switch

SomniumSomnium Posts: 46
edited 2006-10-23 02:12 in Propeller 1
does anyone have a schematic for a sound activated switch? Ex: Sound comes in starts the circuit and finishes. Starts over when sound comes in.

Post Edited (Somnium) : 10/11/2006 3:03:41 AM GMT

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2006-10-11 10:36
    A schematic hey? As you have said elsewhere "I'm still not that gud with the making of schematics..." how about some practice then?

    Since you have posted this on the Propeller forum I guess you are trying to do this with a Propeller, so here we go.

    Ok, get a sheet of paper and draw a Propeller chip with the RC network for A/D and microphone. Now draw a line from one of the I/O lines to the output drive circuit (take your pick). Now add a 3.3V regulator circuit and the serial EEPROM for the Propeller.

    Is that what you wanted?

    No? Ok, try sci.electronics.design then.


    *Peter*
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2006-10-11 11:18
    Peter, this is the second response of this type you have made in the past few days. If you don't want to answer a question then don't. Seemingly simple questions often show a lack of confidence and that is not boosted through sarcasm. There is a lot to learn when it comes to the propeller. Take, "with the RC network for A/D and microphone" that aready assume you know all about that, if he did he might not be asking anything.


    Somnium,

    You can download the schematics for the demo board, this includes an RC network (which becomes part of a delta sigma ADC) and an amplifier that allows the use of a microphone. You can copy this to get the schematic.

    As far as your program, check out:

    http://forums.parallax.com/forums/default.aspx?f=25&m=115264&g=115358#m115358

    This does rather more than you need but shows code for DAC and ADC, if you look at the ADC stuff you should be able to write something that will trigger when the voltage measured is greater than some level.

    That thread also notes the great importance of having the RC network right on the pins of the propeller.

    Graham
  • TyreBiterTyreBiter Posts: 40
    edited 2006-10-11 11:32
    I will second Graham's comment about sarcasm. There a a number of peopld viewing these threads who, unfortunalty, do not have a great deal of confidence in there abilitites or experience with the propellor chip. Comments of this kind are not helpful on any level.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2006-10-11 13:26
    Well I was certainly hoping that someone would notice the slight sarcasm, I can't say I am happy when I get to this point. I have seen other forums cluttered and loaded down with endless "how do I" questions that are not directly relevant to the forum but are more general questions that also show not only inexperience but a total lack of resourcefulness (read lazy). Are we all just a bunch of hand servants waiting to pander to anyone who cries "help!" at the slightest whim? Doing so is not helpful to anyone really if it is done indiscriminately as the one seeking help does not learn in this manner, as we see.

    I am fairly new to the Propeller and when I first saw the forum posts I thought WOW!, these are real roll-up-your-sleeves guys here and lots of meaty stuff to discuss. Lately the threads have been cluttered with inane and endless questions about very very basic stuff. There are plenty of other places that these questions could get answered although I am not at all against sincere questions that show that the person is trying. I have found from much experience in answering posts that there are some people who will ask first and maybe think later, if at all.

    Perhaps I am working too hard, I was thinking of just raising this issue as a new post, but take this for what it is, I just like to see these persistent non Propeller related general electronics questions handled elsewhere as there are plenty of places for this. This is not a blanket rule but nothing is guaranteed to run smoothly unless you have some kind of self-regulation and limits in place, like speaking out against sarcasm [noparse]:)[/noparse]

    *Peter*
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-11 14:39
    The question of how much help to give, how much "hand-holding" is not simple. Sometimes there are a lot of "how do I" questions and sometimes they seem like they're from "lazy" folks, but sometimes they're from folks that are just "lost", confused or very inexperienced. You are correct in that there are some people who will ask first and maybe think later. What may be different about this forum is that the company whose products and people are behind it have made a career and business of supporting hobbyists and the education market particularly. They do put a tremendous amount of effort into making "cool" things like the Propeller, but also provide very well done books, magazine articles, tutorials, and other support information

    A good guiding principle is to give people the benefit of the doubt, do point them to existing educational material like the "What's a Microcontroller?" text, try to make them think for themselves or at least try things out, and, if you get tired or grumpy or frustrated, leave the last question for someone else to answer. They may come up with the right approach to make sense to the questioner. There are occasional threads that are too general or seem like the questioner is not paying attention to the answers. These often eventually go unanswered or stop with a message "go read here ..." and that's ok.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2006-10-11 19:27
    I think the word "lost" sums things up well. There is also the fact that some beginners (who might also be beginners to learning about technical matters) might not REALLY know that efforts in trying themselves will help. The propeller manual is of course a good place to start but there is a lot of it!

    I find that when a person knows a lot about a subject they forget about all about the tiny details that build up to form their knowledge, a beginners question can seem really stupid. But does anyone actually want to ask a stupid question? The same person can end up asking equally stupid questions a minute later on a subject they don't know. I was asking my mum about finance the other day and she looked at me like I was stupid but you should hear the questions I get asked!!

    If you want to stop the stupid questions then help with some documentation, nice examples or links or just suggest a more suitable forum of learning method. For example "I think it would be best for you to buy Horrowitz and Hill and insert it up your rectum", or I guess you could be nice.

    Graham
  • ALIBEALIBE Posts: 299
    edited 2006-10-11 20:07
    I want to pitch in my thoughts into this thread - not as a guru like others in the thread - but, as a newbie.

    Sometimes, for electronics newbie like me, it is not knowing the unknown. Many times I have found myself lost in the maze of, "What do I need to know before I can do something in a particular project". Sometimes those questions might seem very basic to others, not to me. So the phrase, "very very basic" is all relative.

    I appreciate all the help I am getting from experienced (at whatever level they are in) folks here. I have become smarter in the electronics area than I used to be. And, the credit goes to the wonderful innovative products that Parallax makes that attracts hobbyists like me, and keeps me on my learning feet. Plus all the folks who w/o losing patience help w/ their advice and recommendations.

    *******************************************************
    Having said all that, I want to comment on "Peter Jackaki"'s note.
    Peter, I honestly believe you have no clue of people-skills do you? Nor, understand the importance of forums and what purpose they serve. If you feel that forums are meant to help serve the elites of the brains (such as "yourself" - at least you feel that way), you might want to consider starting your own forum and let me know, I will ensure I don't clog up your space. And looks like you have all the knowledge you need so, not sure why you're here in the first place. If you're all abt R&D and self-learning *only*, you should consider packing your bags dude.

    if none of the above options seem interesting to you, then *behave* and start applying some respect to fellow students. If you can't help or don't want to help, you're better of keeping it silent.

    We're all here w/ one goal - learn and grow - in whichever capacity that might be.

    And, remember, "relativity".
    *******************************************************

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://ALIBE.crosscity.com/
    http://fstop.crosscity.com/
    http://icar.crosscity.com/


    Post Edited (ALIBE) : 10/11/2006 8:21:09 PM GMT
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2006-10-11 21:48
    Ali, don't be nasty, I may come across sacastic at times but I do answer questions (lots n lots). My reply to Som did direct him to something more general and I did answer his "question" in an attempt to stimulate at the very least his question asking abilities. No, I am not trying to be smart but education is more than answering questions or even about asking questions, sometimes it's about behaviour, discipline, and doing it yourself (something they don't teach much of anymore).

    Also, would you like this forum to "become" a general electronics "how do I" forum?. When I click on "Propeller Forum" I expect substantial Propeller related content, if I go to newsgroups it's the same thing. We could answer questions about finance on here but is it appropriate?

    BTW Ali, I did not or was not thinking of you at all in my previous post. It's not whether you are a beginner or whether you ask lots of questions, you at least take the time to think about your questions. The references I made are made to ones who go "gimme". As regards to people skills observe Mike and Graham who seem to have answered, told me to sit still and eat my porridge, all without being nasty or personal.

    Thanks to all for your feedback.

    *Peter*
  • ALIBEALIBE Posts: 299
    edited 2006-10-12 00:18
    Peter,
    there's a saying a very old saying, "emails and text can only do so much justice to the sender's intent". Well not that old really. So, well, we both got carried away w/ what we actually intended to say and how we said it.

    I know that you did not intend me or was referring to me - but, for the health of this forum, I was steping up (probably a little bit more heavily) speaking for the "electronics meek" (or so - like myself). I honestly believe we all want to learn and help - sometimes ?s comes out stupid and basic, and that must be expected to nuture the growth of a true community. The maturity is in giving that room to grow to the not-so-knowledgeable. Nobody enjoys wanting to be "gimmes" or asking immediate gratification questions - it is probably just the moment of time thing, out of wanting to know in quick so we can go implement stuff and learn. It's natural - I hope you understand

    I was not getting personal at all BTW, but was trying to get a point across as sharply as I could - on a hind sight, I could have done it differently.

    But, to your point on whether we want this forum to be "how do I forum" - I believe that is "the nature of the beast"- A forum is a forum is a forum - it must be a collage of all kinds. Unless Parallax wants to moderate all traffic. I highly doubt they want that - they are busy already inventing cool stuff for us. The most fun part about being a part of the forum is helping folks grow in their knowledge and in the process learn, get some bragging rights, and boost our ego w/ cool projects we do, among other things.

    I look to experienced folks for recommendations, advice, guidance, etc, etc. True mentorship and willingness to help - and humbly knowing that my ?ns might come out as basic as they can be. This is what makes a forum a true community - not just a site w/ a whole bunch of great people (it would just be a site - no life). You need a mix of both ends to make it a pleasurable experience for all. Parallax forums have always been probably the best compared to I have seen out there. And, I tell you what, it is the mix of beginners:mid level[noparse]:advanced:[/noparse]most advanced.



    Oh, BTW, Ali is not my name. You might have confused w/ my project name ALIBE - which is really A.L.I.B.E.


    caio - as good friends

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://ALIBE.crosscity.com/
    http://fstop.crosscity.com/
    http://icar.crosscity.com/


    Post Edited (ALIBE) : 10/12/2006 12:32:33 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-12 00:36
    Peter and others,
    So much of what goes on here is a response to questions. Ask complex, sophisticated questions and you will get hopefully less complex, but sophisticated answers. For example, there's a thread going on now about the CORDIC transformation. It's very sophisticated, both in the mathematics and the applicability to the Propeller, the Stamps and the SX processors. Some of our past discussions on multiprocessing have not been anywhere near the beginner's level. On the other hand, there seem to be certain topics that crop up again and again and again and, when some of us have the time and patience, we explain them again, like why you can't realistically recover a Stamp program from a programmed Stamp or some kind of project instability that's all about having a well filtered, stable, adequate power supply and how to do that or how to activate a relay or motor from an I/O pin. Fortunately, there's usually someone here who is willing to answer again and, hopefully, some newbie may get excited about robotics or some other kind of microcontroller thing. Anyway, ask good questions, make the rest of us think, both about how to answer effectively, and how to solve the problem presented. That's part of what makes this kind of thing fun.
    Mike
  • ALIBEALIBE Posts: 299
    edited 2006-10-12 01:23
    Mike,
    "ask good questions, make the rest of us think..."

    AMEN to that!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://ALIBE.crosscity.com/
    http://fstop.crosscity.com/
    http://icar.crosscity.com/
    ·
  • SomniumSomnium Posts: 46
    edited 2006-10-12 01:27
    wow... amazing what a simple question could lead up to... i just found a few different schematics for sound switches online that were way too complicated and was wondering if there was a simpler version... i had a friend help me read the schematics for the propeller demo board and got a mic and headphone jack workin... i'm still going to have to delve in more with the code directed by Graham, thank you, thanks for the help
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-10-12 01:55
    Somnium,
    For future reference, some people are more amennable to helping (or at least not jumping on you) if you show you've done some research into the subject (the effort bit mentioned above). If you posed the question that you had done some research, maybe included a link or two to schematics you looked at. And stated basically what you just posted (that it seemed overly complicated and ask for pointers on how to approach the problem using a Propeller), the fire-storm most likely wouldn't have occured. In an ideal world this wouldn't be necessary, but we are all humans with emotions, so sometimes it helps to show you've made an effort.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • SomniumSomnium Posts: 46
    edited 2006-10-14 03:55
    Graham said...
    As far as your program, check out:

    http://forums.parallax.com/forums/default.aspx?f=25&m=115264&g=115358#m115358

    This does rather more than you need but shows code for DAC and ADC, if you look at the ADC stuff you should be able to write something that will trigger when the voltage measured is greater than some level.

    That thread also notes the great importance of having the RC network right on the pins of the propeller.

    I've been lookin through this code and code given to me by my teacher pertaining to the audio input and I'm comfused with the assembly programming... The two programs are similar, I'm thinking my teacher looked at the one from the link above and made a version of his own to go to headphones... but the portion where they set the pins as input and output

    Original: mov dira,#$101
    Teacher: mov dira,asm_dira
    asm_dira long $00000E00\

    How does that designate pin 8 as ADC and 0 as DAC?...

    wishing there was a program that would do the Assembly code with normal text... ugh...
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 04:12
    The DIRA (and OUTA) register consists of 32 bits that correspond to the 32 I/O pins. Bit 0 corresponds to pin 0. In the "Original" example, the instruction makes bit 0 and bit 8 of DIRA one bits and all the other bits zero ($100 is bit 8 and $001 is bit 0). That makes pins 0 and 8 become outputs with all other pins as inputs.

    The "Teacher" example sets bits 10 and 11 to ones ($E00 = $800 or'd with $400).

    Usually a DAC uses one output pin while an ADC uses an input and an output pin. In the case of the Propeller Demo Board, pins 8 and 9 are the ADC pins (8 - output, 9 - input) while pins 10 and 11 are DAC outputs for the two headphone channels (right and left respectively). The output pin of the ADC is sometimes left as an input, so that explains why only pins 10 and 11 are set as outputs initially.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2006-10-14 13:10
    A few simple details and notes:

    If you want to put a number straight into a assembly command you precede is with a # so mov dira,#257 would put the decimal number 257 into dira.

    If you want to write the number in hex you add a $ so #$101
    If you want to write the number in binary add a % so you write #%100000001

    #257, #$101 and #%100000001 are all the same number and all set bit 8 and bit 0 to one.

    A note on hex and binary:

    Firstly you can use the calculator in windows to do conversions and to help check your understanding, just make sure it is in scientific view.

    Secondly as hex goes from 0 to 15 written as 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

    Each hex digit represents 4 binary bits because it takes 4 bits to make 15 (8+4+2+1=15) this means that is is a convenient way to write long binary numbers

    for example
    1001010100101011
    |___|___|___|___|
    ..9.....5....2.....B..


    Back to the plot, I am sure that if you wanted some help to make the object more spin friendly it could be arranged its not a lot of work.

    Graham

    Post Edited (Graham Stabler) : 10/14/2006 4:41:57 PM GMT
  • SomniumSomnium Posts: 46
    edited 2006-10-14 15:41
    is there a way to get a debug screen like the PBasic for propeller?

    Also I'm testing out with a pushbutton switch to try and figure out the coding for just the switch aspect... sound seperately and I've read through the "What is a microcontroller?" manuel and redid them into propeller chip... question is the circuit only seems to connect when you press and hold the button down... is there a way to press the button once and let the code run its toll and then end?

    Post Edited (Somnium) : 10/14/2006 4:07:19 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 16:27
    Somnium,
    1) Short answer: no. Truthfully, the Propeller has a lot of different ways to do debugging. There are some examples in the library included with the Propeller Tool and in the Parallax Object Exchange for a serial debugging connection to a PC using a PC terminal emulator (like Hyperterminal). You can also hook up either a VGA display or a TV video display to a Propeller with only a couple of resistors and a plug and use one of the display drivers to display stuff going on in your program. I do this all the time and have even had a VGA hires text display and a TV display running at the same time. The Propeller Demo Board already has the parts on it for both.

    2) Short answer: yes. The question is "What does your pushbutton code look like?" and "How did you connect the pushbutton to the Propeller pin?". Assuming you connected the pushbutton to ground with a resistor from the I/O pin to +3.3V, that causes the input pin to normally be a one, then change to a zero when you push the button. In that case, you want to sit in a loop while the pin is a one ("REPEAT WHILE INA[noparse][[/noparse]pin] == 1") followed by the code you want to execute. As soon as the pin becomes a zero, the code will execute. At the end of your code, you probably want to put a ("REPEAT UNTIL INA[noparse][[/noparse]pin] == 1") to wait until the pushbutton is released. If you don't and your routine starts over again, the "push" code will execute again since the button is still down.
  • SomniumSomnium Posts: 46
    edited 2006-10-14 22:40
    Mike Green said...

    In that case, you want to sit in a loop while the pin is a one ("REPEAT WHILE INA[noparse][[/noparse]pin] == 1") followed by the code you want to execute. As soon as the pin becomes a zero, the code will execute. At the end of your code, you probably want to put a ("REPEAT UNTIL INA[noparse][[/noparse]pin] == 1") to wait until the pushbutton is released. If you don't and your routine starts over again, the "push" code will execute again since the button is still down.

    Umm... hmm... still confused here... so what it is doing is that currently it stays at one and repeats the code that is in the If statement... then when the button is pushed it will execute the code that comes after the WHILE... wouldn't that still mean that I have to have the button held down for the program to execute?
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-14 22:56
    Again, this is all based on a particular connection for the pushbutton. If the pushbutton is connected between a Propeller I/O pin and ground and you have a resistor (maybe 10K) between the I/O pin and +3.3V. With this, when the pushbutton is out (open), the I/O looks like a one. When you push it in (closed), the I/O looks like a zero. If you have the pushbutton the other way with it connected between the I/O pin and +3.3V and the resistor connected to ground, the I/O looks like zero when the button is out and one when the button is pushed.

    What I suggested is to wait in your program initially while the button is out/released/open. At the first instant when the button is in/pushed/closed, that REPEAT WHILE loop exits and your code executes. At the end of your code, you should have a REPEAT UNTIL loop that hangs waiting for the button to be out/released/open at which point, you're ready to start over again. You don't have to keep the button pushed because the initial REPEAT waits for the first instant only of the button being pushed (the change from one to zero in my example). The button can remain pushed while the code is executing. The REPEAT after your code makes sure you've released the button before it continues on.

    Does that help?
  • SomniumSomnium Posts: 46
    edited 2006-10-15 01:48
    Umm... wow... I'm feeling really stupid at the moment...

    ok so I've got my circuit the way that you explained and i have the code so far up to here...

    CON

    Button = 24 'Input Pin
    LEDpin = 18 'Output Pin
    Button1 = 28
    LEDpin1 = 16
    '
    Var
    long Stack[noparse][[/noparse]9]

    PUB START
    'cognew (Button_1, @Stack)
    Booton

    {{PRI Button_1 | PIN

    Dira[noparse][[/noparse]Button] := 0 'Make Button pin an INPUT
    Dira[noparse][[/noparse]LEDpin] := 1 'Make LED pin an OUTPUT

    repeat
    Outa[noparse][[/noparse]LEDpin] := Ina[noparse][[/noparse]Button]
    IF (Ina[noparse][[/noparse]Button] == High)
    OutA[noparse][[/noparse]Pin] := High 'LED ON
    WaitCnt(8_000_000 + Cnt)
    OutA[noparse][[/noparse]Pin] := Low 'LED OFF
    WaitCnt(8_000_000 + Cnt)
    ELSE
    OutA[noparse][[/noparse]Pin] := 0}}

    PRI Booton | PIN

    Dira[noparse][[/noparse]Button1] := 0 'Make Button pin an INPUT
    Dira[noparse][[/noparse]LEDpin1] := 1 'Make LED pin an OUTPUT

    repeat
    Outa[noparse][[/noparse]LEDpin1] := Ina[noparse][[/noparse]Button1]

    currently have the code so that is only does the "Booton" function, had two buttons working at the time... I'm still a lil lost with the explaination... trying hard to understand it... what I'm getting right now is that when the button is pushed it starts up the While loop... but i'm still having a hard time understanding the rest... sorry... wish my brain would work for a change...
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2006-10-15 15:59
    Let me explain the code that Mike mentioned

    REPEAT WHILE INA[noparse][[/noparse]pin] == 1

    What that means is:
    REPEAT
       nothing
    WHILE INA[noparse][[/noparse]pin] ==1
    
    



    So it sits there repeatedly doing nothing as long as the input pin is one. Peter is assuming that when you push the button it is making the pin low. As soon as it goes low it will leave the loop and go to the next piece of code.

    Graham
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2006-10-15 16:01
    p.s. I've uploaded a cleaned up version of the ADC code along with a sound detection example as an object and demo. I need an ADC for one of my projects so it made sense.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-15 17:19
    Somnium,
    I just noticed one of your comments "when the button is pushed it starts up the While loop". See if you can think of your SPIN program as the active agent rather than the buttons and LEDs, etc. Your program is doing everything ... looking at the world outside and doing things when it sees stuff happen. Your program would be waiting for the button to not be open, then your program would do something probably with some LEDs, then wait for the button to be released, then start all over again.
    Mike
  • MacGeek117MacGeek117 Posts: 747
    edited 2006-10-23 02:12
    There is another way to do the 'repeat while' code bit, waitpeq(state, mask, port); see pg. #326 of the Prop Manual.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
Sign In or Register to comment.