Tuesday, July 21, 2020

How to build your own microcontroller board from scratch







Hey peeps, welocome back to the channel. so,this is a kind of tutorial blog to let u known what it takes to build your own microcontroller from scratch
 
I hope this blog will guid you to build your own microcontroller board from scratch.


TARGETED AUDIENCE
This blog is for those who are curious to build projects by thier own but don't know how and where to start. during my initial days of learning i have faced problems due to the lack of resources to learn from, all the articles out there in the internet were too complex,and they are not at all beginner friendly

if this blog helps even a single person my major goal is achieved. for this tutorial on building a microcontroller board ,i'll start from scratch.

let's get started...


WHAT IS A MICRO CONTROLLER??

Let me tell u this, Microcontrollers is the thing which excited me when i was learning. i was all the time thinking of using them to build my own projects, i read many articles about them in quora the information i got to read, made me to feel power full, unstoppable.

as per the defination, it is an integrated circuit that contains a microprocessor along with memory and associated circuits and that controls some or all of the functions of an electronic device (such as a home appliance) or system















the question which fascinated me all the way in my learning stage was "What can we do with it???", And the answer to that question is "Almost Anything", you can make it talk,listen,walk,swim,spy...you name it and it will do it.(ofcoz with help of sensors and acctuators). The possibilities are endless.

let us consider a scenario that you want to build a robot, for this u have to specify the tasks you want your robot to do, and add sensors actuators(motors and devices which help to move) according to the need and the final part is to programme the controller to perform tasks.

when you know how to build microcontroller circuits, there will be no limit for what you can do.

A microcontroller has several pins 40 pin,100pin...etc,most of these pins are there for the input and output purpose, so that the microcontroller can interact with the outside world.

 








we are told that computers are intelligent, but the fact is they are not!!!. It is we who programme them to behave like intelligent, microcontrollers fake intelligence.we programme them to do what ever we want, the programme you write will control the I/O(input and output) of it.

inputs are used to get the information from the outside environment and outputs are send to change the environment.the outputs are programmed according to the inputs it get.for example let us consider an automatic hand sanitiser. In the automatic hand sannitiser we use proximity sensor(which senses things or objects when they come near to it) this sensor will sense the hand movement and send the data to the controller, now the controller will output the signal to the spraying machine to spray sanitiser on hand.


PROGRAMMING THE MICROCONTROLLER

Programming a microcontroller is bit complex because there are many choices to make (you dont need to worry about that), I remember how confusing it is with the enormous no.of softwares, IDEs, programmers and etc..,

so lets break this down first,there are three steps in programming 
1. Write code
2. Compile it to machine code
3.upload the the machine code to microcontroller with the help of a programmer(see the image)




have you ever questioned that "how the computers can understand the code we write in C,C++,python..etc.???" . The answer is simple, the code we write in the editor is compiled, which means the code we wrote will be converted into assembly language and then the assembly code is coverted into hex.file this hex file is dumped into the microcontrollers.


Now lets get back to the actual task which is to build a microcontroller board. First we have choose a microcontroller which is perfect for our needs.there are millions of types you can choose from.


Ok, let me help you choose.


CHOOSING A MICROCONTROLLER

This part is as confusing as a girl confused between a pink dress and a black dress (ok, its a bad joke but you have no choice ). the confusion is because there are millions of options to choose from.

As cristofer nolan quoted that  "FILM IS AN INTELLIGENT COMPROMISE". Same thing applies here as well, so we need to make a intelligent compromise as well. atleast you should know what you really want.

When you have the answer for this question, everything becomes much simpler. lets first look at the differences between microcontrollers.

NUMBER OF BITS

 In the market out there you can find 8-bit,16-bit,32-bit...etc, an 8-bit microcontroller is nothing but a controller which is capable of taking 8-bits at a time to perform actions. same with the others as well As the bit size increases speed also increases accordingly. the 8-bit microcontroller is the most used by the hobbyists.


MEMORY,IO AND PERIPHERALS

Different microcontrollers have different amount of memeory, no.of IO pins and peripherals.
peripherals are nothing but extra funtionalities which are added to the microcontrollers such as ADC(Analog-to-Digital converter),DAC(Digital-to-Analog converter) and etc..,The most used microcontroller are AVR and PIC ,the microcontoller which is used in the arduino uno.

