PDA

View Full Version : Lis3lv02dq



James Long
10-24-2006, 11:50 PM
Ok.....so I have this new sensor.....Triple Axis....Spi interface. Accelerometer......But I can't seem to talk to it.

Mike or any other person who could help out would be appreciated.....I have attached the datasheet.

Man......I just don't know about this one. It looks like it takes full duplex to talk to this thing. But how do you clock full duplex...and set in and out bit width?

James L

Post Edited (James Long) : 10/24/2006 4:56:03 PM GMT

JoMo
12-31-2007, 08:04 AM
Hi,
I have the LIS3LV02DQ also, has anyone been able to·make it work·with the Propeller?
thanks!
Joe

Paul Baker
12-31-2007, 08:19 AM
I was looking at this chip just last night, why not use the I2C interface since there are several objects for I2C availible?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

deSilva
12-31-2007, 10:49 AM
By all means follow Paul's advice! There is no real need to exceed the common I2C speed, as data is delivered at most at kHz..... One can even suspect that it will also run a high speed version of I2C...

The SPI is one of the many half-duplex variations with DO and DI on the same line (which is not worse than I2C, but AFAIK there is no driver for it).

This is not a simple device, so you have to master its features...

JoMo
12-31-2007, 11:19 AM
Hi,
I tried (for a little while) then went to SPI and failed.
The I2CObject wants an address of the device. But I couldn't find the address in the doc.
·(or if·it's in the doc then I missed it.)
That and I am not sure how it should all work.

for i2c I tried:




OBJ
A_I2C : "i2cobject"
pub main
A_I2C.Init(A_SDA,A_SCL,false)
printRegister(WHO_AM_I,true)

pri printRegister(register, isNewLine) | c
register |= %10000000
A_I2C.i2cWrite(register,8)
c:=A_I2C.i2cRead(1)
print(c,TINY_FONT,0,255,0,ISNBR,isNewLine)


also tried using readLocation(deviceAddress, deviceRegister, addressbits, databits)


but can't seem to find the deviceAddress


thx

·-Joe

Post Edited (JoMo) : 12/31/2007 4:31:28 AM GMT

deSilva
12-31-2007, 11:32 AM
page 17 said...
The Slave ADdress (SAD) associated to the LIS3LV02DQ is 0011101b.

This sounds a little bit unusual but is o.k. as the chip has no pin programming.
Rather it has a CS (Pin 13) which you have to honour.

ReadLocations should work with that address...

JoMo
12-31-2007, 11:39 AM
Ah,
Thanks deSilva, (my eyes must be getting old) I will give that a try.

-Joe

JoMo
01-01-2008, 12:57 AM
Hi again,
I remember now·that, just before I gave up on the·I2C (mailto:I2@C)·approach,·I did try that address with readLocation and
didn't get far.
Here is my·hardware hook-up.


LIS3LV02DQ Vdd -> Prop Vdd -> +3v
LIS3LV02DQ Gnd -> Prop Vss -> -gnd.
LIS3LV02DQ SDA -> Prop pin 10
LIS3LV02DQ SCL -> Prop pin 11

LIS3LV02DQ CS -> Prop pin 12


LIS3LV02DQ INT -> NC
LIS3LV02DQ SDO -> NC
LIS3LV02DQ CK -> Nc (also tried grounding it)

Here is my code.·I can't figure out what I am missing or doing wrong.



{{
Accerlometer Test
}}
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

'OLED
ISTEXT = 0
ISNBR = 1
TINY_FONT = 0
WITH_AMB = 1
RAW = 0
O_TX = 7 O_RX = 6 O_RS = 5

'accelerometer
A_SDA = 10
A_SCL = 11
A_CS = 12

OBJ
OLED : "uOLED-128-GMD1"
A_I2C : "i2cobject"
DELAY : "Clock"



VAR
byte dispX
byte dispY
byte reds[255]
byte greens[255]
byte blues[255]

PUB main
OLED.INIT(O_TX,O_RX,O_RS)
OLED_SETUP
cls
print(TINY_FONT,0,255,0,string("Testing..."),ISTEXT,0)
dira[A_CS]~~
outa[A_CS]:=1 ' SPI=0 , I2C=1
A_I2C.Init(A_SDA,A_SCL,false)
delay.pausesec(1)
printRegister($0f,true) 'who am i
repeat
printRegister($28,true) 'high byte of x output
printRegister($29,true) 'low byte of x output
delay.pausesec(1)
cls


pri printRegister(register, isNewLine) | c
register |= %10000000
c:=A_I2C.readLocation(%0011101,register,8,8)
print(c,TINY_FONT,0,255,0,ISNBR,isNewLine)

PUB OLED_SETUP
OLED.ERASE
DELAY.PauseMSec(20)
OLED.BACKGROUND(0,0,0)

pub cls
oled.erase
dispX:=0
dispY:=0

PUB print (text,FONT, R,G,B, dTYPE,ISNEWLINE)
OLED.FTEXT(dispX,dispY,FONT,R, G,B,text,dTYPE)
dispX += strsize(text)
if(ISNEWLINE)
newLine
handleCursor
pri newLine
dispY++
dispX:=0

pri handleCursor
if(dispX > 20)
dispY++
dispX:=0
if(dispY > 14)
delay.pausesec(1)
cls

The displayed results are:

Testing...
255
255
255

Any ideas what I am doing wrong?
Thanks a lot.
-Joe

Sapieha
01-01-2008, 01:24 AM
Hi JoMo

Read data shet on this IC.
It say ---------------------- I2C/SPI mode selection (1: I2C mode; 0: SPI enabled).

CS pin must be level 1 if you will have I2C mode.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.

Sapieha

JoMo
01-01-2008, 01:40 AM
Hi Sapieha,

Aren't I doing that in the main method?
dira[A_CS]~~
outa[A_CS]:=1 ' SPI=0 , I2C=1

-Joe

RytonMike
01-01-2008, 01:40 AM
No comments on the device but here are some interesting links for accelerometer and giro applications/research
http://www.invensense.com/support/library.html

Happy new year to all propeller heads!

Mike

deSilva
01-01-2008, 02:32 AM
Tree remarks:

(a) I did just copied the device address yesterday, but 0011_101b looks funny... It is in fact the device address: but the first left bits of the eight bit value only. Normally such a §device address is presented as 4 bit, as the last three bits are pin programmed.

So use 0011_1010 as address!!!

(b) You stated "non driving" as thrird parameter of the INIT. This is only possible when you have a pull uip at both SDA and SCL Have you?

(c) Start with a call of "devicePresent"

Much luck!

JoMo
01-01-2008, 03:25 AM
Hi,
I have tried what you suggested.
a) using 00111010 address works!
Well, I get a 58 (3A) reply to a WHO_AM_I which is correct and a good sign.
But my calls to the out_x,y,z registers only reply 0s. Dang.
b) ok, just did that.
c) Don't know how to do this. Not sure what to send or what register to send to.

