Application Note. Communication between arduino and IMU Software capturing the data

Similar documents
Motion Capture for Runners

IMU: Get started with Arduino and the MPU 6050 Sensor!

Practical Assignment 1: Arduino interface with Simulink

ZX Distance and Gesture Sensor Hookup Guide

Application Note AN 102: Arduino I2C Interface to K 30 Sensor

Lesson 3: Arduino. Goals

smraza Getting Start Guide Contents Arduino IDE (Integrated Development Environment)... 1 Introduction... 1 Install the Arduino Software (IDE)...

ARDUINO BASED CALIBRATION OF AN INERTIAL SENSOR IN VIEW OF A GNSS/IMU INTEGRATION

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Coding with Arduino to operate the prosthetic arm

Arduino Lesson 1. Blink. Created by Simon Monk

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

EARTH PEOPLE TECHNOLOGY. EPT-200TMP-TS-U2 Temperature Sensor Docking Board User Manual

9DoF Sensor Stick Hookup Guide

TWEAK THE ARDUINO LOGO

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

Veyron Servo Driver (24 Channel) (SKU:DRI0029)

APDS-9960 RGB and Gesture Sensor Hookup Guide

LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

Welcome to Arduino Day 2016

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Module: Arduino as Signal Generator

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Getting Started with the micro:bit

Arduino

Understanding the Arduino to LabVIEW Interface

DragonLink Advanced Transmitter

Master Op-Doc/Test Plan

Tarocco Closed Loop Motor Controller

BW-IMU200 Serials. Low-cost Inertial Measurement Unit. Technical Manual

Application Note AN 157: Arduino UART Interface to TelAire T6613 CO2 Sensor

Flight control Set and Kit

Arduino An Introduction

BW-VG525 Serials. High Precision CAN bus Dynamic Inclination Sensor. Technical Manual

CPSC 226 Lab Four Spring 2018

Experiment 1: Robot Moves in 3ft squared makes sound and

INA169 Breakout Board Hookup Guide

High Voltage Waveform Sensor

IX Feb Operation Guide. Sequence Creation and Control Software SD011-PCR-LE. Wavy for PCR-LE. Ver. 5.5x

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

10 Things to Consider when Acquiring a Nanopositioning System

FLCS V2.1. AHRS, Autopilot, Gyro Stabilized Gimbals Control, Ground Control Station

Introduction to the Analog Discovery

1Getting Started SIK BINDER //3

RigExpert TI-7 USB Transceiver Interface User s manual

Using the S5U13781R01C100 Shield Graphics Library with Atmel Studio

LoRa Quick Start Guide

On the front of the board there are a number of components that are pretty visible right off the bat!

Revision 1. March 21, ADC Operation Manual N 11 th St San Jose CA

Blue Bamboo P25 Device Manager Guide

INSTRUCTIONS. 3DR Plane CONTENTS. Thank you for purchasing a 3DR Plane!

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

The wiring is relatively simple. You should put the module on one of the compatible Arduinos. The following are compatible:

Master Thesis Presentation Future Electric Vehicle on Lego By Karan Savant. Guide: Dr. Kai Huang

Programming 2 Servos. Learn to connect and write code to control two servos.

nrf24l01+ Transceiver Hookup Guide

AUTOPILOT QUICK START GUIDE

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Catalog

iphoto Getting Started Get to know iphoto and learn how to import and organize your photos, and create a photo slideshow and book.

SPEEDBOX Technical Datasheet

MINIMUM SYSTEM REQUIREMENTS

Servomotor Control with Arduino Integrated Development Environment. Application Notes. Bingyang Wu Mar 27, Introduction

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Topcon Receiver Utility: GNSS Receiver Firmware Update Process. Oscar R. Cantu

Lab 4 Rev. 1 Open Lab Due COB Friday April 6, 2018

LC-10 Chipless TagReader v 2.0 August 2006

INTRODUCTION to MICRO-CONTROLLERS

INTRODUCTION to MICRO-CONTROLLERS

