Physical prototyping lab6-motors

Post on 10-Feb-2017

163 views 0 download

transcript

PHYSICAL PROTOTYPING

© 2011 K3 Creative Commons v3.0 SA-NC

Lab 6: Motors

With the Arduino prototyping board

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

micro() Returns the number of microseconds since the

Arduino board began running the current program

Returns a long Works the same way as millis()

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

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

random value to the computer.

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)

constrain()

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

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.

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

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

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

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

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

STEPPER 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

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()

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()

Power

Battery packs Rechargables Ampere * Volt = Watt Biltema

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.

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.

Transistor

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

PWM)

How to hook up a motorusing IRF Z24

Copyright Kajsa Sahlström and Matilda Marcelius

How to hook up a motorusing BC547

DANGER!

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...

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

a analog sensor Create a gaspedal!