Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessors Tutorial 2: Arduino Robotics

Similar presentations


Presentation on theme: "Microprocessors Tutorial 2: Arduino Robotics"— Presentation transcript:

1 Microprocessors Tutorial 2: Arduino Robotics

2 Agenda 1. Robot Anatomy 2. Sensor Review 3. PWM 4. MAKE: Fade
5. Motors 6. H Bridge 7. Robot Control library 8. MAKE: Robot react 9. Challenge: Solve Maze 10. Links

3 Robot Anatomy

4 Robot Anatomy

5 Sensor Review Example:
Analog Arduino mapping: 0-5V  3 connections: V+, pin, GND Serial Monitor: Use Serial.begin(9600) to start communication Use custom function serialOutputValue(“msg”, value) to see sensor value in serial monitor This robot has IR range sensor: Outputs V (0-600 in Arduino) Peaks at 15cm, farther objects create lower voltage BUT code inverts relationship! Example: Example 1 Analog_in

6 Pulse Width Modulation
Duty cycle = percentage of time signal is positive in square wave Min-Max voltage: 0 – 5v Min-Max Arduino mapping: 0 – 255 PWM pins have a ~ on Arduino 10% average 50% average 90% average

7 Challenge: Fade Increments
Make: Fade Use analogWrite(pin, value) to fade light on/off using for loop to vary value Remember PWM range is 0-255 Recall LED connection: long leg = positive small resistor in series necessary Challenge: Fade Increments Use PWM to fade the led from 0 to full in 5 seconds, hold for 2 secs, fade back down in 7 seconds. Then each loop would do it faster and faster or brighter and brighter!

8 Motors They draw more current than USB/Arduino can supply (40mA per pin, 200mA in total) so need another power supply: batteries Current through in 1 direction turns them in 1 direction More voltage = More speed, how to control voltage? Use electronically controlled switch (transistor) between motor and batteries Use PWM pin to control switch Motors in this robot run on V and have a peak current of 1A.

9 H- Bridge Used to make 1 motor turn in either direction by directing current use 4 switches controlled by 2 signals

10 H- Bridge The IC we will use (SN754410N) has 2 H-Bridges to control 2 motors PWM is used here at the enable pin to control speed A

11 Robot Control Library Example:
Written by Sebastien Parent-Charette last year Get sensor values with updateSensorRangeState() And values state_sensor_range_value Display with serialOutputValue(“msg”, value) Change directions with modifyMotorState(motor, direction, speed) Followed by updateMotorState() Example: Example 3: Spin_in_a_Loop

12 MAKE: Robot Move MAKE: Robot React
Change code in Example 3 so you are in control For example, go forward 5s, stop, turn right 90˚, forward, backwards, left 270 ˚ and come back. Use modifyMotorState(motor, direction, speed) updateMotorState() MAKE: Robot React When you feel comfortable, add sensor information Use Example 4: Wall stop, as a base Get sensor data with updateSensorRangeState() Use state_sensor_range_value to decide on a move

13 CHALLENGE: solve the maze!
Create your own algorithm to beat the maze using Example 0: Template Or start from our other example codes Example 4, 5, 6

14 Useful Links http://www.jeremyblum.com/category/arduino-tutorials/
Arduino Examples MAKE projects Jeremy Blum Tutorials (#5: motors and transistors)

15 academics@ieee.concordia.ca ieee.concordia.ca
Questions? Comments? Suggestions? ieee.concordia.ca


Download ppt "Microprocessors Tutorial 2: Arduino Robotics"

Similar presentations


Ads by Google