1. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Hi All!

    Again I have to deal with making sounds...this is little different and very important...

    I need some ideas on how to approach/solve this design...of course no code is required...will post my code based on your ideas (mine too) and have it checked if I am stuck...

    Please find the requirements attached!! sorry if you don't like the fact that I have attached the problem design!

    I am thinking about this and will post my ideas/plans as soon as I can!

    Any guidance is appreciated...

    But the mic will need a circuit...I used the attached circuit for a voice recognition project but think that it is too much breadboarding and i am dealing with musical notes not human voice...so was wondering if the attached circuit could be simplified to something smaller...that I can breadboard fast...

    regards,

    Eric
     
    Last edited: Oct 16, 2012
  2. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    A gain of 300 should be enough.
    You should also add automatic gain control.
     
    Eric007 likes this.
  3. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    what the automatic gain control for??
     
  4. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Based on the requirements...I think attached is the frequencies I'll be working on in that order...

    Can someone explain about zzero crosssing and how to go about it I heard there are detector circuits for it...

    Ima do some google on it!

    Im tired of these sounds but this was the easiest choice compared to some complex ones I did not want to work on...
     
  5. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    I'm reading on zero crossing toget an understanding...but got a quick question!

    when the mcu (mic) listens...it shouldn't listen to anythimg right? or it doesn't matter what it listens to?

    should I make it listen to only ABCD...notes or I can whistle or make some kind of weird sounds...

    Hope my concern is clear...
     
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Whistling is pretty good, it's nearly a sine wave. You could also search youtube for 440Hz tone, etc. and play it through speakers.
     
  7. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    I been reading this http://sound.westhost.com/appnotes/an005.htm but pfff it like I was reading chinese...I don't get much ...maybe I should really focus...

    the play mode of the problem is doable...it the first part that confuses me a bit...my understanding is we should determine the duration of the pulse by determining the time between the two consecutive changes...this duration x2 give the period which is the frequency of a given note...BUT how do that...well I don't wana write my rubbish ideas here...not to sound too dumb...

    Any helps? any circuitry needed for that?
     
  8. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Ok I wana make thingz quick and simple!

    what if I write another program with frequencies from A2 to G4...then play one of these tones to the mic...for it to recognize the tone...is it ok?

    But how that zero crossing works!!! that's problem number1. I really don't get it!!
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    When you are using a mic for frequency analysis you want the signal to be amplified to produce the same loudness level regardless of the actual sound level. This is what an automatic gain control circuit does.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    Zero crossing analysis is a simple method of frequency estimation when the signal consists of mainly fundamentals and very low levels of harmonics. In this process, one counts the number of times the signal crosses the zero voltage line in a given time interval. If the time interval is 0.5 seconds, the number of zero crossings equals the fundamental frequency.

    This method is preferred over standard edge counting of leading or trailing edges of square waves which would tend to give an overestimation of the frequency.
     
  11. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Ok! but I read one needs to know what output level is needed and the range of the gain control in order to come up with the right circuitry!

    what would be those in my case...?

    Also to reduce the gain to 300 I guess I just need to change the feedback resistor to 30k, correct? but I just need another circuit!!
     
  12. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Timing 10 zero crossings is better than just one.
    You can use a circuit, probably a comparator with hysteresis. Plenty of examples if you search for it.
    Or just use the ADC and do it that way. Have a range around Vdd/2 that is ignored and time in between one transition from below the range to above the range and the next, or time 10 of them.

    [​IMG]

    2 is the real zero line, it will be at Vdd/2 if you use the last circuit mentioned.
    Measured zero crossings are at B,E,H,I,J, etc. but that would give a false reading.
    To do it in software, if you set a flag when the level is below line 3, then only count a zero crossing when that flag is set and the level has risen above line 1 (then clear the flag), it avoids the false readings. This would equate to setting the flag at F and counting at K. You can also count the other downwards crossing using C and F and another flag.
    It is more accurate to count multiple crossings in a given time period, but the most accurate way is to start a timer at a crossing, eg. C and stop it at K. Again timing multiple crossings is better.
    As the time period increases, the difference between the methods is less. At a second they would be similar, but at 1/10th second the second method is better, especially for low frequencies.

    Another option apart from software and external comparator with hysteresis is to use a digital I/O pin with a Schmitt Trigger input (search the datasheet to find them). They do the same job but the points are fixed at 0.2 X Vdd and 0.8 Vdd which gives less flexibility.

    There are also built in comparators in most PICs, some with internal voltage references.
    http://ww1.microchip.com/downloads/en/devicedoc/41215a.pdf
     
    Last edited: Oct 11, 2012
  13. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Ok! I think I'll try implementing this method...I wana do it in software!
    Hardware giving me headache right now...So for the above method no circuitry is required just ADC channel, correct?
    Guess I'll be using my circuit :( as no other one has been suggested...

    but Im a bit lost when you talking about flag at K, F...

    I think I'll break it down in 2 parts...I'll implement the play mode first! then the tune one!

    doing pins layout now...

    thanks!
     
  14. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Yes, just an ADC pin required.
    I mean something like:

    do until (ADC < level3 and high = 1)
    loop
    low=1
    high = 0
    do until (ADC > level1 and low = 1)
    loop
    low=0
    high =1
     
    Eric007 likes this.
  15. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    I want to use pins RC0-RC6 for the SSD but pin RC5 is CCP1 that I will need for PWM...(PIC16F690)...is there a way of still using RC0-RC6 with RC5 for PWM

    or I can use another PIC like PIC16F877...and use pins RD0-RD6 for SSD multiplexing??

    thamks!
     
  16. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    You can use RC0-4 and RC6-7 for the SSD at the same time as using the PWM pin. Writing values to PORTC doesn't make any difference to PWM module pins.
     
  17. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    Beautiful!!!:D

    but How come it does not make any difference to RC5 pin?

    thanks!
     
  18. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Just the design of the chip, if pin is set to digital output then RC5 gets changed by writes to PORTC, if not it's unaffected.
     
  19. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,044
    33
    That's correct...that a fundamental thing I forgort...just understand that I don't really think straight these dayz as I'm in panic mode...:)

    So here's the change to be done...put a '1' or '0' (I have used '0') at pin RC5, correct?
    I have spaced them so you can understand what I mean...this way I'll be using pin RC0-4, RC6-7, correct?

    Code ( (Unknown Language)):
    1.  
    2.  
    3.  retlw b'01 0 11111' ; 0
    4.  retlw b'00 0 00110' ; 1
    5.  retlw b'10 0 11011' ; 2
    6.  retlw b'10 0 01111' ; 3
    7.  retlw b'11 0 00110' ; 4
    8.  retlw b'11 0 01101' ; 5
    9.  retlw b'11 0 11101' ; 6
    10.  retlw b'00 0 00111' ; 7
    11.  retlw b'11 0 11111' ; 8
    12.  retlw b'11 0 01111' ; 9
    13.  
     
  20. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Yes, that's fine.