Thanks a ton, I'm getting there! I think.
Why do you think I would get a reply from a the whoami but only zeros from the outx,y,z registers?
It's like it's not active but by default I think each axis output is enabled.
Thanks
-Joe

Post Edited (JoMo) : 12/31/2007 8:30:10 PM GMT

deSilva
01-01-2008, 03:36 AM
device Present is this routine in i2cobject:


PUB devicePresent(deviceAddress) : ackbit
' send the deviceAddress and listen for the ACK
ackbit := _i2cNAK
if i2cStarted == true
i2cStart
ackbit := i2cWrite(deviceAddress | 0,8)
i2cStop
if ackbit == _i2cACK
ackbit := true
else
ackbit := false
return ackbit


But thats BTW.

Well, I think you now have to PROGRAM that beast http://forums.parallax.com/images/smilies/smile.gif
Try reading register $20
Then set it (and other registers), that's the fun of it! Still some hours this year...

James Long
01-01-2008, 03:46 AM
I hate to say it......but I believe I killed my unit. The Datasheet states if you write to the wrong register.....you can kill the chip. I think I actually did that when I first started working with it. Mine give out wierd numbers when I try to interface with it. But I may still be doing it wrong.

I moved on to other projects, and never got back to it.

If anyone does get it talking, let me know......I could always try mine again.

