01 circuits & microcontrollers

64
Circuits & Microcontrollers September 1, 2020

Upload: others

Post on 02-May-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 01 Circuits & Microcontrollers

Circuits & Microcontrollers

September 1, 2020

Page 2: 01 Circuits & Microcontrollers

interactive device designSeptember 1, 2020

Page 3: 01 Circuits & Microcontrollers

Tour of class kit and toolbox

Page 4: 01 Circuits & Microcontrollers

CircuitsCommon Components | Voltage | Current | Resistance

Ohms Law | Watt’s Law | Series and Parallel Circuits Voltage Divider | Pull-up and Pull-down circuits

Page 5: 01 Circuits & Microcontrollers

Electrical circuits are networks of electrical elements that contain a closed loop which allows electrons to flow through the elements.

This electron flow allows the circuits to do things.

Page 6: 01 Circuits & Microcontrollers

images from Wikipedia

Examples of Electrical Components

Page 7: 01 Circuits & Microcontrollers

V Voltage (measured in Volts) is the potential difference in electrical charge between two points in a circuit.

I Current (measured in Amperes or Amps) is the quantity of electrons passing through a point in a circuit.

R Resistance ( measured in Ohms - Ω) is the capacity of a circuit element to impede the flow of electrons in an electrical circuit.

Page 8: 01 Circuits & Microcontrollers

Ohm’s Law states that Voltage = Current X Resistance

V=IR

Watt’s Law states that Power = Voltage x Current

P=VI= I2R

Page 9: 01 Circuits & Microcontrollers

Ohm’s Law states that Voltage = Current X Resistance

V=IR

10V

Page 10: 01 Circuits & Microcontrollers

Ohm’s Law states that Voltage = Current X Resistance

V=IR

5V

Page 11: 01 Circuits & Microcontrollers

images from Wikipedia

Where does Voltage come from?

Page 12: 01 Circuits & Microcontrollers

Power can come from supplies or batteries.

P=VI= I2R

Page 13: 01 Circuits & Microcontrollers

Ground symbol

5v

Page 14: 01 Circuits & Microcontrollers

Current flows with almost no resistance in metal.

Things that are connected by direct metal-on-metal contact share the same voltage.

Page 15: 01 Circuits & Microcontrollers

images from Adafruit

Page 16: 01 Circuits & Microcontrollers

sketch by Bill Verplank

Page 17: 01 Circuits & Microcontrollers

image from https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard

Page 18: 01 Circuits & Microcontrollers

image from https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard

Page 19: 01 Circuits & Microcontrollers

Resistance regulates the current in a circuit.

Page 20: 01 Circuits & Microcontrollers

images from www.steiniche.dk/.../resistors-filer

Page 21: 01 Circuits & Microcontrollers
Page 22: 01 Circuits & Microcontrollers

Resistors in series ADD

Page 23: 01 Circuits & Microcontrollers

Resistors in parallel DIVIDE

Page 24: 01 Circuits & Microcontrollers

Ohm’s Law states that Voltage = Current X Resistance

V=IR

Watt’s Law states that Power = Voltage x Current

P=VI= I2R

Page 25: 01 Circuits & Microcontrollers

V=IR P=VI

V=?

I =?

P=?

10V

Page 26: 01 Circuits & Microcontrollers

V=IR P=VI

V=?

I =?

P=?

5V

Page 27: 01 Circuits & Microcontrollers

What is a SHORT CIRCUIT???

Why is this bad?

Page 28: 01 Circuits & Microcontrollers

V=IR

I=V/R

If R=0, I = ∞

Page 29: 01 Circuits & Microcontrollers

DON’T SHORT POWER TO GROUND

Page 30: 01 Circuits & Microcontrollers

A Tour through a Pushbutton LED circuit

Page 31: 01 Circuits & Microcontrollers

Pushbutton LED circuit breadboard drawing

diagram made in Fritzing

Page 32: 01 Circuits & Microcontrollers

Equivalent Pushbutton LED circuit

5V

5V

R

Page 33: 01 Circuits & Microcontrollers

image from https://learn.sparkfun.com/tutorials/how-to-use-a-breadboard originally from http://www.instructables.com/id/Use-a-real-Bread-Board-for-prototyping-your-

circui/

Sketching in Hardware

Page 34: 01 Circuits & Microcontrollers

KIRCHOFF’S LAW in the Pushbutton LED circuit

R

In any 'loop' of a circuit, the voltages must balance: the amount generated = the amount used

Page 35: 01 Circuits & Microcontrollers

Input in the Pushbutton LED circuit

R

5V

Page 36: 01 Circuits & Microcontrollers

Switches/Buttons

images from Wikipedia

Page 37: 01 Circuits & Microcontrollers

Switches/Buttons

Page 38: 01 Circuits & Microcontrollers

Output in the Pushbutton LED circuit

R

5V

Page 39: 01 Circuits & Microcontrollers

LEDs

images from Wikipedia

Page 40: 01 Circuits & Microcontrollers

LED datasheet

SPEC NO: DSAF2433 REV NO: V.2 DATE: MAY/11/2007 PAGE: 1 OF 6 APPROVED: WYNEC CHECKED: Allen Liu DRAWN: Y.L.LI ERP: 1101005271-02ʳ

T-1 3/4 (5mm) SOLID STATE LAMPʳ

Part Number: WP7113SRD/D Super Bright Redʳ

Features z LOW POWER CONSUMPTION.

z POPULAR T-1 3/4 DIAMETER PACKAGE.

z GENERAL PURPOSE LEADS.

z RELIABLE AND RUGGED.

z LONG LIFE - SOLID STATE RELIABILITY.

z AVAILABLE ON TAPE AND REEL.

z RoHS COMPLIANT.ʳ

Description

The Super Bright Red source color devices are made with

Gallium Aluminum Arsenide Red Light Emitting Diode.ʳ

Package Dimensionsʳ

Notes: 1. All dimensions are in millimeters (inches). 2. Tolerance is ±0.25(0.01") unless otherwise noted. 3. Lead spacing is measured where the leads emerge from the package. 4. Specifications are subject to change without notice.

https://learn.adafruit.com/all-about-leds/the-led-datasheet

Page 41: 01 Circuits & Microcontrollers

Inside LEDs

Page 42: 01 Circuits & Microcontrollers

RGB LEDs

Page 43: 01 Circuits & Microcontrollers

VOLTAGE DIVIDER CIRCUIT

Page 44: 01 Circuits & Microcontrollers

PULL UP RESISTOR

Page 45: 01 Circuits & Microcontrollers

PULL DOWN RESISTOR

Page 46: 01 Circuits & Microcontrollers

Adjusting the brightness of your LEDs

A potentiometer is a variable resistor,

a voltage divider in a package.

Page 47: 01 Circuits & Microcontrollers

Adjusting the brightness of your LEDs

The LED is a diode, with a fixed voltage drop.

The Current is set by the series resistor

The brightness of the LED is a function of the current, created by the resistance.

I= V/R

Page 48: 01 Circuits & Microcontrollers

R

Why is this a BAD circuit?

Page 49: 01 Circuits & Microcontrollers
Page 50: 01 Circuits & Microcontrollers

Microcontrollers are very small computers

Page 51: 01 Circuits & Microcontrollers
Page 52: 01 Circuits & Microcontrollers

We are using Arduino.

This is a family of microcontroller boards

and an associated integrated development

environment (IDE)

Page 53: 01 Circuits & Microcontrollers
Page 54: 01 Circuits & Microcontrollers
Page 55: 01 Circuits & Microcontrollers

Physical Hardware

Page 56: 01 Circuits & Microcontrollers

Microcontroller

Page 57: 01 Circuits & Microcontrollers
Page 58: 01 Circuits & Microcontrollers

Schematic

7/27/2017 2:28:31 PM f=0.75 C

:\Users\ladyada\D

ropbox (Personal)\breakouts\DevBoards\Adafruit-M

ETRO

-328-PCB\M

etro Mini R

ev B.sch (Sheet: 1/1)

Original diode was M7 (1A Si diode)Replacement is 1A SchottkyOr MOSFET switchReplaced THM with SMT 2.1mm

Default = 5VCut trace and solder to 3V3 to change

GND

GND20609

GND

+5V

10uF

GND

GND

GRE

EN

GND

+5V

GND

GND

RED

GND

GND

10uF

CSTCE16M0V53-R0 16MHZ

GND

3.3V

+5V

KMR2

20610

3.3V

+5V3.3V

GN

D

MBR

120

+5V

20609

ATMEGA328P

20610

CP2104

20329GND

GND

GND

GND

GND

+5V

YELL

OW

YELL

OW

3.3V

+5V

GND

3.3V

+5V +5V

AD

123456

C2

ON

LC3

RESET

A BB'A'

IOL12345678

VSELECT31

2

D3

AD1

123456

U1

MIC5225-5.0

IN1 OUT 5EN3GND2 P4 4

U2

RESET29

XTAL28

XTAL17

AREF20AVCC18AGND21

VCC4*2GND3*3

(SCK)PB5 17(MISO)PB4 16(MOSI)PB3 15

(SS)PB2 14(OC1)PB1 13(ICP)PB0 12

(ADC5)PC5 28(ADC4)PC4 27(ADC3)PC3 26(ADC2)PC2 25(ADC1)PC1 24(ADC0)PC0 23

(AIN1)PD7 11(AIN0)PD6 10

(T1)PD5 9(TO)PD4 2

(INT1)PD3 1(INT0)PD2 32(TXD)PD1 31(RXD)PD0 30

POWER112345678

RI 1

GND2

D+3D-4

VIO5VDD6REGIN7

VBUS8

#RST 9

NC10

GPIO3 11GPIO2 12

DCD 24DTR 23DSR 22TXD 21RXD 20RTS 19CTS 18

SUSPEND 17

VPP16

#SUSPEND 15

GPIO0/TXLED 14GPIO1/RXLED 13

U3G$1

X1

D+D-

VBUS

GNDID

THERMALPAD

U3G$2

D4 D5

U4

MIC5225-3.3

IN1 OUT 5EN3GND2 P4 4

GND

AREF

AREFRESET

RESET

VIN

VIN

SCK

SCK

MOSI

SS

SS

DTR

DTR

AD0AD1AD2AD3AD4/SDAAD5/SCL

IO2

IO0

IO3IO4IO5IO6IO7

IO8

IO8

IO9

IO9

RXD

RXD

TXD

TXD

TXD

VBU

S

VBUS

VCCIO

MISO

POWER SUPPLY: 5VUSB/Serial Bridge POWER SUPPLY: 3.3V

IO LEVEL SELECTION

POWER LED

ATMEGA328 MCU

SCK LED

Lots of room for BLAH BLAH BLAH notes

A

B

C

D

E

1 2 3 4 5 6 7 8

A

B

C

D

E

1 2 3 4 5 6 7 8IO

IO

IO

IO

CP2104USB/UART BRIDGE

VIO: 1.8-VDDOp. Temp: -40~85°C

01234567

8910111213

Page 59: 01 Circuits & Microcontrollers

Arduino Software Environment

IDE | Structure of Arduino programs | Flashing programs

Page 60: 01 Circuits & Microcontrollers

Sketch

Page 61: 01 Circuits & Microcontrollers

Sketch

/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */

void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); }

void loop() { digitalWrite(13, HIGH); // set the LED on delay(2000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(2000); // wait for a second }

Page 62: 01 Circuits & Microcontrollers

What happens when we flash code?

1. Code from libraries (if any) are included (linked). 2. Code is checked for errors (verified). 3. Code is “cross-compiled” into machine code (a.k.a

machine code or hex code) using avr-gcc. 4. Code is written to the program memory of the

Arduino over USB using avrdude.

Page 63: 01 Circuits & Microcontrollers

Flash Demonstration

Page 64: 01 Circuits & Microcontrollers

Multimeter demonstration

Voltage Resistance

Connections