Physical prototyping lab6-motors

26
PHYSICAL PROTOTYPING © 2011 K3 Creative Common Lab 6: Motors With the Arduino prototyping board

Transcript of Physical prototyping lab6-motors

Page 1: Physical prototyping lab6-motors

PHYSICAL PROTOTYPING

© 2011 K3 Creative Commons v3.0 SA-NC

Lab 6: Motors

With the Arduino prototyping board

Page 2: Physical prototyping lab6-motors

millis()

• millis(); returns the number of milliseconds the arduino has been on

• Useful when you want two things to happen at once ”semi threading”

• Returns a long• Examples/Digital/Blinkwithoutdelay

Made by: David Sjunnesson

Page 3: Physical prototyping lab6-motors

micro() Returns the number of microseconds since the

Arduino board began running the current program

Returns a long Works the same way as millis()

Page 4: Physical prototyping lab6-motors

Random

• random(min, max) • Returns a pseudorandom number

between min and max. • random(10,50) returns a number

between 10-49• randomSeed();• randomSeed(analogRead(4)); Gives you

a better random value

Page 5: Physical prototyping lab6-motors

Try it out• Create a program that randomly in time sends a

random value to the computer.

Page 6: Physical prototyping lab6-motors

map()

Re-maps a number from one range to another Useful when a sensor sends one range of

values but you need it in another. map(value, fromLow, fromHigh, toLow, toHigh)

Page 7: Physical prototyping lab6-motors

constrain()

Constrains a number to be within a range. Helps to make sure a value is in a certain range constrain(value, minimum, maximum)

Page 8: Physical prototyping lab6-motors

Try it out!

Create a program that maps your value from a potentometer from the read range into another and sends it back to the computer.

Page 9: Physical prototyping lab6-motors

MOTOR• Actuator that transforms electricity into movement• Motors can be of different kinds: DC, stepper, servos, etc. Each type has a different

way of being driven• New motors can be very expensive. In many cases we will not be interested in high

accuracy and precission, just in showing the basic functionality• It is in those cases when dismounting some kind of motor-driven device will be

useful to acquire the basic components for our design• Car-toys, electric razors, printers, CD-drives, old hard drives, cash registers, and

many devices contain motors that we should be able of using

Page 10: Physical prototyping lab6-motors

TYPES OF MOTORS• There are three main types of motors

– DC motors: they are used in toys and devices that do not need high degrees of accuracy in terms of speed or angle. With certain circuits that can be improved

– Stepper motors: they can move to a very precise position. We find them in printers, scanners, etc

– Servo motors will move and stop at a certain angle on request. They are used in car models to control the direction, model-planes for the flaps, etc

Page 11: Physical prototyping lab6-motors

TYPES OF MOTORS• DC motors:

– run freely– hard to control their position/speed– can use as less as 2,5Volts– speed can be controlled using PWM– we use relays, transistors or H-bridges to control them from Arduino– with encoding circuits can become very precise

Page 12: Physical prototyping lab6-motors

DC MOTORS: PWM• PWM stands for Pulse Width Modulation. Microprocessors cannot produce pure

analog signals, nor can they provide enough current to drive motors• Through calculating the average value of a sequence of pulses, microprocessors

emulate the generation of analog signals• It is with PWM that we can change the speed of a DC motor. It is anyway needed the

use of a transistor, since the pins on Arduino cannot handle the amount of current to move the motor

PICTURES © their authors

Page 13: Physical prototyping lab6-motors

STEPPER MOTORS• Stepper motors:

– 2 types: unipolar or bipolar– rotate a certain amount of degrees at each pulse– typical values of angles are 1,8 - 3,6 - 7,2 ... – we use transistors, transistor chips, and H-bridges to control them– they have 4 or more wires– RepRap

Page 14: Physical prototyping lab6-motors

STEPPER MOTORS

Page 15: Physical prototyping lab6-motors

SERVO• they will rotate to a certain angle depending on a PWM value we push into them• recently there are continuous rotation servos• broadly used in robotics

Page 16: Physical prototyping lab6-motors

SERVO/Continuous

• Connect the servo to the arduino • Black ----> Arduino ground• Red -----> Arduino 5v+• White ----> Arduino motorPin

• Make it move Clockwise or Counter-clockwise depending on the values read from a potentiometer

• Usefull functions is map()

Page 17: Physical prototyping lab6-motors

SERVO/Standard

• Connect the servo to the arduino • Black ----> Arduino ground• Red -----> Arduino 5v+• White ----> Arduino motorPin

• Make it move to a specified angle depending on the values read from a analog input

• Usefull functions is map()

Page 18: Physical prototyping lab6-motors

Power

Battery packs Rechargables Ampere * Volt = Watt Biltema

Page 19: Physical prototyping lab6-motors

Transistor

• The transistor is considered by many to be the greatest invention of the twentieth century. It is the key active component in practically all modern electronics.

Page 20: Physical prototyping lab6-motors

Transistor

• A transistor is a semiconductor device, commonly used to amplify or switch electronic signals. The transistor is the fundamental building block of computers, cellular phones, and all other modern electronic devices.

Page 21: Physical prototyping lab6-motors

Transistor

• We use transistors for:– turning DC devices on/off: motors, lamps, etc– dimming DC lights– changing the speed of motors seamlessly (using

PWM)

Page 22: Physical prototyping lab6-motors

How to hook up a motorusing IRF Z24

Copyright Kajsa Sahlström and Matilda Marcelius

Page 23: Physical prototyping lab6-motors

How to hook up a motorusing BC547

Page 24: Physical prototyping lab6-motors

DANGER!

Page 25: Physical prototyping lab6-motors

Relay• A relay is an electrical switch that opens and closes under the

control of another electrical circuit • Makes it possible to control big stuff with Arduino• Control up to 220V with 5v from Arduino• Cant control speed...

Page 26: Physical prototyping lab6-motors

Hook it UP! Connect a DC motor and control the speed with

a analog sensor Create a gaspedal!