Thanks

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services)

JoMo
01-01-2008, 03:47 AM
Hi deSilva,
oh.. THAT devicePresent :)
sorry, tunnel vision I guess.
Good advice, I will just keep plugging away at it.
Thanks very much for everything.

Cheers
-Joe


James, sorry to hear about your misfortune.
I hope I didn't kill mine too. Can·(could) you get a whoami out of it?

Post Edited (JoMo) : 12/31/2007 8:53:01 PM GMT

JoMo
01-01-2008, 04:08 AM
Hi,
Ah ha! The final thing·was that the powerUp bit was not being set! By default this thing is powered down.
Here is my code that works.
deSilva cheers to you·again.· The Forum at it's best.
Much thanks!
-Joe :)


{{

LIS3LV02DQ Test

LIS3LV02DQ Vdd -> Prop Vdd -> +3v
LIS3LV02DQ Gnd -> Prop Vss -> -gnd.
LIS3LV02DQ SDA -> Prop pin 10 (pulled high) seems to work fine without pullup.
LIS3LV02DQ SCL -> Prop pin 11 (pulled high) seems to work fine without pullup.
LIS3LV02DQ CS -> Prop pin 12
LIS3LV02DQ INT -> NC
LIS3LV02DQ SDO -> NC
LIS3LV02DQ CK -> Nc

}}

CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

'OLED
ISTEXT = 0
ISNBR = 1
TINY_FONT = 0
WITH_AMB = 1
RAW = 0
O_TX = 7
O_RX = 6
O_RS = 5

'accelerometer
A_SDA = 10
A_SCL = 11
A_CS = 12
A_Addr = %00111010

OBJ
OLED : "uOLED-128-GMD1"
A_I2C : "i2cobject"
DELAY : "Clock"

VAR
byte dispX
byte dispY
byte reds[255]
byte greens[255]
byte blues[255]

PUB main
OLED.INIT(O_TX,O_RX,O_RS)
OLED_SETUP
cls
print(TINY_FONT,0,255,0,string("Testing..."),ISTEXT,0)
A_I2C.Init(A_SDA,A_SCL,false)
dira[A_CS]~~
outa[A_CS]:=1 ' SPI=0 , I2C=1
delay.pausesec(1)
writeRegister($20,%01000111) ' power up! ctr reg1
printRegister($20,true) ' ctr reg1
delay.pausesec(3)
repeat
printRegister($28,true) ' high byte of x output
printRegister($29,true) ' low byte of x output
printRegister($2A,true) ' high byte of y output
printRegister($2B,true) ' low byte of y output
printRegister($2C,true) ' high byte of z output
printRegister($2D,true) ' low byte of z output
delay.pausesec(1)
cls

pri printRegister(register, isNewLine) | c
register |= %10000000
c:=A_I2C.readLocation(A_ADDR,register,8,8)
print(c,TINY_FONT,0,255,0,ISNBR,isNewLine)

pri writeRegister(register,value)
register |= %00000000
A_I2C.writeLocation(A_ADDR,register,value, 8,8)

pri showAccDevicePresent | c
c:=a_i2c.devicePresent(A_ADDR)
print(c,TINY_FONT,0,255,0,ISNBR,true)

pri OLED_SETUP
OLED.ERASE
DELAY.PauseMSec(20)
OLED.BACKGROUND(0,0,0)

pri cls
oled.erase
dispX:=0
dispY:=0

pri print (text,FONT, R,G,B, dTYPE,ISNEWLINE)
OLED.FTEXT(dispX,dispY,FONT,R, G,B,text,dTYPE)
dispX += strsize(text)
if(ISNEWLINE)
newLine
handleCursor

pri newLine
dispY++
dispX:=0

pri handleCursor
if(dispX > 20)
dispY++
dispX:=0
if(dispY > 14)
delay.pausesec(1)
cls





Post Edited (JoMo) : 1/11/2008 4:06:13 AM GMT

deSilva
01-01-2008, 05:36 AM
Thank you, and Happy New Year - I live in an early time zone http://forums.parallax.com/images/smilies/smile.gif
@James: I doubt that you killed your device. Try exactly what JoMo has done!

