Arcadia

the quieter you become, the more you hear

SAMSUNG NB30 onboard accelerometer upgrade

Return to index HERE


The Story:

For many years I kept my old NB30 as a small fallback computer, because I believe there are much potential to this little under powered netbook. With more I learn, the more I discovered.

The first time I had my hands on this netbook, I noticed there was a free fall sensor driver for windows 7. That's when I knew there is a small accelerometer in this netbook. It detects sudden acceleration of the computer in case of free fall, and temporarily lock hard drive to protect disk and data. Then I had the idea to read from the sensor and see what I can do with the data. I remember I did try to examine the free fall driver, but came out nothing, since I didn't know what I was looking for.

One day I installed debian on my other computer Elitebook 8540w, I noticed in the dmesg log, there is a input device for accelerometer. I googled it and found that many computers use accelerometer to protect their hard drive. In the second attempt, I installed Ubuntu in my NB30, but still nothing in dmesg log related to any accelerometer showed up. Again I search online forums for a while and found a free fall driver for ubuntu. Unfortunately it was for another model(cann't remember which one) and did not work for NB30. And that's where I was going to leave it.

Several years later I just googled the netbook for information and found the schematics of the netbook somewhere free to download ! That's when things started to become interesting. It says the the sensor chip is LIS331DL [DATASHEET Here] and connected to the mothermoard through I2C interface. The following picture shows the location of the sensor on the motherboard. The back cover needs to be freed in order to see it.

LIS331DL location

Then I learnt that I can use the i2c-tools to detect and check the sensor. However, when I fired up the tool, although I can see 5 i2c buses, all I could find from them was the display EDID eeprom. The accelerometer was not found anywhere, even the RAM SPD eeprom was not there.
  1. root@SNB30-UBUNTU:~# i2cdetect -l
  2. i2c-3 i2c i915 gmbus dpc I2C adapter
  3. i2c-1 i2c i915 gmbus vga I2C adapter
  4. i2c-4 i2c i915 gmbus dpb I2C adapter
  5. i2c-2 i2c i915 gmbus panel I2C adapter
  6. i2c-0 i2c i915 gmbus ssc I2C adapter

only bus i2c-2 has a target at 0x50(common address for eeproms), and i2cdump shows it was a EDID eeprom chip for the internal LCD panel(writable).
  1. root@SNB30-UBUNTU:~# i2cdetect -y 2
  2. 0 1 2 3 4 5 6 7 8 9 a b c d e f
  3. 00: -- -- -- -- -- -- -- -- -- -- -- -- --
  4. 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  5. 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  6. 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  7. 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  8. 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  9. 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  10. 70: -- -- -- -- -- -- -- --

Several months later when I was using lm-sensors, I noticed it tried to load a module named i2c-i801. I did the same thing and there it is! An extra i2c bus i2c-6 showed up!
  1. root@SNB30-UBUNTU:~# modprobe i2c-dev
  2. root@SNB30-UBUNTU:~# modprobe i2c-i801
  3. root@SNB30-UBUNTU:~# i2cdetect -l
  4. i2c-3 i2c i915 gmbus dpc I2C adapter
  5. i2c-1 i2c i915 gmbus vga I2C adapter
  6. i2c-6 smbus SMBus I801 adapter at 18a0 SMBus adapter
  7. i2c-4 i2c i915 gmbus dpb I2C adapter
  8. i2c-2 i2c i915 gmbus panel I2C adapter
  9. i2c-0 i2c i915 gmbus ssc I2C adapter
  10. i2c-5 i2c i915 gmbus dpd I2C adapter

I searched the bus and had some interesting results!
  1. root@SNB30-UBUNTU:~# i2cdetect -y 6
  2. 0 1 2 3 4 5 6 7 8 9 a b c d e f
  3. 00: -- -- -- -- -- 08 -- -- -- -- -- -- --
  4. 10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- --
  5. 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  6. 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  7. 40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
  8. 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  9. 60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
  10. 70: -- -- -- -- -- -- -- --

According to the schematic found online, adress 0x69 is a CK-505M (Clock generator), dump as follows:
  1. root@SNB30-UBUNTU:~# i2cdump -y 6 0x69
  2. No size specified (using byte-data access)
  3. 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
  4. 00: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  5. 10: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  6. 20: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  7. 30: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  8. 40: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  9. 50: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  10. 60: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  11. 70: 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d 0d ????????????????
  12. 80: 65 83 ff 77 ff 00 00 06 10 25 01 b6 0d 00 0d 00 e?.w...??%???.?.
  13. 90: 00 00 06 00 6a 00 00 00 14 00 00 00 00 ff ff ff ..?.j...?.......
  14. a0: 65 83 ff 77 ff 00 00 06 10 25 01 b6 0d 00 0d 00 e?.w...??%???.?.
  15. b0: 00 00 06 00 6a 00 00 00 14 00 00 00 00 ff ff ff ..?.j...?.......
  16. c0: 65 83 ff 77 ff 00 00 06 10 25 01 b6 0d 00 0d 00 e?.w...??%???.?.
  17. d0: 00 00 06 00 6a 00 00 00 14 00 00 00 00 ff ff ff ..?.j...?.......
  18. e0: 65 83 ff 77 ff 00 00 06 10 25 01 b6 0d 00 0d 00 e?.w...??%???.?.
  19. f0: 00 00 06 00 6a 00 00 00 14 00 00 00 00 ff ff ff ..?.j...?.......

Address 0x50 is the SPD eeprom for the single DDR2 RAM. 0x3D should be the CPU thermal sensor, but it is missing for some reason, and I don't know whats sitting at address 0x08 and 0x44. That could be the story for another day. Originally there was something at 0x30, but when I tried to dump the content, nothing was there and it just disappeared ! Very strange. This happened on two different NB30 netbook. I hope I didn't break something.

After checking the device datasheet, I can see the sensor at 0x1D. Then I wrote a small program to read the device register. The data decoded from the register contains the 3-axis accleration value, and that's what I was hoping to get all along!

Later I spend some time searching the ST website, I found that there are some other sensor models share the same package and pinout with the LIS331DL, I picked the LIS3DH [DATASHEET Here] for better scale, resolution and the fact that it also has a temperature sensor built-in. Then I planned a chip upgrade from LIS331DL to LIS3DH. After I got the chips, I took out the whole motherboard and desoldered the original LIS331DL.

LIS331DL (marking "33DL")

desoldered PCB

then I soldered the new LIS3DH carefully, not my best work but it works.

LIS3DH(marking "C3H")

I started the computer and there is the new sensor at address 0x19:
  1. root@SNB30-UBUNTU:~# i2cdetect -y 6
  2. 0 1 2 3 4 5 6 7 8 9 a b c d e f
  3. 00: -- -- -- -- -- 08 -- -- -- -- -- -- --
  4. 10: -- -- -- -- -- -- -- -- -- 19 -- -- -- -- -- --
  5. 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  6. 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  7. 40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
  8. 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  9. 60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
  10. 70: -- -- -- -- -- -- -- --

register dump at 0x19, at 0x0f we can see the value 0x33 corresponds with the WHO_AM_I device identification register for LIS3DH (0x3b for LIS331DL).
  1. root@SNB30-UBUNTU:~# i2cdump -y 6 0x19
  2. No size specified (using byte-data access)
  3. 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
  4. 00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 ...............3
  5. 10: 88 9e 87 20 a0 32 1d 21 1b 90 90 85 c0 00 10 00 ??? ?2?!?????.?.
  6. 20: 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 ?..............
  7. 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

To read the sensor, it must first be powered up, the register CTRL_REG1 is responsible. And we need to set register CTRL_REG4 for resolution. Then we can read 3-axis accelerometer value at register OUT_X, OUT_Y and OUT_Z. I find the application information in the datasheet for LIS331DL explained better:
  1. read STATUS_REG
  2. if STATUS_REG(3)=0 then goto 1
  3. if STATUS_REG(3)=1 then some data have been overwritten
  4. read OUT_X
  5. read OUT_Y
  6. read OUT_Z
  7. data processing
  8. goto 1

With the chip datasheet, I modified my program so that it can read 3-axis value from the new sensor as well as the temperature value (only relative temperature change, to measure absolute temperature value, calibration may be required).

I set the sensor at 400Hz, 2g scale and high resolution(HR) mode. In HR mode, each axis has 12-bit data output and takes 2 bytes(L byte and H byte) expressed in 2's complement and left-aligned. Below is a code snippet to convert the raw output data to actual value.
  1. uint8_t acc_x_l = 0;
  2. uint8_t acc_x_h = 0;
  3. int16_t acc_x = 0;
  4. acc_x = (acc_x_h << 8)|acc_x_l;
  5. acc_x >>= 4;

The temperature sensor inside LIS3DH has a similar way to read. First the TEMP_CFG_REG must be set to connect temperature sensor to ADC3, then we read register OUT_ADC3 for data. However, even the ADC supports up to 10-bit data ouput, the sensor is still only 8-bit, which means only the data in OUT_ADC3_H is useful. Also the sensor has a precision about one celsius per digit change.

You can find the source of the program here [SOURCE Here](for both LIS331DL and LIS2DH). Below is the sample program output on my NB30:
  1. >> LIS3DH found ! ID = 0x33
  2. >> dispaly all registers
  3. 0 1 2 3 4 5 6 7 8 9 A B C D E F
  4. 00 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33
  5. 10 | 88 9E 87 20 A0 32 1D 21 1B 90 90 85 C0 00 10 00
  6. 20 | 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20
  7. 30 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  8. >> please enter 'y' to set registers
  9. y
  10. >> enable sensor
  11. >> enable high resolution
  12. >> enable temperature sensor
  13. CTRL_REG1 0x20 = 0x77
  14. CTRL_REG4 0x23 = 0x88
  15. TEMP_CFG_REG 0x1F = 0xC0
  16. >> please enter 'y' to read from sensor
  17. y
  18. X = -49, Y = -1, Z = -945, T = 8
  19. X = -36, Y = 10, Z = -956, T = 8
  20. X = -56, Y = 15, Z = -965, T = 8
  21. X = -35, Y = 1, Z = -914, T = 9
  22. ...



Some other pages to read:

1, SOLDER ANY EXPANSION DIRECTLY TO YOUR COMPUTER’S MEMORY [LINK Here]

2, Hacking DDR3 SPD [LINK Here]

3, TWILight - VGA I²C breakout board [LINK Here]



update on 2019.Mar.01