Juan Carlos Miranda Castro

FabAcademy - 2017

Costa Rica - St. Jude School


Back

Embedded programming



Assignment
  • Read a microcontroller data sheet.
  • Program your board to do something, with as many different programming languages and programming environments as possible.
  • Optionally, experiment with other architectures.
Learning outcomes
  • Identify relevant information in a microcontroller data sheet.
  • Implement programming protocols.
Have you
  • Documented what you learned from reading a microcontroller datasheet.
  • What questions do you have? What would you like to learn more about?
  • Programmed your board.
  • Described the programming process/es you used.
  • Included your code.


Hardware


hardware

My board

Computer

Mobile



Software


software

Arduino IDE



Materials


materiales

attiny45



Designing the table

  • My board uses ATtiny45 (datasheet).

    Information that I find important and useful:

    • Operating voltage: 1,8 V - 5,5 V. This range is compatible with USB power supplying. USB is mainly used for the board powering while programming and testing.
    • Industrial temperature range: -40°C to +85°C. Depending on the final application and its environment, the temperature range must be chosen accordingly. For this board, wich will be used for testing and program practicing, the average temperature will be 20°C - 30°C.
    • Pin configuration and pin description: for schematics, wiring and possible later reparations of the board. In some cases, one pin can have several possible functions. The datasheet gives this functions and the configuration for each one.
    • Block diagram: block diagrams for the microcontroller and its parts. It gives information like the units in te microcontroller, timers, shift registers, oscillators, etc.

    I also used datasheets for week 10 and week 15.


Programming the board

  • I used Arduino IDE. There are two main parts in the code: the setup and the loop. (there may be a third part in which you can include libraries).

      Setup: runs once when the board is powered or reset. Variables are initializaed in the setup.

      Loop: runs continuously, executing the commands line after line until it reaches the last line and starts again at the first one.

    I started with the "Hello world" of electronics: the blink code. In the setup, the command pinMode establishes the indicated pin (0 in this case) as output, meaning the microcontroller will send digital signals to this pin. The, the loop section has the commands to put pin 0 to HIGH state, wait for 1 second, put pin 0 to LOW state, wait for 1 second, and repeat.

    In this case, HIGH and LOW mean a voltage of about 5 V and 0 V respectively, and because a LED is conected between pin0 and GND, the LED will be on and off according to the state set by the program.

    This is the code for the blink program:

    void setup()
    {
    pinMode(0, OUTPUT);
    }
    void loop()
    {
    digitalWrite(0, HIGH);
    delay(1000);
    digitalWrite(0, LOW);
    delay(1000);
    }
  • Questions

    What questions do you have?

    What other microcontroller is available to make a bigger board?

    I used the ATMega328 for later assignments, and came back to coplete this one

    What would you like to learn more about?

    I would like to learn more about other programming languages, besides the arduino code.


Programming my board

  • When my fabduino was ready (week 15) I came back to this assignment and programmed a lights sequence.

    I used Arduino IDE. There are two main parts in the code: the setup and the loop. (there may be a third part in which you can include libraries).

      Setup: runs once when the board is powered or reset. Variables are initializaed in the setup.

      Loop: runs continuously, executing the commands line after line until it reaches the last line and starts again at the first one.

    I created the code, wich basically declares tree int variables, one for each led pin, and then the loop turns on and off each light in a sequences. The program has a delya of half a second between each change.

    This is the code for the lights sequence:

    int led1 = 2;
    int led2 = 3;
    int led3 = 4;

    void setup()
    {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    }
    void loop()
    {
    digitalWrite(led1, HIGH);
    delay(500);
    digitalWrite(led1, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led3, HIGH);
    delay(500);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    }

Back