fubar labs tutorial - hampton sailer · 10/3/2017 introduction to arduino and ide 1 fubar labs...

23
10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors

Upload: others

Post on 30-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

10/3/2017 Introduction to Arduino and IDE 1

Fubar Labs Tutorial

Arduino Motor Control Tutorial

DC Motors, Servo Motors, Stepper Motors

Page 2: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Hampton Sailer, HW Engineer

• 30+ years experience designing microprocessor

based circuit boards.

• 25% of my time with software for debug

• 7 years website design,UI and backend

• TCP/IP Ethernet networking debug

• Lots of power wiring (120 volt) work

• Stage lighting and sound system work

• Home construction and revovation

Page 3: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Arduino Motor Control

• Requirements: some programming experience, a

Laptop, Arduino starter kit (including motors).

• Use ready made hardware – Motor Control Shield

• DC Motors - speed and direction

• Servo Motors (used in R/C models) - position

• Stepper Motors – CNC milling, 3D printers, etc.

• Open loop control, programmed behavior

• Follow through with IDE “Example” codes

• Follow http://www.tutorialspoint.com/

10/3/2017 Fubar Labs - Introduction to Arduino and IDE 3

Page 4: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

DC Motors, Servos, Stepper

• DC hobby motors on Google

• Mabuchi dc motor on eBay

• Really cheap hobby dc motor (Alibaba Express)

• DC+hobby+motor+shaft+coupling

• Hobby King Servo Motos

• Hobby King Sensored-brushless-motor

• Tower Hobbies Servo Motors

• http://www.solo-labs.com/diy-dual-stepper-motor-driver-

shield-arduino/

Page 6: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Heavy Duty Motor Control

• One L298 chip

• Dual “H” Bridge

• Run 2 stepper motors

• Up to 2 amp output

• Up to 46 Volts

• 25 Watts dissapation

• Digital pin control

• $15 or less http://www.learningaboutelectronic

s.com/Articles/2-motor-H-bridge-

circuit.php Qunqi-Controller-Module-Stepper-Arduino

Page 7: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

10/3/2017 Introduction to Arduino and IDE 7

DC Motor “H” Bridge

Page 8: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Reverse motor direction

Page 9: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Careful to program valid logic

• You can “smoke” the

driver transistors if

you turn on the wrong

pair.

• Usually there is some

kind of fuse in the

supply circuit to

prevent damage.

• Go buy some fuses

when learning to

program

Page 10: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

L293 Motor Control Shield

Page 11: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Pulse Width Modulation

• Uno has 6 output

pins that can PWM

• analogWrite(arg)

• analogWrite

• Repeats at 490Hz

• Poor man’s D/A

Page 12: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

DC Motor and Servo Motor

Page 13: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

PWM speed control

Page 14: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Robot Arm driven by hobby Servos

Page 15: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Servo Motors

• Used for hobby device mechanical control

• R/C Airplanes

• R/C Toy Cars

• R/C Boats

• Toy Robots

• Rotate 180 degrees

• Some full rotation

• Low power

• Light weight

• Will hold static position

Page 16: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Inside a Servo Motor

• Small DC motor to

drive a gear chain to

the output shaft.

• Encoder connected to

the output shaft

• Error correction

amplifier to drive DC

motor

• Pulse Train input

Page 17: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton
Page 18: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

• Pulse width duty cycle determines angle of output shaft

• Repeats on a 50 Hz basis in this example

Page 19: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Stepper Motors

10/3/2017 Fubar Labs - Introduction to Arduino and IDE 19

Page 20: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

10/3/2017 Fubar Labs - Introduction to Arduino and IDE 20

Page 21: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

Stepper Motors

Stepper motors effectively have

multiple "toothed" electromagnets

arranged around a central gear-

shaped piece of iron. The

electromagnets are energized by an

external driver circuit or a micro

controller. To make the motor shaft

turn, first, one electromagnet is

given power, which magnetically

attracts the gear's teeth. When the

gear's teeth are aligned to the first

electromagnet, they are slightly

offset from the next electromagnet.

This means that when the next

electromagnet is turned on and the

first is turned off, the gear rotates

slightly to align with the next one

Page 22: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

10/3/2017 Introduction to Arduino and IDE 22

Free Arduino Tutorials

• https://www.arduino.cc/en/Tutorial/BuiltInExamples

• https://www.tutorialspoint.com/

• http://www.me.umn.edu/courses/me2011/arduino/

• http://www.computerprogrammingbook.com/arduino/

• https://playground.arduino.cc/Main/ManualsAndCurriculum

• http://www.free-engineering-books.com/2014/10/the-largest-collection-of-arduino-books.html

• http://www.electronicshub.org/arduino-project-ideas/

• https://randomnerdtutorials.com/arduino-step-by-step-projects/

• https://www.elprocus.com/

• http://arduinolearning.com/code/multi-function-shield-examples.php

Page 23: Fubar Labs Tutorial - Hampton Sailer · 10/3/2017 Introduction to Arduino and IDE 1 Fubar Labs Tutorial Arduino Motor Control Tutorial DC Motors, Servo Motors, Stepper Motors . Hampton

10/3/2017 Introduction to Arduino and IDE 23

Some Hardware Vendors

• Ebay, Aliexpress, Amazon, Sears, Walmart

• https://www.adafruit.com/

• https://www.sparkfun.com/

• http://shieldlist.org/

• www.jameco.com http://www.mpja.com/

• www.digikey.com www.mouser.com

• https://www.dfrobot.com/

• http://www.apcmag.com/12-raspberry-pi-alternatives.htm/

• https://playground.arduino.cc/Main/Resources

• https://www.tindie.com/browse/arduino/