Author Archives: admin

Matrix 3 Axis Accelerometer and FriendlyARM NanoPi.

Matrix is a new set of sensor and driver expansion or break-out boards from FriendlyARM. Matrix has been designed with the FriendlyARM NanoPi Series in mind and most of the Matrix devices will work with a big variety of microprocessors with some GPIO, IIC, and SPI. (I set up the kernel and Debian by the directions on the FriendlyARM Wiki. Beginning at “Make OS Image”. There are some errors and several places that can be confusing. I will duplicate the directions with more detailed notes on another post.)

The first device I have tested is the 3 axis accelerometer. This is a board with an Analog Devices ADXL345 which can measure up to plus and minus 16g or 156 meters/s/s. The sample software for Matrix uses the default plus or minus 2g setting. The wiring is simple and uses 8 female-female jumpers. Two of these are interrupts and are not needed for the example code. The Accelerometer Wiki page at FriendlyARM shows adding the Matrix sample library to the NanoPi Debian. (There are some confusing bits and I will add some notes on that on the blog entry about building the kernel and OS).

NanoPi with 3 axis accelerometer.

NanoPi with 3 axis accelerometer.

I set up a small machinists rotary indexing table on its side so I could set any angle I liked. The device measures acceleration and the most convenient acceleration around the lab is the Earth’s gravity. Change the angle of the PCB and the values of the X, Y and Z components By shear luck and unrivaled instrumentation skills the PCB of the accelerometer aligned nearly perfectly so that rotation of the indexing table and the chip’s X-axis were co-axial, meaning I could ignore the X-axis output because it would never change. Here is the setup with X perpendicular to the face of the rotary indexer – pointing out of the screen so to speak. Y is to the right, and Z is straight up. These are all relative to the chip, or surface of the PCB. Rotate it 90 degrees to the right clockwise, and Z will point right and Y straight down.

AccN45s

A word about the ADXL345. According to the data sheet, in 2g mode the data is 10 bits in X, Y, and Z, with a 1g reading that varies from 230 to 282 from axis to axis and chip to chip. Any project that uses inertial navigation or measures angles (like a smartphone level app) will need to be calibrated. Does that mean you need an accurate fixture to align each axis with g? No, three arbitrary rotations can be used as long as they meet a simple constraint I’ll describe later. Here is a reading from the above setup. The Z-axis on this chip has a 1g reading of 238.

root@nanopi:~# matrix-3_axis_digital_accelerometer
Get position: (2, 1, 238)

The data sheet gives an RMS noise value of 0.75 LSB (least significant bit) for X and Y and 1.1 LSB for Z. In my fixed rotation test this is around 1 degree noise in X and Y and a little more in Z. Averaging readings will reduce the noise proportional to the square root of the number of readings.

Theory behind this test: I’m assuming that the three nano-scale tuning forks that make up the accelerometers are truly orthogonal – they are independent and measure the components of an acceleration. This means the square root of X squared plus Y squared plus Z squared is the magnitude of any acceleration being experienced by the device.

What does this all mean? Since the X axis was aligned well enough to not change and gave a reading close to zero, I can calculate acceleration from square root of Y squared plus Z squared. I can also get the angle of the board from the inverse tangent of Z/Y. I’ll see if I can get a diagram in here. Here is the setup at 45 degrees.

AccN60as

Testing at various angles (and normalizing using the 1g in Z of 238 and the 1g in Y of 272) I compared the indexer angle to the calculated angle. Here mg is milli-g’s and 1g = 1000mg. For calculating the angle of the PCB, only the ratios are used so scaling is not needed. Calibration, yes. Scaling no. Just use the ratio as the vector components of g in order to find the angle form the vertical. Here is an explanation. Imagine the V in that link points straight up and the diagrams are rotated to match.

MatrixAccCalc

 

 

 

 

FriendlyARM NanoPi

Note: ARMWorks (www.andahammer.com) is having a week long sale with some 7″ ARM11 6410 systems at nearly half price.

I have been able to experiment with the new NanoPi from FriendlyARM. This is a Samsing S3C2451 400 MHz ARM that can run Debian (Jessie as of Aug 2) and use all the FriendlyARM LCDs. It has ‘Pi’ in the name because the double row 0.1″ header is Raspberry Pi compatible. But, the NanoPi also has WiFi and Bluetooth. Plus, the MicroUSB is recognized as Ethernet by Ubuntu or Fedora and you can SSH into the NanoPi to set up your WiFi connection and do anything else you would do with SSH. The NanoPi is half the size of an RPi at 30x75mm and much lower power usage.

NanoPiPan

Anyway, I was able to very easily with just a few commands, prepare a uSD with the bootloader (u-boot) and Debian Jessie. I connected the USB and the board started up. SSH worked fine and with two commands I had set up my WiFi and restarted the service. I pinged a few places without problems and I had a FriednlyARM P43 4.3″ LCD attached and all looked good.  SSH worked just as easily on Fedora 20 and the MicroUSB was recognized as an Ethernet gadget.

FriendlyARM has gone full Open Source on the software and there is work to do. The camera driver is not finished and I’m sure there are plenty of projects to use the GPIO and make sure it can drive various Pi expansion boards. If you are a driver/kernel/application tuner, check out the Github repos and dive in. WiFi camera with a decent battery sounds like a good project for me.

I had to send my samples out to developers and as soon as I get more I’ll do a power test and a test with a LiPo battery and a muRata DC/DC converter while WiFI is running. These 3 pin devices are like a TO-220 package and will provide 5V at 1.5A 90% efficiency. Digikey has them. There are cheaper eBay solutions bit none this small and simple and in volume these are $3.70.

Next, the FriendlyARM Matrix sensor and driver add-ons usable with NanoPi, Raspberry Pi, and basically all the FriednlyARM boards with GPIO.