Shop OBEX P1 Docs P2 Docs Learn Events
Help accelerometer adxl345 spi for fast datalogger — Parallax Forums

Help accelerometer adxl345 spi for fast datalogger

mauro.adslmauro.adsl Posts: 3
edited 2011-12-14 01:39 in Accessories
Hello,
I am Italian and I d'ont speak English well. I'm sorry.

I'm looking for SPIN files for communication between the propeller and ADXL345 accelerometer in the SPI for fast data logger.

I can't make it work in SPI mode.

Someone can help me please?
Thank you.

Comments

  • Dantes LegacyDantes Legacy Posts: 16
    edited 2011-12-12 08:07
    Can you explain your set-up a bit more? Are you trying to communicate with the ADXL345 accelerometer AND an SPI Data Logger (presumably an SD card or USB Drive)? Is the Propeller the master device in this SPI network? I have found the object called 'safe_spi' by Jonathan Dummer very helpful with basic SPI communications. I do not know where it can be found on the Onject exchange as it has been awhile since I used it. Maybe someone else here could help source it?
  • mauro.adslmauro.adsl Posts: 3
    edited 2011-12-12 13:43
    The microcontroller used is the parallax propeller. I connected the sensor adxl345 i2c mode. Everything works but the communication is too slow.
    Then I connected the sensor spi mode but I can not make it work.
    I can not configure the SPI protocol for communication.
  • Dantes LegacyDantes Legacy Posts: 16
    edited 2011-12-13 01:14
    I'm not sure exactly what the problem could be as I have not worked with that type of sensor before. I would recommend that you make sure the Chip Select line has a pull up or pull down resistor depending on whether it is active high or active low. Also, be sure to use resistors on SCLK, MISO and MOSI lines. If you have achieved I2C then you can't be too far off achieving SPI communications. AT least you know the sensor is working. Is there any chance we could see some of your code?
  • mauro.adslmauro.adsl Posts: 3
    edited 2011-12-13 12:04
    I have not used any resistors between propeller and adxl345. Where do I put the resistors in SPI mode?
    Accelerometer MMA7455 I have never used resistors in SPI mode and it worked.
    I send you my code and the data sheet for adxl345.

    Thanks for your patience. Hello.
  • Dantes LegacyDantes Legacy Posts: 16
    edited 2011-12-14 01:39
    I would generally put 10k resistors on the MOSI, MISO and SCLK lines when using SPI. Especially if there are other SPI devices on your SPI bus. Also, as I mentioned previously, a pull up or down resistor on the Chip Select (CS) pin. Your code looks solid. I don't have the time to check all the registers for your device and insure you are writing out the correct values. Have you checked the 4 SPI lines with an oscilloscope? For testing, I would recommend changing line 29 of your code to:
    spi.start(10_000, 1)  'Put a huge number here to really slow down the SPI CLK signal and observe what is happening on an oscilloscope
    

    The main thing you are looking for is data being returned to the Prop on the MISO line. If there is something coming back, you know you have successful SPI communication with the slave device, you may just be programming it wrong in that case. If you get nothing back, then you might be transmitting the data at the wrong speed (The ADXL345 has a max clock speed of 5MHz) or you may not be transmitting in the right SPI mode (0, 1, 2 or 3).
Sign In or Register to comment.