FaBo3Axis-ADXL345-Library

Working libraries, libraries being ported and related hardware
User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

FaBo3Axis-ADXL345-Library

Postby BennehBoy » Thu Jan 12, 2017 11:12 am

https://github.com/FaBoPlatform/FaBo3Ax ... 45-Library

If I've read things correctly, all I should need to do to get this working for STM32 is correctly type the variables?

I see in the code that it uses 'int' regularly, presumably these need to be typed as int16_t.

I haven't spotted any of the other nasties and am assuming that the STM32 version of Wire will take care of i2c.

So, what's the correct way to go about this, should I fork the original authors code and issue a PR for the edits or do we make a private copy postfixed STM32? Or is anyone else bothered and I just reference a local version? :D

I ditched adafruits ADXL345 libraries (also requires their generic sensor library) in favour of this one because it's way less bloaty.

Just trying to get things lined up ready for when my boards arrive.
-------------------------------------
https://github.com/BennehBoy

danieleff
Posts: 139
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby danieleff » Thu Jan 12, 2017 11:49 am

I think that library is fine as it is. Did not test it, but it's not like you have to change every int to run on STM32.

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Thu Jan 12, 2017 4:57 pm

OK fair enough :D

Presumably it would ever so slightly reduce the amount of dynamic ram used though.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 3:09 pm

Board arrived,

Transferred my project over to it and started to code the differences in.

Working so far:
3X SSD1306 OLED's working using software SPI (adafruit library)

A max 31586 working over another software SPI bus (adafruit library)

Analogue inputs working fine, using a 4096 vs 1024 divisor.

What I can't get to work is the fabo over I2C.

The fabo relies on Wire.h for hardware I2C, do I need to include a maple mini variant of this with I2C hardcoded to pins 15 & 16? Those are the pins silkscreened on my board and match this reference -> https://developer.mbed.org/media/upload ... nout01.png
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 4:56 pm

I've checked the obvious stuff:

The 345 board I'm using has a regulator on, it's passing 3.3v so the chip is getting VCC.

The pullup resistors on the board are 4.7K

The library has a searchdevice method on the object, this is what is failing - suspect it's something to do with how things are cast in the code, OR I've just plain got the I2C pins wrong/something, OR it's some quirk of multiple I2C buses and the code is expecting an address that doens't exist.

Not massively familiar with I2C so I guess it's time to go do some googling.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 5:34 pm

Generic I2C scanner finds the device

Code: Select all

Scanning...
I2C device found at address 0x53  !
done



Must be an implementation error in the library, will see if this old mental sloth can figure it out.
-------------------------------------
https://github.com/BennehBoy

zmemw16
Posts: 1075
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: FaBo3Axis-ADXL345-Library

Postby zmemw16 » Mon Jan 23, 2017 5:57 pm

try the sniffers from the Wire lib examples, one of them usually works for me.

the other is trying the address + 1, e.g. 0x3C & 0x3D istr a 9.98" OLED doing that for some reason - link set to an alternate address ?

stephen

<edit> i need to type faster </edit>
Last edited by zmemw16 on Mon Jan 23, 2017 10:57 pm, edited 1 time in total.

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 6:07 pm

I tried a sniffer, see previous post, it returns the correct address.

Here's the definition of the address from the library header:

/** SLAVE_ADDRESS */
#define ADXL345_SLAVE_ADDRESS 0x53

I'm pretty sure there's something going wrong with the way that the library constructor works on STM32, but I'm not the worlds greatest coder (especially object oriented code) so am a bit clueless at the moment.

Here's the class definition from the library header:

Code: Select all

class FaBo3Axis
{
public:
  FaBo3Axis(uint8_t addr = ADXL345_SLAVE_ADDRESS);
  bool searchDevice(void);
  void configuration(void);
  void powerOn(void);
  void readXYZ(int *x, int *y, int *z);
  uint8_t readIntStatus();
  void enableTap();
  bool isSingleTap(uint8_t value);
  bool isDoubleTap(uint8_t value);
private:
  uint8_t _i2caddr;
  void writeI2c(uint8_t register_addr, uint8_t value);
  void readI2c(uint8_t register_addr, uint8_t num, uint8_t *buf);
};


Here's the constructor in the cpp

Code: Select all

FaBo3Axis::FaBo3Axis(uint8_t addr)
{
  _i2caddr = addr;
  Wire.begin();
}


My instantiation:

Code: Select all

FaBo3Axis accel;


And my error checking to ensure the device is connected

Code: Select all

  if (!accel.searchDevice()) {
    return (doFaults(1, 0, 0, index)); // set fault state if the ADXL345 is not connected
  }


So, in short, the searchdevice method always returns false.
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 8:14 pm

OK, so paired everything back, and the library works fine in isolation.

So either my code is stomping on it, or it doesn't play well in conjunction with the other software SPI libraries I'm using but only for STM32??

:(
-------------------------------------
https://github.com/BennehBoy

User avatar
BennehBoy
Posts: 408
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: FaBo3Axis-ADXL345-Library

Postby BennehBoy » Mon Jan 23, 2017 8:16 pm

Actually, no it doesn't, it's pulling the same random result back....
-------------------------------------
https://github.com/BennehBoy


Return to “Libraries & Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest