1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

Electrical team Arduino tutorial I BY: JOSHUA arduini
Lab7: Introduction to Arduino
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
How to use Arduino By: Andrew Hoffmaster.
Embedded Sumo 1T4 – 1T5 UTRA.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
Intro to Programming and Microcontrollers. Activity Group into pairs and sit back-to-back. Pick one person who is going to draw. The other person will.
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Arduino Part 1 Topics: Microcontrollers Programming Basics: structure and variables Digital Output Analog to Digital Conversion.
chipKit Sense Switch & Control LED
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Introduction to the Arduino
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi. Objectives 1. Control the rotation of standard servo motor  A standard servo motor is limited in its rotation.
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Introduction 2 Smart Design. What is smart design? 2 Everything is designed except nature The packaging of a Band-Aid The curve of a bike frame The shape.
Code The Arduino Environment.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
SAMI MAKERSPACE MAKE: AN ELECTRONICS WORKSHOP. ARDUINO BASICS Credit to: Sparkfun and Linz Craig, Nick Poole, Prashanta Aryal, Theo Simpson, Tai Johnson,
Microcontrollers, Microcomputers, and Microprocessors
Arduino libraries Datatekniker Udvidet hardware/software.
Microcontroller basics Embedded systems for mortals.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Bdps 2 Lecture 2. Circuits and Ohm's Law For resistive circuits.
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
Introduction to Programming the Arduino Dr Gaw 3/21/14.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
ME 120: Arduino Programming Arduino Programming Part 1 ME 120 Mechanical and Materials Engineering Portland State University
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Having fun with code, using Arduino in a middle school CS classroom
Arduino.
Arduino Part 1 Topics: Microcontrollers
INTRODUCTION TO ROBOTICS Part 5: Programming
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Microcontroller basics
Val Manes Department of Math & Computer Science
Microcontroller basics
Arduino & its hardware interfacing
Arduino Programming Part II
UTA010 : Engineering Design – II
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Arduino 101 Credit(s):
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Arduino programs Arduino toolchain Cross-compilation Arduino sketches
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Lab #1: Getting Started.
Arduino Uno circuit basics
Setting up a basic program with Arduino
UNIT 1 First programs.
Arduino程式範例.
Introduction to Arduino IDE and Software
Presentation transcript:

1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University

2 We need to calibrate the Hapkit so that we know what positions and forces we are working with in real, translational units (meters and Newtons) Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Motor calibration: Given a desired force output (based on what we want our haptic VE to feel like), what duty cycle must we command? 1. Assume you start with the desired force at the handle in Newtons. (Since this the force that your haptic virtual environment will generate) 1. Using the kinematic equations for force/torque, find what motor pulley torque (tp) is required to generate that force. Add this to your code. 1. The lab has determined a calibration equation to compute the PWM duty cycle needed to generate this torque. In Arduino code, it is: duty = sqrt(tp/0.03); Activity: Calibrate Sensor and Actuator 2

3 We need to calibrate the Hapkit so that we know what positions and forces we are working with in real, translational units (meters and Newtons) Stanford University Introduction to Haptics © Allison M. Okamura, 2013 MR sensor calibration: Use angle markings on your Hapkit sector, the Serial Monitor (SM), and r handle to determine x handle. Manually record a series of about 10 sector angles (degrees) and their corresponding A/D output values. Plot these sector angles in Excel with angles on vertical axis (y) and A/D outputs on horizontal axis (x) and fit a straight line. Record the m and b parameters of the fit y = mx + b. Convert sector angle to radians, and then use kinematics to convert sector angle to handle position in meters. Add the equations from steps 3 and 4 to your code, and test using the Arduino Serial Monitor. Activity: Calibrate Sensor and Actuator 3

4 Programming the Hapkit Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino is a single-board microcontroller that makes using electronics in multidisciplinary projects relatively easy The Hapkit board is based on the Arduino design, with some added features The Hapkit board can be programmed using the same Arduino integrated development environment (IDE) as an Arduino board Follow the instructions in the handout to download, install, and test the Arduino software 4

5 Arduino Programming Language Components Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino reference materials obtained from under a Commons Attribution- ShareAlike 3.0 License.Commons Attribution- ShareAlike 3.0 License StructureVariablesFunctions Basic syntax Arithmetic operators Control structures Comparison Operators Boolean Operators Constants Data types Scope Digital I/O Analog I/O Math Serial communication Defining your own 5