Pico-Satellite Training Kit HEPTA-Sat: Hands-on Practices for Space Engineering

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Milli Developer Kit Reference Application Published on Silver Spring Networks STAGE (

Internet of Things Student STEM Project Jackson High School. Lesson 2: Arduino and LED

M-16DX 16-Channel Digital Mixer

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

AS726X NIR/VIS Spectral Sensor Hookup Guide

Zybo Z7 Pcam 5C Demo

HG1120 INERTIAL MEASUREMENT UNIT (IMU) Installation and Interface Manual

IMU60 Inertial Measurement Unit

Troubleshooting Rig Connection Issues

Quick Start. Precis-BX305. Precise GNSS RTK Board.

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

INTRODUCTION to MICRO-CONTROLLERS

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

Catalog

Studuino Color Sensor Manual

Sensors Fundamentals. Renesas Electronics America Inc Renesas Electronics America Inc. All rights reserved.

Using the USB2.0 camera and guider interface

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

Light Emitting Diode IV Characterization

PalmGauss SC PGSC-5G. Instruction Manual

Touch Potentiometer Hookup Guide

Arduino Setup & Flexing the ExBow

Attack on the drones. Vectors of attack on small unmanned aerial vehicles Oleg Petrovsky / VB2015 Prague

isys-4004 GUI interface - V2.1 Power up Initialize Peripheral Start Measurement YES LED flashes red Object available LED blinking

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

Transcription:

Application Note Communication between arduino and IMU Software capturing the data ECE 480 Team 8 Chenli Yuan Presentation Prep Date: April 8, 2013

Executive Summary In summary, this application note is about how to have the arduino communicate with IMUs. In order to achieve that goal, the effort is put into two major parts, the hardware connection and software programming. This application note is focused on the software part. It will guide users through how to correctly choose the libraries corresponding to the hardware components used by design team, how to write the code which will tell arduino to read the data from the sensors, the way to have the software display captured data in the serial monitor in an intuitive form, and the method of time stamping the data. This application note is based on the team s experience of using arduino software provided with hardware from Sparkfun. Keywords Controller & Sensors communication, Arduino Software, Library, Code Functions, Time Stamping, Serial Monitor Introduction Team 08 is tasked to design a product that captures the motion of a runner, and then analyzes the captured data with the data of an elite runner, which is stored as a baseline in the comparison software. At last, the product send feedback to the runner in order to have the runner corrects his running posture immediately. This task can be divided in to three major parts: data capturing, post processing and feedback. For the first part, which is data capturing, it is important to have correct data from sensors and smooth communication between IMUs and Arduino, otherwise, it will be impossible to go to the following two major parts. In order to correctly program the Arduino, programming software named arduino-1.0.3 is chosen to be the solution of programming the Arduino because this software is provided from the same company that fabricates the Arduino. The advantages of using this software are: ensured compatibility between software and hardware, intuitive user interface, plenty of build-in examples and library for team to consult and test. Three main libraries included in the team s coding: Wire.h Arduino Wire library, required if I2Cdev I2CDEV_ARDUINO_WIRE implementation is used in I2Cdev.h. I2Cdev.h I2C specialized pins function library, required if I2C buses is used for data transferring. MPU6050.h MPU6050 IMU library, modified to be compatible with IMU-9150, which is the sensors solution of design team. Some main functions used in the team s arduino programming are the followings: Serial.begin (baudrate) initialize serial communication.

Accelgyron.initialize() initialize device (IMUs). Accelgyro.GetMotion9 build-in function of MPU6050.h, read 9 axis measurements from device. String prints the data points into a string Serial.print print the text or data string to the serial monitor Micros() useful when doing time-stamping, give time in microseconds. These codes will be discussed in details, and relative examples of how to use these code swill be provided in following section. Objectives 1) To have the Arduino continuously read data collected by IMUs. Besides hardware connection and setup, correct software programming is required. Furthermore, write code which can indicate that the Arduino and sensors are collecting data, i.e. using on-board LED. 2) The arduino software should be able to print the data collected by Arduino. Use serial monitor to verify whether the collected data is correct or not. Use serial monitor of arduino software for testing IMUs and debugging purpose. 3) Time-stamp the collected data, which is important when using multiple sensors. 4) Transfer data points from IMUs to a string, so that the data can be used for post processing. 5) Modify the display format of collected data to give an intuitive visual result. Preparation & Arduino software set-up

The figure above shows a hardware connection of the IMU and Arduino. This application note will not go deeper into the hardware specification of the design. However, one thing needs to be mentioned before programming is that in order to upload the software programming into the board, the Arduino needs to be connected with computer via an usb cable. Besides powering the board, all the data communication including program upload is done using usb connection, and the usb connector is located in the top right corner of the Arduino. Furthermore, the on-board memory has a size of 32Kb, which means the file size of our programming can not exceed that limitation. If it does reach the maximum allowed size, simplification for codes and modification for libraries will be necessary to control the actual size of the uploaded program file to ensure the program stored in Arduino is in complete form. Software Set-up Arduino-1.0.3 is provided with the hardware board on the Sparkfun s website and is free to download at http://arduino.cc/en/main/software. For stability purpose, the team chooses version of 1.0.3, which is not the latest version but it is recommend for stability and compatibility purpose. After correctly install the software and launch it, one will get the following user interface: On the bottom right corner of the software interface, it indicates the number of serial port which the Arduino is connecting to. However, for first time users, the detection might be wrong because there is another software issue with Arduino installation of driver. To install the driver, do the following steps:

