What is a Microcontroller?

 

A microcontroller is a self-contained system with peripherals, memory and a processor that can be used as an embedded system. Most programmable microcontrollers that are used today are embedded in other consumer products or machinery including phones, peripherals, automobiles and household appliances for computer systems. Due to that, another name for a microcontroller is "embedded controller." Some embedded systems are more sophisticated, while others have minimal requirements for memory and programming length and a low software complexity. Input and output devices include solenoids, LCD displays, relays, switches and sensors for data like humidity, temperature or light level, amongst others.

 

 

Assignment:

Individual

-Read a microcontroller datasheet

-Program your board to do something

    -With as many different programming languages

    -And programming environments as possible

 

Group

-Compare the performance and development workflows for other architectures

 

Software :

-Eagle

-Mods

-Arduino

 

Materials :

-FR1 Boards

-Datasheets

 

Accomplised

 

-Understood what to look for in a datasheet

-Learned how to program a board

- Learned a couple of ways to communicate with the board

 

 

Group Work

 

Download Files

IC is just a package . It could be a single gate in IC, several gates, a microcontroller (which is effectively a complete computer), a processor, memory or just some analog circuit. There might be not only transistors in IC, but passive compenents like resistors and capacitors too.

 

Logic components like NOR, NAND, etc are basic building blocks for computer, so yes, any processor or memory is built of logic gates

Datasheet

 

A datasheet, data sheet, or spec sheet is a document that summarizes the performance and other technical characteristics of a product, machine, component (e.g., an electronic component), material, a subsystem (e.g., a power supply) or software in sufficient detail to be used by a design engineer to integrate the component into a system. Typically, a datasheet is created by the component/subsystem/software manufacturer and begins with an introductory page describing the rest of the document, followed by listings of specific characteristics, with further information on the connectivity of the devices. In cases where there is relevant source code to include, it is usually attached near the end of the document or separated into another file.

 

 

Where to find a datasheet?

 

Every manufacturer while producing an MCU will definitely print a datasheet as well. It's like a manual. Datasheet can be found on the manufacturer's website or even by simply googling the name of the MCU.

 

 

I went through several website trying to figure out how to read a datasheet. There are so many abbreviations and technical terms that couldn't comprehend. I wouldn't say I understood all of them but I figured out a simple way to use the datasheet.

 

The most logical way is to question what the processor is going to be used for and in what environment it is going to be used in. This would give a brief idea whats in the datasheet.

 

So the questions that I've come up with to understand the datasheet are these:

 

 

 

-What does this MCU have?

-What is it made of?

-What & How do I connect my devices?

-What conditions should I use them in?

-How can I use it in my design of PCB?

 

Answering these simple question will give a basic idea of whats in the datasheet. The datasheet I'm going to explore can be downloaded from HERE

 

Its Attiny family MCU from Atmel

 

What does this MCU have?

 

The Features on the first page of the datasheet is the answer to this question.

 

 

Features

This page explains what type of processor it is, what its architecture, the memory information on it, peripheral features, some special features that it may have, I/O and packages. When you go through this, you get a basic idea of the processor and if it will or will not suit your needs.

 

What is it made of?

 

Now we know what the processor packs, but its also necessary to understand how they are packed.

Block Diagram

This block diagram provides a schematic idea of how the processor works. It gives a brief idea of how the information gets in - processed  - get's out of the processor. This is essential because it gives the user an idea of how the processor is going to behave with the given information. Now in the diagram as shown, ADC is connected to PORT-A, ISP interfaces are to PORT B. This can also be understood by looking at the pinout, but this is for in-depth understanding

 

What & How do I connect my devices?

 

A circuit may have various components in them and some may interact with the MCU and some won't. The interacting devices are also of vast types like input or output devices, clock, sensors (digital and analog) etc. In an MCU each pin is specified a certain task and they have to be connected accordingly. To help understand this the manufacturer provides the user with this pin configuration.

Pin Configuration

When I started looking at the abbreviation I found it hard to identify what was what. So here is a list of abbreviations and even if not the abbreviations can be googled and can also be checked what its function is.

