ADXL345 accel - only 2 sigfigs
I'm new to the propeller and trying to get an adxl345 accelerometer working, using this object: http://obex.parallax.com/objects/562/
I can get it working and read data from it (using the demo included), but it'll only read in 2 sigfigs (ie instead of 32_something ft/s/s, i only read 32). I've dug though the code in the object and the demo and done some searching but I'm officially stumped so I'd appreciate some help.
Thanks,
~Bird
I can get it working and read data from it (using the demo included), but it'll only read in 2 sigfigs (ie instead of 32_something ft/s/s, i only read 32). I've dug though the code in the object and the demo and done some searching but I'm officially stumped so I'd appreciate some help.
Thanks,
~Bird

Comments
PUB Read2byte(_axis): data '' Read in i2c data, Data byte is output MSB first, SDA data line is '' valid only while the SCL line is HIGH. SCL and SDA left in LOW state. '' The routine reflects the ADXL345 datasheet recommendations for '' multiple byte read for each axis. StartI2C Write(deviceAddressWrite | 0) Write(_axis) StartI2C Write(deviceAddressRead | 0) data := 0 dira[SDA]~ ' Make SDA an input repeat 8 ' Receive data from SDA outa[SCL]~~ ' Sample SDA when SCL is HIGH data := (data << 1) | ina[SDA] outa[SCL]~ outa[SDA] := ACK ' Output ACK repeat 8 ' Receive data from SDA outa[SCL]~~ ' Sample SDA when SCL is HIGH data := (data << 1) | ina[SDA] outa[SCL]~ data := data << 16 ' Shift data bits 16 bits left these are LSB outa[SDA] := NAK ' Output NAK to SDA dira[SDA]~~ outa[SCL]~~ ' Toggle SCL from LOW to HIGH to LOW outa[SCL]~ outa[SDA]~ ' Leave SDA driven LOW StopI2C data := data <- 8 ' puts the 8MSB to the 8LSB data := ~data ' extend signMy suspicion is that in order to get more digits I need to read more than two bytes, but I don't know enough about i2c to figure out how to do that, I've tried playing around with the Read2byte function but haven't gotten it working.
Could You post more of Your code? just use the handy Archive feature in the Prop tool.
I am not sure what a "sigfigs" is...
Thanks for the offer of help, I can still post the code if you're interested.
I'm telling you, this stuff is so easy, it's hard...
Feel free to post up Your code, it serves as an example for others trying to hard..
Personally, I get a kick out of seeing code I have written previously, I have come very far in a year, (for me anyway).
and I am amazed that I could actually make the thing work in spite of my copy and paste code "writing" skills.