1) Disconnect the Arduino from computer and plug in the board again; Windows will begin its driver s installation process automatically, wait until the automatic driver installation fails. 2) Click on the Start Menu, and open up the Control Panel. While in the Control Panel, navigate to System and Security, and then click on System. Once the System window is up, open the Device Manager. 3) Look under Ports (COM & LPT), one should see an open port named Arduino UNO (COMxx) (xx is the number of serial port, which varies depending on different computers). 4) Right click on the Arduino UNO (COMxx) port and choose the Update Driver software option. Next, choose the Browse my computer for Driver software option. 5) Finally, navigate to and select the Arduino Uno s driver file, named ArduinoUNO.inf, located in the Drivers folder of the Arduino Software download. 6) Wait until windows finish up the driver installation from there. Now the Arduino should be recognized by windows and be ready to use. Users can check if the Arduino is working in device manager, similarly, the number of serial port the Arduino is connecting to can be found there. The tutorial above is the guide of installing drivers for the Arduino Uno with Windows OS. More information about installing drivers for MAC OS or Linux can be found at http://arduino.cc/en/guide/homepage. Once the users get to this step, go back to arduino software and finish the software set-up and configuration. To choose the right Arduino board, from the menu bar, select Tools > Board > Arduino UNO.

In order to let the arduino software upload program to Arduino board, configure the serial port number. From the menu bar, select Tools > Serial Port > COMxx. Add libraries Once the software set up is done, user can proceed to next step adding libraries. Libraries are a collection of code that makes it easy for users to use the functions of an Arduino. Arduino

software comes with some build-in libraries like SPI, WiFi and SD. Adding additional libraries can extend the ability of Arduino. It is also required if user want to connect additional parts like sensor, display and modules to Arduino. In the team s design project, two important libraries added are MPU6050 and I2Cdev. MPU6050 library is used for MPU6050 sensor, which is an earlier version of MPU9150. The difference between them is MPU6050 is a 6-axis motion capture sensor composed of a 3-axis accelerometer and a 3-axis gyroscope. MPU9150 is a newer version which is capable of doing 9-axis measurement with an additional magnetometer. Because of the similarity shared by the two sensors, an MPU6050 library is easily modified to be compatible with MPU9150. In order to add the necessary library, firstly, download the MPU6050 libraries from http://www.i2cdevlib.com, the libraries distributed are ZIP files. Uncompress the ZIP file, and copy the desired libraries folder into the software s libraries folder:. Libraries in red box are essential for the design project; make sure they are added to the correct path. Arduino Programming & Examples The team develops a code that allows the Arduino continuously read data from IMU including all

9-axis measurements from accelerometer, gyroscope and magnetometer. Then convert the data to string format so that it can be used for post processing. Furthermore, for debugging purpose, the team adds code that have the arduino software display collected data in a serial monitor. Key functions are explained and relative examples are shown below. Set-up code #include xxx.h add libraries to program (xxx is the name of librairy) As mentioned before, the three main libraries are one build-in library named Wire.h and two additional libraries added by team named I2Cdev.h and MPU6050.h. Because the communication chosen in the design project is I2C, corresponding libraries need to be added in advance to active the communication. Between the two libraries related to I2C communication, Wire.h is used to support the functioning of I2Cdev.h. As for the MPU6050.h, it is code library specifically used for IMUs. Build-in functions of this library allows the user to get data of 9-axis measurement with one single command, which makes the programming much easier. Example of adding library: Serial.begin (baudrate) the speed of transferring data, replace baudrate with number of desired speed. Wire.begin() active the I2C bus. Both of the two codes are used for setup purpose. The I2C communication does not automatically active, thus use this build-in code from library trigger on the data transition of I2C bus. The Arduino support several baud rates, i.e. 9600, 38400 and so on. Higher baud rate allows more data to be transmitted in a unit time. For accuracy purpose, a high baud rate is chosen in the design to ensure that plenty of data is collected. However, faster data collection also means more power consumption, thus the tradeoff of durability and accuracy needs to be taken into consideration. Example of setting baud rate:

