Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Log scale for an A2D.

Status
Not open for further replies.

Nigel Goodwin

Super Moderator
Most Helpful Member
I'm playing about with a PIC16F876, reading an analogue voltage and displaying the result on a bar of 16 LED's - rather like an LM3914. As the A2D has 10 bit resolution I'm lighting an LED for every 64 (0x40) of the A2D reading. Also, like the 3914, I'm planning having it switchable for either bar or dot display.

I'd also like to add the option of using it as a VU meter with a log scale, like the LM3915 - to that end (rather than simply repeatedly subtracting 64) I've implemented a 16 bit lookup table for the subtractions for each LED - which currently is 0x0040 for all values. I'm going to add a second 16 bit table to give log readings, switchable from one of the PIC pins.

What I want to know (at last!), is how to calculate the log values to put in the table?.
 
Do you have an electronic calculator?

Unless there is more to the problem - you have to select a place to begin and everything is referenced to that point. Let's say you start at 10 mv and work your way up from there.

The log of 10 is 1.
The log of 100 is 2.
The log of 1,000 is 3

I don't know a lot about VU meters - enlighten me if you are able. I recall that they respond "logarithmically" but that's about it.

I hope this helps.
 
stevez said:
Do you have an electronic calculator?

Unless there is more to the problem - you have to select a place to begin and everything is referenced to that point. Let's say you start at 10 mv and work your way up from there.

The log of 10 is 1.
The log of 100 is 2.
The log of 1,000 is 3

I don't know a lot about VU meters - enlighten me if you are able. I recall that they respond "logarithmically" but that's about it.

I hope this helps.

Hi Steve,

Thanks for the thoughts, but I was hoping someone would know exactly how to do it - without me having to try and think back 30+ years :D

VU meters are usually calibrated in dB's, dB's are basically an expression of a ratio, giving either gain or attenuation (positive dB's are gain, negative ones attenuation). dB's are also different for power and for voltage, 0.5 is -3dB for power and -6dB for voltage - for VU's I think I need voltage.

I eventually managed to drag out from my memory the formula for dB's:

dB=20 * Log(Input / Output)

Rearranging this I managed to work out all the table values I needed for 16 LED's, from 0dB to -45dB, in -3dB steps.

I've also checked the threshold values on the LM3915 datasheet, they correspond nicely down to -27dB :D
 
If you use just 10 LED's then the 10-bit A/D output can be directly applied to the ports driving the LEDs (one LED per bit). I believe this results in a logarithmic scale response with each LED representing aprox. 3dB increase.
 
motion said:
If you use just 10 LED's then the 10-bit A/D output can be directly applied to the ports driving the LEDs (one LED per bit). I believe this results in a logarithmic scale response with each LED representing aprox. 3dB increase.

That doesn't generate either a bar or a dot display though, it just displays the binary number on the LED's.

My current scheme is working quite well so far, with both linear and log bar display working beatifully, but I'm having a problem with my dot display - the last LED doesn't light up, the 15th one goes out, but the 16th one doesn't come on - I'm still trying to find out why!.

A further plan is to multiplex two rows of LED's and use two of the A2D converters to give a two channel display.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top