Top Banner
Microcontroller Microcontroller Hands-on Workshop Hands-on Workshop #3 #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009
25

Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

Dec 27, 2015

Download

Documents

Kevin Watkins
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

Microcontroller Hands-Microcontroller Hands-on Workshop #3on Workshop #3

Ahmad ManshadNew Mexico State University

Institute of Electrical and Electronics Engineers

November 7, 2009

Page 2: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

2

Agenda for TodayQuick ReviewMore sensors (Infrared)Introduction to pulse width modulation

(PWM)Controlling motors with the ArduinoBegin working on robot

Page 3: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

3

Today’s Kit1. Arduino Microcontroller/ USB Cable

2. Breadboard

3. 1x Red LED

4. Infrared Sensor

5. Wires

6. Soldering Iron w/ solder

7. Freeduino Motor Controller

Page 4: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

4

Quick Review - Codeint ledPin = 13; // LED connected to digital pin 13

void setup(){ pinMode(ledPin, OUTPUT); // sets the digital pin as output}

void loop(){ digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second}

Page 5: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

5

Quick Review - Breadboard

Page 6: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

6

Infrared Proximity SensorSend infrared light through IR-LEDs, which is then

reflected by any object in front of the sensor.

Page 7: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

7

Infrared Proximity SensorSender: IR Emitter LED

Receiver: IR Detector LED w/ an operational amplifier.

Page 8: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

8

Solder Wires to IR SensorLeft pin (1) – SIGNALMiddle pin (2) – GROUNDRight pin (3) – POWER( +5 volts)

1

2

3

Page 9: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

9

How to Solder Wires to IR Sensor

1. Warm up the iron

2. Prepare a moisten sponge

3. Apply heat to the lead.

4. Apply solder to the lead

5. Allow solder to cool down

6. Inspect the connection

Page 10: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

10

IR connected to arduino - CODE

Page 11: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

11

Pulse Width Modulation PWM signal is a digital square

wave where the fraction of the time the signal is on can be varied between 0 and 100%.

Call analogWrite(pin, dutyCycle), where dutyCycle is a value from 0 to 255.

Use one of the PWM pins (3, 5, 6, 9, 10, or 11).

Page 12: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

12

Applications of Pulse Width ModulationDimming an LED

Generating audio signals.

Generating a modulated signal, for example to drive an infrared LED for a remote control.

Providing variable speed control for motors.

Page 13: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

13

Motors Electromechanical device that converts electrical energy to mechanical energy

Page 14: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

14

Motors!DC Motor

Servo Motors

Stepper Motor

Page 15: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

15

DC Motor

ProsSimple & cheap (only 2 wires)Fast & can be geared down for higher torqueEasy to reverseSpeed control through PWM

ConsNo built-in feedback

Page 16: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

16

Servo Motor (DC motor w/ feedback)

ProsSimple (3 wire) and “Standard”accurate even under loadHigh torque

ConsSlowerMore expensive

Page 17: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

17

Servo Motor

Page 18: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

18

Simple Motor DriverMotors are inductive loads and require a high

current

Use a transistor to switch the high-current load

Page 19: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

19

H-Bridge

An H-bridge is an electronic circuit which enables a voltage to be applied across a load in either direction.

Often used in robotics and other applications to allow DC motors to run forwards and backwards.

H-bridges are available as integrated circuits, or can be built from discrete components (i.e. four switches)

Page 20: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

20

H-BridgeS1 and S4 closed - positive voltage applied across

the motor. S2 and S3 closed - voltage is reversed, negative

voltage applied.S1 and S2 (or S3 and S4) closed – short circuit!

Page 21: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

21

Freeduino Motor ControllerControl 2 motors from your ArduinoSN754410NE motor driver

Board and Arduino pinout:Motor A Direction -

Arduino Digital pin 13Motor A Speed (PWM)

- Arduino Digital pin 10

Motor B Direction - Arduino Digital pin 12

Motor B Speed (PWM) - Arduino Digital pin 9

Page 22: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

22

Assembling Freeduino Motor Controller

GO TO: WWW.GOOGLE.COMTYPE: FREEDUINO MOTORCLICK ON THE FIRST LINK

CLICK THE LINK: “THIS GUIDE”

Or Type the following in the address bar:http://mcukits.com/2009/03/12/assembling-the-freeduino-

arduino-motor-shield/

Page 23: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

23

Soldering Components to PCB

Page 24: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

24

Robot Design

Discuss Robot Plans with Team Members!

Page 25: Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.

25

Questions or

Comments?