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 2003
    Location
    Greece
    Posts
    4,133


    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

  2. #2
    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.

  3. #3
    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?

  4. #4
    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.

  5. #5
    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!

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


    Did you find this post helpful? Yes | No

    Default

    Don't fall into the trap that a PIC is a panacea for all your problems... half the forum thinks that way and then they discover after a lot of wasted time and effort these little things sometimes need external help to accomplish some tasks - and multi-channel complex signal processing is one of them.

    0603 size Resistors and Diodes are still very much hand solderable with a pair of tweezers and a steady hand. You quickly tack one end with a soldering iron so it anchors, solder the other end properly, then go back and solder the first end properly. If you're building a one-off it won't matter. Trust me, you WILL need to rectify and filter those inputs. You are going to waste a shed-load of time and effort and end up with mediocre results going down the route you plan.

    The final output from the Guitar to the Amp is a sum of the individual strings anyway. You can always build an external 'in-line' box which has the added advantage that it can be fitted to any Guitar without voiding manufacturers warranties etc. If you do it using Thermionic Valves (a single ECC83 or any twin-triode equivallent will make an eminent AGC and pre-amp) you will have a queue of people breaking your door down to get one (since valves and stage gear are very much in vogue).

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Don't fall into the trap that a PIC is a panacea for all your problems... half the forum thinks that way and then they discover after a lot of wasted time and effort these little things sometimes need external help to accomplish some tasks - and multi-channel complex signal processing is one of them.

    0603 size Resistors and Diodes are still very much hand solderable with a pair of tweezers and a steady hand. You quickly tack one end with a soldering iron so it anchors, solder the other end properly, then go back and solder the first end properly. If you're building a one-off it won't matter. Trust me, you WILL need to rectify and filter those inputs. You are going to waste a shed-load of time and effort and end up with mediocre results going down the route you plan.

    The final output from the Guitar to the Amp is a sum of the individual strings anyway. You can always build an external 'in-line' box which has the added advantage that it can be fitted to any Guitar without voiding manufacturers warranties etc. If you do it using Thermionic Valves (a single ECC83 or any twin-triode equivallent will make an eminent AGC and pre-amp) you will have a queue of people breaking your door down to get one (since valves and stage gear are very much in vogue).
    Just seen your reply (before I made my posting immediately above).

    This PIC circuit is not for a guitar output...but for a guitar sustainer (ie feed the guitar signal back into a circuit which drives a coild to keep the string virating ...there's no combining any output here...the normal (mono) guitar signal still goes to the amp as normal. The only combining would possibly of a hex pickup into my circui to feed a sustainer driver coil.

    The reason I initially want handle 'six' strings, is becuase there are quite a few guitar variants out there that have hex pickups (one pickup per string), but like I say, I can sume these & then treat them as one. The sustainer needs an AGC, a threshold, a limit & an attack/release 'user definable' input parameters...this makes a PIC ideal.

    I don't think a PIC is a panacea...but in this instance it could be very useful - what I don't have any knowledge about - is how hard they can be pushed. For example is carrying out AtoD every 20us for 13ms, then repeating again in 130ms afterwards that onerous for a PIC?

    I'm assuming not, as I'm only talking about 32 samples at 1.4khz for 13ms on one input pin ...then repeating every 130ms (& I can't imagine Microchip would have been able to call its converters 'AtoD converters' if they struggle at this relatively low sample rate & base frequency!)

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    I'm going to give it a go anyway (on one pin - combined strings), so to my questions.....

    Working on the basis that the highest note on a Guitar (fundamental frequency), is about 1.4kHz, Therefore, this highest (guitar string) note 'cycle' will take about 700us to complete

    The lowest note is 82Hz - therefore this lowest (guitar string note) 'cycle' will take 12ms to complete.

    I'll work on 32 'samples periods'for the highest frequency as a starter, so to cater for the highest note, I need to carry out an AtoD command every 21us (700us/32)...& to cater for the lowest note, I must continue doing this for 12ms. (the time it takes for the lowest note to complete one cycle of sound)

    How can I be sure that such fairly rigid sample times are met?

    At a PIC internal clock rate of 4Mhz, would I be right in saying that each clock cycle is 0.25us?

    Therefore I need to carry out AtoD every 84 clock cycles?

    Can someone help out here to get me started ...please?!!!

  9. #9
    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!)



  10. #10
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok - I manged to kludge my way through it & get two AtoD channels working - but man, what a struggle ...you'd think they'd gone purposely out of their way to getting something as simple as AtoD setup (it's akin to having to read the service manual on the hubble space telescope!)

  11. #11
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    Did you find this post helpful? Yes | No

    Default

    Have you considered using the NE/SA 572 chip? I think to propr do such a job with controller you need a fast one like dsPIC or better a DSP processor.

    PIC'c do not have many resources for analog processing.

    Ioannis

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