assignment 8. 16 march 2016

Embedded Programming

1. Read the microcontroller Data Sheet

First I have reviewed the data sheet of the micro-controller, a bit huge, but I have solved some points that I had not clear enough as the actual meaning of the pins name.

VCC: Voltage Supply
GND: Ground
PA Port: 0-7 pins. (PA7:PA0) 8-bit bi-directional I/O port with internal pull-up resistors.
PB Port: 0-3 pins.(PB3:PB0) 4-bit bi-directional I/O port with internal pull-up resistors.
ADC: Analog Digital Converter
USI: Universal Serial Interface
MISO: Master Input Slave Output
MOSI: Master Output Slave Input

2. Programm the board

I have been in touch with Arduino not too long ago therefore I have not a deep enough knowledge about it, so I started to work reviewing some really interesting lectures: Getting Started with Arduino, Programming Arduino and Interactive Prototyping. The third one is about FireFly, a plug-in that offers a set of tools dedicated to bridging the gap between Grasshopper and the Arduino micro-controller. It constitutes the nexus between physical and digital world in fact, furthermore for me it allows going one steep beyond because it is somehow like closing the circle into the parametric and form finding area. In this way you can develop a parametric design using Grasshopper and after that the variables that control the design can come from any kind of sensor and on the other hand you can read and transform several data extracted from the digital design in order to be used into the physical designs. For me, in particular, it is very interesting the possibility to transform geometric data from digital model to physical one.

This week assignment is focused on programming a board built in assignment 6, the famous HelloWorld PCB, this kind of board uses a quite simple ATTiny 44 micro-controller, and so is not possible to write into it the necessary IDE sketch in order to connect the board and the design environment FireFly. Actually if you want to establish an appropriate communication between FireFly and Arduino board you have to upload into the board the FireFly Firmata Sketch. I have found an interesting work belongs to Francesca Perona on FabAcademy 2015 ( thanks to her ). She gets a link between FireFly and the modified HelloWorld PCB but only in one direction by time what it means that you can send or receive data but not in both directions. Therefore I have decided to fabricate a FabKit or Fabduino and try to connect this board with Firefly. I have been reading some tutorials about and just started to build this model designed by Daniele Ingrassia last year. ( thanks to him ) I hope it would be used in my final project in order to control the mechanical movement.

Turning to this week assignment I have to say that it has not supposed a great problem to me. The board works correctly, it has no hardware error and all the stuff was well set up. Really I can say this after seeing it work.


Materials:


FabISP
HelloWorld PCB board ( modified )
FTDI cable


The process: (Windows)


Install IDE Arduino software.
Install FTDI drivers
Add ATtiny support on Arduino environment
Configure the MC

Configuration of ATtiny’s (very useful site)

By default, the ATtiny’s run at 1 MHz. Here I have to configure it to run at 20 MHz external clock instead, to do so, once I had the microcontroller connected, selected “20 MHz (External)” from the Tools > Clock menu. (In Arduino 1.0.x, selecting the appropriate 20 MHz clock option from the main Tools > Board menu.) Then, run the “Burn Bootloader” command from the Tools menu. This configures the fuse bits of the microcontroller so it runs at 20 MHz. Note that the fuse bits keep their value until you explicitly change them, so you’ll only need to do this step once for each microcontroller. (Note this doesn’t actually burn a bootloader onto the board; you’ll still need to upload new programs using an external programmer.)


IMPORTANT! Check the accordance between the Arduino board and the Attiny micro-controller connections. You have to take in account where the modified circuits were connected.


ERROR! After some successful trials the sketch loading started to fail. In fact, at the end of the loading an error message appears. I tried to switch off the cable and the USB, restart the computer, and even install several versions of the Arduino IDE. Without success, sometimes the sketch was charged properly, sometimes not and in other cases it seemed to work but not correctly, somehow as if the sketch had not loaded completely.

Searching for the solution I had any fulfilling result:

Might be encountering a glitch in the way Arduino uses avrdude. Avrdude assumes that memory has been cleared to 0xFF before uploading. If it finds a 'page' of 0xFF in the code it won't bother sending it because it assumes the memory is already set that way. If the memory is not set that way (from a previous upload) then the code will not verify.

Anyway I could not find a solution in this way.

Finally I tried to work on my desktop computer which runs on Windows 8 ( I usually work on my laptop working on Windows 7 ) and using any version of the IDE it works properly. So I suppose that could be some problem with the SO version but I do not what is it.

I have tried many sketches from the Arduino library and have written some more too. It is really important to do the process from zero in order to get accustomed to the programming language, writing all the semicolons, closing curly brackets, and so on.

Download Button_Blink

Download Button_Blink_02