Mod-SMB380

Started by iafo1, August 05, 2015, 05:36:43 PM

Previous topic - Next topic

iafo1

Did any of you ever used the accelerometer MOD-SMB380 with an imx233 board (archlinux)?

I used the test program downloaded here:

https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/iMX233/MOD-SMB380

but after I compiled the software with the following warning:


[root@foreman AccelerometroOlimex]# make
gcc -c -Wall spi.c
In file included from spi.c:8:0:
gpio-mmap.h: In function 'gpio_map':
gpio-mmap.h:18:22: warning: 'return' with no value, in function returning non-vo                                     id
  if (gpio_mmap != 0) return;
                      ^
gcc -c -Wall i2c.c
gcc -c -Wall main.c
main.c: In function 'main':
main.c:184:13: warning: backslash and newline separated by space
    fputs("\n\
             ^
main.c:185:19: warning: backslash and newline separated by space
USAGE: -[PARAMS]\n\
                   ^
main.c:186:38: warning: backslash and newline separated by space
-spi\t\tRead data via SPI interface\n\
                                      ^
gcc spi.o i2c.o main.o -o mod-smb380



I get the following output:

[root@foreman AccelerometroOlimex]# ./mod-smb380 -spi
CHIP_ID = 0x00
ML_VER = 0x00
AL_VER = 0x00
ACC_X = 0.0000
ACC_Y = 0.0000
ACC_Z = 0.0000
TEMP = -30.0

[root@foreman AccelerometroOlimex]# ./mod-smb380 -i2c
-1 of 1 bytes sended
Failed to send data: No such device or address


May the module be broken?
What can I have done wrong?

Greetings.

kyrk.5

I did not used the module nor the mentioned hardware.

The warnings are of course not nice, but still the software might be working correctly.

pio-mmap.h:18:22: warning: 'return' with no value, in function returning non-void
Ok no return value, the CPU register used to return the value will have some garbage value. Not nice but can still work. Any way, that particular function never returns any usefully values, however it should (int * is expected as return value).
In my opinion, header files should contain only interface descriptions and not executable codes or variables. Not nice :(

main.c:184:13: warning: backslash and newline separated by space
Ok, this is only due to the backslash character at the end of the line. Used to concat the next line with this. This should not cause any problems. Can be avoided if code is not splitted like this:
fputs("\nUSAGE: -[PARAMS]\n-spi\t\tRead data via SPI interface\n-i2c\t\tRead data via I2C interface\n",stdout);

Conclusion: I think the code can still work ok, and the warnings are not the root cause of your problems. However the does not look nice for me, since the header is containing c definitions and some strange warnings are generated.  You should check why the address is not ok. Is the sensor powered properly? Connections are ok? Is there any data send or receive measurable with an ossci? Is there a way to set the sensor to some I2C address? If yes check if the code is using the same as the sensor.

iafo1

Hello Kyrk,
I will try to answer your questions.

Quote from: kyrk.5 on August 05, 2015, 06:02:53 PM
...  You should check why the address is not ok. Is the sensor powered properly? Connections are ok? Is there any data send or receive measurable with an ossci? Is there a way to set the sensor to some I2C address? If yes check if the code is using the same as the sensor.


How can I check "why the address is not ok"?
The sensor is connected through the UEXT mod so, no way to mistake the power supply and the connections.
What is ossci? If you are wondering if I can receive any asci character or string from the sensor the answer is no. But maybe I don't know how to do that, I am new on spi and I2C connections.
Via hardware I can't modify the setup of the accelerometer, via software the only thing I have is the code I showed you....and seems not working.

Thanks!  :)

kyrk.5

Hello,

ossci is an ossciloscope. You should measure the lines to see what is going on.

But! Did you read the datasheet of the device? Chapter 4 and Chapter 6. There is a table that shows, how to connect the device to the uC for different setup of wiring (various SPI and I2C). Also notice that the schematic is having some solderable jumpers and some optional resistors. So try to figure out for which wiring setup you hardware was built, then select one wiring setup which you want to use (possible the same what your HW is currently setup but not necessarily). Then configure the HW according to the selected setup, and try you software again with the proper interface.
Lets see maybe the problem gets solved by configuring the HW properly and using the correct software. If not then we have to look further.

swahren

Looking at the example code makes me sick :(

The SPI variant uses some hardcoded GPIOs for pin toggling. Try to avoid it.

The I2C variant is better. Try to enable I2C-DEV and I2C in your Kernel config / DTS (there must be a /dev/i2c-0).

iafo1

#5
Here we are,
sorry for my delay but I have been busy.
The new is that I am now using the Module in I2C mode and finally it answers something. To do this you have to modify a little bit the HW adding the 2 missing resistors (33KOhm works) and also the SCL/SCK and SDA/MOSI jumpers (they are not jumpers actually, you will find out).

As mentioned, now the accelerometer is answering something but it seems that the temperature data is more or less meaningless.
Now the output is oscillating around 5 and 7 though the real temperature is 20 °C!
The acceleration data seem correct.

Have you got some idea concerning the temperature?

Bye!

kyrk.5

Hello,

Strange. Can you please verify the temperature values again? Are you reading the right register?

The data sheet says, the temperature is stored at address 0x08, it should be 8 bits wide. Resolution is 0.5K/LSB and 0x00 is -30 degree. So +20 degrees should be about ((30+20)*2)  100 dec, 0x64 or 0b01100100.

I am not quite sure, how the temperature conversion is triggered. Maybe some kind of timing issue?

iafo1

Hi!
No, I am pretty sure I am reading the right register. The acceleration are reasonable but the temperature has quite crazy values. What is really strange is the way it changes from about 5 to 6 in less than 1 second: this makes me to think it is not just a problem of calibration...
I will update you!
Again, if somebody has used this module, please talk!