Welcome, Guest

Author Topic: Mod-SMB380  (Read 3874 times)

iafo1

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Mod-SMB380
« on: August 05, 2015, 05:36:43 PM »
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:


Code: [Select]
[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:

Code: [Select]
[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

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +3/-0
Re: Mod-SMB380
« Reply #1 on: August 05, 2015, 06:02:53 PM »
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

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: Mod-SMB380
« Reply #2 on: August 11, 2015, 11:21:13 AM »
Hello Kyrk,
I will try to answer your questions.

...  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

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +3/-0
Re: Mod-SMB380
« Reply #3 on: August 11, 2015, 12:52:57 PM »
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

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +7/-0
Re: Mod-SMB380
« Reply #4 on: August 13, 2015, 08:12:43 PM »
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

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: Mod-SMB380
« Reply #5 on: October 13, 2015, 12:47:42 PM »
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!
« Last Edit: October 13, 2015, 05:00:28 PM by iafo1 »

kyrk.5

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +3/-0
Re: Mod-SMB380
« Reply #6 on: October 14, 2015, 01:56:14 PM »
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

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: Mod-SMB380
« Reply #7 on: October 19, 2015, 10:45:29 AM »
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!