33
Hands-on Learning: Platforms to Teach Programming Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Hands-on Learning: Platforms to Teach Programming - Freescale

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Hands-on Learning: Platforms to

Teach Programming

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Eric Gregori

[email protected]

• Eric Gregori is an Embedded Firmware Product Specialist at

Freescale Semiconductor. He is a robot enthusiast with over

15 years of embedded firmware design experience.

• His specialties are computer vision, artificial intelligence, and

programming for Windows® Embedded CE, Linux®, and

Android™ operating systems. Eric authored the Robot Vision

Toolkit, and developed the RobotSee Interpreter.

• Eric writes for Robot magazine (www.botmag.com), and has a

blog about Robotics and Embedded Systems

at: http://blogs.freescale.com/author/ericgregorifsl/

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

My headshot

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session Description

• “I hear and I forget. I see and I remember. I do and I understand.” – Confucius.

People of all ages benefit from using interesting tools to teach complex concepts.

This presentation covers the tools Freescale uses for hands-on training on complex

topics, such as sensor programming, Computer Vision, Android programming, and

microcontrollers.

• The low-cost Freescale Robot ( FreeBot ) is a 4 Degrees Of Freedom walking

robot with touch sensors, and a 3-axis accelerometer. The robot is a sensor

programming training assistant, used in hands-on classes around the world. The

robot is upgradeable with a low-cost embedded Linux computer converting it into a

Linux/Android programming and Computer Vision training platform.

• The Freescale i.MX53 Quick Start Board is a inexpensive yet powerful embedded

Linux computer. Packing a whopping 1GHz ARM® Cortex™-A8 processor with 1GB

of RAM into a 3-inch by 3-inch package. The i.MX53 is used for Linux and Android

programming training.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

How to Teach

Sensor Programming

• The best part of my job is conducting training

– Focus on Embedded Linux, Android and Sensor Software training

– Students range from master programmers to those that have not

programmed since college

• Added computer vision to robots with the Robot Vision Toolkit

– Open source project

– Simple programming language called RobotSee

• RobotSee is a great way to teach sensor programming!

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

WebcamsComputer Vision

Devices Supported by the

Robot Vision Toolkit

JoySticksGamePads

SpeechRecognitionMP3/WAV play

NeroSky™ MindsetBrain Interface

Walking Robots Rolling RobotsGPS ( NEMA ) Robot Arms

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

How to teach Sensor Programming

Now we had a language for sensor training that was easy to

learn but what about the platform?

The platform had to be:

1. Interactive

2. Interesting

3. Affordable

4. Unique

A walking robot would make a perfect sensor training platform!

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

The Freescale Sensor Trainer

1. Interactive• 12-channel touch sensor

• 3-axis accelerometer

• Plug-in sensors for expansion

• 4-RC servos

2. Interesting• It’s a walking robot!!!

3. Affordable• Only $199.00

4. Unique• A 4DOF walking robot with a 3-

axis accelerometer touch sensor

and 32-bit, 512K flash,64K RAM

microcontroller with built-in

debugger

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Success• We did multiple sensor trainings using the robot and the

Robot Vision Toolkit. They were all very well received with

positive reviews.

• The training platform worked out so well that Freescale

decided to sell it. On April 4th, we will be releasing the Robot

platform for sale on the Freescale website at $199.00.

• The platform includes support for programming in RobotSee,

C, or C++. We are starting a community around the robot on

TowerGeeks.org.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Example Lab Slides

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Lab 1 : Using the accel in 1D mode

• In this lab, only 1 channel of the accelerometer is used.

• The data is displayed using the graphics library in the robot

vision toolkit.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Graphics Language Extension

RobotSee

Graphics

Language Extension

winpen( width, r, g, b )winbmp( "filename", "copy_type", r, g, b )winline( pen, x1, y1, x2, y2, plane )winimg(bmp, x, y, plane)winbut( bmp, x,y )wineditline( handle, x1, y1, x2, y2, plane )wineditimg(bmp,x,y, plane )wineditbut( bmp )wingetbut()wingetmouse()winupdate( )

Hardware

Language Extension

servos( )leds( )usbopen()readtouch( )readaccel( )readsensors( )iicwrite( )iicread( )spiwrite( )spiread( )

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

X

z

Y

Y – Axis of Accel

Z –

Axis

of A

cce

