You are on page 1of 35

Intel Do-It-Yourself Challenge

Maestro Pololu USB card


Cdric Andreolli
www.Intel-Software-Academic-Program.com
paul.guermonprez@intel.com
Intel Software
2013-02-08

Agenda

Agenda
Introduction
Configuring the Android project
USB Communications
Manage the Pololu card
Create an App
Conclusion

Introduction

Introduction
The Maestro Pololu is a USB Servo Controller
with the following specifications:

It's cheap =~ 20$

It's very small (4x2cm)

We can use it with Android

This course will explain how to create and


Android application for controlling this card.

Configuring the Android


Project

Configuring the Android Project


We will use Android Intents to launch the
application.
You won't be able to start the app if you don't
plug the Pololu to the phone.
This project uses the Micro Maestro 6 channels
card but you will be able to adapt the code to
another card.

Configuring the Android Project


Create a new Android Application
Create a basic Android application. Choose a
Blank Activity.
In this course, our application is named
PololuUSBController.
Our plan is to create an application that will be launched by
Android when the Pololu is plugged.

Configuring the Android Project


Open the Manifest
Automatic launch can be achieve with Intents
First, change the intent-filter to

You can directly add a meta-data markup to link


a USB device filter

Configuring the Android Project


Create the file device_filter
Create a folder xml in res and add a xml file
(device_filter.xml)

Configuring the Android Project


Retrieve your card information
Plug the Maestro card to your computer and
open a terminal
Type the following command

You can output the command in a file and look


for Maestro

Configuring the Android Project


Retrieve your card information
Result of lsusb -v

Then fill the file device_filter.xml

You will have to use decimal values instead of


hexadecimal

Configuring the Android Project


Install your application
Plug your phone to your computer and install the
application
The applications should not be launched
Plug the Pololu card to the phone with a USB
host cable, Android should ask you
Open PololuUSBController....

USB Communications

USB Communications
Control transfert
To send commands to the card, we will use the
Android ControlTransfert method
We will use the samples to configure the method
parameters

requestType is set to USB_TYPE_VENDOR

request is the operation code

index represents the channel

buffer can be set to null, length to 0

USB Communications
Operation codes
Here are the different operation codes available:

REQUEST_SET_SERVO_VARIABLE = 0x84,

REQUEST_SET_TARGET = 0x85

SET_TARGET allows to change the position of


the servo
SET_SERVO_VARIABLE allows to modify servo
parameters (such as speed and acceleration)

USB Communications
Encapsulate USB communications
Let's create a new Java interface

And a new class that implements this interface

USB Communications
Encapsulate USB communications
Implements the interface with the
controlTransfert method

USB Communications
Encapsulate USB communications

Set position uses the command 0x85, num


corresponds to the servo number
The value of position is in quarter of
microseconds, so we multiply the position by 4

USB Communications
Encapsulate USB communications

Speed can be set by using the command 0x84


(SET_SERVO_VARIABLE)
We just need to provide the speed value

USB Communications
Encapsulate USB communications

Acceleration can be set by using the command


0x84 (SET_SERVO_VARIABLE)
We must use the 4th parameter to set the servo
number and to define the type of variable
To set the acceleration, the most significant byte
of the channel must be 0x8

Manage the Pololu card

Manage the Pololu card


Create a new class
Create a class to manage the pololu card

Manage the Pololu card


Fill the constructor
The constructor is private and is called from a
static method (createCard)

Manage the Pololu card


Provide controls on the servos
The card must be able to send information to the
servo motors

Manage the Pololu card


Provide a builder
The card is built via a static method

Create an app

Create an app
Create your xml view

Create an app
Add behavior
In your activity, in the onCreate method

You write similar code for acceleration


and speed

Create an app
Add behavior

Create an app
Other improvements ?
You can use the sensors to automatically
activate the servo motors
You can use the GPS data to modify servo
motor's behaviors
Intel organize a contest on para-glider
autonomous drones using those technologies

Conclusion

Conclusion
Control your card with your Intel phone
An Intel phone is a computer, you can program it
to control the Maestro card
Take advantage of the powerful CPU, sensors,
GPS, etc that the Intel phone can provide
If you have ideas that use Intel hardware and
Pololu cards, feel free to let us know

License Creative Commons - By 3.0


You are free:
to Share to copy, distribute and transmit the work
to Remix to adapt the work
to make commercial use of the work
Under the following conditions:
Attribution You must attribute the work in the manner specified by the author or licensor (but not in
any way that suggests that they endorse you or your use of the work).
With the understanding that:
Waiver Any of the above conditions can be waived if you get permission from the copyright holder.
Public Domain Where the work or any of its elements is in the public domain under applicable law,
that status is in no way affected by the license.
Other Rights In no way are any of the following rights affected by the license:
Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
The author's moral rights;
Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.

Notice For any reuse or distribution, you must make clear to others the license terms of this work.
The best way to do this is with a link to this web page.
http://creativecommons.org/licenses/by/3.0/

You might also like