Paul Baker
01-01-2008, 08:14 AM
The document explains the "missing bit" a couple paragraphs later· "The slave address is completed with a Read/Write bit. If the bit was ‘1’ (Read), a repeated START (SR) condition will have to be issued after the two sub-address bytes; if the bit is ‘0’ (Write) the Master will transmit to the slave with direction unchanged." Though they should have used a place holder (like R for read) to make it clear there is additional inofrmation which need to be filled in.

James, it's possible you overwrote a calibration parameter which would result in unpredictable behaviour, but upon each power up these are restored to thier original value, so you may not have harmed it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

Post Edited (Paul Baker (Parallax)) : 1/1/2008 1:19:21 AM GMT

James Long
01-01-2008, 11:21 AM
JoMo,

I'll try to duplicate your results when I get the chance.....I'm currently up to my neck with the New SMT service coming online the next few months.

deSilva ( and Paul )

The datasheet does state if you write into restricted areas it is possible to kill the chip. I think I had the address to write the power up sequence wrong when I first started. I figured out later this was a restricted area. I will however try JoMo's code to see if it infact still works, but I tried quite a few times and never could get any useful results from it.

Thanks all,

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services)

deSilva
01-01-2008, 03:53 PM
Paul Baker (Parallax) said...
Though they should have used a place holder (like R for read) to make it clear there is additional inofrmation which need to be filled in.

Everything is absolutely clear - the issue is just you expect a 4-bit value and rather read a long string of bits, and do not count them http://forums.parallax.com/images/smilies/smile.gif It is not even misleading as the use the correct terms. It is just - unexpected, thus: error prone...

Caleb
01-11-2008, 01:04 PM
Hi,

I am a beginner for BASIC Stamp, and can you show me if and how I can modify your code for me to reading LIS3LV02DQ USING basic stamp, instead of propeller? Or can you modify and show me?

Thanks,

Caleb


JoMo said...
Hi,
Ah ha! The final thing·was that the powerUp bit was not being set! By default this thing is powered down.
Here is my code that works.
deSilva cheers to you·again.· The Forum at it's best.
Much thanks!
-Joe :)


{{

LIS3LV02DQ Test

LIS3LV02DQ Vdd -> Prop Vdd -> +3v
LIS3LV02DQ Gnd -> Prop Vss -> -gnd.
LIS3LV02DQ SDA -> Prop pin 10 (pulled high) seems to work fine without pullup.
LIS3LV02DQ SCL -> Prop pin 11 (pulled high) seems to work fine without pullup.
LIS3LV02DQ CS -> Prop pin 12
LIS3LV02DQ INT -> NC
LIS3LV02DQ SDO -> NC
LIS3LV02DQ CK -> Nc

}}

CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

'OLED
ISTEXT = 0
ISNBR = 1
TINY_FONT = 0
WITH_AMB = 1
RAW = 0
O_TX = 7
O_RX = 6
O_RS = 5

'accelerometer
A_SDA = 10
A_SCL = 11
A_CS = 12
A_Addr = %00111010

OBJ
OLED : "uOLED-128-GMD1"
A_I2C : "i2cobject"
DELAY : "Clock"

VAR
byte dispX
byte dispY
byte reds[255]
byte greens[255]
byte blues[255]

PUB main
OLED.INIT(O_TX,O_RX,O_RS)
OLED_SETUP
cls
print(TINY_FONT,0,255,0,string("Testing..."),ISTEXT,0)
A_I2C.Init(A_SDA,A_SCL,false)
dira[A_CS]~~
outa[A_CS]:=1 ' SPI=0 , I2C=1
delay.pausesec(1)
writeRegister($20,%01000111) ' power up! ctr reg1
printRegister($20,true) ' ctr reg1
delay.pausesec(3)
repeat
printRegister($28,true) ' high byte of x output
printRegister($29,true) ' low byte of x output
printRegister($2A,true) ' high byte of y output
printRegister($2B,true) ' low byte of y output
printRegister($2C,true) ' high byte of z output
printRegister($2D,true) ' low byte of z output
delay.pausesec(1)
cls