Port Information

VCC-           Voltage, common collector

GND-           Ground

PCINT-        I/O Pins

XTAL-          Crystal Oscillator

RESET-       Reset

MOSI-          Master Out Slave In

MISO-          Master In Slave Out

OC-              Timer

ADC-           Analog to Digital Converter

SCK-            Serial Clock

AIN-             Analog Comparator

 

Further even there is graphical pinpoint such as these that help in understanding the processors better.

Graphical Pinout

What conditions should I use them in?

 

 This is an important question. If the processor is not used in the way they are meant to, it would lead to the frying of the processor or connected device, malfunction etc. To avoid all this from happening the manufactures provide the user with information on how to use the processor optimally. The following are some of the factors to be considered.

 

Memory

This section describes the different memories in the Atmel® ATtiny24/44/84. The AVR® architecture has two main memory

spaces, the data memory space, and the program memory space. In addition, the Atmel ATtiny24/44/84 features an

EEPROM memory for data storage. All three memory spaces are linear and regular.

Memory

 This section deals with topic s like the programmable memory available, then the data memory access times, how to erase/write memory.

 

Power

This is a very important parameter. Less power leads to malfunction of the processor and high power may result in frying od the chip. The manufacturers provide the optimum power that's required. There is even table showing the maximum that it can take and the optimum level that required.

Power

Registry summary

This provides with information on how the data is distributed within the processor. Registers are the data holding spaces where micro-controller holds the specific data. These registers can or can't be read or written with the content. Few registers hold the status of the device, some of them holds the configuration of the device.

Registry Summary

Clock

 Most of the processors these days come with inbuilt clock. This section in the data sheet provides all the information on the clock cycles of the CPU clock, I/O clock, Flash Clock etc.

Clock

How can I use it in my design of PCB?

 

There are several types of MCU depending upon how they are packed. Here are a few types

 

Thin Shrink Small Outline Package (TSSOP)

MicroLeadFrame (MLF)

OPQFN - Open-molded Quad Flat Pack No Leads

Small Outline Integrated Circuit (SOIC)

Plastic Dual In-Line Package (PDIP)

So to solder or to design a PCB for a specific MCU the dimension is required. This information can be accessed from the packaging information in the datasheet

Packaging Information

These are some of the basic information that is provided in the datasheet. One needs to study the datasheet before designing the PCB for that MCU.

 

 

Programming

 

To program, I designed a new board with LDR(Light Dependant Resistor) as a switch and connected it to an RGB led with Attiny 45 as my processor. You can check out this page to see how I designed.

LDR Scheme

LDR Board

Cut & Trace

I soldered all the components and this was my board.

Soldered Board

I did a similar kind of design in week 7 where I programmed it using the Arduino software and also using Arduino hardware to program. How I installed the attiny family in the software can be viewed in my Week 7

 

This time to programmed the board I decided to use Arduino but then I used my USBitny that I had made in Week5 as a programmer

 

 

Connecting FabISP to Board

Once the board is connected to ISP, connect it to USB port for programming.

Step 1 is to setup the right board and processor type for programming.

Setting Board

The programmer needs to be USBtiny. I was stuck while programming as I had no clue about the language.

 

I found this video online that I followed to help me program

https://www.youtube.com/watch?v=v8pHgQ4iVe4

I made a few modifications to the program to suit my needs. Once the program is written it needs to be compiled.

Program

Compile

 This process checks the code for errors, and if there are any will be highlighted.

Debugging

Uploading

Once the debugging process is complete it time to upload the program to the board. But before this, the jumper needs to be connected to both the boards correctly. It better to check the circuit diagram of both the boards and connect them appropriately.

Code

#define ldr 3

#define Rpin 4

#define Gpin 0

#define Bpin 1

 

int Rvalue;

int Gvalue;

int Bvalue;

 

void setup() {

 

pinMode(ldr,INPUT);

pinMode(Rpin,OUTPUT);

pinMode(Gpin,OUTPUT);

pinMode(Bpin,OUTPUT);

 

}

 

