IR & Servos

14
Lab 3 P. 1 Engineering H193 - Team Project Spring Quarter Gateway Engineering Education Coalition IR & Servos Lab 3

description

IR & Servos. Lab 3. Servos. DC Gearhead motor with interface circuitry Often used for angular positioning Can be “hacked” to act as a standard DC Gearhead motor. Servos – Handy Board Specifics. Handy Board uses PWM to command servo to desired angular position - PowerPoint PPT Presentation

Transcript of IR & Servos

Page 1: IR & Servos

Lab 3 P. 1

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR & Servos

Lab 3

Page 2: IR & Servos

Lab 3 P. 2

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Servos

• DC Gearhead motor with interface circuitry

• Often used for angular positioning

• Can be “hacked” to act as a standard DC Gearhead motor

Page 3: IR & Servos

Lab 3 P. 3

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Servos – Handy Board Specifics

• Handy Board uses PWM to command servo to desired angular position

• Handy Board can control 2 servos (second servo requires alternate source of 5 volts)– Digital port 9– TOC3 port (under LCD)

• Need to include library files – Servo.icb– AND Servo.c– OR servo.lis

Page 4: IR & Servos

Lab 3 P. 4

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Servo - Calibration

• Servo.c constants may need "calibrated" to make full use of servo

• To do so, use servo (x) command– Set MIN_SERVO_WAVETIME=0,

MAX_SERVO_WAVETIME=10000 (interaction window)

– Reduce x (>1400) until servo is at 0°– Increase x(<4860) until servo is >180°– In your main program, assign new values to

the global variables MIN_SERVO_WAVETIME and MAX_SERVO_WAVETIME

Page 5: IR & Servos

Lab 3 P. 5

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Servo – use

• Load servo.lis • To turn servo on – servo_on ( );• To command servo -

– servo (int period);– servo_rad (float radians);– servo_deg (float degrees);

• To turn servo off – servo_off ( );

Page 6: IR & Servos

Lab 3 P. 6

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Infrared (IR) Basics

• EM wave – 1013- 1014 Hz• Many things give off IR

– Remote controls– Sun– Fluorescent lights– Handy Board

• How do we avoid interference from all these sources?

Page 7: IR & Servos

Lab 3 P. 7

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Specifics

• Use Sharp GP1U5 IR detector– Looks for a 40kHz IR pulse

• 40kHz?– Used to reduce interference– Also rumored to be used due to legacy remote

controls (ultrasonic)

Page 8: IR & Servos

Lab 3 P. 8

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Waveform Specifics

• Another waveform is “modulated” on this 40 kHz carrier

Page 9: IR & Servos

Lab 3 P. 9

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Handy Board detection

• Handy Board can look for 100Hz, 125Hz signals

• Handy Board looks for a matching waveform by sampling and pattern matching

Page 10: IR & Servos

Lab 3 P. 10

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Waveform matching

Signal

Stored copy of signal

X X X X

X X X X

X X X X

X X X X

X X X X

Page 11: IR & Servos

Lab 3 P. 11

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Handy Board specifics

• Handy Board checks incoming signal for match w/ stored copy

• When they match, ir_counts return a number from 1 to 255

• If there is no match, 0 is returned• The longer the receiver sees a valid signal, the

higher the count• If you look away, counts goes to 0

Page 12: IR & Servos

Lab 3 P. 12

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Handy Board use

• Handy Board does not handle mixed mode arithmetic

• Must use casting operators - angle=(float)deg where deg is integer and angle is floating point

• IR reception can take as much as 30% of HB resources ! !

Page 13: IR & Servos

Lab 3 P. 13

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

IR – Handy Board functions

• void set_ir_receive_frequency (int f) ;• void ir_receive_on ( );• void ir_receive_off ( );• int ir_counts (int p);

– Where you should note that:– ir_counts (5) => from digital port 15– ir_counts (4) => from digital port 14

Page 14: IR & Servos

Lab 3 P. 14

Engineering H193 - Team Project

Spring Quarter Gateway Engineering Education Coalition

Lab

• Write code to seek out an IR beacon– Scan a servo over 180°– Return to angle where beacon is located

• Try for accuracy, fast search time