ADXL335 + MCP3208 output G's question
I am using Mike Rector's MCP3208_DEMO. I have the sparkfun ADXL335 connected to 3 inputs on the MCP. This works fine in returning a number from 0 - 4096, how do i convert this to mV and G's. in the adxl doc i mentions this if running on 3.3v:
USE WITH OPERATING VOLTAGES OTHER THAN 3 V
The ADXL335 is tested and specified at VS = 3 V; however, it can be powered with VS as low as 1.8 V or as high as 3.6 V. Note that some performance parameters change as the supply voltage is varied.
The ADXL335 output is ratiometric, therefore, the output sensitivity (or scale factor) varies proportionally to the supply voltage. At VS = 3.6 V, the output sensitivity is typi- cally 360 mV/g. At VS = 2 V, the output sensitivity is typically 195 mV/g.
The zero g bias output is also ratiometric, thus the zero g output is nominally equal to VS/2 at all supply voltages.
am i correct the the ratiometric value when running at 3.3v would be 330 mV/g ? and therfore the g formula should be something like :
x,y or z reading [ 0-4096 ] - ( 4096 / 2 ) * 1000 / 330 [ ratiometric value calculated ? ] of do i need to convert eh MCP value to mV first?
Thanks
USE WITH OPERATING VOLTAGES OTHER THAN 3 V
The ADXL335 is tested and specified at VS = 3 V; however, it can be powered with VS as low as 1.8 V or as high as 3.6 V. Note that some performance parameters change as the supply voltage is varied.
The ADXL335 output is ratiometric, therefore, the output sensitivity (or scale factor) varies proportionally to the supply voltage. At VS = 3.6 V, the output sensitivity is typi- cally 360 mV/g. At VS = 2 V, the output sensitivity is typically 195 mV/g.
The zero g bias output is also ratiometric, thus the zero g output is nominally equal to VS/2 at all supply voltages.
am i correct the the ratiometric value when running at 3.3v would be 330 mV/g ? and therfore the g formula should be something like :
x,y or z reading [ 0-4096 ] - ( 4096 / 2 ) * 1000 / 330 [ ratiometric value calculated ? ] of do i need to convert eh MCP value to mV first?
Thanks

Comments
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ adc : "MCP3208" pst : "Parallax Serial Terminal" f32 : "Float32Full" fs : "FloatString" CON dpin = 26 'both din and dout of the mcp3208 are connected to this pin on the prop demo board. cpin = 27 'the clock pin of the mcp3208 is connected to this pin on the prop demo board. spin = 25 'the chip select pin of the mcp 3208 is connected to this pin on the prop demo board. pub go pst.start(115200) 'Start the Parallax Serial Terminal object at 115200 baud adc.start(dpin, cpin, spin, 255) 'Start the MCP3208 object and enable all 8 channels as 'single-ended inputs. repeat pst.Str(String(pst#cs, pst#NL, pst#HM, "vref = ")) pst.Str(fs.FloatToString(f32.FMul(f32.FDiv(f32.FFloat(adc.in(3)), 4096.0), 3.3))) ' read adc pin 3, convert to float, divide by 4096, multiply by 3.3 ( input voltage ) waitcnt(clkfreq/10 + cnt) '10Hz screen refreshhowever nothing is displayed on the serial terminal
John Abshier
also is the 4096 the correct divider or should it be 4095? adc value when feeding 3.3v is 4095? i only assumed 0-4095 is 4096 places
Thanks
I think you are right about the 4,096 value. There are 4096 places. (I'm not sure about this.)
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 VAR long adc OBJ SIO : "FullDuplexSerialPlus" PUB Main SIO.StartPST(115200) repeat adc := SIO.GetDEC adc := adc * 3300 adc := adc >> 12 SIO.Dec(adc) SIO.TX(13)I didn't have time to hook up and ADC chip so I simulated it with input from PST.
John Abshier
If its ratiometric then you don't need to know the supply voltage, the same ADC output value will appear - that's what ratiometric means. Here the sensitivity is Vcc/10 per g. With a 12 bit ADC that means 409.6 counts = 1g, and the zero is at 2048. So you calculate (adc_value - 2048) * 10 / 4096
Thanks Duane, true they are not floats so not really worth converting
Thanks works fine resulting in 3.299
i just found jwoods 5dof obex (no point in reinventing the wheel) and although not using the gyro have hooked up the adxl335 x,y,z and when returning the axis i get 0ish on z, 0ish on y and 415ish on z, so pretty close to the 409.6 Mark_T formula uses.
i think i need to average the readings now to get a smoother result.
Thanks for the help so far