pri printRegister(register, isNewLine) | c
register |= %10000000
c:=A_I2C.readLocation(A_ADDR,register,8,8)
print(c,TINY_FONT,0,255,0,ISNBR,isNewLine)

pri writeRegister(register,value)
register |= %00000000
A_I2C.writeLocation(A_ADDR,register,value, 8,8)

pri showAccDevicePresent | c
c:=a_i2c.devicePresent(A_ADDR)
print(c,TINY_FONT,0,255,0,ISNBR,true)

pri OLED_SETUP
OLED.ERASE
DELAY.PauseMSec(20)
OLED.BACKGROUND(0,0,0)

pri cls
oled.erase
dispX:=0
dispY:=0

pri print (text,FONT, R,G,B, dTYPE,ISNEWLINE)
OLED.FTEXT(dispX,dispY,FONT,R, G,B,text,dTYPE)
dispX += strsize(text)
if(ISNEWLINE)
newLine
handleCursor

pri newLine
dispY++
dispX:=0

pri handleCursor
if(dispX > 20)
dispY++
dispX:=0
if(dispY > 14)
delay.pausesec(1)
cls

James Long
02-26-2008, 10:36 AM
Caleb,

I just noticed something when I was playing with my LIS3LV02DQ

You have your highs and lows mixed up in relation to the Bytes.

Just thought I would say something.

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services) (http://www.lilbro.mosquito.net.nz/index.html)

Caleb
03-23-2008, 12:25 AM
Hi,
1. I have propeller demo boards, and it seems the code from Jomo seems not matched with this. My demo boards only have p0~P7. can I just simply change p10, p11, p12 in the code to pin 1, 2, 3 in my demo board, then modify the code accordingly?

2. I don't have OLED, and try to use TV for seeing the output. It seems not easy as I am beginner. Does anyone can help to modify or give me comments how I can modify the Jomo's code for LED display to TV display code?

Thanks,
Caleb

James Long
03-23-2008, 01:24 AM
Caleb said...
Hi,
1. I have propeller demo boards, and it seems the code from Jomo seems not matched with this. My demo boards only have p0~P7. can I just simply change p10, p11, p12 in the code to pin 1, 2, 3 in my demo board, then modify the code accordingly?

2. I don't have OLED, and try to use TV for seeing the output. It seems not easy as I am beginner. Does anyone can help to modify or give me comments how I can modify the Jomo's code for LED display to TV display code?

Thanks,
Caleb
Caleb,

I modified the code for Hyper terminal on the PC if you want the code. I do not have a TV or VGA convenient for use....so I use Hyper terminal a lot. I have thought of using the new Prop Terminal....but didn't ever get that far.

I used pins 5,6, and 7 on the demo board for the connection.

James L



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services) (http://www.lilbro.mosquito.net.nz/index.html)

Caleb
03-23-2008, 04:39 AM
James,
Thanks for the help. I could compile, but I couldn't see any debug like terminal opened. Did I miss something to make Hyper terminal work? I don't have any idea how to use the hyper terminal, can you comment me?
Thanks,
Cheol

James Long
03-23-2008, 07:32 AM
Caleb said...
James,
Thanks for the help. I could compile, but I couldn't see any debug like terminal opened. Did I miss something to make Hyper terminal work? I don't have any idea how to use the hyper terminal, can you comment me?
Thanks,
Cheol
Caleb,

Hyper terminal is not an automatic opening device, because it is just a general communication terminal.· You will need to get the propeller programmed and then open hyper terminal (usually under accessories>communications)

You will need to configure a new connection with these settings.

When asking how to connect choose the com port that the Propeller tool was using to program with.

The following will work with the files I sent:
460800 Bits per second
8 Data bits
parity None
Stop Bits 1
flow control hardware.

After you do this......(if the propeller is running) it will start communicating with the propeller.

These are all basic things......if you are new and using the propeller.....you will have a very steep learning curve.

James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L

Partner/Designer
Lil Brother LLC (SMT Assembly Services) (http://www.lilbro.mosquito.net.nz/index.html)