void loop() {

 int x =analogRead(ldr);

  x=map(x,0,1023,0,100);

 

 

if(x<=15)

{

  digitalWrite(Rpin,LOW);

  digitalWrite(Bpin,HIGH);

  digitalWrite(Gpin,LOW);

 

 

 //delay(150);

}

if ((x>15 && x<=25))

{

  digitalWrite(Bpin,LOW);

  digitalWrite(Rpin,HIGH);

  digitalWrite(Gpin,LOW);

 

 //delay(50);

}

if(x>25 && x<=40)

{

  digitalWrite(Gpin,HIGH);

  digitalWrite(Rpin,LOW);

  digitalWrite(Bpin,LOW);

 

// delay(150);

 

}

if(x>40 && x<=60)

{

  digitalWrite(Rpin,HIGH);

  digitalWrite(Gpin,HIGH);

  digitalWrite(Bpin,LOW);

 

}

if(x> 60 && x<= 71)

{

  digitalWrite(Rpin,HIGH);

  digitalWrite(Gpin,LOW);

  digitalWrite(Bpin,HIGH);

 

 //delay(150);

}

if(x>71)

{

  digitalWrite(Rpin,HIGH);

 digitalWrite(Gpin,HIGH);

  digitalWrite(Bpin,LOW);

 

 //delay(150);

 

}

}

 

Connecting Board to ISP

The result was amazing. The board was working perfectly fine.

Programmed Board

I used my ISP programmer to re-program the board I had designed in week 7. The only changed I had to make from the previous method was to change the programmer, board etc. Everything else was the same and it worked perfectly.

ISP TO TRI Board

Code

int red = 4;

int blue = 1;

int green = 0;

int BUTTON = 3;

 

void setup(){

 

pinMode(red,OUTPUT);

pinMode(green,OUTPUT);

pinMode(blue,OUTPUT);

 

 

pinMode(BUTTON,INPUT);

 

}

 

void loop(){

int a = digitalRead(BUTTON);

if(a == HIGH)

{

 

digitalWrite(red,0);

delay(100);

digitalWrite(red,1);

digitalWrite(green,0);

delay(100);

digitalWrite(green,1);

digitalWrite(blue,0);

delay(100);

digitalWrite(blue,1);

 

 

}

else if (a == LOW)

{

 

digitalWrite(red,1);

digitalWrite(green,1);

digitalWrite(blue,1);

 

}

 

}

Programmed TRI

Programmed Boards

Week 9 Group Work:

 

The assignment was to compare the architecture of different micro processors. This went as more like a discussion in the group. Out of 4 we split into two where each one read about Harvard Architecture and while the other read about Von-Neumann architecture.

I read about Harvard architecture, and that is what is used in almost all devices today. Harvard is better than Von-Neumann as it can carry out multiple functions at the same time and need not wait for a set of instructions to be complete to start with a new one. All our modern gadgets are based on this. It can read instructions, perform memory access simultaneously thus increasing the performance and speed of the system.

Additionally we took up responsibility to document different weeks in the group website. It was my responsibility this time to document the website.

Conclusion

 

As I said, in the beginning, I did not understand half of what was being discussed during the lectures. All the terminologies were new and did not really understand what was happening, but as it turns out this week was very informative and thanks to Electronic design week I was able to quickly grasp the information in the datasheet. The week was quite informative and I think I'm still at just at the threshold of electronics.

Files

 

All files can be downloaded from HERE

WEEK 9

This week is Embedded Programming. I must stay its a very new topic for me and has a lot to learn. Neil started the lecture with a different type of architecture of a microcontroller. Then we discussed the memory and peripherals of the microcontrollers. Then he spoke about the different families they are being classified into and the vendor details for the same. After an in-depth discussion on them, he moved to programmers and language, their basics, debugging, how to communicate the language to the processor etc. To be honest, I did not understand 60% of what was being said, but I guess these are the thing that you will eventually know once you start using them.