Download presentation
Presentation is loading. Please wait.
1
IR & Servos Lab 3 Spring Quarter
2
Servos DC Gearhead motor with interface circuitry
Often used for angular positioning Can be “hacked” to act as a standard DC Gearhead motor Instructor: When hacked, the positional control is removed. Directions for hacking the motor can be found on the web. Spring Quarter
3
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 Spring Quarter
4
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 Instructor: Many teams found this is not necessary for this lab, but is very useful when used on the robot. Spring Quarter
5
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 ( ); Instructor: Servo_deg(); is the common command used by the students; the 0 to 180 degree range is easy to deal with as compared to a period. Spring Quarter
6
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? Spring Quarter
7
IR – Specifics Use Sharp GP1U5 IR detector Looks for a 40kHz IR pulse
Used to reduce interference Also rumored to be used due to legacy remote controls (ultrasonic) Spring Quarter
8
IR – Waveform Specifics
Another waveform is “modulated” on this 40 kHz carrier Instructor: The 40 kHz carrier is the smaller waveform on the top waveform. The 100 Hz “data” signal is the waveform shown on the bottom waveform. The actual frequency of the IR is too fast to be shown. Spring Quarter
9
IR – Handy Board detection
Handy Board can look for 100Hz, 125Hz signals Handy Board looks for a matching waveform by sampling and pattern matching Instructor: Routines have been written to look for other types of signals, but the ones used for this lab detect 100 and 125 Hz signals. Spring Quarter
10
IR – Waveform matching Signal Stored copy of signal X X X X X X X X
Instructor: This is how the Handyboard determines the frequency of the signal. The signal is compared against a stored copy of the signal. If they match, then the function returns a nonzero integer. X X X X X X X X X X X X Stored copy of signal Spring Quarter
11
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 Instructor: As the signal gets weaker, the count still increases until there is no signal detected, then a zero is detected. This can cause problems with “overshoot” since the highest number received doesn’t correspond to the strongest signal detected. Spring Quarter
12
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 ! ! Instructor: Taking up so many resources means that using other programs at the same time may cause problems, such as a shaft encoder routine losing counts. Spring Quarter
13
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 Instructor: Ir_counts returns a higher integer depending on how long the signal has been detected. Spring Quarter
14
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 Instructor: Tell them to try out different ways to compensate for overshoot. Spring Quarter
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.