Data related code (data capturing, transform, display and time-stamping) Accelgyro.initialize() build-in function of MPU6050.h, used to initialize the sensors. Accelgyron.GetMotion9 build-in function of MPU6050.h, used to commend Arduino to read dara from sensors. Both of the two codes above are built into the IMU library. For the second code, the captured data is in the order of x, y, z axis of accelerometer; x, y, z axis of gyroscope; x, y, z axis of magnetometer respectively. By assigning variables names to these captured data, it will be easier to use or transmit those data in other code. Example of having Arduino read data from sensors & name the captured data: Define the name of IMU sensor and xyz axis measurement variables for accelerometer, gyroscope and magnetometer respectively. The first code prints text message in serial monitor when IMU is initializing. The second code reads the data from IMU and assigns the captured data to the pre-defined variables. String transfer the data into string format The reason the team wants to put the data into sting format are the followings: 1) Data in string format can be directly transmitted to other via Xbee. 2) MATLAB can read data of string format.

3) String formatted data can be easily change back to number. Example of printing the data points into a string: The code above firstly changes all numerical value to strings and then combines them into a single one. Serial.print prints data or text to the serial monitor In order to understand the data collected by the sensors, the team writes the code that prints data to serial monitor. Even though it is not necessary for final product, it is helpful during the test phase. By monitoring the continuous updated data, the team can know if the Arduino and sensors are working as expected. Example of prints data and text to the serial monitor: The first picture shows a text message in the serial monitor when Arduino is testing the connection with IMUs. Once the test passes, the program proceeds to the second main function looping the codes in the second picture. In that manner, the data is being continuously displayed. Micros () & Millis() Give user time in microseconds or milliseconds These two are useful codes for time-stamping. To use these two codes, first define time variables, and then assign the variable with one of the codes. At last, use serial.print to display timing information in serial monitor.

Arduino working status related code In final design, we will not have the chance to monitor the serial port, so the team needs to come up with something else to verify if the Arduino and IMUs are working or not. The way is to utilize the on-board LED indicator. The idea is to have LED keep blinking if it is reading data. Example of LED coding: Define the variables relates to LED and LED statues. Name pin 13 as LED_PIN, and set the initial state of LED be off. Add this code in the setup part. Because all the analog and digital pins on Arduino can be either an output pin or input pin, the mode needs to be chosen before using them. Because the team wants to send control signal to LED, the pin is used as output pin. Add this code in the loop. Every time the Arduino capture data from sensors, the on/off statues of LED changes. PIN 13 is a digital pin, so use digitalwrite to change the output signal of that pin. Results This is a result of correct programming. The IMU is not moving at the beginning, thus the measurement of 9-axis almost stay constant. For the first three values, they stand for acceleration of xyz axis. Only one of them is large, which makes sense because while holding the IMU one side up, only y axis experience the earth gravity and have a large acceleration. The other two axes have a relatively much smaller acceleration. The gx, gy and gz are the angular speed of three axes; they are close to 0 under a very large resolution, which is also correct. As for the last three values, they record the strength of magnetic field on different direction. The magnetic field changes under different situation with different surroundings. However, these values are in the range of measurement, and they did change when IMU is moved. It is proved that the data capturing is working and the programming is correct.

Serial Monitor results: One thing needs to be noted, while in the serial monitor, choose the same baudrate used in the code, otherwise, no reasonable results will be shown because it is monitoring other baudrate. Conclusions and Recommendations After getting familiar with the arduino software and get all preparation done, the team successfully does a programming with arduino software. By following all the steps listed above, the team is able to write a code to have the Arduino read data from sensor, change the format of data, and display the result in a serial port intuitively. Furthermore, a LED indicator will indicate the working statue of device. One aspect of the programming that can be modified is to make the data easier to understand. Currently, the data is kept as it was; conversion is done in the post processing. If the user does not understand the meaning of this value, it will be difficult to debug during the programming development phase. There are two solutions, first, using a newer IMU library which is able to directly give speed and angle information instead of binary value (or corresponding decimal value). Second, write those conversion programs directly in the program. However, there is some disadvantage with this recommendation. While the library is having more build-in functions, the size of library increases. If the whole program exceeds the 32 Kb limitations, user cannot upload the whole program to Auduino. To sum up, if the size of program can be limited under certain value, the team can consider using a more complex library to have the Arduino deal with more data processing.