Knock Tutorial, conversion from analog to V to G

In the tutorial

The sketch reads the piezos output using the analogRead() command, encoding the voltage range from 0 to 5 volts to a numerical range from 0 to 1023 in a process referred to as analog-to-digital conversion, or ADC.

I want the electric potential/voltage range, not the conversion (0 to 1023).
Also, I would like to convert that number to the unit G, as this is used for vibration, how do I do that?

Thanks!!

Also, I would like to convert that number to the unit G, as this is used for vibration, how do I do that?

you need the sensitivity specification for the sensor. Like so many volts per milli g

The way ADCs work, the closest thing to what the pin senses actually is a value 0-1023.

Basically, how an ADC works is it sets up a DAC from reference (usually ground) to VRef (+5VDC by default on 5V Arduinos). It then starts counting from 0 to 1023 (for a 10bit ADC) internally comparing it's DAC output to the input voltage. When the DAC output reaches (or exceeds) the input voltage it then captures the number it reached and reports it. That is why the value is sometimes referred to as the ADC count. (I remember building an ADC circuit with 74xx series TTL chips and an opamp in comparator mode in school. First had to build a counter, then a DAC to convert the hex number to a voltage, and then a latch to capture the count when the comparator output flips. Do they still do that in schools anymore?)

It's up to you to convert the ADC count to a voltage based on what your VRef is, or directly to a value with some algebra based on either empirical readings from your sensor or from the sensor's datasheet.

. It then starts counting from 0 to 1023 (for a 10bit ADC) internally comparing it's DAC output to the input voltage

No, it does a binary chop, based on a simple comparator and a digital to analog converter.

The analogRead() will always return a number in the range 0 to 1023 You can convert this to another range, such as 0 to 5 using the map() function, but it will only produce integer values (by truncating values) so it will not be very accurate.
See http://arduino.cc/en/Reference/Map

Given the limitation of the map() function it is unlikely to be any use to you in converting voltage to G force even if you have a table or conversion factor to apply to the voltage to derive G. You could, perhaps, use the 0 to 1023 value directly depending on how you intend to convert voltage to G.

Thank you for your answers.

http://www.parallax.com/Portals/0/Downloads/docs/prod/compshop/LDTOSensor.pdf
On the second page it shows the relationship of V and G.

Since I need V, I need to convert the ADC count to voltage based off my voltage reference? Can I assume it is almost exactly 5V?
What is my best option to do the conversion, map() is not accurate enough in this case, unfortunately

Masonry:
Thank you for your answers.

http://www.parallax.com/Portals/0/Downloads/docs/prod/compshop/LDTOSensor.pdf
On the second page it shows the relationship of V and G.

Since I need V, I need to convert the ADC count to voltage based off my voltage reference? Can I assume it is almost exactly 5V?
What is my best option to do the conversion, map() is not accurate enough in this case, unfortunately

It's a simple ratio. ADCcount/1023 = Vsense/5 You can either do it with math in the code:

float Vsense = analogRead(pin) * 5 / 1023;

or to save processing cycles if the compiler doesn't do the math on the literals first,

float Vsense = analogRead(pin) * 0.00489; // ADCcount/1023 = Vsense/5
-- or --
float Vsense = analogRead(pin) / 204.6; // ADCcount/1023 = Vsense/5

The second one is probably more accurate as I rounded to get 0.00489, but didn't have to round to get 204.6.

If the actual voltage isn't important, try to combine all your arithmetic into a simple linear formula (slope and offset) that you apply the analogRead() against to get G. (Then include the full formula and algebraic work in comments so you remember where that weird number came from when reviewing your code in 6 months.) Often what we do at work is for preparing actual deployment have a raw mode that just gives the ADC count. We then apply different effects to our sensor based on a known calibration source. (I don't know how much time I've spent calibrating readings for pressure sensors over the years...) Then plot the ADC counts and calculate the slope and offset from the empirical data. Often it is close to the datasheet, but the empirical data then compensates for tolerances. The datasheet values are usually good enough for proof of concept designs, or rough readings.