Tuesday, August 12, 2008

Cheap 3D accelerometers and SPI issues.

Just added support for Kionix accelerometers to the Butterflylogger project. In particular the KXPS5 using the breakout PCB from Crodnet. The main advantage of this accelerometer of others as far as I can see is the price as well as having both digital (SPI and I2C) as well as analogue interfaces.

Had a small hiccupp in getting the SPI bus to behave. It seemed that when I drove the SCLK line while clocking out a response from the accelerometer, the cross talk (with the MISO Line) would interfere with the output (see above)

After a number of ineffective tweaks with speed and the IO setup for the lines I decided to shorten the lines. After shortening the lines all the problems went away. For reference the original lines were approximatly 10cm between the butterfly and the breakout board.

NOTE: the code for talking to the accelerometer is KXPS5-3157.c and KXPS5-3157.h The will be included in the next code release but for the meantime you will need to get them from the CVS repository.


At 3:40 am, Blogger Unknown said...

Could you possibly send me a schematic of how the accelerometer connects to the butterfly? For a university project I'm a little stuck on. Cheers

At 3:42 am, Blogger Unknown said...

Forgot to include my email - reply to this comment please

At 7:40 am, Blogger Nick said...

I use the spi port of the butterfly available on PortB. This J400 on the schematic in the butterfly users guide. J400 has connections for VCC_EXT as well as PB0..7.

The power will only be available if you have something connected to vcc_ext. If you are running purely from the included battery then this circuit will not work.

PB5 was used as chip select (CS) out of convenience any General Purpose IO (GPIO) pin could have been used. The MOSI, MOSI, and SCK signals are from the butterfly's SPI interface so these pins need to be used unless we want to build our on SPI interface from scratch using software.

The connections are as follows:
(please keep these very short under 30mm if possible.)

1 vcc butterfly vcc - J400.10
2 gnd butterfly gnd - J400.9
3 cs butterfly PB5 - J400.4
4 sdi butterfly PB2 (MISO) - J400.3
5 sdo butterfly PB3 (MOSI) - J400.4
6 sclk butterfly PB1 (SCK) - J400.2
7 enable vcc via 10K resistor
8 FF/MOT not connected
9 MOT enable not connected

At 2:47 pm, Blogger Unknown said...

Thanks, I'll let you know how I get on. :)

At 11:10 am, Blogger Unknown said...

I've just recieved the dev board, and am soldering a butterfly to kxps5 connector. I'm now thinking about software, how did you read the values from the accelerometer?
Could you give me an example of some code?

At 11:20 am, Blogger Nick said...

have a look here http://butterflylogger.cvs.sourceforge.net/viewvc/butterflylogger/logger/KXPS5-3157.c?view=markup



sorry haven't released the code yet.

At 12:17 pm, Blogger uwadb said...

Hi Nick,

Do you know the dates of these comments? I'm trying to track down the price of the board and perhaps an invoice.


At 2:17 pm, Blogger Nick said...

The first posts were on 2nd October 2008 the last one on the 17th October. Hope this helps.


Post a Comment

<< Home