Week 8 - Embedded Programming


Program your board



Steps:
* Learn basics
* Boolean expression
* Test the board and program it in C


Learn basics

Computers use "bits" (short for "binary digits") to represent information in digital form. A computer bit is a binary value. When represented as a number, bits can have a value of either '1 (one)' or '0' (zero) and that's why it is a binary system. Modern computers generate bits from higher and lower electric voltages running through the device's circuits.





It is important to know that bytes are abbreviated with a capital B, where as bits use a lowercase b. Therefore, Mbps is megabits per second, and MBps is megabytes per second. So 8Mbps is equal to 1MBps..
Bits are most often used to measure data transfer speeds, Bytes are used to measure data storage. Just for remember: internet at 20 Mb per second? Your files will download at 2.5 MB per second.
Hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a, b, c, d, e, f) to represent values ten to fifteen.







Boolean expression

In computer science, a Boolean expression is an expression in a programming language that produces a Boolean value when evaluated. A Boolean expression may be composed of a combination of the Boolean constants true or false, Boolean-typed variables, Boolean-valued operators, and Boolean-valued functions. Boolean expressions correspond to propositional formulas in logic and are a special case of Boolean circuits.





There are another important concept: the conditions. The most important for a biginner like me are: IF-ELSE, FOR, DO, WHILE.
Before starting remember also the structure of a coding sheet: Declaration - Main - Function.







Test the board and program it in C

Program a micro controller means to know its structure, how it is build inside, how it communicate with the outer world and what I can or can not do with it. I want try a lot of ISP in order to have a different experience in this new world and have a lot of practice: in this assigment I'll use my fabISP, an ArduinoUNO as ISP and a commercial ISP.
I decided that my board will be a simply blinking echo, but when you'll press the button keeps the LED on.
I plug in the bord using my FTDI board and no overhating nor smoke happened.





I decide to make something easy to program it in C, so I take the hello.ftdi.44.echo.c and the hello.ftdi.44.echo.c.make in order to analyze them. First of all, I read the datasheet and I choose how to manage input and otput.





So I start with the .c file and I copy the #include part,



I modified the #define part,



I create a main, where microcontroller starts to execute the code and find all the operations to do.



I create a command: I use "while (1)".
While introduces a cycle and with condition,(1) means that is always true. Set and clear mean turn on and turn off the led.



I opened the Makefile and I modified it: I have a 20 Mhz frequency resonator, but we had problem with this component, so I decided to use the 10Mhz internal one.
I also deleted all the programmers and I create a program-arduinoisp, that I will use.






REMEMBER: .c file and makefile should be in the same folder, and makefile should not have any extension!
As I told, I decided to try an ArduinoUno as ISP following this web page.






Open the terminal, go to the .c and Makefile folder and write: make program-arduinoisp. Taht's it!
Than I changed the original make file in order to use my FabISP (just delete the others) and I use it.





boardW8.c
Makefile

I then changed the programmer to make the delay testing, and on that occasion I used a commercial avrispmkii , which is what you find now in the make file.





Now I had apparently an useless echo hello-world board, but it works well and if necessary can light up a room!



RETURN UP


Week 7 / Computer-Controlled Machining week 9 / Mechanical Design