Embedded programming

Week 8

Data sheet comprehension and learnings

When I first open that file I was like wow what a document! I didn't know right away how useful it would be. I read a lot of it and then looked at all the graphics but it didn't really tell my anything. So, I stopped that phase of the assignment to go on the next telling me that maybe using an ATTiny for real would help me understand the data sheet. I was right. At some point, when I was looking at some tutorial to begin to code, I didn't understand the concept of pins and how to use them and then, I realized that I saw some information about it in the data sheet. I guess that for this exercise, the important part was to be able to know were to connect my input and output on my chip. I first began to explore coding with Arduino IDE and the code that I explored with it were obviously dedicated to an Arduino UNO setup. So, the codes I made never worked until I came back to the datasheet and understand the concept of pins. Here a little graph of where I got to in my comprehension of it. Also, I got to understand the minimum and maximum voltage that I can use with that kind of chip (2.7v to 5.5v). It's nice because I can power it with a coin CR2032 battery.

I came back and foward using the graph on the datasheet until it worked until I felt I could use that kind of sheet on another project.

Programming the board

The assignment here is to program the board that we design in the Electronics design week. In other words, the Helloboard with the button and the LED added to it.

After my experience with Electronics production week and the programming of the FabISP, I was very afraid of this week. The programmation part of FabAcademy seemed very far of what I can do. But I still needed to go on with the assignment.

I needed first to choose a first language to try. I've been doing some basic C classes online and then, I realize that I was a bit behind to give result as fast. My instructor propose to pass to Arduino IDE and learn that language as it is also possible to program an ATTiny with this language so why not! More over, in the lab, we use Arduinos very often so I thought it would be usefull to learn it and it is so much well documented all around the web that I could not get lost. I downlaoded the Arduino IDE program and needed after this to make it compabible with ATTiny chips. To do that, I used the tutorial "Programming an ATtiny w/ Arduino 1.6" that I presented above. I followed the steps :

  • Go to "preferences"
  • Enter that URL : https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  • Then, if you go to card manager, you'll be albe to add the ATTinys
  • If it worked, it'll be in the tools options
  • Then, I needed to connect all of the material needed together meaning : The FabISP to the USB connector of my computer; with the 6pos headers, from my FabISP to the board; and then, as my FabISP don't generate power, with the serial port, connect it to another USB port of my computer. With all those connection made, I was ready to prepare et push de code into the chip. I have to say that in my first try, I plugged the serial connector on the wrong side, so I saw smoke as my chips burned. Damn you positive and negative! So I had to make my board again. The second one worked well.

    Then, it was time to create the code and to push into the chips. I watched a lot of tutorials to get ready, but as it was kind of a simple code, I got it at the first attempt. I was flabbergasted about it and very proud. Here are the code and some photos! But still, preparing the code, I had to make sure that the pins that I declared were the right one because form Arduino to ATTiny there's not the same, but my instructor already told me that ! :p Here's also a chart that I used to understand what he meant.

    // set pin numbers:
    const int buttonPin = 6;     // the number of the pushbutton pin
    const int ledPin =  8;      // the number of the LED pin
    // variables will change:
    int buttonState = 0;         // variable for reading the pushbutton status
    bool led_on;
    void setup() {
      // initialize the LED pin as an output:
      pinMode(ledPin, OUTPUT);
      // initialize the pushbutton pin as an input:
      pinMode(buttonPin, INPUT);
      led_on = true;
    }
    void loop() {
      // read the state of the pushbutton value:
      buttonState = digitalRead(buttonPin);
      // check if the pushbutton is pressed.
      // if it is, the buttonState is HIGH:
      if (buttonState == HIGH) {
        // turn LED on:
        digitalWrite(ledPin, HIGH);
      }
      else {
        // turn LED on and off:
        if (led_on) {
          digitalWrite(ledPin, LOW);
          led_on = false;
          delay(50);
        } else {
          digitalWrite(ledPin, HIGH);
          led_on = true;
          delay(50);
        }
      }
    }
    
    											

    Once the code is ready, to push it in the ship, you prepare some settings and then uoload it.

    There you go !!!!