This week was a huge dive in the microcontroller world which is full of possibilities. I read the microcontroller datasheet and took a few weeks of experimentation and reading to get some kind of understanding that I summarized here below. I tested the use of the PWM output pin of the microcontroller to make a led to blink with a varying intensity (sinusoidally). I then used the serial transmission to make the board do something and also read something from it. I've sent an ascii character and read the corresponding numerical value through the serial line. Along the way, I found that my echo hello-world board had some problems that I solved back on week 6.
I started by opening this data sheet of the 8-bit AVR Microcontroller with 2K/4K/8K Bytes In-System Programmable Flash (ATtiny24A, ATtiny44A, ATtiny84A) which is 286 pages long.
The first thing I looked at is at the pin descriptions that depends on the microcontroller we have, here it is the ATtiny84 microcontroller. All the pins can have different functions that can be found at the beginning of the datasheet. A critical limitation of the microcontroller is the number of pins and the functions they allow. the most important ones are
I found this unofficial pinout diagram pretty useful to have an overview of what each pins does.
If more information is required, we can dig into the microcontroller datasheet. For example, the ADC (Analog to Digital Converter) is detailed on page 132. The way we should add the external clock on the board is explained on page 28.
It is interesting to dig further into the microcontroller and learn more about this complete ecosystem. It is impressive how many possibilities are hidden into this millimetric microchip. Looking into the block diagram, we learn about the chip's AVR enhanced RISC architecture.
In the ATtiny84 microcontroller, I've learned that there are 6 types of memory:
The ATtiny can perform about 1 MIPS (Millions of instructions per second) per MHz which means that for internal or external clock of 20 MHz, it can perform about 20 MIPS.
Arduino's are often really well known and used in the maker community. But what about them ?
An Arduino is made of 5 different things:
Diving into the world of microcontrollers can feel overwhelming as it opens enormous possibilities. So keep moving and learning bit by bit seems a good option. If I think about some questions that I have at the moment, here are they: What are the limits and the possibilities of these little microcontrollers ? For what kind of applications are they useful ? Are they reliable for scientific data acquisition ?
To program the board I made on week 6, I used an Arduino micro ISP to upload a program on the microcontroller.
To do that, I used the Arduino IDE. I opened the simple "blink" program to test the microcontroller. In the program, I just changed the led pin number to 7. In Arduino's world pin 7 corresponds to the pin number 6 of the microcontroller (see above pinout diagram) on which the led is wired on my board.
To connect my ATtiny, I had to upload additional board manager in the Arduino IDE. I have followed this tutorial.
Then I set the microcontroller parameters in the tool tab and uploaded the program.
Problem !! I used the wrong microcontroller on my board... The ATtiny44 I soldered has an external clock limited to 16MHz and I am using a 20Mhz. We thus had to change the microcontroller and use a ATtiny84 instead. Let's unsolder the ATtiny44 and solder back the ATtiny84.
Ok, now everything seems to work properly.
David had a problem with the external clock of its board. We debugged it using an oscilloscope. Here we can see the oscillation of the 16MHz crystal.
I wanted to learn more about PWM. Thus I followed this PWM tutorial and I made this code to make the led to blink at different intensities (sinusoidally).
Code to make the led to blink sinusoidally
I then explored the world of serial communication following this Serial communication tutorial. I used an FTDI cable and I found that something was wrong with the board. In fact there was a problem with the reset pin of the FTDI cable that I corrected here on week 6.