Download presentation
Presentation is loading. Please wait.
Published byRamiro Veazie Modified over 10 years ago
1
Welcome to Workshop 88’s Arduino 301: Control the World! Please have your Arduino, IDE, and breadboard fired up and ready to go. ver 1.0 2/2/14
2
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Bonus demo: BLDC motor intro Some of this is Arduino, some basic electronics.
3
Please Introduce Yourself! Name, job, school etc Why you’re here Programming in general, and with Arduino in particular Electronics experience: Digital? Analog? AC house wiring? Hobby stuff: Robots? RC vehicles?
4
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Some of this is Arduino, some basic electronics.
5
Direct connect Arduino I/O pin hardware capabilities
6
Direct connect Arduino I/O pin hardware capabilities Atmel AVR processor
7
Direct connect Arduino I/O pin hardware capabilities 4 states – Output: HIGH: ~5V, source ~20 mA – Output: LOW: ~0V, sink ~20 mA – Input: Hi-Z, no pullup – Input: 38KΩ pullup to Vcc (5V often) Absolute Max V: Vcc + 0.5V Atmel AVR processor
8
Atmel AVR Pins: Output
10
Atmel AVR Pins: Input - Normal
11
Atmel AVR Pins: Input - Pullup
12
Atmel AVR Pins: Input - Button
13
How do you know the details? Look at the datasheet!
14
Direct connect (Output!) LED (with resistor!) Some input expecting a “logic level” Opto isolator (looks just like an LED!)
15
Direct connect: PWM Digital output are either ON or OFF but a computer can turn them ON and OFF really fast. If fast enough you get an effect in between ON and OFF. Works great for LED brightness control.
16
Direct connect: PWM The usual approach is called Pulse Width Modulation AVR chips support PWM only on certain pins. Arduino does PWM by analogWrite(pin,value). Must do pinMode(pin, OUTPUT); analogWrite() accepts 8-bit values (0-255).
17
Direct connect: PWM
18
(demo with scope)
19
Direct connect: PWM LED lab Run up 2 LEDs, fading up/down, 180° out of phase.
20
Direct connect: PWM and LEDs PWM is especially good for dimming LEDs since brightness is directly related to current. Varying voltage to an LED+resistor doesn’t work well at low levels.
21
Direct connect: PWM and LEDs (demo LED with PWM v varied voltage using scope meters)
22
Direct connect: logic level input “TTL” standard Servos (we’ll cover those later) Serial communication Any device with I2C or SPI interface
23
Direct connect: logic level input
24
Direct connect: opto isolator
25
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Bonus demo: BLDC motor intro This is all basic electronics.
26
More muscle: Relays & Transistors Let us control higher CURRENT Let us control higher VOLTAGE Sometimes provide ISOLATION
27
More muscle: Relays Classic open-frame relay
28
More muscle : Relays What you’re likely to use: a reed relay
29
More muscle : Relays Inside a reed relay
30
Relays: Snubber! Snubber, clamp, flyback, suppressor, free- wheeling, catch diode Do some kind of demo
31
Snubber/Freewheel/Clamp Diode
32
More muscle : Transistors We can use transistors as electronically controlled switches. (Sort of like a relay, but often better.)
33
More muscle : Transistors Lots of kinds of transistors We’ll use two: Common bipolar Metal Oxide Field Effect (MOSFET)
34
More muscle : Transistors: Bipolar This is the most common type of bipolar transistor, and is the one we’ll use here.
35
More muscle : Transistors: Bipolar Think of it as this: In general, transistors can be considered amplifiers, but
36
More muscle : Transistors: Bipolar
37
Point iN Place
38
More muscle : Transistors
39
Switching terms: “HIGH SIDE” “LOW SIDE”
40
More muscle : Transistors: Bipolar
41
How?
42
More muscle : Transistors: Bipolar Inject small current into BASE to EMITTER to turn transistor ON Main current flow
43
More muscle : Transistors: Bipolar
45
More muscle : Transistor Lab 1 2N2222
46
More muscle : Transistors: Bipolar What part numbers? – NPN: 2N2222(A), 2N3904 – PNP: 2N2907, 2N3906 What’s important? – Max collector voltage – Max collector current
47
More muscle : Transistors: Bipolar
48
More muscle : Transistors: MOSFET These are great! Voltage controlled VERY low ON resistance Insulated Gate!
49
More muscle : Transistors: MOSFET Think of it as this:
50
More muscle : Transistors: MOSFET
52
How?
53
More muscle : Transistors: MOSFET
54
More muscle : Transistor Lab 2 IRF630
55
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Bonus demo: BLDC motor intro This is all basic electronics.
56
Optos: Solid State Relay PWM does NOT work with these!
57
Optos: Solid State Relay
58
Optos: SSR Lab Warning: We’re not in Kansas any more, Toto. In addition to 5V toys that couldn’t hurt you if they tried, there’s exposed 120 volts AC here that can kill you. Be careful out there.
59
Optos: SSR Lab Set up a “blink” sketch on your Arduino Use I/O pin of your choice Wire the AC side of the SSR in series with AC plug and socket. Have your setup checked BEFORE you plug it in! Wire the LED side of the SSR to your Arduino. Plug in and try it out!
60
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Bonus demo: BLDC motor intro Some of this is Arduino, some basic electronics.
61
Movers We’ll talk about these: Servos DC motors Solenoids Stepper motors Brushless DC motors
62
Movers: Servos
63
Use feedback to control position Hobby/RC servos use logic level pulse input Continuous rotation servos are like motors Other kinds exist
64
Movers: Servo feedback
65
Movers: Servo input
66
Movers: Servo library Arduino controls PWM specifically to drive servos with the SERVO library. Initialize like this: #include Servo fred; // “myservo” would be better! #define SERVOPIN 9 void setup(){ fred.attach(SERVOPIN); } void loop(){ }
67
Movers: Servo library Telling servo where to go with Servo.write(): void loop(){ fred.write(90); // go to midpoint delay(1000); fred.write(0); // go to one end of travel delay(1000); fred.write(180); // go to OTHER end of travel} delay(1000); } //end loop()
68
Movers: Servo library Other functions in Servo library: Specify pulse width for 0, 180 in microseconds fred.attach(pin, min, max); // default 544,2400 Read back latest position written with servo.write() int angle = fred.read(); Specify pulse width in microseconds fred.writeMicroseconds(value);
69
Movers: Servo Lab Load the Sweep example Do NOT use the default pin Modify so that it: – Sweeps twice as fast – Pauses at each end of each sweep Predict what you’ll see with an LED on the servo input pin (and check it out!)
70
Movers: Servo: RC transmitter
71
Movers: Servo: RC receiver
72
Movers: Continuous rotation servos
73
Movers: DC motors Always only 2 wires Reverse by reversing polarity
74
Movers: DC motors Regular “brushed” motors controlled by: Relays (old school!) FETs Use PWM for speed control “H-bridges” for reversing direction
75
Movers: DC motors Try this paper lab: How can you arrange some switches to connect a battery and a DC motor so you can control the motor direction?
76
Movers: H-bridge
78
AB
80
Movers: H-bridge Lab Your board has 2 full H-bridges Each H-bridge has separate inputs for each side (each “half H-bridge”). – HIGH input connects that side to GND – LOW input connects to VCC Hook a yellow motor across the MOTOR terms GND and VCC go to Arduino GND, +5V Inputs go to 2 Arduino output pins.
81
Movers: H-bridge Lab Use one input as direction control Use other input as PWM speed control Write code to demonstrate running forward and reverse, with low and high speed for each direction.
82
Movers: Robot Lab 1.Make robot. 2.Write code to: – Drive forward in a gentle right hand curve for ~1 second, Pause – Turn 180° in place, Pause – Return to start along same path – Optionally do victory dance at end
83
Movers: Robot Lab Special H-bridge cable
84
Movers: Solenoids It’s an INDUCTIVE load. That means you must _______.
85
Movers: Steppers
86
What we’re going to cover Arduino pins: What you can connect directly For more muscle: Relays, Transistors Solid state relays and 120VAC control Movers: Servos, DC motors, Solenoids, Steppers Bonus demo: BLDC motor intro This is basic hobby electronics.
87
Movers: BLDC motors “Brushless DC” motors: ARE brushless ARE NOT DC. They’re 3 phase AC motors! Must use special 3 phase inverter, often called an Electronic Speed Control to run from DC supply Are often very light and efficient
88
Movers: BLDC motors: Quadcopter
89
Movers: BLDC motors The interesting part is the ESC Has an embedded processor Uses PWM on the 3 phase AC for speed control Speed control input is servo pulse train Hobby ESCs often provide 5V to run the RC receiver. That’s called Battery Eliminator Circuit.
90
Movers: Servo: RC receiver
91
Movers: ESC/BEC ESC has to connect to receiver anyway (for throttle info), so it provides power to the receiver on the same cable.
92
Movers: BLDC demo
93
ESC programming 1
94
ESC programming 2
95
Thanks for coming!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.