6 Structure: Basic Syntax Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino reference materials obtained from under a Commons Attribution-ShareAlike 3.0 License.Commons Attribution-ShareAlike 3.0 License Each statement ends in a semicolon. For example: int a = 13; Curly braces always come in pairs; they are used to define the start and end of functions, loops, and conditional statements. For example: while (boolean expression) { statement(s) } Single line comment Multi-line comment Used to give a name to a constant value. For example: #define ledPin 3 ; {} // /* */ #define 6

7 Structure: Basic Syntax Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino reference materials obtained from under a Commons Attribution- ShareAlike 3.0 License.Commons Attribution- ShareAlike 3.0 License Each statement ends in a semicolon. For example: int a = 13; Curly braces always come in pairs; they are used to define the start and end of functions, loops, and conditional statements. For example: while (boolean expression) { statement(s) } Single line comment Multi-line comment Used to give a name to a constant value. For example: #define ledPin 3 ; {} // /* */ #define 7

8 Structure: Arithmetic Operators Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino reference materials obtained from under a Commons Attribution-ShareAlike 3.0 License.Commons Attribution-ShareAlike 3.0 License Assignment operator stores the value to the right of the equal sign in the variable to the left of the equal sign: sensorVal = analogRead(FSRPin); Addition, subtraction, multiplication, and division. For example: result = value1 + value2; result = value1 - value2; result = value1 * value2; result = value1 / value2; where value1 and value2 are any variables or constants =+-*/=+-*/ Tips: Choose variable sizes that are large enough to hold the largest calculated result For math that requires fractions, use float variables (but there are drawbacks) Check for order of operations; use parentheses to enforce order 8

9 Example Hapkit Program Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Programming Area Code: // Blink the pin 13 LED void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } material courtesy Paulo Blikstein The Arduino programming language is similar to C and Java 9

10 Structure: Control structures Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Arduino reference materials obtained from under a Commons Attribution-ShareAlike 3.0 License.Commons Attribution-ShareAlike 3.0 License Creates a loop for repetitive operations. for (initialization; condition; increment) { //statement(s); } for 10

11 Running a Hapkit Program Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Click File > Upload Clicking Upload sends the code from the computer to the Hapkit board material courtesy Paulo Blikstein or click the Upload button Your code is now running on the Hapkit Board! What is the LED doing? 11

12 Programming syntax/hints Stanford University Introduction to Haptics © Allison M. Okamura, 2013 Use // before any text you want to have as a comment (and comment well!) Each statement must end with a ; (semicolon) You must declare variables before you use them Call built-in Arduino functions to perform I/O (input/output) See for a language reference that describes structure, variables, and functions If you have never programmed before, the easiest way to learn is by looking at and modifying example programs. Don ’ t modify too many things at once before testing your code. Many examples under File > Examples 12

13 Understanding the code Stanford University Introduction to Haptics © Allison M. Okamura, 2013 // Blink the pin 13 LED void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } material courtesy Paulo Blikstein void setup() { … } Any code inside the setup function runs once to setup the Arduino void loop() { … } Any code inside the loop function loops over and over again 13

14 Understanding the code Stanford University Introduction to Haptics © Allison M. Okamura, 2013 // Blink the pin 13 LED void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } material courtesy Paulo Blikstein void setup() { … } Any code inside the setup function runs once to setup the Arduino void loop() { … } Any code inside the loop function loops over and over again 14

15 Understanding the code Stanford University Introduction to Haptics © Allison M. Okamura, 2013 // Blink the pin 13 LED void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } material courtesy Paulo Blikstein pinMode(Pin Number, INPUT or OUTPUT) This tells the Arduino whether the pin is an input (ie. sensor, switch) or an output (i.e. LED, motor). You will connect Pin 13 to an LED. The other pins can be externally connected to whatever you want! 15

16 Understanding the code Stanford University Introduction to Haptics © Allison M. Okamura, 2013 // Blink the pin 13 LED void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } material courtesy Paulo Blikstein digitalWrite(Pin Number, HIGH or LOW) This makes the specified pin HIGH (a digital 1) or LOW (a digital 0). The LED is on if it is HIGH and off if it is LOW. We first make the LED turn on by making pin 13 HIGH, then we make it turn off by making pin 13 LOW. Digital 1 = +5 Volts = HIGH Digital 0 = 0 Volts = LOW delay(Milliseconds) This makes the Arduino wait for the specified number of milliseconds. Without the delay, the LED would blink so fast, you wouldn't notice! 16