Fun with 3-Axis Acceleration Sensor BMA020

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc

Moderators: roger, 99jonathan, imaqine

Fun with 3-Axis Acceleration Sensor BMA020

Postby s.frings » Sat Jan 07, 2012 6:52 pm

I just bought a 3-Axis Acceleration Sensor from ELV in germany and have great fun with it. This chip is much cheaper than the "official" Tilt sensor from Hitechnics. The chip provides 3 10bit values that are automatically refreshed in a configurable time interval.

Datasheet: http://www.datasheetdir.com/BMA020+download

ELV put the chip onto a small board with a 2,5V power regulator and a set of MOS transistors as level shifters. The board is not compatible to Lego but this can be fixed easily: Just remove the four pull-up resitors and the level-shifter transistors for the two I2C bus wires. The internal 4k7 resistors in the NXT do proper level shifting already (verified with an oscilloscope).

If you plan to use the chip directly, the following hints might be helpful:
- Use a 2,5V regulator for both VDD and VDDIO. The power consumption is less than 1mA.
- Configure the I/O interface as I2C bus in the following way:
- Connect SDO to GND
- Connect CSB to VDD
- The INT line is not used
- Use two 82k Pull-up resistors for the I2C bus, which are the pins SDI and SCK
- SDI is bidirectional
- The I2C bus can be connected directly to the next without level shifters

The following example program displays the three numeric values and draws 3 bars on the display. It does not configure the chip because the defaults are already ok. The program uses only the most significant 8 bits, to keep it simple.

Code: Select all
package de.butterfly;
import lejos.nxt.*;
import javax.microedition.lcdui.Graphics;

// Test program for an Acceleration Sensor Bosh BMA-020

public class Main {
   
    // Buffer for I/O
    static byte buffer[]=new byte[8];

    // I2C bus address of the sensor
    static int i2cAddress=0x70;
   
    // Paints onto the display
    static Graphics g=new Graphics();
   
    public static void main(String[] args) throws InterruptedException {
        SensorPort.S1.i2cEnable(I2CPort.STANDARD_MODE);
       
        LCD.drawString("X=",0,0);
        LCD.drawString("Y=",0,1);
        LCD.drawString("Z=",0,2);       
       
        while (true) {
            buffer[0]=0x00; // First register to read
            int count=SensorPort.S1.i2cTransaction(i2cAddress,buffer,0,1,buffer,0,8);
            if (count==8) {
                int x=buffer[3];
                int y=buffer[5];
                int z=buffer[7];
               
                LCD.drawInt(x,4,3,0);
                LCD.drawInt(y,4,3,1);
                LCD.drawInt(z,4,3,2);
               
                // Clear bars
                g.setColor(255,255,255);
                g.fillRect(0,26,99,42);
                g.setColor(0,0,0);
               
                // Draw X-Bar
                x/=2;
                if (x<0)
                    g.fillRect(50+x,26,-x,4);
                else
                    g.fillRect(50,26,x,4);
               
                // Draw Y-Bar
                y/=2;
                if (y<0)
                    g.fillRect(50+y,32,-y,4);
                else
                    g.fillRect(50,32,y,4);
               
                // Draw Z-Bar
                z/=2;
                if (z<0)
                    g.fillRect(50+z,38,-z,4);
                else
                    g.fillRect(50,38,z,4);
            }
            else {
                LCD.drawString("----",3,0);
                LCD.drawString("----",3,1);
                LCD.drawString("----",3,2);
            }
        }
    }
}
Last edited by s.frings on Sun Jan 08, 2012 4:28 pm, edited 2 times in total.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: Fun with 3-Axis Acceleration Sensor BMA020

Postby gloomyandy » Sat Jan 07, 2012 6:58 pm

Do you have a link for the ELV web site?

Thanks

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Fun with 3-Axis Acceleration Sensor BMA020

Postby s.frings » Sat Jan 07, 2012 7:18 pm

s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm

Re: Fun with 3-Axis Acceleration Sensor BMA020

Postby TuRRiCAN » Fri Mar 23, 2012 9:07 am

Hello,
sorry for my "stupid question" - I'm very new to all this.
I remove the transistors and so on, but how do I connect the board with the NXT properly? (Or with a socket to stay "plug"able?)

Thanks

TuRRiCAN
TuRRiCAN
New User
 
Posts: 1
Joined: Fri Mar 23, 2012 8:44 am

Re: Fun with 3-Axis Acceleration Sensor BMA020

Postby s.frings » Fri Mar 23, 2012 6:38 pm

SInce the Lego cables have special connectors, you need to cut one of the original cables. You can easily order new cables from the Lego online shop.

The cable connections are:

3 = red = GND
4 = green = VCC 4,3 Volt
5 = yellow = SCL
6 = blue = SDA

Image
The two 82k Ohm resitors, the red wires and also the lead connection between SDO and GND are required.

I hope you did not forget to bridge the Gate-Source connectors of the solder pads of T3 and T4 (that are removed), otherwise the two digital lines are effectively not connected to the sensor chip.
s.frings
Active User
 
Posts: 131
Joined: Tue Jul 20, 2010 2:01 pm


Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff