Main

Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11 Week 12 Week 13 Week 14 Week 15 Week 16 Week 17 Week 18 Week 19

Glossary

Inventory

Mindmap

Week 08 : EMBEDDED PROGRAMMING

Overview

The assignment this week was to "measure something: add a sensor to a microcontroller board and read it". During Week 6 I had adapted and assembled the 'Hello World' FTDI board that contained a tiny44 microprocessor, an LED, a Tactil Switch and a Thermistor, it also had FTDI and ISP connectors. During Week 4 I assembled the 'FabISP' which houses another tiny44 microcontroller a usb connector and an ISP header. So for this week that leaves programming: A Tutorial from High-low tech explained how to use the tiny programmer (FabISP). The tutorial "explains how to use the TinyProgrammer, a small circuit board for loading code on the ATtiny44 and 85 microcontrollers (or other AVRs)".

A second tutorial by High-Low tech explained how to program using Arduino IDE. The Arduino IDE is a development environment that uses the C++ language but works with a lot of embedded libraries to simplify your coding. Finnaly the AVR microcontroller datasheet for the Tiny44 was a usefull source of infomation to understand the function and capacity of the microcontroller. I felt the best way to explain what i did was to write a step by step how-to: so here goes.

High-Low Tech : Using the Tiny programmer
High-Low Tech : Programming an ATtiny w/ Arduino 1.0
AVR Tiny44 Microcontroller Datasheet

Settup

The FabISP connects to the computer through its USB cable connection (This also gives it power). The 'FabISP' then connects to the 'Hello World FTDI board' by the ISP headers common to both boards and a six-wire ribbon cable. The FTDI header of the Hello World board should be connected to provide power to the Atiny microcontroller. It is important to make sure that the Power ('VCC' in the circuit) and indicated by the red cable in the ribbon is connected correctly through both headers on both boards. (That is connecting MISO, MOSI, SCK, RESET, VCC, and GND pins of the FabISP header to the corresponding pins or the Hello World Board ISP) When this is done ... your ready to roll!

Using the FabISP programmer with Arduino IDE 1.3

  • 1. Openning the Aduino IDE automatically starts a new Sketch. Save this.
  • 2. Download the ATiny master.zip file
  • 3. Locate the Arduino Sketchbook folder eg. Documents > Arduino ... Then create a new folder called "Hardware"
  • 4. Unzip the Atiny Master and copy the folder to the new Hardware folder. (restart Aduino IDE)
  • 5. Select the type of Board by going to Tools > Board > ATiny44 (External 20 MHZ clock)
  • 6. Select USBtinyISP from the Tools > Programmers menu. (if not the FabISP then we could select and use the AVRISP mk2)
  • 7. The FabISP has already been burned with the Bootloader. Now it the turn of the Hello World Board. Tools > Burn bootloader

    NOTE :The Sketch is now setup with the correct hardware. Next a script can be transfered through the FABISP or AVRISP mk2 to the 'Hello World FTDI board'

    Scripting (Blink example)

  • 7. Open the 'Blink sketch' from the examples menu.
  • 8. Change the Arduino example pin numbers to correspond to your own board. In my case I connected the LED to Microcontroler pin 6.
  • 9. You can change the delay time of the blink by miliseconds 1000 = 1 second
  • 10. Upload the sketch by pressing the right arrow in the Arduino IDE
  • NOTE :The Microcontroller Pin numbers describe physical pins. Each of those pins corresponds to a function that which Arduino IDE uses. So in this case Microcontroller Pin 6 = (PWM, Anolog Input 7) Pin 7

    Scripting Objective

    I have decided to create a script that Records the temperature and light up the LED when the button is pressed. I used the Academy tutorial as the base script to help me. Again I had to change the Arduino Pin Labels to match those of the Atiny44 and Hello World Assembly. To reiterate this process .. I connected the Button to the Atiny44 pin 5 which translated to Arduino Pin Label 8 (PWM Pin 8).

    Problem 1

    The First problem was that I needed a resistor between the microcontroller and the button. Pullup

    Tutorial : Dojo Dave LED off until button pressed

    Micro processors, AVR ... one of the first Modern. a family of Microcontrollers. Pins vs dollars. Embedded Programming Tutorial By Chris Malcom.

    KEY RESOURCES:
    Week 8 Class Lecture : Embedded Programming
    Week 8 Howework Review
    Week 8 Blog : Ghosts and Bugs