Presentation is loading. Please wait.

Presentation is loading. Please wait.

Working with Photorestistors

Similar presentations


Presentation on theme: "Working with Photorestistors"— Presentation transcript:

1 Working with Photorestistors
MAKING YOUR ROBOT SEE Working with Photorestistors 6/3/2019 1

2 RC Time and Photo-Sensors
RC is the product of the resistor value wit the capacitor value RC is proportional to the time taken for the power in the capacitor to reduce to its minimum or increase to its maximum, we’ll call this RCtime RCtime is proportional to the resistance of the photosensors As light increases, do you think the resistance of the photo-sensors will increase or decrease? Decrease – the resistance is extremely low if placed in direct sunlight 6/3/2019

3 How the Photo-Sensors Work
By comparing the RCtime for each sensor. Remember!! More light means less RCtime If the ________ (left/right) sensor has less RC time, then there’s ________ (more/less) light on the left. By introducing a deadband Take the absolute difference between the left and right RCtimes The robot does nothing if this value is within the deadband which you will choose If the value falls outside the deadband, then make appropriate adjustments, that is, ask the robot to turn left or right This prevents the robot from changing directions unnecessarily 6/3/2019

4 Illustration Assume I want my robot to follow some light source:
First I introduce a dead band, 2 (if not the robot will be too sensitive): If the difference between the left and right RCtimes is less than 2, then move forward. If not, then turn in the direction with the least RCtime (i.e. with more light) Here’s what will happen: 6/3/2019

5 Illustration Right Left The robot keeps going forward until the direction of the light changes, then it turns in that direction. 6/3/2019

6 Question What do you have to do to make your robot turn away from the light? 6/3/2019

7 Illustration This is what you want:
Right Left The robot moves in the opposite direction from the light 6/3/2019

8 How About on Paper? Paper works the same as light, but you must follow some precautions: Uniform lighting in the room is very important, as bright lights or dark shadows can deceive the robot White paper is not as powerful as light, so the sensors should be far over the front of the robot, but not too close as this may cause some shadowed following 6/3/2019

9 How About on Paper? Your Robot should be able to follow a black (or dark colored) line on white paper. You will need to adjust the deadband from the light source follower program. Also, note that you are now following the darkness… i.e. you are avoiding the light… so what do you need to change? 6/3/2019

10 Illustration This is what you want: The robot moves on the black line
Right Left The robot moves on the black line 6/3/2019

11 But How Do You Program It?
First declare a space where you will store your left and right RCtimes Then reset the servo ports, that is the ports that control the left and right wheels (you should know the commands for this) Then start the main program  left_photo var word right_photo var word low 12 low 13 6/3/2019

12 Main Program First declare a label for the main program so you can always return there: Then set the left and right photo-sensor ports (p3 and p5) to high, measure their RCtime values, and save them in the space you declared earlier Main: high 3 pause 3  need some time to obtain rctime rctime 3,1,right_photo high 5 pause 3 rctime 5,1,left_photo 6/3/2019

13 Main Program Check if the difference between the left and right RCtimes is within the deadband, if yes it is, move forward, if not, move in the direction of the dark line. if abs(left_photo-right_photo) > 7 then check_dir forward_pulse: pulsout 12, 500 pulsout 13, 1000 pause 20 goto main  this loops the command, remember remember you had previously declared ‘main’ The name of a routine you call to tell the robot to turn in the direction of the line Move left and right wheels forward 6/3/2019

14 Routines Now we need to tell the robot was check_dir means, basically, we are saying that if the left rctime is less than the right rctime, then the black line is in the right direction, so the robot needs to turn right, otherwise, the line is in the left direction so the robot should turn left. Right turn routine check_dir: if left_photo < right_photo then right_pulse if left_photo > right_photo then left_pulse Left turn routine 6/3/2019

15 Navigation Routines Right Turn Routine right_pulse: pulsout 12, 1000
pause 20 goto main Turn right left_pulse: pulsout 12, 500 pulsout 13, 500 pause 20 goto main Turn left 6/3/2019

16 Trouble Shooting Now what do you do if your program doesn’t run as expected? If the lighting in the room changes, it may affect the Rctime of your sensors, so you might need to adjust the deadband number a bit. If you’re following a dark line, the deadband number should be smaller in brighter areas and larger in darker areas. Sometimes the position of your sensors might be shifted, so make sure they are positioned properly. Check to see if your left and right wheels are flipped. If they are just flip the values for ports 12 and 13 in all routines. 6/3/2019

17 Now Your Turn Make paths with different turn angles and see if you can make your robot follow it. Hint: you may have to play around with the deadband a bit. For all turns you try, determine the lowest and highest deadband value you can set with which the robot will still follow faithfully. These are your deadband ranges. 6/3/2019


Download ppt "Working with Photorestistors"

Similar presentations


Ads by Google