since we have many softwares for the arduino and there are no.of bloggs out there to help you, the arduino community is a huge community. so let us select AVR.

so, now we narrowed it down to a 8-bit AVR microcontroller, our next goal is to design a simple microcontroller board,we need a simple circuit to connnect our microcontroller to a USB of computer so that we can programme it.


There are several ways to programme a microcontroller, they are by adding a USB to serial converter which converts the USB data to machine understanding code.
The other way of doing it is to choose a microcontroller which has in-built USB interface it reduces the space on board.

and one thing we should consider is to make sure that the microcontroller comes with pre-loaded bootloader so that it can understand the code we send to it,otherwise we have to programme the bootloader which is tidious process.

and last requirement is to make sure that it is of decent size so that it will be easy to solder it.

there are some softwares which can be used to select the microcontrollers and other components as well.
USB to Serial converter


HOW TO DESIGN A MICROCONTROLLER CIRCUIT

Now we are stepping into the next level which is designing the circuitour goal is to design a simple microcontroller circuit with all the components needed.so, what are the components we need to build a controller board

WHAT COMPONENTS DO WE NEED TO BUILD CIRCUIT??

Let's think about it, First we need a poweer supply to power up the board next we need a usb connection because we need to programme the controller , as we have in-built USB interface we dont need a USB -SERIAL convertor, And we some input and output pins so that we can connect sensors, actuators and peripherals which are required like LEDs,MOTORS,ADCs and DACs...etc.

1. Power
2. USB connection
3. Pins to connect peripherals and IOs.


DATASHEETS

To know which components like resistors,capasitors..etc do we need and how to connect them you have to refer the DATASHEETS(link for ATmega32U2 microcontroller). The datasheets consists of technical data on how th microcontroller works specifications and how to connect different parts...so on.

They are too lengthy to read because they consists of lot of information, but we just need to read what ever we required.fo example for power supply, go to the power supply part of the datasheet there you can get information about how to connect what values of resistors to be used, how to connect them and how much supply is need and etc.








similarly for the USB connetions, UART connections etc.from the guide lines mentioned in the datasheet we select the passive components like resistors,capacitors etc,


CRYSTAL

A microcontroller needs clock to work it is heart of the microcontroller, In the imaage above we can see that there is a crystal and two capacitors connetcted to XTAL1 and XTAL2 pins, most microcontrollers have internal oscillators that generate clock signals. But the thing is the devices such as peripherals and USB part of microcontroller is not able to run  from the internal clock. So, to make them work we add an external clock to the pins XTAL1  and XTAL2.

Now go to the crystal part of the DATASHEET  and from there you find the details about connections and capacitor values needed.






 

We want to connect periferals ,actuators like LEDs,motors...etc.So we'll add some physical pins to the board which are connected to IO pins PB0-PB7 & PD0-PD7 physical pins are nothing but the pins we see on the Arduino board these oins are used to connect LEDs,motors, semsors to the microcontrollers.


RESET-BUTTON

It is a very wise option to integrate reset button into the circuit this makes it easy to reset the micro controller, now go to the reset part of the DATSHEET to look at the reset circutary we need to impliment on board.






MICROCONTROLLER CIRCUIT DIAGRAM

  



If do all the steps we discussed above the circuit diagram will look something like this, in the  diagram above you can notice that there is no connection for some parts to the microcontroller, but when there is a name on a wire , it means the wire is connected to the other wire which has the same name.
This diagram is called as the schematic diagram. you can use softwares like KiCad to build circuits as above





Once you finished with the schematics now you have to design the PCB(Power Circuit Board) .
PCB is the final board on which all the components such as microcontroller ,USB slots, voltage regulators,resistors, capacitors, LEDs sits on.


you can use the JlcPCBonline store to place the order for PCBs,and the PCD will look like this


once you recived the PCBs and the Components you can solder them there are N-no.of videos on youtube which can teach you hoe to solder them.





  




THANK YOU



STAY TUNED FOR MORE.....







No comments:

Post a Comment

who owns the internet ???

WHO OWNS THE INTERNET ??? This is one such a question which most of us have but no one really questions it. Is it the internet providers lik...