l

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Graphics Keywords• winpen( width, r, g, b ) // Create a pen of a specific width and color• winbmp( "path_filename", "copy_type", r, g, b ) // Create a image from a bitmap• winline( pen, x1, y1, x2, y2, plane ) // draw a new line from xy1 to xy2• winimg( bmp, x, y, plane ) // display a new image at x,y• winbut( bmp, x,y ) // display a button using a bitmap at x,y• wineditline( handle, x1, y1, x2, y2, plane ) // modify a lines properties• wineditimg( bmp, x, y, plane ) // modify a images properties• wineditbut( bmp ) // modify a buttons properties• wingetbut() // get a button click event from the queue• wingetmouse() // get last mouse click x,y,button info• winupdate( ) // update the window with current changes

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Lab 2: Balancing on 1 Leg

using 2 Channels

• In this lab, 2 channels of the accelerometer are used and

combined using trigonometry into a vector. The resulting

vector is used in a closed loop control algorithm to make the

robot balance on 1 leg.

• The data is plotted in real-time using the Robot Vision Toolkits

data plotter.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Measuring Roll using the Y and Z

axisX

z

accel

Y

Z

Y

Gravity

SOHCAHTOA

Tan = opp/adj

Tan(a) = Y/Z

a

Z^2+Y^2 = 1g

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Lean to One Side

// p10=leftankle, p9=lefthip, p8=rightankle, p7=righthip

gosub(guimove,dump,leftankle=136,lefthip=128,rightankle=118,righthip=117)

print( "\nLeaning Right" )

// p10=leftankle, p9=lefthip, p8=rightankle, p7=righthip

gosub(guimove,dump,leftankle=111,lefthip=128,rightankle=118,righthip=117)

// p10=leftankle, p9=lefthip, p8=rightankle, p7=righthip

gosub(guimove,dump,leftankle=110,lefthip=128,rightankle=96,righthip=117)

soundplay( "WavFiles\playgames.wav" )

for( temp = 25 )

faceled = rand( 0, 7 )

gosub( ledtalk, dump )

delay( 100 )

next( temp = temp - 1, temp > 0 )

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Take a calibration reading- this will be your setpointgosub( calcangle, calibrate )

calcangle:

local( decimal )

local( whole )

local( ltemp )

local( ax )

local( ay )

local( az )

readaccel( ax, ay, az )

if( ax & 0x80 ); ax = ax - 0x100; endif()

if( ay & 0x80 ); ay = ay - 0x100; endif()

if( az & 0x80 ); az = az - 0x100; endif()

print( "\n x = ", ax, " y = ", ay, " z = ", az )

ltemp = atan( 1000, az, ay )

if( az<0 && ay<0 ); ltemp+=180000; endif()

if( az<0 && ay>0 ); ltemp+=180000; endif()

if( az>0 && ay<0 ); ltemp+=360000; endif()

if( ay == 0 ); ltemp = 0; endif()

if( az == 0 ); ltemp = 270000; endif()

whole = ltemp/1000

decimal = ltemp

decimal -= whole*1000

decimal = abs( decimal )

print( " = ", whole, ".", decimal, " degrees" )

return( ltemp )

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Closeloop control servo around

the setpointinfloop:

rate = 10

gosub( calcangle, angle )

error = calibrate/10000

error -= angle/10000

if( error > 0 ); rightankle += 1; endif()

if( error < 0 ); rightankle -= 1; endif()

print( " error = ", error )

if( rightankle < 85 ); rightankle = 85; endif()

if( rightankle > 110 ); rightankle = 110; endif()

if( rightankle > 90 ); leftankle = 120; endif()

if( rightankle < 90 ); leftankle = 90; endif()

print( " right = ", rightankle, " left = ", leftankle )

gosub(guimove,dump)

goto( infloop )

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Plotting Calibrate and Error

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Play Video

• http://www.youtube.com/watch?v=aS_KxpGbPaw

Chumby Walking Robot Demo

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Play Video

• play video

Linux and Android Training

• A hands-on class is most effective when the attendees get to

take the labs home with them after the class.

• For years I have been teaching embedded Linux

programming on systems that cost thousands of dollars.

• The number one request from students ( especially college

students ) was the availability of low-cost tools.

• The i.MX53 is a low-cost ( $149.00 ) high performance

embedded Linux development system.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Do all the training on the

development system, then take it

home with you!!

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Easy to use tools actually get used

The Problem:

• Many development boards are incomplete.

• When someone purchases a training tool, they want the open-

box-experience to be as trivial as possible.

• They want something that will let them concentrate on the

training.

The Solution:

• The i.MX53 Quick Start Board boot to Ubuntu out of the box.

• No extra cables to buy, no host computer required

• Just add a USB mouse, keyboard, and VGA monitor

• www.freescale.com/imxquickstart

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Just as important as the training

is the material available after the

training

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.

Thank YouPlease join us in the networking lounge for a

Q&A Chat

And please do not forget to visit the Freescale Booth

www.freescale.com/robotics

Session sponsored by

Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other

product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.