monitor a guitar signal strength, then output a DC level?


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    I'm not sure if this would help you. I remember a gentleman called Robert A Penfold in the late 80's-early 90's who used to write lots of audio related articles in Practical Electronics Mag or Everyday Electronics Mag. If you can search for his articles, I'm pretty sure, he has covered this too. What you're trying to do is called an envelope grabber, I think.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    I probably didn't explain myself very well (for the sake of simplicity) - I can see that you've probvably not sussed what I'm trying to achieve!

    So, a little more meat on the bones...

    I'm intending 'tapping' off a guitar signal (six signals actually...one from each string)...I need the 'level of the output of these six strings monitored. I originally implied having the PIC carry out this monitoring on the alternating guitar signal, but it makes more sense to do the following...


    Since these six signals will be buffered (and will likely be amplified a little), I could actually turn them into a DC level with a full wave rectifier & smoothing cap...so I don't need any massive A/D processing...a simple sample of the string's DC level about 5 times per second should suffice.

    I need the PIC here to act as a DC voltage comparator....let's say the rectified/extracted DC level of a particular incoming guitar signal is 2V, but it needs to be 3V...therefore we get the PIC to increase a DC level on an output pin (this feeds a DC 'volume control' pin on a power amp IC, this elevated DC will make the power amp 'drive' a guitar string sustainer coil more, which in turn makes the string vibrate more...the 'increased' guitar output signal is fed back into my circuit.

    Thererefore, what we have is a feedback loop....if the incoming guitar signal is too low, the corresponding guitar string will be 'driven more' until its amplitude is increased & it hit's the target reference voltage.

    I know all of this can be done in analog, but I'd like the circuitboard to go inside the guitar, so small size is paramount & a PIC with say IO 20 pins is an awful lot smaller than the several opamps per sting needed to do this.

    So what I really need is a PIC to monitor 6 x DC levels against a reference voltage & subsequently change a DC output level on six of its output pins to suit. (ie I don't need any fancy logarithmic algorithms, etc)
    Last edited by HankMcSpank; - 2nd April 2009 at 18:24.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default

    IMHO, every audio needs at least 60-70db dynamic range. With the full wave rectifier I am not sure that you will reach over 25-35db. Your ear, no matter what post processing you are going to do, needs this logarithmic treatment.

    Anyway, about the PIC now, if 5 times/sec is enough for you, then almost any PIC may do the job. What you need at the output is a PWM signal with a low pass filter to get the analog control voltage for the VCA.

    Forum has covered the last many times.

    I really would love to hear some samples of the effect if you make it working.

    Ioannis

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    IMHO, every audio needs at least 60-70db dynamic range. With the full wave rectifier I am not sure that you will reach over 25-35db. Your ear, no matter what post processing you are going to do, needs this logarithmic treatment.

    Anyway, about the PIC now, if 5 times/sec is enough for you, then almost any PIC may do the job. What you need at the output is a PWM signal with a low pass filter to get the analog control voltage for the VCA.

    Forum has covered the last many times.

    I really would love to hear some samples of the effect if you make it working.

    Ioannis

    Many thanks...in the time since posting I've been on intense googling & realised that the PIC doesn't have the opposite of ADCin (which is a shame as DACout would have been fab!).....sussed the PWM approach but hadn't realised about the low pass filter on the PWM output - tks.

    Re the end result itself...I'm not trailblazing....it's been done - I'm just trying to do it with six channels (the commerical units send one 'summed' signal to their driver), as having six channels means more control & cool possibilities, but the component count will be 6 times more, hence trying to condense using a PIC...

    (about 12 seconds in)
    Last edited by HankMcSpank; - 3rd April 2009 at 01:03.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Hi peeps,

    Since starting this threa, I went away & knocked up a little program to monitor a DC level at a PIC input pin & then output a PWM stream accordingly ...it increases the PWM duty cycle if the incoming DC level is too low & vice versa...it works well.

    But now I'm thinking it would be really cool if I didn't have to rectify the incoming analogue guitar signal first (ie to derive DC level for the PIC input pin)...as this means I could do away with 6 x rectification circuits (& space is tight) ....there must be a slicker way of doing this in software?

    The frequency 'band' of each string is quite small ...therefore what my 'concept is', is to work out the highest frequency per string (I'm monitoring each string individually) & sample the signal level at a fast enough rate to make sure the highest frequency 'peak' is detected.

    A highest fretted top E string is about 1kHhz (give or take!), which means the shortest time between 'peaks' will be 1ms. I guess that I'd need to take a reasonable amount of samples to make sure I catch 'peak' ...I'm thinking 64 samples within that 1ms. (guitar signals aren't exactly sine waves, but they're not square waves either so I'm thinking 64 samples ought to get me very close to 'peak')

    Therefore 1ms divided by 64 samples = 15us between samples.

    Is a PIC up to this level of AtoD rate? (there'd be six different individual strings to sample).

    Now, I'm no programmer & I find myself having to learn this PIC programming melarkey out of need, so at a high concept level, how does this sound...

    Start looping (to be done every 15us for 1ms)
    'sample1' - store result in a Variable1
    'sample2' - compare result to Variable1, if it's less do nothing, if it's more update Variable1
    'sample3 - compare result if less do nothing, if more update Variable1
    & so on...

    after 1ms stop stampling - the data stored in 'Variable1' is the peak.

    Now go and 'act upon' the data.

    Start next loop sampling cycle


    Does this sound about right?

    Have I missed anything?


    Does anyone have a link to some suitable sample code to get me started?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Most PICs only have ONE ADC which is multiplexed to a whole heap of pins. This means you have to select your Input, perform an ADC operation, select the next input etc etc...

    So, with 6 inputs, your 15uS slot becomes 3uS (15uS/6). With all the other processing, variable comparison, PWM updates etc, it's just not going to happen (at least not with a 12F, 16F or 18F device with PBP - even at 40MHz).

    A splattering of small surface mount Diodes, Capacitors and Resistors suddenly become very attractive.

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    Thank you for such a fast response & enlightening post! (I had no idea that PICS simply multiplexed their one AtoD (I feel cheated ).

    So if summed the six strings & therefore just went with the one 'commonised' string input ...& perhaps trimmed the sample rate down a little (say 32 samples, therefore 1ms/32 = 1 ADC sample every 30us) ......do you think be viable on the 'standard issue' PICKit2 PIC - a 16F690?

    I should have said I don't need this intense sampling to run continuously.... probably every 150ms would suffice (there 32 samples at 30us per sample for 1ms, pause for 149ms & repeat)

    I'm not geared up for SMT & ultimately, this little widget will have to go in a guitar - and space it stight, so the lower the component count the better!

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Most PICs only have ONE ADC which is multiplexed to a whole heap of pins. This means you have to select your Input, perform an ADC operation, select the next input etc etc...
    This is an old thread of mine, but I've just revisited it on account I wanted to be sure what I'd asked previously!

    Ok, I have my PIC program successful carrying out AtoD on one incoming (full wave rectified) guitar signal.

    Presently I'm hard coding the 'target DC' level for the PIC AGC circuit to strive for eg (let's say I've set a raw AtoD value of 550 as the optimum incoming DC level ...but the full wave rectified guitar signal is only measuring 400 - then the PIC just sends some pulses to a volume control to increase the signal)

    Now to try & save POTs/switches having to be mounted on the guitar, I'd like to design my own little board with a resident pot on it - I'd like use the DC level from this pot to set the AGC's target incoming DC level for the circuit to strive for - the thing is my PIC 16F690 is already using one channel of AtoD to sample the incoming rectified guitar signal. From Melanies post above it seems that I'll need to switch the AtoD converter to another input pin

    How do I switch the AtoD pin - is that done with the ADCON0 setting? (& presumably I have to switch back & forwards between the two pins involed - each time changing the pin that the AtoD converter is connected to)

    Let's say my guitar signal is AtoD'ed on AN1 ...if I then want to use AN2 in my circuitry, does this mean that everytime I want to establish the DC level on the pot, I need to invoke a ADCON0 command to change the CHS2,CHS1 and CHS0 bits (bits 3,4 & 5 of the ADCON register?) Forgive the naive line of questiong - I'm far away from even being considered an entry level programmer - this stuff doesn't come easy to me!)

    Someone asked a bit further up this thread, to post a demo of the thing I'm pottering on with , well here's a link to a short video I made (albeit this video was when I was using analogue for the AGC aspect - which was not flexible enough in the end, hence returning to the scary world that is digital!)



Similar Threads

  1. small dc signal amplifier schematic need
    By phoenix_1 in forum Schematics
    Replies: 9
    Last Post: - 8th May 2009, 03:32
  2. Output current to a DC motor
    By bigbanner in forum General
    Replies: 1
    Last Post: - 6th April 2009, 07:29
  3. Unwanted output signal jitter
    By LinkMTech in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 18th January 2008, 02:31
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts