arduino: exploring mighty attiny85 · • selection of atmega168 then atmega328 – attiny is a...

29
Arduino: Exploring Mighty ATtiny85 Slides and Programs: http://pamplin.com/dms/ Brady Pamplin DMS: @bpamplin 1 DMS SSID: “DMS Member” Password: dms--109238

Upload: others

Post on 24-Oct-2020

7 views

Category:

Documents


1 download

TRANSCRIPT

  • Arduino: Exploring Mighty ATtiny85

    Slides and Programs: http://pamplin.com/dms/

    Brady Pamplin DMS: @bpamplin

    1 DMS SSID: “DMS Member” Password: dms--109238

    http://pamplin.com/dms/http://pamplin.com/dms/

  • Terminology

    2

    Microprocessor – CPU for servers, PCs, laptops • Requires external memory and IO controllers • All pins dedicated for specific purposes • A primary goal is speed

    Microcontroller, MCU - embedded computer - pins available for sensors and actuators

    • Chip includes limited size CPU, flash memory, IO capabilities • Great for Physical Computing • 25-35 in typical car - 60-65 in top end luxury cars • Worldwide production of billions per yeat • ATmega328 used in Arduino Uno, Nano • ESP8266 used in Wemos • ATtiny family

    System on Chip, SoC

    • Integrates all components of a computer or other electronic system • Digital, analog, mixed-signal, radio frequency • Raspberry Pi, cell phones

  • WARNING

    3

    If the 5V, 3V3 or output data pins are shorted directly to ground, there is a danger of damaging the microcontroller or USB port. These circuits use five volts and less so there is no danger to a person.

  • Microcontroller Functions

    4

    Microcontrollers are Real Time computers which generally do a limited number of operations in a continuous loop. Sense some condition

    • Time, temperature, humidity, pressure, speed, moisture • Light, touch, distance, movement, open/close, RFID, fingerprint • Elapsed time, sound • Specified combination of the above

    Analyze

    • Decide if action is required Action

    • Turn on or off: Lights, AC, alarm, lawn sprinkler, fountain • Adjust: Speed, voltage, volume • Display to: Screen, small display, light • Transmit to: WiFi, server, cloud, mesh network, Tweet, SMS text msg

  • Popular Sensor Kit

    5

  • Why did Arduino Go Viral?

    6

    Following are a few of the things that I think contributed in a major way to the success of Arduino. It was suddenly possible to buy a single little board and USB cable and program a real microcontroller

    • Open hardware and software – Arduino IDE

    • Selection of ATmega168 then ATmega328 – ATtiny is a very reduced version

    • USB-Serial chip – FTDI or CH340 – Not on ATtiny chips

    • Voltage regulator and UART – Not on ATtiny chip

    • Bootloader included – Not on ATtiny chip

    • Awesome price compared to Basic Stamp,…

    • Maker movement – the time was right

  • Popular Microcontrollers and Boards

    7

    Non WiFi – Line Power Arduino Nano - Equivalent to Uno – breadboard friendly DigiSpark - ATtiny85 - USB and voltage regulator

    Non WiFi - Battery Power ATtiny85 chip - required 3.3-5 volt source

    WiFi - Line Power

    Wemos D1 Mini - ESP8266, voltage regulator,

    WiFi - Battery ESP12F

    Hundreds of other microcontroller options are available.

  • Why the ATtiny85 for Embed?

    8

    Popular in hobby electronics articles and blogs for embedded MCU projects Adequate for many hobby electronics projects Eight pin DIP and surface mount packages Tanners Electronics carries the eight pin DIP – ATTiny-20PU Adafruit and Sparkfun feature this MCU on various parts and documentation DMS KiCAD class featured this device Can program with Uno or Nano

  • Board and Chip Comparison

    9

    Nano Brd ATmega328 DigiSpark Brd ATtiny85

    Arduino IDE Yes No Partial No

    Serial IO Yes No Partial No

    LED Yes No Yes No

    FTDI Yes No No No

    Voltage reg Yes No No No

    UART No Yes No No

    IO pins No 20 No 6

    Package pins 30 28 9 8

  • Microcontroller Comparison

    10

    https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328 https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/ https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_chart

    https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328https://goddess-gate.com/projects/en/arduino/attiny85vsatmega328https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://thewanderingengineer.com/2013/04/28/comparison-of-atmel-chips/https://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_charthttps://en.wikipedia.org/wiki/Atmel_AVR_ATtiny_comparison_chart

  • Methods of Programming the ATtiny85

    11

    ISP – In System Programmer • Pros: Uses no flash memory – no need to remove chip • Cons: $10 - $20 - … • Universally used in commercial development and production

    Programmer board

    • Pros: Cheap – few dollars • Cons: May require bootloader which takes flash, must remove chip

    Arduino Uno or Nano as programmer

    • Pros: Free – requires one 10uF capacitor • Cons: Requires bootloader which takes flash, must remove chip • Somewhat complicated process • Training available – demo and lab exercise in this class

  • Demonstrations

    12

    Download Blink to Arduino Nano – Serial monitor Programming the DigiSpark Display/Debug Digispark Program ATtiny85 chip using Arduino Nano

    • Download SPI writer to Arduino • Configure breadboard to program ATtiny • Burn boot loader to ATtiny • Download program to ATtiny

  • Parts Kit

    • Digispark w/ Micro USB connector • ATtiny85 DIP • Arduino Nano • Breadboard and jumper wires • RGB LED module • 10uF Capacitor • USB cables – mini and micro

    13

  • Breadboards and Jumpers

    Breadboards are great for prototyping circuits. Each row of five holes has a clip below it so that a component or jumper will be connected to jumper wires plugged into others. Larger boards often have long run down the edges for power and ground.

    14

  • Breadboards and Jumpers

    15

  • Light Emitting Diodes - LEDs

    16

    An LED must be connected in series with a resistor to prevent too much current from destroying the Arduino.

  • Resistors

    17

    • Commonly used to limit current • Typically 300 to 600 Ω (ohms) when used with an LED

  • Digispark ATtiny85 USB Development Board

    18

    • Support for the Arduino IDE 1.0+ (OSX/Win/Linux) Power via USB or External Source - 5v or 7-35v (12v or less recommended, automatic selection) On-board 500ma 5V Regulator Built-in USB 6 I/O Pins (2 are used for USB only if your program actively communicates over USB, otherwise you can use all 6 even if you are programming via USB) 8k Flash Memory (about 6k after bootloader) I2C and SPI (vis USI) PWM on 3 pins (more possible with Software PWM) ADC on 4 pins Power LED and Test/Status LED

  • Lab Exercise: Program the Digispark

    19

    This page is an overview. See the following link for specifics. https://digistump.com/wiki/digispark/tutorials/connecting Paste this: http://digistump.com/package_digistump_index.json Step 1: Add Support for the Digispark to the Arduino IDE Board Manager File/Preferences, add comma and paste URL, OK Step 2: Install the ATtiny Board Package Tools/Board/Board-Manager, search digistump, Digistump AVR, Install Step 3: Set the Arduino Uno Into ISP Mode – USB unplugged Tools/Board/Digispark Default 16.5 MHz File/Examples/Digispark-Examples/Start With USB cable disconnected – Upload Wait for “Plug in Device Now” Plug in the USB cable

    https://digistump.com/wiki/digispark/tutorials/connectinghttps://digistump.com/wiki/digispark/tutorials/connecting

  • Display/Debug Digispark

    20

    Following text from this page: https://digistump.com/wiki/digispark/tutorials/debugging • The simplest is the DigiKeyboard. You can use this where you would use

    serial.print with an Arduino. To use this you will need to add the keyboard library. Here are the steps to try out the example:

    • Start Arduino • open DigiSparkKeyboard, under File > Examples > DigiSparkKeyboard→Keyboard • On windows: Open Notepad, under All Programs > Accessories > Notepad On

    Mac/Linux open your favorite text editor. • Drag the Notepad/text Editor window to the side • Select Upload • When it asks you to plug in the DigiSpark • Quickly move the cursor into the open Notepad window and click • In a few second “Hello Digispark!” should start appearing in the Notepad/Text

    Editor - it is acting as a keyboard and so will type in any application that has the focus.

    https://digistump.com/wiki/digispark/tutorials/debugginghttps://digistump.com/wiki/digispark/tutorials/debugging

  • Lab Exercise: Use Arduino to Program Attiny – 1/2

    21

    This page is an overview. See the following link for specifics. http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/ Text to paste: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json Step 1: Add Support for the ATtiny85 to the Arduino URL Board Manager File/Preferences, add comma and URL, OK Step 2: Install the ATtiny Board Package Tools/Board/Board-Manager, search attiny, select David A. Mellis, Install Step 3: Set the Arduino Uno Into ISP Mode Tools/Board/Arduino Nano File/Examples/11-ISP-Arduino...Upload

    http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/

  • Lab Exercise: Use Arduino to Program Attiny – 2/2

    22

    Step 4: How a Microcontrollers Pins Are Labeled see next slide Step 5: Connecting the Arduino to the ATtiny Pins see next slide Step 6: Making the ATtiny85 Arduino Compatible Tools/Board/ATtiny25/45/85 Tools/Processor/ATtiny85 Clock:Internal 8 MHz Tools/Programmer/Arduino as ISP Tools/Burn Bootloader Step 7: Uploading the Blink Sketch File/Examples/01.Basics/Blink Change pin number to 0 in three places Upload

  • Lab Exercise: Wiring

    23

    Arduino

    Pins Attiny

    DIP Pins #

    5V 8

    Gnd 4

    D13 7

    D12 6

    D11 5

    D10 1

    Detail wiring is on this link. http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/ Connect a 10uF capacitor between RST & GND of the Nano From pin 5 of the Attiny, connect an LED and resistor to GND.

    Functions are outside labels DIP pin numbers are inside

    http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Unohttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno

  • ATtiny - RGB LED

    24

    Connect the R, G, B leads to Attiny DIP pins 5, 6, 7 Connect GND to GND Program: attiny_rgb_led

  • Ultrasonic Distance Sensor

    25

    • https://gist.githubusercontent.com/imjacobclark/5464198/raw/a1723b9968366e2e26ce0786c7d7235876dfdba1/Ultrasonic_Ranging_ATtiny85.ino

  • Resources

    Download and install Arduino IDE: https://www.arduino.cc/en/Main/Software CH340 driver https://sparks.gogo.co.nz/ch340.html https://digistump.com/wiki/digispark?redirect=1 https://digistump.com/wiki/digispark/tutorials/gatekeeper http://digistump.com/wiki/digispark/tutorials/connecting I have not worked with Linux or MacOS but the following may be helpful in case of difficulties. https://digistump.com/wiki/digispark/tutorials/linuxtroubleshooting https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/ If your laptop runs OSX be sure to check this article: https://digistump.com/wiki/digispark/tutorials/gatekeeper 26

    https://www.arduino.cc/en/Main/Softwarehttps://sparks.gogo.co.nz/ch340.htmlhttps://digistump.com/wiki/digispark?redirect=1https://digistump.com/wiki/digispark/tutorials/gatekeeperhttp://digistump.com/wiki/digispark/tutorials/connectinghttps://digistump.com/wiki/digispark/tutorials/linuxtroubleshootinghttps://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://mikaelleven.wordpress.com/2015/10/18/troubleshooting-digispark-attiny85-on-mac-os-x/https://digistump.com/wiki/digispark/tutorials/gatekeeper

  • Resources

    • Good bootloader article • https://www.hackster.io/porrey/bootload-your-attiny85-625387

    27

    https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387https://www.hackster.io/porrey/bootload-your-attiny85-625387

  • Digispark Notes

    28

    • https://digistump.com/wiki/digispark/tutorials/connecting

    • Programming • http://www.instructables.com/id/How-to-

    Program-an-Attiny85-From-an-Arduino-Uno/

    https://digistump.com/wiki/digispark/tutorials/connectinghttps://digistump.com/wiki/digispark/tutorials/connectinghttps://digistump.com/wiki/digispark/tutorials/connectinghttp://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/http://www.instructables.com/id/How-to-Program-an-Attiny85-From-an-Arduino-Uno/

  • H2OhNo! - Retired Product Excellent ATtiny85 Documentation

    29

    • https://www.sparkfun.com/products/retired/12069 • https://learn.sparkfun.com/tutorials/h2ohno • https://learn.sparkfun.com/tutorials/h2ohno/low-power-

    attiny • https://github.com/sparkfun/H2OhNo/blob/master/firmware/

    H2OhNo/H2OhNo.ino

    https://www.sparkfun.com/products/retired/12069https://www.sparkfun.com/products/retired/12069https://www.sparkfun.com/products/retired/12069https://learn.sparkfun.com/tutorials/h2ohnohttps://learn.sparkfun.com/tutorials/h2ohnohttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://learn.sparkfun.com/tutorials/h2ohno/low-power-attinyhttps://github.com/sparkfun/H2OhNo/blob/master/firmware/H2OhNo/H2OhNo.inohttps://github.com/sparkfun/H2OhNo/blob/master/firmware/H2OhNo/H2OhNo.inohttps://github.com/sparkfun/H2OhNo/blob/master/firmware/H2OhNo/H2OhNo.ino