9. Embedded programming

This week I will:

  • Compare the performance and development workflows for other architectures (group project)

  • Read a microcontroller data sheet. Program my board to do something, with as many different programming languages and programming environments as possible (individual project)

Research

  • Visited LCCC Fab Lab this week during our Spring Break to fulfill the requirement in my remote student agreement.

  • Found that the 3D Benchy was printed there too :)

  • Met Paul and Brigette O’Neill and our instructors Scott Zitek and Chris Rohal. Below photos taken and provided by Paul O’Neill

  • Proof of presence :)

Results

  • Used Atmel Studio 7.0 to read a USBTiny device using the Atmel ICE as the tool, but could not access it. I tried reading an Arduino UNO which did work. Prefer to use avrdude going forward

  • Skimmed the data sheet for the ATtiny and found the section on temperature measurement. I will be able to use this for my wearable temperature display. Also found the table of contents at the end.

  • Waves were coming in big sets and I got washed into shore a couple of times. I paddled out, again, each time; and now I can ride these waves and will only improve with practice.

  • The main obstruction was the coding and wondering whether I was doing it right. Although I got the FabTinyISP made and programmed twice, I still felt like I cookbooked the whole process and didn’t truly understand what I was doing. I followed http://fab.cba.mit.edu/classes/863.16/doc/projects/ftsmin/index.html and really appreciated the help. I am not comfortable yet, but I will be with time.

  • When I visited LCCC, I had been dabbling in Eagle, but I really wanted to learn to use the python code that Neil showed us. Paul and Bridgette helped, but I just didn’t like the interface. Eagle was nice for stuffing the board, but the trace placement was a little frustrating. I couldn’t put the traces exactly where I wanted to and was at the mercy of the “program”. This was in the “Make Something Big” week and I was already behind. I really needed to get things going to get caught up.

  • When I got back home, I really immersed myself into the python and got “outside”. I used the board image and the hello.ftdi.44.py to get the hang of it. Once I got the switch and LED figured out, I needed to learn how to program the board. I wasn’t even sure if my FabTinyISP would be able to program my Hello World board. Thankfully, I did manage to program and Putty into the Hello World board and make it talk to me 🙂 I made that entry in Week 7 Electronics Design where it was supposed to be done.

  • Next I had to build the Input Board. I intended to use temperature as my input. I spent a lot of time trying to refine my documentation process; I’m still not there, yet. After organized git and mkdocs, I immersed myself into python. I used Neil’s board as a guide and stuffed the python board from scratch; that, running the traces, and milling the board took the rest of my Saturday. That night, I made Hello World work. On Sunday, I got the LED to flash S-O-S when I held the button.

  • Here are some artifacts of where I have been. Kelly Shaw really helped me out today! Thanks, Kelly!! http://fab.cba.mit.edu/classes/863.11/people/kelly.shaw/week7_embedded_programming.html

  • Referred me to this http://highlowtech.org/?p=1695 and this http://highlowtech.org/wiki/pmwiki.php?n=Main.AVRProgrammingAdvanced But this was the biggest find of all from Kelly http://www.nongnu.org/avr-libc/ and this http://www.nongnu.org/avr-libc/user-manual/pages.html and got me to this https://www.microchip.com/webdoc/AVRLibcReferenceManual/group__avr__io.html

  • I tried to program the ATMega328P, but I will have to save that for another day https://www.sparkfun.com/datasheets/Components/SMD/ATMega328.pdf

Code Example

// LED Button S-O-S Program
//Credit goes to Kelly Shaw MAS.863 / FALL 2011 for the assistance I discovered through Google
#include <avr/io.h>
#define F_CPU 1e6
#include <avr/delay.h>

#define TRUE 1
#define FALSE 0

int main()
{
//SETUP
//Button is on PB2
//LED is PA7

PORTB= _BV(PB2); //Turn button pullup resistor on
DDRA = _BV(PA7); //Enable output on the LED pin
PORTA = _BV(PA7); //Turns LED on

//LOOP
while (TRUE)
{
if ((PINB & _BV(PB2))) //button is not pushed
{
PORTA = 0; //turn LED off
}
else
{
PORTA = _BV(PA7); //turn LED on
_delay_ms(500);
PORTA = 0;
_delay_ms(500);
PORTA = _BV(PA7); //turn LED on
_delay_ms(500);
PORTA = 0;
_delay_ms(500);
PORTA = _BV(PA7); //turn LED on
_delay_ms(500);
PORTA = 0;
_delay_ms(1500);
PORTA = _BV(PA7); //turn LED on
_delay_ms(1500);
PORTA = 0;
_delay_ms(1500);
PORTA = _BV(PA7); //turn LED on
_delay_ms(1500);
PORTA = 0;
_delay_ms(1500);
PORTA = _BV(PA7); //turn LED on
_delay_ms(1500);
PORTA = 0;
_delay_ms(500);
}
}
}