LED Bargraph chip (guitar LED bling-age) ..do with a PIC?


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2009
    Posts
    653

    Default LED Bargraph chip (guitar LED bling-age) ..do with a PIC?

    Just been looking at twinkler guitar (because deep rooted in every musician is LED bling just waiting to be mounted on his guitar)...

    Originally discussed here...

    http://projectguitar.ibforums.com/in...howtopic=41134

    with a youtube video of the end end goal here...



    Here's the chip they use....
    http://www.national.com/ds/LM/LM3915.pdf

    Now I'm fairly new to PICs, & even I reckon I could fairly quickly kludge some LEDs that light depending on the analogue input level, but I guess what separates my likely awful code from the likes of the h/w chip is the algorithm for fading the LEDs out smoothly (and the 3dB bit).

    Has anyone done such a thing with LEDs? (not LCD bargraphs...nice bright, twinkly LEDS)...or would anyone have a good starting point ?

    Ta,
    Hank.

  2. #2
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Smile

    Hey Hank,
    that's just a LED VU meter using a bargraph IC.
    3915 is log while the 3914 is linear.
    I'm using the 3914 with a PIC in a BatteryMonitorSystem(BMS) that I
    am working on. For monitoring 18 batteries in real time.
    U don't really need a PIC for this simple VU meter.
    I've seen several "light shows" circuits using LEDs and bargraph ICs.
    IIRC, Craig Anderton had a "blinky light machine" using bargraphs.
    that's all I got for ya..... afn Tone

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by toneman View Post
    Hey Hank,
    that's just a LED VU meter using a bargraph IC.
    3915 is log while the 3914 is linear.
    I'm using the 3914 with a PIC in a BatteryMonitorSystem(BMS) that I
    am working on. For monitoring 18 batteries in real time.
    U don't really need a PIC for this simple VU meter.
    I've seen several "light shows" circuits using LEDs and bargraph ICs.
    IIRC, Craig Anderton had a "blinky light machine" using bargraphs.
    that's all I got for ya..... afn Tone
    Thanks Tone,

    I guess it's the log that would be most useful on a guitar. (the reason I want to use a PIC, is I'm putting on in my guitar anyway & it has lots of unused pins still! BLING!)

    Just thinking here that to get the LEDs to fade rather than abrutly cut off, would problably need nothing more than a capacitor.

    So...how on earth can log calculations on an analogue input be achieved on a PIC?

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


    Did you find this post helpful? Yes | No

    Default

    With a PIC it is a little difficult to do all the math and stil have time for the A/D and display.

    Also for the Log function you might need floating point calculations (even slower...).

    If 55-60db dynamics are enough for you with linear response then you have to:

    1. amplify the signal to be in the range of 0-5 volt
    2. use an absoluter value converter to feed the A/D of the PIC with just positive voltages
    3. setup PIC to continusly read the analog value, make a small average and display it

    If you insist on making it logarithmic then use an CA3089 or CA3189 chip and take advantage of the log amplifier that is used for the AGC and S-meter.

    And if you want to do the math way, have a look at http://www.emesys.com/BS2math3.htm#Logtable

    Ioannis

  5. #5
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Hank and all,
    I still think a PIC is overkill. Even if U have "extra pins" LOL!!
    It's the software that will drive U insane!!! LOL!!!!!!!
    The 3915 (and 3914) **are** A-2-D converters!
    They are known as "flash converters" cause they just use a bunch of
    comparators and convert the input V either to a bar or a dot...in a FLASH!
    Really cool (and complex) would be to use a hexphonic guitar like a Roland-Ready Stratocaster and tap off the six preamps inside and split to six bargraphs!! IIRC, the bargraph IC just needs 2.5V for max level.
    I'm using an expanded scale to measure a narrow voltage range for my BMS.
    I also use a divide-by-2 attenuator to scale the approx 6V down.
    For regular strat PUs, U should still use a singlesupply opamp as a preamp/buffer. I think either lin or log ICs would work fine.
    The trick is to dial the gain of the preamp(direct from PUs), and dial in the bargraph to make a responsive looking display. Then, if U ran to 3 filters, low, mid, hi, U would have a triple LED bargraph lite show on your Axe!
    But, where would U put all those LEDs?!?!?!?
    LOL!!! <shakes his head> :-)

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by toneman View Post
    Hank and all,
    I still think a PIC is overkill. Even if U have "extra pins" LOL!!
    It's the software that will drive U insane!!! LOL!!!!!!!
    The 3915 (and 3914) **are** A-2-D converters!
    They are known as "flash converters" cause they just use a bunch of
    comparators and convert the input V either to a bar or a dot...in a FLASH!
    Really cool (and complex) would be to use a hexphonic guitar like a Roland-Ready Stratocaster and tap off the six preamps inside and split to six bargraphs!! IIRC, the bargraph IC just needs 2.5V for max level.
    I'm using an expanded scale to measure a narrow voltage range for my BMS.
    I also use a divide-by-2 attenuator to scale the approx 6V down.
    For regular strat PUs, U should still use a singlesupply opamp as a preamp/buffer. I think either lin or log ICs would work fine.
    The trick is to dial the gain of the preamp(direct from PUs), and dial in the bargraph to make a responsive looking display. Then, if U ran to 3 filters, low, mid, hi, U would have a triple LED bargraph lite show on your Axe!
    But, where would U put all those LEDs?!?!?!?
    LOL!!! <shakes his head> :-)
    Funny you should mention Roland GK (as it goes I'm well into midi guitars - this is me )...becuase I'm presently designing a 6ch HEX sustainer driver to bo on my guitar (note: not a pickup.....the very opposite in fact), furthermore, I'm having to design my own bobbins in CAD, then cut them on a CNC machine I built (out of dot matrix printers!), so I can therefore cater for 6 LEDs to be mounted within the bobbin itself. (I already intend having an LED light under each string when it's plucked but figured an LED bargraph might be cool too!)

    Re getting the guitar signal level up ....well my sustainer driver circuit alreeady does that. I simply want to go ther PIC route to save PCB real estate (there's not a lot of room in a guitar for big PCBs), & like I say, I'll already have a PIC on the PCB. I use the PIC for digital AGC for my sustainer (basically I AtoD the amplified incoming analogue signal then make some gain decision based on the corresponding DC level....with that in mind, I guess I'm 70% of the way there for LED bling already!

    I think I'll give it a pop regardless...it ought to be fun....& like I say, you can never have enough LED bling!

    Thanks for you comments.
    Last edited by HankMcSpank; - 10th July 2009 at 09:32.

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, my first attempt. I'm a beginner, so I welcome any comments towards a more efficient way of doing what I've just done (see code below)

    I'm using the Microchip low count board...which only has 4 LEDs - the code I've kludged together below works fine as I turn the potentiometer on the Low Pin Count Board.

    I don't think doing 'log' will be so tough after all (on account, there'll only be six LEDs involved when this is on the guitar, just a matter of tweaking with those individual thresholds to get it looking 'right').

    My next attempt will be to get a sample & hold vibe going down (which I'm thinking will just be some form of short 'pause' in each of those 'blocks' & some resistors/caps in series with the LEDs?)

    Code:
    Start:
    ADCIN 2, DC_In ; Read the DC level IN
    DC_In = DC_In /2 '256 is too much resolution...cut it down by 50%
    IF DC_In < 10 THEN
    low PortC.0 
    low PortC.1 
    low PortC.2 
    Low PortC.3
    endif
    IF DC_In > 25 THEN
    HIGH PortC.0 
    low PortC.1 
    low PortC.2 
    Low PortC.3
    endif
    IF DC_In > 55 THEN 
    High PortC.0 
    High PortC.1 
    low PortC.2 
    Low PortC.3
    endif
    IF DC_In > 85 THEN
    High PortC.0 
    High PortC.1 
    high PortC.2 
    Low PortC.3
    endif
    IF DC_In > 110 THEN
    High PortC.0 
    High PortC.1 
    high PortC.2 
    HIGH PortC.3
    ENDIF
    GOTO START
    end
    Last edited by HankMcSpank; - 10th July 2009 at 14:59.

  8. #8
    Join Date
    Feb 2009
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    Ok, my first attempt. I'm a beginner, so I welcome any comments towards a more efficient way of doing what I've just done (see code below)

    I'm using the Microchip low count board...which only has 4 LEDs - the code
    which board??? which PIC??
    I'm assuming U R using PicBasicPro(?)


    Quote Originally Posted by HankMcSpank View Post
    just a matter of tweaking with those individual thresholds to get it looking 'right').
    yes, this applies to analog and/or digital.


    Quote Originally Posted by HankMcSpank View Post
    My next attempt will be to get a sample & hold vibe going down (which I'm
    S&H usually refers to a gated analog capacitor with a HiZ buffer.
    In digital "terms", U are storing the value(s) in binary and "delaying" the output processing via conditions.
    Since U are already processing the input voltage signal level(one) for the digital AGC,
    U already have the info. Just output it to a bunch of LEDs.
    The refresh rate needs to only be fast enough so that it looks good to the eyeballs.

    Sounds like a very interesting project.
    Have U visited the DIYStompbox forum?
    There is a "digital" section.
    afn
    T

  9. #9
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by toneman View Post
    which board??? which PIC??
    I'm assuming U R using PicBasicPro(?)
    This board ( with a 16f690 which is part of the PICKit2 beginners setup)...

    http://ww1.microchip.com/downloads/e...e%2051556a.pdf

    Quote Originally Posted by toneman View Post
    S&H usually refers to a gated analog capacitor with a HiZ buffer.
    I've read that more than once...no matter how many times I read it, it's still not sinking in (the gated capacitor bit!)


    Quote Originally Posted by toneman View Post
    Sounds like a very interesting project.
    Have U visited the DIYStompbox forum?
    There is a "digital" section.
    I haven't but I will.

    Re that code I posted above, hmmm, well - after posting it up, I realised it's not what I want (damn it...wish they had a delete button!) - it's just a simple LED level representation of signal level. What I want (what I really, really want) is a sample /hold representation ...I've spent a frustrating couple of hours, trying to do this with the PIC...it ought to be a piece of wII, but I actually spontaneously combusted (freaked the wife out a bit I can tell you...only because it made a terribly mess on the sofa)...just got back from the burns unit - I'll have another go, but will keep a fire blanket handy.

    re the project - yep, it is a good 'un....all the elements are coming together, this LED level indicator is just bells whistles - totally unnecessary, but much sought after nevertheless!
    Last edited by HankMcSpank; - 11th July 2009 at 21:50.

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


    Did you find this post helpful? Yes | No

    Default

    Yes, it could be done... but simplest solution probably requires a little compromise...

    First pick a PIC which is more suitable... say a 18F2420... I select this because it has a heap of I/O's and ADC as well. It also has an internal Oscillator so no Xtal or Resonator. Each LED is connected to TWO I/O's through two Resistors. The LED Anode is connected to Vdd, and the Kathode is connected twice... once via one Resistor to one I/O, and a second time via a second Resistor to a second I/O. This arrangement means that with your input into RA0/AN0, you can have eleven LED's connected. Chose a high intensity LED (say with 1300mcd or greater), this means that you can have a decent light output without overloading the PIC when all LEDs are illuminated.

    You now have FOUR states for each LED...

    OFF = Both I/O's HIGH.

    LOW BRIGHTNESS = First I/O is LOW, Second I/O is HIGH (Current flows through R1 - eg 820R).

    MED BRIGHTNESS = First I/O is HIGH, Second I/O is LOW (Current flows through R2 - eg 560R).

    HIGH BRIGHTNESS = Both I/O's are LOW (Current flow is through both R1 and R2).

    The actual Resistor values you will have to chose through experimentation... I just threw those in as a 'best guess'.

    This way you have a two-bit digital fadeout (easilly accomplished through software).

    If you wish to save a few mA/mW, then HIGH means the PIC pin is in INPUT mode. LOW means it is OUTPUT LOW.

    You take say an ADC sample every 500mS. This is your program 'cycle'. Your fade will take four cycles - namely two seconds. If you increase your cycle period, then your fade-out will be quicker. Depending on your ADC Input (max span), your LED's will be illuminated accordingly. At the next cycle, if the ADC value is lower, then the upper LED's are switched into the next level of brightness lower... and so on... simple really...

    Each LED is represented as a BYTE in an Array. The BYTE value is between 0 and 3, where 0 is both I/O's for that LED HIGH (LED OFF), and 3 is both I/O's LOW (LED max ON). The good thing is that you can probably feed your (low-level) Audio straight in with a minimum of components, because if say you only have 100mV peak/peak to play with, then you just set your math for ADC span accordingly. Your span (LED switching) range is in software, your Sample & Hold is in software and your fade is in software... what more do you want?

    Never mind about LOG, LIN, 3DB points etc etc... this is a light show - not a studio reference instrument!

    Cost less than US$10 and an hour of coding.

  11. #11
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Yes, it could be done... but simplest solution probably requires a little compromise...

    First pick a PIC which is more suitable... say a 18F2420... I select this because it has a heap of I/O's and ADC as well. It also has an internal Oscillator so no Xtal or Resonator. Each LED is connected to TWO I/O's through two Resistors. The LED Anode is connected to Vdd, and the Kathode is connected twice... once via one Resistor to one I/O, and a second time via a second Resistor to a second I/O. This arrangement means that with your input into RA0/AN0, you can have eleven LED's connected. Chose a high intensity LED (say with 1300mcd or greater), this means that you can have a decent light output without overloading the PIC when all LEDs are illuminated.

    You now have FOUR states for each LED...

    OFF = Both I/O's HIGH.

    LOW BRIGHTNESS = First I/O is LOW, Second I/O is HIGH (Current flows through R1 - eg 820R).

    MED BRIGHTNESS = First I/O is HIGH, Second I/O is LOW (Current flows through R2 - eg 560R).

    HIGH BRIGHTNESS = Both I/O's are LOW (Current flow is through both R1 and R2).

    The actual Resistor values you will have to chose through experimentation... I just threw those in as a 'best guess'.

    This way you have a two-bit digital fadeout (easilly accomplished through software).

    If you wish to save a few mA/mW, then HIGH means the PIC pin is in INPUT mode. LOW means it is OUTPUT LOW.

    You take say an ADC sample every 500mS. This is your program 'cycle'. Your fade will take four cycles - namely two seconds. If you increase your cycle period, then your fade-out will be quicker. Depending on your ADC Input (max span), your LED's will be illuminated accordingly. At the next cycle, if the ADC value is lower, then the upper LED's are switched into the next level of brightness lower... and so on... simple really...

    Each LED is represented as a BYTE in an Array. The BYTE value is between 0 and 3, where 0 is both I/O's for that LED HIGH (LED OFF), and 3 is both I/O's LOW (LED max ON). The good thing is that you can probably feed your (low-level) Audio straight in with a minimum of components, because if say you only have 100mV peak/peak to play with, then you just set your math for ADC span accordingly. Your span (LED switching) range is in software, your Sample & Hold is in software and your fade is in software... what more do you want?

    Never mind about LOG, LIN, 3DB points etc etc... this is a light show - not a studio reference instrument!

    Cost less than US$10 and an hour of coding.
    Many thanks Melanie...grasped the concept, but just need to work out the actualy resistor interconnectivity (I'm sure you explained it well, but I'm slow on the uptake!)

    Re Toneman's query about where are the LEDs are physically going to go...well, I just knocked together a bobbin 'top' tonight & inserted the LEDs loosely (they look clear, they're actually the bright ultra blue variety)...



    (it's just a rough 'proof of concept' cut at the moment' ...obviously magnetic pole pieces will fill those empty holes above the LEDs & then a coil will be wound around the whole bobbin - the middle piece, & bottom pice need making up too))
    Last edited by HankMcSpank; - 13th July 2009 at 00:19.

Similar Threads

  1. Calulating BJT base resistance for PIC led switching?
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th November 2008, 09:41
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 21:19
  3. Camera with PIC chip
    By The Master in forum Off Topic
    Replies: 5
    Last Post: - 1st July 2008, 15:28
  4. PIC chip resetting. Very weird
    By The Master in forum Off Topic
    Replies: 0
    Last Post: - 28th October 2007, 18:07
  5. Help on coding/ selecting PIC chip for project
    By lovemeok in forum General
    Replies: 0
    Last Post: - 27th July 2006, 20:21

Members who have read this thread : 1

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