Simulate First Electronics Project in Proteus ISIS
Hello friends, I hope you all are doing great. In today's tutorial, we will simulate our
First Electronics Project in Proteus ISIS. It's our 2nd tutorial in Proteus series. In our previous tutorial, we have seen a basic Introduction to Proteus and today, we will design a simple electronics circuit in it and will also simulate it.
If you want to work on Proteus, then you must have some prior knowledge about electronics. Proteus doesn't provide any suggestion about circuit designing so if you don't have electronics knowledge then you can't work with Proteus. Throughout this series, I will keep on explaining electronics circuits as well and will also embedded related components' links. So, if you are new to electronics then no need to worry and just follow these instructions and also do read those embedded links to understand electronic components. So, let's Create our First Project in Proteus:
Simulate First Electronics Project in Proteus ISIS
- Open your Proteus ISIS software and then click on Components Mode in left menu tab, as shown in the figure.
- After that click on the P (Pick from Libraries) Button, and a new window will open up.
- This new window is called Pick Devices and is used to make search for electronics components.
- Proteus has a huge database of electronics components in the form of libraries. i.e. Diode Library will have all the diode components.
- So, from these millions of components, we need to make a search for our required components to design electronic circuit.
- You can see Pick Devices window in below figure, so let's first discuss its layout:
- Keywords textbox is used to make a search for any component and Proteus will display the related components in Results panel. ( We will search in a while )
- Category Section displays all the categories available in Proteus and when you click on any category then it's components will be displayed in Results panel.
- After that, we have Sub-category & Manufacturer, rite now I don't have any.
- On the right side we have Schematic Preview & PCB Review, so when we select any component then its respective Previews will be shown here.
- So, now let's make a search for LED, as shown in below figure:
- As you can see in above figure that Proteus has provided us with 141 Results and I have boxed four LEDs, which I am going to use in my circuit.
- Moreover, Category section is now showing only those categories which are related to searched keyword.
- Moreover, we also have a Schematic Preview but we don't have any PCB Preview as it's not available for this component.
- So, double click on these four LEDs and they will be added in Proteus workspace.
- Moreover, we also need to add resistance so make a search for resistance, as shown in below figure:
- Double click on this RES component and then close this Pick Devices window.
- You will get these selected components in the Devices section, as shown in below figure:
- As we are designing a simple project so we have selected just four components but in complex projects, we have a long list of components in this Devices section and it proves quite helpful.
- So, let's place these components, one by one in the central work area.
- You can drag & drop them OR can select by clicking and then again click to place.
- I have placed these components in the work area, as shown in figure on right side.
- So, now let's connect them together using wires and for that, we need to click on the pin terminal of each component.
- I have combined these electronic components together using wires, as shown in below figure:
- Now we need to provide voltage supply to this circuit and there are several voltage sources in Proteus. ( We will cover them in coming lectures )
- For now, let's click on the Terminals Mode in the left Toolbar and you will get Proteus Terminals, as shown in figure on right side.
- From these terminals, we are going to use Power & Ground, so place them in the circuit, as shown in below figure:
- We will discuss all these Terminal Components in detail in our coming lectures.
- If we place multiple Ground components in the circuit then Proteus will consider them all as connected/short.
- These Terminals are quite helpful, as in complex circuits, these wires can become too messy and we can avoid them by using these terminals.
- So, we have completely designed our circuit but we need to change the properties of these components a little.
- So, double click on resistance to open its Properties Panel, as shown in below figure:
- From this Edit Component window, we can edit different properties of selected component.
- As you can see, first we have Component Reference, that's the name of our component i.e. R1. If we have multiple resistances, then there names will be R2, R3 and so on.
- We can't have multiple items with same Component Reference, as it will create an error.
- Second Property defines the resistance of the component and I have changed it from 10k to 1k.
- Then we have Model Type and its analog.
- Finally we have PCB Package, we will use it when we will be designing the PCB design of this circuit.
- So, click on the OK Button and resistance value will change from 10k to 1k.
- Now, double click on first LED to open its Properties Panel, as shown in below figure:
- As LED is a bit complex component as compared to resistance, that's why it has a lot more Properties to Edit.
- As we are designing a digital circuit, so we need to change the Model Type of LED from Analog to Digital and then click on the OK Button.
- You need to change this Model Type for all these four LEDs.
- So, now we have completely designed our first electronic circuit in Proteus.
- Let's run this simulation, by clicking the Play button at the bottom.
- If everything goes fine, then all LEDs will glow, as shown in below figure:
- We have successfully simulated our first electronics circuit in Proteus ISIS and you can see these LEDs have different colors as specified in their Reference Value.
So, that was all for today. I hope you have enjoyed today's tutorial. In the next lecture, we will have a look at How to use Relays in Proteus ISIS. Till then take care & have fun !!! :)
Introduction to Proteus
Hello readers, I hope you all are doing great. In today's tutorial, I am going to share a detailed
Introduction to Proteus. It's our first tutorial in Proteus series. Today's tutorial is for beginners but still I would suggest you to read it once, as I am going to explain why Proteus?
Throughout our Engineering Course, we have to design a lot of electronics or embedded circuits and it's always a best approach to simulate these circuits first on some simulation software i.e. Proteus, PSPice etc., before assembling them on actual hardware. Among these simulation software, Proteus is my favorite one so let's get started with detailed Introduction to Proteus:
Introduction to Proteus ISIS
- Proteus Design Suite (designed by Labcenter Electronics Ltd.) is a software tool set, mainly used for creating schematics, simulating Electronics & Embedded Circuits and designing PCB Layouts.
- Proteus ISIS is used by Engineering students & professionals to create schematics & simulations of different electronic circuits.
- Proteus ARES is used for designing PCB Layouts of electronic circuits.
- It's available in four languages i.e. English, Chinese, Spanish & French.
Why use Proteus ?
"Our circuit is working perfectly on Proteus but when we have implemented it on hardware, it's not working.
" I receive a lot of such questions from engineering students, that's why, I am explaining what's the real purpose of Proteus:
- Proteus is quite lenient in circuit designing and it works on ideal conditions i.e. if you don't add pull up resistors in Proteus simulation, then it won't give garbage value.
- Proteus is also used for PCB designing, we use Proteus ARES for that. ( We will discuss it in upcoming lectures )
So, when I am working on some electronics circuit, then I first design the
simulation on Proteus ISIS and once I got sure that everything's working fine then I design its circuit on either the vero board or the bread board and again I perform some real world testing & when I got sure that my circuit is fully working then I design its PCB in Proteus ARES.
- Proteus is also used for designing/testing programming codes for different Microcontrollers i.e. Arduino, PIC Microcontroller, 8051 etc.
In Embedded projects, we need to design a programming code for Microcontrollers and for designing such codes you have to perform a lot of testing, which involves uploading code to Microcontroller. So, in such projects, Proteus is a great relief. Let's say, you have to print some strings on 20x4 LCD, then its quite annoying to burn the Microcontroller several times for typographical errors. Instead, design a circuit in Proteus and test your code in the simulation and once you are sure that you are getting perfect output then burn your PIC Microcontroller and test it on real hardware. Quite easy and handy. In the coming classes, I will show you how to burn code in Microcontrollers in Proteus.
Note: In code testing, there's again a possibility that you get different results in real hardware but its quite rare and mostly happens in delay functions.
Getting Started With Proteus
You can download Proteus software from it's
official website and you should also read
How to Download & Install Proteus software. So now I hope you have installed Proteus and ready to work on it:
- Click on Proteus ISIS and it will open up as shown in below image.
- In the central area surrounded by blue lines, we design our circuit i.e. place the components and then join them together.
- As you can see in above figure that we have a lot of icons in Proteus software, so let's first understand these sections one by one.
- In the below image, I have divided the Proteus font-end in four sections:
- Section 1 is a toolbar which you would have seen on many simulation software, it has simple functionalities i.e. first icon to create a new layout, second one to open an existing layout, next one is to save layout, then there comes few zooming options and few other tools which we will discuss in coming tutorials.
- Section 2 has two buttons. P is used to open the components list and E is used for editing purposes, like you want to edit the properties of any component then simply click on that component and then click on E and it will open the properties of that component and you can easily edit it.
- Section 3 has different tools, used for designing circuits, we will discuss them in detail, at the end of today's tutorial.
- Section 4 is the remote control section of Proteus, as it contains four buttons i.e. Play, Step, Pause & Stop. In order to run the simulation, we have to click on this play button.
Component Selection in Proteus ISIS
- As shown in below image, click on the icon that says Click # 1, it's a Component Mode Icon.
- After that click on P button and a new window will open up named Pick Devices.
- In this new window there's a textbox on which Keyword is written, this text box is used for the component search.
- Proteus database has unlimited components in it so now in order to get your desired component, you have to search for it as I did.
- I have searched for PIC16F877A and Proteus provided me that component along with its preview in top right corner and PCB package ( if available ). Unfortunately, my Proteus doesn't have the PCB preview of PIC16F877A that's why it's blank.
- In order to add the component in Proteus workspace, either double click on it or click on the OK button.
Instruments in Proteus ISIS
- There are few measuring instruments available in Proteus, which you can open by clicking the Instruments Icon, as shown in figure on right side.
- First one is oscilloscope, we use it for viewing the behavior of different signals generated.
- Another important instrument is Virtual Terminal, it is shown on the fourth number. This Virtual Terminal is used for checking data coming through Serial Port.
- Then there's Signal Generator, it is used to generate signal like sine wave of desired frequency.
- We also have Voltmeter & Ammeter for both AC & DC.
- We will discuss them in detail in our coming lectures.
- As you can see in figure on right side, Icon A is called Graph mode, used to create graphs of voltage and current. It has different style of graphs.
- Icon B and C are voltage and current probes respectively. Suppose you have designed some circuit in Proteus and you want to check the value of voltage at any point in the circuit. In order to do so, simply select this voltage probe and place it there and when you run your circuit, the probe will show the value of voltage above it and same for current probe.
- Icon D is used when we want to design our own component in Proteus.
- Icon E is a simple text editor, used for placing labels, warning or components names etc.
So, that was all for today. I hope you have enjoyed this detailed Introduction to Proteus. If you have any question, feel free to ask in comments and also subscribe through email to our mailing list, so that you don't miss any part of this tutorial series. Stay blessed. Take care.
Introduction to ATmega128
Hey Guys! Hope you are doing well. I am back to feed you with valuable information relating to engineering and technology. Today, I'll uncover the details on the
Introduction to ATmega128. It is an AVR, 8-bit low power microcontroller, that comes with a 64-pin interface and is based on RISC architecture. Availability of 133 Powerful Instructions with single clock cycle and 32 x 8 General Purpose Working Registers make this device an ideal choice for many applications where decent code execution is required.
The memory space incorporates on this module is more than normal AVR controllers including Program memory around 128K, enough to store the number of instructions on a single chip.
In this post, I'll try to cover each and everything related to ATmega128, so you can get clear idea what is this about before aiming to pick it for your relevant project. Let's jump right in and get down to the nitty-gritty of this module.
Introduction to ATmega128
- ATmega128 is an AVR, 8-bit low power microcontroller that contains 64-pin interface and is based on RISC architecture.
- It is mainly used in an embedded system and industrial automation.
- This AVR controller differs from PIC controllers in accordance with the instruction set where AVR requires one clock cycle to execute a number of instructions while PIC controllers need a number of clock cycles to execute a single instruction.
- The ADC is included in the device that makes it an ideal choice for sensor interfacing where it receives the analog signal and converts it to a digital one. There are total 8 channels available on the ADC module.
- Apart from communications protocols like SPI, I2C, and USRAT, this tiny module comes with watchdog timers, external interrupts, power up timer, 6 sleep modes and programming enable pin.
- The Program Memory is based on Flash and comes with a memory space around 128K while EEPROM and SRAM are 4K each.
- If you are an expert or newbie, you need this module every now and then for the development of the electronic projects where automation is a major concern. Ability to perform a number of functions without buying external components makes this device highly economical and best choice for the tech geeks.
1. ATmega128 Features
This AVR microcontroller comes with very useful features. Large memory space and number of pins make this device a step ahead for driving automation in the relevant project. Following table shows the main features of ATmega128.
No. of Pins |
64 |
CPU |
8-Bit AVR |
Operating Voltage |
4.5 to 5.5 V |
Program Memory |
128K |
Program Memory Type |
Flash |
RAM |
4K |
EEPROM |
4K |
ADC
Number of ADC Channels |
10-Bit
8 |
Analog Comparator |
Yes |
PWM Channels |
6 |
Oscillator |
up to 16 MHz |
Timer (4) |
16-Bit Timer (2)
8-Bit Timer (2) |
Packages (3) |
PDIP
TQFP
QFN |
Power Up Timer |
Yes |
I/O Pins |
53 |
Manufacturer |
Microchip |
SPI |
Yes |
I2C |
Yes |
Watchdog Timer |
Yes |
Brown out Detection (BOD) |
Yes |
USART |
Yes |
Sleep Modes |
6 |
Minimum Operating Temperature |
-40 C |
Maximum Operating Temperature |
85 C |
2. ATmega128 Pinout and Pin Description
The pinout and pin description of each pin will help you understand the major functions associated with each pin. Some pins are able to perform more than one functions on each pin.
Pinout
Following figure shows the pinout of ATmega128.
- The AVCC is the voltage applied to the ADC module while AREF is the reference voltage applied to the controller. The VCC and GND are the voltage supply and ground pins respectively.
Pin Description
Following table shows the description of each pin.
1 |
PEN |
Programming Enable |
2 |
PE0
RXD
PDI |
I/O Pin
Serial Receive Pin (USART) |
3 |
PE1
TXD
PDO |
I/O Pin
Serial Transmit Pin (USART) |
4 |
PE2
XCK0
AIN0 |
I/O Pin
External Interrupt
PinAnalog Comparator Positive |
5 |
PE3
OC3A
AIN1 |
I/O Pin
Dedicated Pin for Timer (PWM Channel)
Analog Comparator Negative |
6 |
PE4
OC3B
INT4 |
I/O Pin
Dedicated Pin for Timer (PWM Channel)
Interrupt |
7 |
PE5
OC3C
INT5 |
I/O Pin
Dedicated Pin for Timer (PWM Channel)
Interrupt |
8 |
PE6
T3
INT6 |
I/O Pin
Timer 3
Interrupt |
9 |
PE7
ICP3
INT7 |
I/O Pin
Timer/Counter3 Input Capture Pin
Interrupt |
10 |
PB0
SS |
I/O Pin
SS (Slave Select Input for SPI). This pin is set to low when the controller acts as a slave |
11 |
PB1
SCK |
I/O Pin
SCK (Serial Clock for SPI). This clock is shared between the controller and external devices for accurate data transfer |
12 |
PB2
MOSI |
I/O Pin
MOSI (Master Output Slave Input) for SPI communication. The data is received by this pin when the microcontroller acts as a slave |
13 |
PB3
MISO |
I/O Pin
MISO (Master Input Slave Output) for SPI communication. The data is sent to the master using this pin when microcontroller acts as a slave |
14 |
PB4
OC0 |
I/O Pin
PWM Channel Output |
15 |
PB5
OC1A |
I/O Pin
PWM Channel Output |
16 |
PB6
OC1B |
I/O Pin
PWM Channel Output |
17 |
PB7
OC2
OC1C |
I/O Pin
PWM Channel Output |
18 |
PG3
TOSC2 |
I/O Pin
MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin
Interrupt |
19 |
PG4
TOSC1 |
I/O Pin
SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer
Interrupt |
20 |
RESET |
Voltage Supply Pin for ADC |
21 |
VCC |
Voltage Reference |
22 |
GND |
Ground Pin |
23 |
XTAL2 |
Crystal Oscillator Output |
24 |
XTAL1 |
Crystal Oscillator Input |
25 |
PD0
SCL
INT0 |
I/O Pin
I2C communication
External Interrupt 0 |
26 |
PD1
SDA
INT1 |
I/O Pin
I2C communication
External Interrupt 1 |
27 |
PD2
RXD1
INT2 |
I/O Pin
Serial Communication Receive Pin (USART)
External Interrupt 2 |
28 |
PD3
TXD1
INT3 |
I/O Pin
Serial Communication Transmit Pin (USART)
External Interrupt 3 |
29 |
PD4
ICP1 |
I/O Pin
Timer/Counter1 Input Capture Pin |
30 |
PD5
XCK1 |
I/O Pin
External Clock I/O for USART |
31 |
PD6
T1 |
I/O Pin
Timer 1 |
32 |
PD7
T2 |
I/O Pin
Timer 2 |
33 |
PG0
WR |
I/O Pin
Control Pin for writing to the external memory |
34 |
PG1
RD |
I/O Pin
Control Pin for reading from the external data memory |
35 |
PC0
A8 |
I/O Pin |
36 |
PC1
A9 |
I/O Pin |
37 |
PC2
A10 |
I/O Pin |
38 |
PC3
A11 |
I/O Pin |
39 |
PC4
A12 |
I/O Pin |
40 |
PC5
A13 |
I/O |
41 |
PC6
A14 |
I/O Pin |
42 |
PC7
A15 |
I/O Pin |
43 |
PG2
ALE |
I/O Pin
ALE (Address Latch Enable), it is used when multiple memory chips are connected to the microcontroller and only one of them needs to be selected |
44 |
PA7
AD7 |
I/O Pin |
45 |
PA6
AD6 |
I/O Pin |
46 |
PA5
AD5 |
I/O Pin |
47 |
PA4
AD4 |
I/O Pin |
48 |
PA3
AD3 |
I/O Pin |
49 |
PA2
AD2 |
I/O Pin |
50 |
PA1
AD1 |
I/O Pin |
51 |
PA0
AD0 |
I/O Pin |
52 |
VCC |
Voltage Supply Pin |
53 |
GND |
Ground |
54 |
PF7
ADC7
TDI |
I/O Pin
ADC Channel 7
JTAG Interface |
55 |
PF6
ADC6
TDO |
I/O Pin
ADC Channel 6
JTAG Interface |
56 |
PF5
ADC5
TMS |
I/O Pin
ADC Channel 5
JTAG Interface |
57 |
PF4
ADC4
TCK |
I/O Pin
ADC Channel 4
JTAG Interface |
58 |
PF3
ADC3 |
I/O Pin
ADC Channel 3 |
59 |
PF2
ADC2 |
I/O Pin
ADC Channel 2 |
60 |
PF1
ADC1 |
I/O Pin
ADC Channel 1 |
61 |
PF0
ADC0 |
I/O Pin
ADC Channel 0 |
62 |
AREF |
Reference Voltage |
63 |
GND |
Ground |
64 |
AVCC |
Voltage Supply Pin for ADC |
3. ATmega128 Main Functions
ATmega128 can perform a number of functions on a single chip. Large memory space with more number of pins interface put this device ahead of other controllers available in the AVR community.
Following are the major functions associated to this tiny module.
Timer
Atmega128 comes with four timers i.e. two 8-bit and two 16-bit timers. These timers play a vital role in creating a delay of any running functions and can be used both ways i.e. timers as well as counters where former is used to control the internal functions of the controller and increments the instruction cycle, while later counts the number of intervals by incrementing the rising and falling edge of the pin and is mainly used for external functions. Two other timers added in the device are
- Oscillator Start-up Timers
- Power Up Timer
Oscillator start-up timer resets the controller to stabilize the crystal oscillator. And power-up timer is used to generating a minor delay once you power on the device, helps in stabilizing the power signals.
Number of Sleep Modes
This device incorporates Six Sleeping Modes for power saving purpose. These modes include:
- Power-save
- Power-down
- Idle
- ADC Noise Reduction
- Standby
- Extended Standby
Brown Out Detect (BOD)
The BOD, also known as BOR (Brown Out Reset), is a valuable addition to the device that helps in resetting the module once the Vcc (voltage supply) goes below a brownout threshold voltage.
In this mode, multiple voltage ranges are produced to save the module once the power drops at the voltage supply line.
If you aim to bring back the device from BOD function, it is advised to enable the Power Up Timer for creating a slight delay.
Watchdog Timer
Most of the chips, if not all, produced by Microchip, incorporate a built-in watchdog timer that resets the controller if the running program hangs up during compilation or gets stuck in the infinite loop. The main purpose of this timer is to prevent the controller from resetting it manually, giving you a slight edge over other processors where you need to wrestle your mind to manually reset the controller in case there comes a glitch in the running function. The watchdog timer behaves like a countdown timer.
Interrupt
The interrupts are very helpful for calling the desired function that puts the main running function on hold until the required instruction is executed. The controller goes back to the main program once the interrupt is executed.
I2C Communication
I2C protocol is used to layout the communication between low-speed devices like ADC and DAC converters and microcontrollers. It is a two wire communication that mainly contains two lines
- Serial Clock (SCL)
- Serial Data (SDA)
The former is a clock signal, mainly used to synchronize the data transfer between the devices and is generated by the master device, while the later is used to hold the desired data.
SPI Communication
ATmega128 houses a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as sensors, shift registers, and SD cards.
Separate clock and data lines are available, layered with a select line for selecting the relevant device for communication.
Two pins used for SPI communication are as follow
- MOSI (Master Output Slave Input)
- MISO (Master Input Slave Output)
The MOSI pin is used for receiving the data when the microcontroller acts as a slave. Similarly, MISO helps in sending data by the microcontroller while later acts as a slave mode.
4. ATmega128 Compilers
Compilers are the basic software used for writing and compiling the code into the AVR controller. Some are free to use and some are paid. If you are getting your hands-on very first time with the controllers, it is advised to go with the free version, you can move to paid version as you grow and learn with the passage of time. Following are some basic compilers mainly used for AVR microcontrollers.
- The IAR is a paid compiler and comes with a professional interface. As per the testimonials and personal experience of some of the experts, this compiler proves to the best version for the AVR microcontrollers.
- CodeVision houses a CodeWizard and turns out to be highly economical for the controllers.
- The GCC Port is another good pick to start with, but it comes with a bit complex interface. It works with both Windows and Linux operating systems.
- ImageCraft is a valuable addition for compiling the code, but it doesn't incorporate some GUI features like editor and project management that may put you in big trouble during the code execution.
5. ATmega128 Memory Interface
Two memory types are mainly used in ATmeag128 named as Program Memory (Flash Memory) and SRAM memory where former makes use of a single pipelining for the execution of the instructions and later is a volatile memory mainly depends on the power supply source. This AVR module incorporates a Harvard Architecture where separate memories spaces are reserved for both data and program. The memory space in the controller is nothing but a combination of the linear and regular memory maps.
The Fast Access File Register is layered with 32 x 8 – Bit general purpose working registers. The single clock cycle is enough for accessing these registers and laying out the ALU (Arithmetic Logic Unit) operation where the result is stored in the Register file.
Program Memory (ROM)
Program memory has a memory space around 128K where recent instruction is called followed by the next instruction, executing the instructions in every clock cycle.
- It is mainly categorized into two parts named as the Boot Program section and Application Program section. The former comes with Applications Flash Memory that plays the main part for SPM instruction writing.
Data Memory (RAM)
The data memory has a memory space around 4K. Five different addressing modes in the AVR architecture are used for addressing this RAM memory. These modes are named as
- Direct
- Indirect
- Indirect with Displacement
- Indirect with Pre-decrement
- Indirect with Post-increment.
Three address registers, known as X, Y, and Z, increment and decrement in indirect addressing modes.
Control registers are present in the flexible interrupt module that mainly come with global interrupt enable bit laying in the Status Register. These interrupts come with an Interrupt Vector Table where Interrupt Vector is a major part of it and both are inversely proportional to each other. It is important to note that, the Interrupt Vector table depends on the Interrupt Vector Position.
- The ALU module operates in a single clock cycle and is divided into three main functions called direct, arithmetic and bit functions, that are directly connected with 32 general purpose registers.
6. ATmega128 Block Diagram
Following figure shows the block diagram of ATmega128.
- ATmega128 comes with six software selectable power saving modes. The Power-down is very helpful for freezing the Oscillator and stops all other module functions while keeping the register contents saved. The functions remain disabled until the next interrupt is called and executed.
- Similarly, the Idle mode allows the interrupt system, SPI Port, SRAM, Timers/Counter to function while keeping the CPU disabled.
- The ADC Noise Reduction mode plays a vital role in minimizing the switching noise and freezes entire module except asynchronous ADC and Timers.
- In the Power-save mode, the entire device is sleeping except asynchronous timer which continues to run.
- The Standby mode puts the whole device in sleep mode except Crystal Oscialltor which continues to run, helping to consume low power. The Extended Standby mode allows both the Oscillator and the Asynchronous Timer to run while the rest of the device sleeps.
ATmega128 Applications
- Embedded systems
- Industrial Automation
- Students Projects
- Making of quadcopters
- Home automation
That's all for today. I hope I have given you everything you needed to know about ATmega128. If you are unsure or have any question, you can approach me in the comment section below. I'll try and help you according to the best of my knowledge. Feel free to keep us updated with your valuable suggestions, so we keep providing quality work and you keep visiting us every now and then. Thanks for reading the article.
Introduction to ATmega8
Hi Friends! Hope you are doing well. I am back to give you a daily dose of useful information so you can excel and improve as per your technical needs and requirements. Today, I'll uncover the details on the Introduction to ATmega8. It is an 8-bit AVR microcontroller that is based on RISC CMOS technology and comes with a 28-pin interface for the PDIP package. The Program memory is 8K Flash while RAM and EEPROM are 1K and 512 bytes respectively.
Microchip has been the main source for producing PIC and AVR microcontrollers that are mainly used in embedded and industrial automation systems. These modules can perform a number of functions on a tiny chip, preventing you from spending too much and purchasing external components for laying out automation in the relevant project.
In this post, I’ll cover each and everything related to this tiny chip including main features, pinout, pin description, functions, the compiler used and everything you need to know. Let’s get down to the details of this onboard module:
Introduction to ATmega8
- ATmega8 is a 28-pin, 8-bit AVR microcontroller, based on RISC architecture, designed by Microchip and is mainly used in the embedded systems and industrial automation projects.
- It comes in three packages known as PDIP, MLF, and TQFP, where the first one contains 28 pins and the other two come with 32-pin on each module.
- The Program memory(Flash Memory) is 8KB used to store the programming code and permanent settings.
- Atmega8 comes with a RAM memory of 1KB, it's a volatile memory and refreshes on restart.
- It also has an EEPROM memory of 512 bytes, which is a semi-volatile memory.
- Other features includes are a power-up timer, a watchdog timer, Brown out Detection, In-Circuit Serial Programming and five sleep modes.
- The instruction set is the main criteria that set this module apart from the PIC microcontroller where the former executes most instructions in one clock cycle and comes with 32 general-purpose registers while later requires a number of clock cycles per instruction and comes with W register.
- The 10-bit ADC module is added to the device that plays a vital role for sensor interfacing and contains a total of 6 channels for the PDIP package and 8 channels for the remaining two packages.
- Communication protocols like SPI, I2C, and USART are added to the device that is widely used for establishing communication with external devices.
ATmega8 Key Features
- Before you start working on the relevant project, it is advised to check the features of the module, in order to get an idea if these features are suitable for the project you aim to work on.
- The following table shows the main features of ATmega8.
Atmega8 Key Features
|
No. of Pins |
28 |
CPU |
8-Bit AVR |
Operating Voltage |
2.7 to 5.5 V |
Program Memory |
8K |
Program Memory Type |
Flash |
RAM |
1K Bytes |
EEPROM |
512 Bytes |
ADC
Number of ADC Channels |
10-Bit
6 in PDIP, 8 in TQFP and QFN |
Comparator |
1 |
PWM Channels |
3 |
Oscillator |
up to 16 MHz |
Timer (3) |
16-Bit Timer (1)
8-Bit Timer (2) |
Packages (3) |
PDIP (28-Pins)
TQFP (32-Pins)
QFN (32) |
Power Up Timer |
Yes |
I/O Pins |
23 |
Manufacturer |
Microchip |
SPI |
Yes |
I2C |
Yes |
Watchdog Timer |
Yes |
Brownout Detection (BOD) |
Yes |
USART |
Yes |
Sleep Modes |
5 |
Minimum Operating Temperature |
-55 C |
Maximum Operating Temperature |
125 C |
ATmega8 Pinout and Description
- You have got a brief introduction to the module. In this section, we will cover the pinout and description of each pin.
Pinout
- The following figure shows the pinout of ATmega8.
- ATmega8 comes in three packages known as PDIP, MLF, and TQFP where the first is used for prototype projects, while the other two are used for industrial and electronic devices.
- The following table shows the complete description of each pinout, which will help you anticipate the major function associated with each pin.
Atmega8 pinout & Description
|
1 |
PC6
RESET
PCINT14 |
I/O Pin
RESET will be generated by keeping this pin LOW for longer than the minimum pulse length
Interrupt |
2 |
PD0
RXD
PCINT16 |
I/O Pin
Serial Receive Pin (USART)
Interrupt |
3 |
PD1
TXD
PCINT17 |
I/O Pin
Serial Transmit Pin (USART)Interrupt |
4 |
PD2
INT0
PCINT18 |
I/O Pin
External Interrupt
Interrupt |
5 |
PD3
INT1
OC2B
PCINT19 |
I/O Pin
External Interrupt
Dedicated Pin for Timer (PWM Channel)
Interrupt |
6 |
PD4
T0
XCK
PCINT20 |
I/O Pin
T0 ( Timer0 External Counter Input)
XCK ( USART External Clock I/O)
Interrupt |
7 |
VCC |
Voltage Supply |
8 |
GND |
Ground Pin |
9 |
PB6
OSC1
XTAL1
PCINT6 |
I/O Pin
Oscillator Input Pin
Interrupt |
10 |
PB7
OSC2
XTAL2
PCINT7 |
I/O Pin
Oscillator Output Pin
Interrupt |
11 |
PD5
T1
OC0B
PCINT21 |
I/O Pin
PinT1 ( Timer0 External Counter Input)
Dedicated Pin for Timer (PWM Channel)
Interrupt |
12 |
PD6
AIN0
OC0A
PCINT22 |
I/O
PinAnalog Comparator Positive
Dedicated Pin for Timer (PWM Channel)
Interrupt |
13 |
PD7
AIN1
PCINT23 |
I/O Pin
Analog Comparator Negative
Interrupt
|
14 |
PB0
ICP1
CLKO
PCINT0 |
I/O Pin
In Circuit Serial Programming
Clock
Interrupt
|
15 |
PB1
OC1A
PCINT1 |
I/O Pin
Dedicated Pin for Timer (PWM Channel)
Interrupt
|
16 |
PB2
SS
OC1B
PCINT2 |
I/O Pin
SPI Slave Select Input. When the controller acts as a slave, this pin is LOW
Dedicated Pin for Timer (PWM Channel)
Interrupt |
17 |
PB3
MOSI
OC2A
PCINT3 |
I/O Pin
MOSI (Master Output Slave Input) for SPI Communication. The data is received by this pin when the controller acts as a slave
Dedicated Pin for Timer
Interrupt
|
18 |
PB4
MISO
PCINT4 |
I/O Pin
MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin
Interrupt |
19 |
PB5
SCK
PCINT5 |
I/O Pin
SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer
Interrupt |
20 |
AVCC |
Voltage Supply Pin for ADC |
21 |
AREF |
Voltage Reference |
22 |
GND |
Ground Pin |
23 |
PC0
ADC0
PCINT8 |
I/O Pin
Analog Channel 0
Interrupt
|
24 |
PC1
ADC1
PCINT9 |
I/O Pin
Analog Channel 1
Interrupt |
25 |
PC2
ADC2
PCINT10 |
I/O Pin
Analog Channel 2
Interrupt |
26 |
PC3
ADC3
PCINT11 |
I/O Pin
Analog Channel 3
Interrupt |
27 |
PC4
ADC4
SDA
PCINT12 |
I/O Pin
Analog Channel 4
Serial Data (I2C)
Interrupt |
28 |
PC5
ADC5
SCL
PCINT13 |
I/O Pin
Analog Channel 5
Serial Clock (I2C)
Interrupt |
ATmega8 Main Functions
- ATmega8 comes with the ability to execute and perform a number of functions.
- Following are the major functions related to this tiny module.
Timer
Atmega8 incorporates three timers where two are 8-bit and one is a 16-bit timer. These timers can be used both ways i.e. timer as well as a counter where the former is used to create the delay in any running function, controls the internal functions of the controller and increments the instruction cycle, while later is used to count the number of intervals by incrementing the rising and falling edge of the pin and is mainly used for external functions. Apart from these timers, two other timers are included in the device named as
- Oscillator Start-up Timers
- Power Up Timer
An oscillator start-up timer is used to make the crystal oscillator stable by resetting the controller. And power-up timer generates a minor delay once you power on the device, helping in stabilizing the power in order to generate power signals with continuous intervals.
Number of Sleep Modes
Five Sleep Modes are incorporated into the device that helps in saving power. These modes include:
- Power-save
- Power-down
- Idle
- ADC Noise Reduction
- Standby
Brown Out Detect (BOD)
The BOD, also known as BOR (Brown Out Reset), is used to resetting the module once the Vcc (voltage supply) goes below a brownout threshold voltage. It is important to note that, the Power Up Timer must be enabled for creating a delay and helping in bringing back the device from a BOD function. In this mode, multiple voltage ranges are created to protect the module once the power drops at the voltage supply line.
SPI Communication
ATmega8 comes with a serial peripheral interface (SPI) - A communication module that helps in establishing communication between the microcontroller and other peripheral devices such as shift registers, SD cards, and sensors. It incorporates a separate clock and data lines with the addition of a select line for selecting the relevant device for communication.
Two pins used for SPI communication are as follow:
- MOSI (Master Output Slave Input)
- MISO (Master Input Slave Output)
The MOSI pin receives the data when the controller acts as a slave. And MISO plays a vital role in sending data by the controller while later is put in the slave mode.
Watchdog Timer
ATmega8 incorporates a built-in watchdog timer that resets the controller if the running program hangs up during compilation or gets stuck in the infinite loop. The watchdog timer is nothing but a countdown timer.
Interrupt
The interrupt hints at a call of emergency that puts the main function on hold until the required instruction is executed. The controller goes to the main program once the interrupt is called and executed.
I2C Communication
- I2C protocol is used to connect low-speed devices like ADC and DAC converters, and microcontrollers.
- It is a two-wire communication that comes with:
- Serial Clock (SCL)
- Serial Data (SDA)
The former is a clock signal that synchronizes the data transfer between the devices and is produced by the master device, while the latter is used to carry the required data.
ATmega8 Memory Interface
The memory space in the controller is the manifestation of the linear and regular memory map. This AVR module comes with a Harvard Architecture that houses separate memories for both data and program.
- Single pipelining is used for the executions of the instructions in the Program Memory - A programmable Flash Memory - where the next instruction is called and executed followed by the next instruction that helps in executing the instructions in every clock cycle.
The Fast Access File Register comes with 32 x 8 - Bit general purpose working registers that can be accessed with the single clock cycle that assists in performing the ALU (Arithmetic Logic Unit) operation where the result is stored in the Register File.
The I/O Memory can be accessed in multiple ways by direct manner or using data Space locations covering Register File, 0x20 – 0x5F.
Program Memory (ROM)
- Program memory comes with a memory space around 8K and can perform the instructions in every clock cycle.
- It stores information permanently and doesn't depend on the source of power supply and is widely known as ROM or Non-Volatile Memory.
- The program memory address can access 16 or 32-bit instruction.
- Program Flash is divided into two parts including the Application Program section and the Boot Program section.
- The latter comes with Applications Flash Memory used for SPM instruction writing.
Data Memory (RAM)
The data memory comes with memory space around 1K (1024 bytes). It can be accessed through the five different addressing modes in the AVR architecture named Direct, Indirect, Indirect with Displacement, Indirect with Pre-decrement, and Indirect with Post-increment.
- Three address registers X, Y, and Z are capable to increment and decrement with regular intervals in the presence of indirect addressing modes.
The flexible interrupt module houses control registers that further contain global interrupt enable bit sitting in the Status Register. All these interrupts contain Interrupt Vector Table with Interrupt Vector where the former depends on the Interrupt Vector Position and are inversely proportional to each other.
- The ALU module, which is divided into three major functions known as direct, arithmetic and bit functions, has a direct connection with 32 general-purpose registers within a single clock cycle.
ATmega8 Compilers
If you are new to a microcontroller, you may be a little skeptical about the compiler you can use for writing and compiling the code into your AVR controller. I've combined some of the basic compilers where some are better than others in terms of efficiency. Although the free versions may lack some features, they are recommended to start with as a newbie to get hands-on experience with the AVR controller.
- The IAR compiler proves to be the best compiler for AVR. Although it is expensive and incorporates a highly professional interface.
- The GCC Port is a good option for AVR that works with both Linux and Windows. The interface is a little bit complex.
- ImageCraft is another right option to start with, but it lacks some GUI features like editor and project management that may create trouble during the execution of code.
- CodeVision comes with CodeWizard and is highly economical.
6. ATmega8 Interfacing with Arduino
ATmega8 can be interfaced with Arduino for the development of the embedded project.
The following figure shows the interfacing of ATmega8 with Arduino.
- If you are new to the Arduino Board, you must try these Arduino Projects for Beginners, they will help understand the major functions of the Arduino Board.
ATmega8 Internal Block Diagram
- A Block diagram will help you get a hold of how major functions and components are connected and perform inside the device.
- The following figure shows the block diagram of ATmega8:
- ATmega8 is a low-power CMOS AVR microcontroller that is mainly based on RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 is capable to perform and execute powerful instructions using 1MIPS per MHz in a single clock cycle that drastically helps in optimizing the power consumption.
8. ATmega8 Projects and Applications
- Used in embedded and robotics system
- It is widely used in students projects
- Home Security System
- For the designing of quadcopters
- Industrial Automation
That's all for today. I hope you have found this article information. If you are unsure or have any questions, you can approach me in the comment section below. I'd love to help you the best way I can. Feel free to feed us with your valuable suggestions - they help us provide you quality work. Thanks for reading the article.
Introduction to ATmega168
Hi Friends! Hope you are doing well. We always strive to give you valuable information as per your needs and requirements so you keep coming back for what we have to offer. Today, I'll uncover the details on the
Introduction to ATmega168. It is an 8-bit AVR microcontroller that comes with 32-pin interface and is mainly based on RISC CMOS technology. The Program memory is 16K, based on Flash, and incorporates read-write capabilities.
The module comes with a wide temperature range from -40 to 85 ºC while operating voltage ranges from 1.8 to 5.5 V. If you are working on project that is related to automation and embedded systems, you can not write off the importance of this module that comes with an ability of performing a number of functions at once on a single chip.
In this post, I'll cover each and everything related to this module including main features, pinout, pin description, functions, the compiler used and real-time applications. Let's jump right it, and get down to the nitty-gritty of this little toy.
Introduction to ATmega168
- ATmega168 is an 8-bit AVR microcontroller that comes in three packages named as PDIP, MLF, and TQFP, where the first two contain 28 pins on each module while other comes with 32-pin interface.
- The Program memory is 16K that is based on Flash while other two memories RAM and EEPROM contain 1K and 512 Bytes respectively with data retention capability of around 20 years.
- The 10-bit ADC module is added in the device that plays a vital role for sensor interfacing and contains total 8 channels that are enough to provide analog to digital conversion to a number of pins.
- Only a few controllers incorporate all three communication protocols i.e. SPI, I2C and USART and ATmega168 is one of them. These protocols are widely used for setting up a communication with external devices.
- Apart from providing decent pace for executing a number of instructions, other features this module includes a watchdog timer, power up timer, oscillator start-up timer, Brown out Detection and In-Circuit Serial Programming.
- What Makes this AVR module Different from PIC Microcontrollers is the instruction set. PIC microcontrollers require a number of clock cycles per instruction while AVR executes most instructions in one clock cycle. Also, PIC contains a 'W' register, while AVR comes with 32 general purpose registers where three pairs can be employed as pointers.
1. ATmega168 Features
Features of any device are very important to get a hold of major functions and characteristics associated with it. Following table shows the main features of this module.
ATmega168 Features |
No. of Pins |
28 |
CPU |
RISC 8-Bit CMOS |
Operating Voltage |
1.8 to 5.5 V |
Program Memory |
16K |
Program Memory Type |
Flash |
RAM |
1K |
EEPROM |
512 Bytes |
ADC
Number of ADC Channels |
10-Bit
8 |
Comparator |
1 |
In-circuit serial programming |
Yes |
Oscillator |
up to 20 MHz |
Timer (3) |
16-Bit Timer (1)
8-Bit Timer (2) |
Capture/Compare/PWM |
1/1/6 |
Power Up Timer |
Yes |
I/O Pins |
23 |
USART |
Yes |
SPI |
2 |
I2C |
Yes |
Watchdog Timer |
Yes |
Brown out Detection (BOD) |
Yes |
Power on Reset |
Yes |
Data Retention |
20 Years |
Minimum Operating Temperature |
-40 ºC |
Maximum Operating Temperature |
85 ºC |
2. ATmega168 Pinout and Description
In this section, we will cover the pinout and pin description of each pin of the controller so you can anticipate the main functions associated with the pins.
The following figure shows the pinout of ATmega168.
- ATmega168 comes in three packages named as PDIP, MLF, and TQFP where first is used for the development of individual projects while the other two are added to the industrial and electronic devices.
Pin Description
Following table shows the pin description of each pin that will help you foresee the major functions associated with each pin of the controller.
Pin# |
Pin Name |
Pin Description |
1 |
PC6
RESET
PCINT14 |
Digital I/O Pin
RESET will be generated by keeping this pin LOW for longer than the minimum pulse length
Interrupt |
2 |
PD0
RXD
PCINT16 |
Digital I/O Pin
Serial Receive Pin (USART)
Interrupt |
3 |
PD1
TXD
PCINT17 |
Digital I/O Pin
Serial Transmit Pin (USART)
Interrupt |
4 |
PD2
INT0
PCINT18 |
Digital I/O Pin
External Interrupt
Interrupt |
5 |
PD3
INT1
OC2B
PCINT19 |
Digital I/O Pin
External Interrupt
Dedicated Pin for Timer (PWM Channel)
Interrupt |
6 |
PD4
T0
XCK
PCINT20 |
Digital I/O Pin
T0 ( Timer0 External Counter Input)
XCK ( USART External Clock I/O)
Interrupt |
7 |
VCC |
Voltage Supply |
8 |
GND |
Ground Pin |
9 |
PB6
OSC1
XTAL1
PCINT6 |
Digital I/O Pin
Oscillator Input Pin
Interrupt |
10 |
PB7
OSC2
XTAL2
PCINT7 |
Digital I/O Pin
Oscillator Output Pin
Interrupt
|
11 |
PD5
T1
OC0B
PCINT21 |
Digital I/O Pin
T1 ( Timer0 External Counter Input)
Dedicated Pin for Timer (PWM Channel)
Interrupt
|
12 |
PD6
AIN0
OC0A
PCINT22 |
Digital I/O Pin
Analog Comparator Positive
Dedicated Pin for Timer (PWM Channel)
Interrupt
|
13 |
PD7
AIN1
PCINT23 |
Digital I/O Pin
Analog Comparator Negative
Interrupt
|
14 |
PB0
ICP1
CLKO
PCINT0 |
Digital I/O Pin
In Circuit Serial Programming
Clock
Interrupt
|
15 |
PB1
OC1A
PCINT1 |
Digital I/O Pin
Dedicated Pin for Timer (PWM Channel)
Interrupt
|
16 |
PB2
SS
OC1B
PCINT2 |
Digital I/O Pin
SPI Slave Select Input. When the controller acts as a slave, this pin is LOW
Dedicated Pin for Timer (PWM Channel)
Interrupt |
17 |
PB3
MOSI
OC2A
PCINT3 |
Digital I/O Pin
MOSI (Master Output Slave Input) for SPI Communication. The data is received by this pin when the controller acts as a slave
Dedicated Pin for Timer
Interrupt
|
18 |
PB4
MISO
PCINT4 |
Digital I/O Pin
MISO (Master Input Slave Output) for SPI communication. When the controller acts as a slave, the data is sent by a controller to master through this pin
Interrupt |
19 |
PB5
SCK
PCINT5 |
Digital I/O Pin
SCK (SPI Bus Serial Clock). This clock is shared between the controller and other devices for data transfer
Interrupt |
20 |
AVCC |
Voltage Supply Pin for ADC |
21 |
AREF |
Voltage Reference |
22 |
GND |
Ground Pin |
23 |
PC0
ADC0
PCINT8 |
Digital I/O Pin
Analog Channel 0
Interrupt
|
24 |
PC1
ADC1
PCINT9 |
Digital I/O Pin
Analog Channel 1
Interrupt |
25 |
PC2
ADC2
PCINT10 |
Digital I/O Pin
Analog Channel 2
Interrupt |
26 |
PC3
ADC3
PCINT11 |
Digital I/O Pin
Analog Channel 3
Interrupt |
27 |
PC4
ADC4
SDA
PCINT12 |
Digital I/O Pin
Analog Channel 4
Serial Data (I2C)
Interrupt |
28 |
PC5
ADC5
SCL
PCINT13 |
Digital I/O Pin
Analog Channel 5
Serial Clock (I2C)
Interrupt |
3. ATmega168 Main Functions
ATmega168 comes with an ability to execute and perform a number of functions. Following are the major functions related to this tiny module.
Timer
Atmega168 comes with three timers where two are 8-bit and one a 16-bit timer. These timers can be used as a timer as well as a counter. The timer mode is used to create the dealy in any running function that increments the instruction cycle and mainly controls the internal functions of the controller.
While the counter mode counts the number of intervals in any function and is mainly used for external functions where it can increment the rising and falling edge of the pin.
- Oscillator Start-up Timers
- Power Up Timer
Oscillator start-up timer resets the controller until the crystal oscillator becomes stable. Similarly, power-up timer is added that generates a minor delay once you power on the device, that provides an appropriate time to stabilize the power where it can generate power signals in a continuous manner.
Brown Out Detect (BOD)
The BOD, also known as BOR (Brown Out Reset), is a very valuable function that resets the module once the Vcc (voltage supply) goes below a brownout threshold voltage.
In this mode, multiple voltage ranges are used and generated to protect the module once the power drops at the voltage supply line, setting you free from manually resetting the device. The Power Up Timer must be enabled, that creates the delay in bringing back the device from a BOD function.
Number of Sleep Modes
Six Sleep Modes are added to the device that help in saving power. These modes include:
- Idle
- ADC Noise Reduction
- Power-save
- Power-down
- Standby
- Extended Standby
SPI Communication
ATmega168 incorporates a serial peripheral interface (SPI) that nails down a communication between the microcontroller and other peripheral devices such as SD cards, shift registers, and sensors. It comes with separate clock and data lines with the addition of a select line to select the given device for communication.
Two pins called used for SPI communication are as follow
MOSI (Master Output Slave Input)
MISO (Master Input Slave Output)
The data is received by MOSI pin when the controller acts as a slave. And MISO is responsible for sending data by the controller when later acts as a slave.
Interrupt
The interrupt is used for a call of emergency which puts the main function on hold and executes the required instructions essential at that time. Once the interrupt is called and executed the running instruction brings the controller back to the main program.
I2C Communication
I2C protocol is a two-wire protocol used to connect low-speed devices like ADC and DAC converters, and microcontrollers. It comes with two wires called
Serial Clock (SCL)
Serial Data (SDA)
The former behaves like a clock signal that is produced by the master device and synchronizes the data transfer between the devices. And the later is used to carry the desired data.
Watchdog Timer
ATmega168 comes with a built-in watchdog timer that brings the controller back in reset position if the program hangs up during compilation or gets stuck in the infinite loop. The watchdog timer acts like a countdown timer in the running function.
4. ATmega168 Memory Interface
This AVR controller encompasses the Harvard Architecture that provides separate memory locations for both Data and Program memory.
The memory is based on Atmel’s high-density technology where Program Memory, also known as Flash memory, can be reprogrammed through SPI serial interface using two ways i.e. Non-volatile memory programmer or On-chip boot code.
The CPU is very useful to access memories and perform calculations on the basis of the number of instructions fed into the controller.
Program Memory (ROM)
Program memory performs the instructions in every clock cycle at regular intervals. It is also known as ROM or non-volatile memory that stores the information permanently and works perfectly in the absence of power supply.
- The controller program memory executes the required instruction followed by the next instruction. Every program memory address is able to access a 16- or 32-bit instruction.
Program memory comes with a memory space around 16K - lot more than some other controllers available in the AVR community.
- Program Flash is mainly categorized into two sections i.e. Application Program section and the Boot Program section. Lock bits are reserved for read/write protection. The Boot Program Section houses Application Flash Memory that is responsible for SPM instruction writing.
Data Memory (RAM)
The data memory contains 1K (1024 bytes) memory space. It categorizes the memory locations three ways where first 32 locations access the file register, next 64 locations are allocated for standard I/O memory and remaining are employed for internal data SRAM.
The data memory is categorized into five addressing modes known as
- Direct,
- Indirect
- Indirect with Displacement
- Indirect with Pre-decrement
- Indirect with Post-increment
The memory space in the controller shows the linear and regular memory map. The address registers X, Y, and Z can increment and decrement with regular intervals when indirect addressing modes are coupled with both pre-decrement and post-increment.
It is important to note that, the I/O Memory can be accessed in two ways i.e. using data Space locations covering Register File, 0x20 - 0x5F or in a direct manner.
5. ATmega168 Compilers
Compilers are used for writing and compiling the code in the AVR microcontroller. Following are some compilers you can use for this AVR module.
- The IAR is the best compiler for AVR. It is expensive and incorporates highly professional interface. If you are a beginner, it is advised to use this compiler as per your technical needs and requirements.
- CodeVision is cheap and easy to use that incorporates CodeWizard.
- The GCC Port is another compiler for AVR. It is available FREE for both Linux and Windows operating systems. It comes with little bit complex interface that may put you in trouble right off the bat.
- ImageCraft is a valuable option but it lacks some GUI features where editor and project management are quite formidable and can create trouble for the code execution.
6. ATmega168 Interfacing with Arduino
ATmega168 can be interfaced with Arduino to drive automation in the relevant project. Both modules work perfectly in embedded systems where they can perform a number of useful functions.
The following figure shows the pinout how Arduino pins are connected with ATmega168.
- If you aim to work on this Arduino board then you must try these Arduino Projects for Beginners, they will help to get familiar with the Arduino Board.
7. ATmega168 Block Diagram
If you intend to closely look into the device and how major functions and components are connected and performed inside the device, a block diagram will help you out. The following figure shows the block diagram of ATmega168.
- AVCC is a voltage supply for analog to digital converter that is necessary to power up the ADC module. Power on reset and brown out detect house in the same package that is also connected with the watchdog timer.
8. ATmega168 Projects and Applications
- It is widely used in students projects
- Used in embedded and robotics system
- Industrial Automation
- Home Security System
- For the designing of quadcopters
That's all for today. I hope you have found this article useful. If you are feeling skeptical or have any question, you can approach me in the comment section below. I'd love to help you in any way I can according to the best of my expertise. Feel free to keep us updated with your valuable suggestion, they help us provide you quality work as per your needs and demands. Thanks for reading the article.
Introduction to ATtiny85
Hey Guys! Hope you are doing well. I am back to give you a daily dose of valuable information. Today, I'll discuss the details on the
Introduction to ATtiny85. It is an 8-bit AVR microcontroller, introduced by Microchip, and is based on RISC CPU. It comes with 8-pin interface (PDIP) and falls under the category of low power controllers. Programmable watchdog timer and 10-bit ADC converter are added in the device that makes it suitable for sensor interfacing and resetting the device in case it gets stuck in an infinite loop.
Microchip never fails to satisfy the requirements of any individual by providing flawless
microcontroller modules that are directly or remotely connected with automation and embedded systems. With the invention of these tiny onboard modules, development of electronic projects has become easy and hassle-free more than ever before.
In this tutorial, I'll cover each and everything related to ATtiny85, its pinout, pin description, main features, block diagram, and applications. Let get down to the nitty-gritty of this module and nail down everything you need to know.
Introduction to ATtiny85
- ATtiny85 is an 8-bit AVR microcontroller that comes with 8-pin interface and mainly used in automation and Arduino projects.
- The CPU is based on RISC architecture and is mainly called low power controller that stands fit for the real-time applications that can operate on minimum power.
- The program memory is 8KB while both EEPROM and RAM contain a memory space of around 512 bytes. These memory spaces are very useful for storing the number of instruction in the form of code.
- This module comes with only one port called Port B that is a bi-directional port and contains 6 I/O pins with internal pull-up resistors. The output buffers on PORTB are designed with symmetrical drive characteristics that come with both high sink and source capability. It is important to note that, Port B pins are externally pulled low and tri-stated that will source current if the pull-up resistors are activated.
- External and internal interrupts are available on the board, while 32 general purpose registers are included in the device that are mainly called data holding spaces.
- Two 8-bit timers are added in the device where one timer comes with compare modes and can be used both ways i.e. timer as well as a counter while other is high-speed timer/counter.
- This module comes with software select power saving modes that are very helpful for the applications that operate with minimum power.
- Like other controllers introduced by the Microchip, this module comes with 10-bit ADC converter that houses 4 analog channels that help in sensor interfacing and converting analog signals to digital ones.
- This tiny chip is available in four packages called PDIP, SOIC, TSSOP, and QFN where first three come with 8-pin interface while the last one contains 20 pins.
- Digital communications like I2C and SPI can be easily employed using this module that helps in developing a communication with external devices.
1. ATtiny85 Features
You have got a brief overview of this module. Now we cover the main features that will help you anticipate the major characteristic associated with the module.
The following figure shows the complete features of ATtiny85.
ATtiny85 Features |
No. of Pins |
8 |
CPU |
RISC 8-Bit AVR |
Operating Voltage |
1.8 to 5.5 V |
Program Memory |
8K |
Program Memory Type |
Flash |
RAM |
512 Bytes |
EEPROM |
512 Bytes |
ADC
Number of ADC Channels |
10-Bit
4 |
Comparator |
1 |
Packages |
PDIP (8-Pin)
SOIC (8-Pin)
TSSOP (8-Pin)
QFN/MLF (20-Pin) |
Oscillator |
up to 20 MHz |
Timer (2) |
8-Bit Timers |
Enhanced Power on Reset |
Yes |
Power Up Timer |
Yes |
I/O Pins |
6 |
Manufacturer |
Microchip |
SPI |
Yes |
I2C |
Yes |
Watchdog Timer |
Yes |
Brown out detect (BOD) |
Yes |
Reset |
Yes |
USI (Universal Serial Interface) |
Yes |
Minimum Operating Temperature |
-40 C |
Maximum Operating Temperature |
125 C |
- You must check these features before making a final decision to install and use this module for your relevant project.
2. ATtin85 Pinout and Description
Until now, you have got a hold of basic information and complete features of ATtiny85. In this section, we will discuss the pinout and pin description of the module.
Pinout
Following figure shows the pinout of ATtiny85.
- The bottom pad available on the board must be soldered to the ground.
- The DNC marked on the pinout stands for don't connect.
Pin Description
Following table shows the pin description that will help you understand the major functions associated with each pin.
Pin# |
Pin Name |
Pin Description |
1 |
PB5
PCINT5
RESET
ADC0
dW |
I/O Bidirectional pin
Interrupt
Reset
Analog Channel 0
Define Word |
2 |
PB3
PCINT3
XTAL1
CLKI
OC1B
ADC3 |
I/O Bidirectional pin
Interrupt
Crystal Oscillator Pin 1
Clock
Analog Channel 3 |
3 |
PB4
PCINT4
XTAL2
CLKO
OC1B
ADC2
|
I/O Bidirectional pin
Interrupt
Crystal Oscillator Pin 2
Clock
Analog Channel 2
|
5 |
PB0
MOSI
DI
SDA
AIN0
OC0A
OC1A
AREF
PCINT0 |
I/O Bidirectional pin
SPI
Serial Data (I2C)
Analog Input
Compare Register
Voltage Reference
Interrupt
|
6 |
PB1
MISO
DO
AIN1
OC0B
OC1A
PCINT1 |
I/O Bidirectional pin
SPI
Serial Data (I2C)
Analog Input
Compare Register
Interrupt |
7 |
PB2
SCK
USCK
SCL
ADC1
T0
PCINT2 |
I/O Bidirectional pin
Serial Clock Line (I2C)
Analog Channel 1
Timer 0
Interrupt |
4 |
GND |
Ground Pin |
8 |
Vcc |
Voltage Supply Pin |
3. ATtiny85 Main Functions
ATtiny85 can perform a number of functions on a single chip. Some pins come with an ability to employ more than one functions. Following are the main functions of this module.
Timers
There are two timers included on the chip that help in generating a delay in the running process of certain function when they work in a timer mode.
In the counter mode, these timers are used to count the number of the interval on a specific function inside in the controller. The timer mode increments the instruction cycle while the counter mode is used to increment the rising and falling edge of the pin.
SPI Communication
ATtiny85 comes with a serial peripheral interface (SPI) that is mainly used for communication between the microcontroller and other peripheral devices such as SD cards, sensors, and shift registers.
It incorporates separate clock and data lines with the addition of a select line to pick the required device for communication. This communication allows both connected device to lay out the same path of communication under one communication protocol.
I2C Communication
I2C protocol is added in the device that is mainly two-wire protocol used to connect low-speed devices like ADC and DAC converters, I/O interfaces and microcontrollers. The two wires, known as Serial Clock (SCL) and Serial Data (SDA), are the main part of this communication protocol.
The SCL line behaves like a clock signal that is generated by the master device and synchronizes the data transfer between the devices. While the SDA line is used to carry the required data.
Brown Out Reset (BOD)
The BOD is a very useful function that helps in resetting the controller once the Vdd (voltage supply) drops below a brownout threshold voltage. The multiple voltage ranges are provided to secure the module once the power drops at the voltage supply line.
Interrupt
The interrupt plays a vital role in an emergency which puts the main function on hold and executes the required instructions that are necessary at that time. Once the interrupt is executed the running code puts the controller back to the main program.
ADC Converter
ADC module is a valuable addition in the device that makes it compatible with the sensors. It is a 10-bit module that contains 4 channels which are little less than the number of channels available on the modules introduced by Microchip that, more or less, come with 7 or 12 channels.
4. ATtiny85 Memory Interface
The memory of this little toy is designed and based on Atmel's high-density technology that is basically non-volatile in nature. The Program Memory can be reprogrammed through SPI serial interface using two ways i.e. On-chip boot code or non-volatile memory programmer.
The main program execution is mainly done inside CPU that plays a vital role to access memories and perform calculations on the basis of the number of instructions incorporated into the controller.
This module falls under the category of AVR controllers that are based on Harvard architecture and come with separate locations reserved for both program and data memory.
Program Memory (ROM)
Program memory, that is basically reprogrammable flash memory, works in a simple manner where next instruction stands in the queue once first is called and executed. This helps in executing the instructions with regular intervals in every clock cycle.
The Flash memory comes with 8k memory space and contains memory endurance around 10,000 write/erase cycle (means you can erase and write the instructions 10,000 times on this board). The program counter available on the flash memory is 12bits wide that can address 4096 program memory locations.
Data Memory (RAM)
The data memory comes with 512bytes memory space and reserves the memory locations three ways i.e. first 32 locations access the file register, next 64 locations are reserved for standard I/O memory and remaining are used for internal data SRAM.
The data memory is categorized into five addressing modes named as
- Direct,
- Indirect
- Indirect with Displacement
- Indirect with Pre-decrement
- Indirect with Post-increment
In the Register File, the registers ranging from R26 to R31 refer to the pointer registers with indirect addressing. While the direct addressing covers the entire data space. Similarly, the Indirect with Displacement mode covers 63 address locations using base address accessed by the Y- or Z register.
The address registers X, Y, and Z increment and decrement with regular intervals when indirect addressing modes are layered with both post-increment and pre-decrement.
EEPROM Data Memory
This memory comes with 512 bytes of memory space which is designed and laid out as a separate data space where single bytes can be accessed. It comes with a memory endurance around 100,000 write/erase cycles which is ten times more than program memory.
5. ATtiny85 Compilers
There are many compilers available for compiling the code in the AVR microcontroller. Some are better than others. Before you pick some compiler for your controller, make sure it is easy to use and stand fit for your needs and requirements.
- If you are in the learning phase, then IAR is the best compiler for AVR. It is highly professional, though expensive, what it lacks in economical price, it covers up by providing both flawless quality and ease of use where it can support most, if not all, of the MCU families.
Another compiler for AVR is the GCC Port for AVR that is available FREE for both Windows and Linux. It can compile the instructions with a decent pace, however, if you are a newbie and getting your hands on very first time with the controller, it might be hard to learn.
- ImageCraft is good option to start with that has made a decent place in the market but lack of GUI features make this compiler difficult to handle where editor and project management are quite daunting and can put you in a total stall in the start.
CodeVision is another easiest compiler that comes with CodeWizard and helps in starting a new project sooner than later. Also, it is highly economical.
6. ATtiny85 Block Diagram
Block diagram is very helpful to visualize the main function available inside the controllers and how each feature and component are connected with each other.
Following figure shows the block diagram of ATtiny85.
- The AVR core is used to combine 32 general purpose register with the rich instruction set.
- Also, these 32 registers are directly connected with the ALU (Arithmetic Logic Unit) which helps in accessing the two independent registers using single instruction.
7. Interfacing ATtiny85 with Arduino
Tiny things can work wonders if used a proper way. Both ATtiny85 and Arduino, when connected, can easily drive automation in your project and help in executing the number of instructions.
You can connect ATtiny85 with the Arduino following way.
- Arduino Pin 10 ...................... ATtiny85 Pin 1
- Arduino Pin 11 ...................... ATtiny85 Pin 5
- Arduino Pin 12 ...................... ATtiny85 Pin 6
- Arduino Pin 13 ...................... ATtiny85 Pin 7
- Arduino +5V...................... ATtiny85 Pin 8
- Arduino Ground ...................... ATtiny85 Pin 4
8. Applications
- It is mainly used in real time applications related to industrial automation.
- Embedded Systems Projects make use of this module to drive automation.
- It can be employed and incorporated in robotics.
- Aeronautical technology houses a wide range of AVR controllers covering Quad-copter and space Aeroplanes.
- Power monitoring and management systems use this module.
That's all for today. I hope you have found this piece of nugget useful and valuable as per your technical needs and demands. If you are unsure or have any question, you can ask me in the comment section below. I'd love to help you according to the best of my knowledge and skills. Feel free to keep us updated with your valuable feedback and suggestions, so we keep providing quality work and you keep coming back for what we have to offer. Thanks for reading the article.
Solar Panel Library for Proteus
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new
Solar Panel Library for Proteus. I hope you guys are gonna enjoy this Proteus Library as it's not available in
Proteus and we are presenting it for the first time. :) I am quite proud of my team. B|
We all know about Solar Panels which is an excellent renewable energy source. It is widely adopted by the inhabitants of this green planet as its totally free and converts solar energy into electricity. Solar panels are also used a lot in
Engineering Projects especially related to renewable energy sources. Proteus doesn't have solar panels in its database that's why our team has designed this library. Using this
Solar Panel Library for Proteus, now you can easily simulate solar panels in Proteus and can design your projects' simulations. I will also share some projects in which I will interface it with different
Microcontrollers like
Arduino,
PIC Microcontroller or
8051 Microcontroller etc. So, let's get started with How to download and simulate Solar Panel in Proteus:
Solar Panel Library for Proteus
- First of all, download the Solar Panel Library for Proteus by clicking the below button:
Solar Panel Library for Proteus
- You will get a zip file which will have these two library files in it:
- SolarPanelTEP.IDX
- SolarPanelTEP.LIB
- Now place these two files in the library folder of your Proteus software.
Note:
- Now open you Proteus software or restart it if it's already open.
- Proteus is not that smart so we have to restart it so that it would add new Library components in its database.
- In the Proteus software click on the components button and make a search for Solar Panel as shown in below figure:
- Now place this component in your Proteus software.
- If everything goes fine then you will get something as shown in below figure:
- Now double click this solar panel and its Properties panel will open up as shown in below figure:
- If you have worked on Solar Panel then must have the idea that output of solar panel depends on the intensity of sunlight.
- So, if its shiny bright day then solar panel normally give in the range of 15V to 19V.
- Similarly, if its night time then solar panels output ranges from 2V to 6V.
- While on a cloudy day it could vary between 8V to 12V.
- So, if you want to change the output of this Proteus' Solar Panel then you have to open this Properties Panel and then change the Voltage value.
- By default, it will give 12V as an output.
- I am working on adding some button so that you could change the output in running simulation but for now you have to stop the simulation in order to change it.
- Now let's place a voltmeter at the output of this solar panel and check its output.
- Here's the simple solar panel simulation in Proteus:
- Now you can see in above figure that our Solar Panel is giving 12V as an output.
- So, now let's open it's Properties Panel and change the voltage value to 16.5V.
- I have changed the value and here's our output:
- You can see in the above figure that now voltage has changed to 16.5V.
- Here's a video demonstration on How to download and install this Solar Panel Library for Proteus.
So, that was all about Solar Panel Library for Proteus. I hope you guys can now easily download and install it. If you still got in to any trouble then ask in comments and I will try my best to resolve them and also let me know about your feedback for this Library. Thanks for reading. Have a good day. :)
Introduction to Atmega16
Hey Fellas! Hope you are doing fine. Microcontrollers play an important role in the development of
embedded systems. They are used where automation is an integral part of the system. Today, I am going to unlock the details on the
Introduction to Atmega16.
It is a 40-pin low power 8-bit microcontroller which is developed using CMOS technology and based on AVR architecture. This is the most commonly used AVR microcontroller which belongs to Atmel Mega family.
You must have a look at microcontroller called
Atmega328 that also belongs to the mega family.
Other microcontrollers that are readily available and fall under AVR category are Atmega 8 and Atmega 32. All these controllers perform similar tasks, however, they are only different in terms of their memory size and cost.
I'll discuss each and everything related to this controller so you don't need to scrape through the internet and find all information in one place. Let's dive in and explore what is this about, its main features, pin diagram and everything you need to know.
Introduction to Atmega16
- Atmega16 is a 40-pin low power microcontroller which is developed using CMOS technology.
- CMOS is an advanced technology which is mainly used for developing integrated circuits. It comes with low power consumption and high noise immunity.
- Atmega16 is an 8-bit controller based on AVR advanced RISC (Reduced Instruction Set Computing) architecture. AVR is family of microcontrollers developed by Atmel in 1996.
- It is a single chip computer that comes with CPU, ROM, RAM, EEPROM, Timers, Counters, ADC and four 8-bit ports called PORTA, PORTB, PORTC, PORTD where each port consists of 8 I/O pins.
- Atmega16 has built-in registers that are used to make a connection between CPU and external peripherals devices. CPU has no direct connection with external devices. It can take input by reading registers and give output by writing registers.
- Atmega16 comes with two 8-bit timers and one 16-bit timer. All these timers can be used as counters when they are optimized to count the external signal.
- Most of the necessary peripherals required to run automatic functions are incorporated in this device like ADC (analog to digital converter), Analog comparator, USART, SPI, which make it economical as compared to a microprocessor that requires external peripheral to perform various functions.
- Atmega16 comes with 1KB of static RAM which is a volatile memory i.e stores information for short period of time and highly depends on the constant power supply. Whereas 16KB of flash memory, also known as ROM, is also incorporated in the device which is non-volatile in nature and can store information for long period of time and doesn't lose any information when the power supply is disconnected.
- Atmega16 works on a maximum frequency of 16MHz where instructions are executed in one machine cycle.
Architecture of Atmega16
Following figure shows the architecture of Atmega16 that is based on Harvard Architecture and comes with separate buses and memories. Instructions are stored in the program memory.
1. CPU
CPU is like a brain of the controller which helps in executing a number of instructions. It can handle interrupts, perform calculations and control peripherals with the help of registers. Atmega16 comes with two buses called instruction bus and data bus.
The CPU reads the instructions in the instruction bus while data bus is used to read or write the corresponding data. The CPU mainly consists of the program counter, general purpose registers, stack pointer, instruction register and an instruction decoder.
2. ROM
The controller program is stored in ROM, also known as non-volatile programmable flash memory. The flash memory comes with a resolution of at least 10,000 write/erase cycles. Flash memory is mainly divided into two parts known as Application flash section and booth flash section.
Program of the controller is stored in the applications flash section. While booth flash section is optimized to work directly when the controller is powered up.
3. RAM
The SRAM (static random access memory) is used for storing information temporarily and comes with 8-bit registers. This is just like a regular computer RAM which is used to supply data through the runtime.
4. EEPROM
The EEPROM (Electronically Erasable Read Only Memory) is non-volatile memory used as a long time storage. It has no involvement in executing the main program. It is used for storing the configuration of the system and device parameters which continues to work in the reset of the application processor.
EEPROM comes with a limited write cycle up to 100,000 while read cycles are unlimited. While using EEPROM, write minimum instructions as per requirement, so you can get benefit from this memory for a longer time.
5. Interrupt
The interrupt is used for an emergency which puts the main function on hold and executes the necessary instructions at that time. Once the interrupt is called and executed the code switches back to the main program.
6. Analog and Digital I/O Modules
Digital I/O modules are used to set a digital communication between the controller and external devices. While analog I/O modules are used for transferring analog information. Analog comparators and ADC fall under the category of analog I/O modules.
7. Timer/Counter
Timers are used for calculating the internal signal within the controller. Atmega16 comes with two 8-bit timers and one 16-bit timer. All these timers work as a counter when they are optimized for external signals.
8. Watchdog Timer
The watchdog timer is a remarkable addition in this controller which is used to generate the interrupt and reset the timer. It comes with 128kHz distinct CLK source.
9. Serial Communication
Atmega16 comes with USART and SPI units that are used for developing serial communication with the external devices.
Atmega16 Pinout
Following figure shows the pin diagram of this AVR microcontroller Atmega16.
- Atmega16 is preferred over other microcontrollers like Atmel 8051 because it comes with much faster ability to execute instructions and consist of modified RISC processor.
- It has a built-in flash which comes with features of a bootloader. It has built-in 10-bit ADC, SPI, PWM, and EEPROM.
Pin Description of Atmega16
Atmega16 comes with 40 pins where each pin is used to perform a specific task. There are total 32 I/O pins and four ports. Each port consists of 8 I/O pins.
- PORTA = 8 Pins ( Pin 33 - 40 )
- PORTB = 8 Pins ( Pin 1 - 8 )
- PORTC = 8 Pins ( Pin 22 - 29 )
- PORTD = 8 Pins ( Pin 14 - 21 )
Following are the main functions associated with pins.
PORTA. Pins from 33 to 40 fall under PORTA. It acts like analog inputs to A/D converter. However, in the absence of A/D converter, PORTA is used as an 8-bit bidirectional I/O port. It comes with internal pull-up resistors.
PORTB. Pins from 1 to 8 belong to PORTB. These are I/O bidirectional pins. This port also consists of internal pull-up resistors.
PORTC. PORTC is an I/O bidirectional port that consists of 8 pins. Pin from 22 to 29 belongs to this port. Similar to other ports, it comes with internal pull-up resistors.
PORTD. Pin from 14 to 21 belongs to this port. It is a bidirectional port where each pin can be used as input or output pin. However, there are additional features associated with this port like interrupts, serial communication, timer, and PWM.
Reset. Pin9 is an active low reset Pin. A low-level pulse for longer than minimum pulse length will produce a reset. Short pulses are unlikely to produce reset.
VCC. Pin10 is a power supply pin for this controller. The power supply of 5 V is required to put this controller in a running condition.
GND. Pin11 is a ground pin.
AREF. Pin32 is an analog reference pin mainly used for A/D converter.
AVCC. Pin30 is an AVCC which is a supply voltage pin for PORTA and ADC. It is connected to VCC through a low pass filter in the presence of ADC. However, in the absence of ADC, AVCC is externally connected to VCC.
Pin 12 & 13. A crystal oscillator is connected with these pins. Atmega16 works at the internal frequency of 1MHZ; the oscillator is added to generate high clock pulses and frequency.
Applications
AVR controllers come with a wide range of applications where automation is required. Following are the main applications of Atmega16.
- Medical equipment
- Home automation
- Embedded systems
- Arduino Projects
- Used in automobiles and industrial automation
- Home appliances and security systems
- Temperature and pressure control devices
That's all for today. I hope you have got enough information regarding Atmega16. If you are unsure or have any question, you can approach me in the comment section below. I'd love to help you in any way I can. Feel free to keep us updated with your valuable suggestions and feedback. They help us provide you quality content. Thanks for reading the article.
Introduction to Buck Converter
Hey Guys! Hope you all are doing great and having fun. Today, I am going to discuss the details on the
Introduction to Buck Converter. It is a power converter which is mainly used to stepping down the voltage from its input to the output load. It mainly consists of two semiconductors and one energy storing components which can be either capacitor or inductor. It works best in the circuits where electrical isolation is not required.
Introduction to Buck Converter
- Buck converters are power converters which are mainly used for converting high voltage to the low voltage. These converters are highly efficient, showing almost 90% of efficiency.
- They are useful for performing a special task like converting the huge supply voltage of 12 V in the computer to 1.8 V for making it useful for operating small components like USB, CPU, and DRAM.
- Transistor used in buck converter act as a switching device. Obtaining a continuous output is the main purpose of buck converter which can be achieved by using the energy stored in the capacitor.
- Transistor switches between on and off at high frequency. Energy stored in the capacitor is mainly used in the buck converter during the off condition of the transistor, making it useful for obtaining a continuous output.
- Circuit diagram of a buck converter is given below:
- Buck converter is mainly called as a DC to DC converter. Source input can either be obtained directly from DC source or from rectified AC source.
- After getting DC source, it is passed through a switching transistor which converts it AC source. Eventually, the AC source is converted to DC source at the output voltage.
1. Buck Converter Working Principle
- Buck converter consists of switching transistor, diode, and energy storing elements such as capacitor or inductor. Transistor switches between on and off continuously. When the transistor switch is turned on, it is denoted by T(on) and when it is turned off, it is denoted by T(off). Duty cycle can be obtained by the dividing the time when switch is turned on with the total time of the cycle
D = T(on)/T
- Inductors works in both ways i.e. it opposes the current from changing its direction and also as an energy storing element. Energy is stored in the inductor which prevents the output from getting too high and that energy is released when the transistor is switched to off condition.
If Transistor is Switched ON
- When transistor is switched on, current will flow from the inductor L. Current flowing through the load is being restricted by the inductor and a surplus amount of energy will be stored in the inductor. Circuit diagram of a buck converter is shown in the figure given below when the transistor is switched on.
- The diode which is reverse biased won't take part in the operation of the buck converter as there is large positive voltage appear to the cathode part of the diode. When the switch is closed the voltage across inductor will be
V(Inductor) = V(in) - V(out)
- The capacitor using in this circuit diagram will continuously charge up to the maximum value and releases its energy when the transistor switches to off condition.
If Transistor is Switched OFF
When transistor switches to off condition, the diode available in the buck converter turns to forward biased, making its cathode negative and anode side positive. Circuit diagram of the buck converter is shown in the figure given below when transistor is switched off.
- When transistor is switched off, the inductor will automatically change its polarity with respect to the polarity given in transistor on condition. Now, the voltage across the inductor is also called back emf and it will give its energy back to the circuit during off condition. Here V(inductor) = - V(out)
- Sometimes we need minimum output at the output voltage, in this case, current flowing through the inductor becomes zero. When it falls below zero, it results in automatically discharing the capacitor energy which is stored when the transistor is operated in on condition. When capacitor is completely discharged, it automatically erupts the high switching losses. Pulse frequency modulation is used to avoid such losses.
- The average value of energy stored in inductor will always remain same at the end of the cycle.
- When output begins to fall, the only source of energy will be the energy from the capacitor, causing the current to flow through load and also preventing it from going too high.
- We get the output in the ripple form, instead of getting in square form. And can be defined as
V(out) = V(in) * T(on)/ T
Here T(on) is a time duration of the cycle when the transistor is on and T is the total time of the cycle.
-
- Ripple formed in buck converter shows that voltage goes high at the on state and drops down at off state.
2. Examining the current waveform during overall cycle
Let us examine the current wave form of diode current, inductor current and input current during overall cycle.
This diagram clearly shows that inductor current is equal to the sum of diode and input/switch current.
- During whole cycle input current will be much less than the output current, resulting in stepping down the voltage at the output. Notice that, assuming the ideal conditions, the overall power of the cycle will remain constant. i.e. V(in)*I(in) = V(out)*I(out)
- However, getting perfect circuit is not possible in reality due to some energy losses. Maximum efficiency that practical buck converters exhibit is about 85%.
3. Applications of Buck Converters
Buck converters exhibit a wide range of application depending on its efficiency and durability. Some of its main applications are given below.
USB ON-the-GO
USB On-the-GO is mainly used for connecting the mouse, keyboard and other useful devices to the smartphone. The main purpose of buck converter using in USB is to draw power from the USB and delivers it to the smartphone. Hence, it is the main source of regulating the power in both directions.
- When smartphone is plugged into charging, the buck converter is used to charge the lithium battery inside the smartphone,
- When some mice or keyboard is connected to the smartphone, buck converter works in a reverse order and draws power from the lithium battery and delivers it to the keyboard or mouse connected to the smartphone.
POL (Point of Load) converter for Laptops
- POL, also known as a voltage regulator, is a converter that is widely used in laptops and desktop computers. It is very useful in operating the motherboard at low voltage.
- Compressors are very delicate devices fixed in the laptops and even a fraction of the increase in voltage can damage its overall performace and quality. So, buck converter in the laptops does its job very nicely by maintaining the voltage in the processor as low as 1.8V.
Solar Chargers
- Buck converters are widely used in solar chargers. They often come with a built-in microcontroller which allows the buck converter to draw maximum power and helps in charging the battery in limited time possible.
Quad-copters
- Quad-copters come with a highly efficient buck converter for dropping down the input voltage. Quad-copter mostly uses DC power supply such as small batteries which are placed in a series. Normally 5 to 6 batteries are used to make quad-copter fully operational. These batteries provide voltage that ranges between 6 to 25 V.
- Buck converter in the batteries converts that voltage to 3.3 V for making it useful for flight controller which is a backbone of quad-copter.
This is the brief overview of buck converter, its working principle, and applications. I have tried my best to cover as many aspects as possible. However, if you still think some of your questions went unanswered, you can connect me in the comment section below. I will try my best to resolve all of your queries relating to buck converters. Will see you all in the next article. Stay Tuned!
Introduction to Transformer
Hey Fellas! I warmly welcome you to be here. Today I'm going to discuss the
Introduction to Transformer. I'll unlock the complete details of its working principle, construction, types, and applications. It is widely used for the transformation of electrical energy. The inception of transformation has revolutionized the electrical field and made our life easy more than ever before.
Because of its extensive advantages, it works as a core for electrical engineering. In today's tutorial, I have explained in detail all about Transformer but still if you got trouble anywhere, then you can ask in comments and I will try my best to resolve them. So, now let's get started with Introduction to Transformer:
1. Introduction to Transformer
- Transformer is a simple static device that helps in transferring the electrical power between two circuits.
- Transformer works on the Faraday’s Law of Electromagnetic Induction.
Faraday’s Law of Electromagnetic Induction:
- It is a process by which primary coil induces a voltage into the secondary coil with the help of magnetic induction. The coil windings are electrically isolated and magnetically connected around a common circuit called core.
- If we apply varying current in one coil, it results in creating a magnetic field and automatically induces the varying voltage in the secondary coil.
- Hence power is transmitted from one coil to another through the magnetic field.
- A slight change in current in transformers helps in increasing and decreasing the AC voltage in many electrical power applications.
Transformers are available in different sizes weighing from cubic centimeters to hundreds of tons. Without transformers it would be very difficult to transfer the power generated at the grid station to the area around the city. The high voltage and current produced at grid station can be reduced to low level which in turn helps in operating the electrical appliances at home.
2. Construction of Transformer
- A simple static transformer is a linear device that consists of coils that are mutually inductive and steel core.
- The windings in the coil are insulated from each other and from the steel core.
- The whole assembly of windings and steel core are encased in a device called tank.
- The major purpose of the tank is to insulate the core assembly from the coil windings.
- In order to take out the terminals of transformer specific bushings made up of capacitor are used.
- Added amount of oil conservator is also used in the tank which provides cooling and reduces friction.
Almost all types of transformers come with a core that is made up of laminated sheets of steel. In order to achieve continuous magnetic path, air gap between the sheets must be kept minimum. Laminated sheets of steel, with the added amount of silicon, are heat treated in order to provide low hysteresis losses and low eddy current and high permeability.
3. Mathematical Formulas for Transformer
Till now, we have seen the basic introduction and construction of Transformers, but when it comes to designing, then we have to make some mathematical derivations. In this section of this tutorial, I am gonna focus on some basic concepts of Transformers and will also share their mathematical formulas.
Turn Ratio
- Transformer has a turn ratio which dictates the operation of transformer and the value of output voltage applied to the secondary windings.
- Turn ratio is defined as a number of turns of the primary coils divided by the number of turns of secondary coil.
TR = Np /Ns
If Ns > Np then it is called step up transformer
If Np > Ns then it is called step down transformer
Transformation Ratio
- Transformation Ratio is defined as the secondary voltage divided by the primary voltage. And it is denoted by K.
K = Vs / Vp or Ns/Np
Transformer EMF Equation
- If we apply electrical source on the primary side of transformer, it will produce the magnetizing flux across the core of transformer.
- It must be a rate of change of flux that is connected to both, primary and secondary coils.
- According to Faraday’s Law of Electromagnetic Induction, changing flux in the coil must induce EMF in it.
- Suppose the flux created forms a sinusoidal function. As it is a rate of change of flux so it must be derivative of sine function which is a cosine function.
- We can easily get the rms value of the induced EMF if we get the rms value of cosine wave and multiply it with the number of turns of coils.
- Now let's have a look at the Faraday's Law of Electromagnetic Induction:
4. Types of Transformers
There are many types of transformers available in market but we can't cover them all in this tutorial. So, I am gonna just focus on those, which are used most commonly. Transformer can be differentiated into following types:
Step Up Transformer
Transformer is known as step up transformer if the number of turns of coil in secondary coil is greater than the number of turns of coil in primary coil. In other words, when transformer is used to increase the voltage on the secondary coil it is called step up transformer.
Step Down Transformer
Similarly, a transformer is known as step down transformer if the number of turns of coil in primary coil is greater than the number of turns of coil in the primary coil. Or if transformer is used to decrease the voltage on the secondary coil, it is called step down transformer.
Impedance Transformer
A transformer is called impedance transformer if it is used to deliver the same voltage to the secondary windings as applied to the primary windings. Hence output remains constant with respect to the input. This type of transformer is used for the isolation of electrical circuits or impedance matching.
Core Type Transformer
Core type transformer comes with a cylindrical coils that are form-wound. In this transformer, windings are encircled around some part of core. The cylindrical coils are insulated from each other with the help of paper or cloth and encompass high mechanical strength. Low voltage windings are arranged in a specific way to provide quick insulation with the laminated core of steel. A core type transformer is shown in the figure given below. L.V and H.V are described as Low voltage windings and High voltage windings respectively.
Shell Type Transformer
Shell type transformer comes with a steel core that covers some part of the coil windings. The coils in this transformer are also form-wound and are arranged in different layers that are insulated from each other. Such type of transformer comes in two shapes i.e. rectangular type or distributed type. It is like a disc arranged with insulated spaces, providing a horizontal cooling. Both, rectangular and distributed types of shell transformer are given in the figures below.
In order to provide compact look and minimum movement, this transformer comes with a rigid bracing that combines the whole transformer at one place. Main purpose of bracing is to control vibration and provide minimum noise during operation.
Both, shell type and core type transformers, encompass same characteristics but they are different with respect to cost. Shell type transformer is high in demand due to high voltage and the construction of its design. Things that are taken into consideration before buying the transformer include, heat distribution, cooling process, weight, voltage rating and kilo-watt ampere rating.
Transformer comes with a tank, brushes, and oil. The oil used in the transformer provides cooling and provides insulation between steel core and coil windings. Sometimes, it happens, the tank used in the transformer doesn’t provide the required cooling effect. This is due to the quality of oil used in the tank. In order to provide accurate cooling and quick insulation, oil must be free from sulfur or alkalies. If we leave alkalies and sulfur in the oil, it causes the oil to moist, hence damaging the quality of oil quite significantly. Even the small amount of this moisture is enough to effect the quality of the oil.
If operational tank doesn’t provide required cooling, then we use radiators on the sides of tank. This provides proper cooling and helps in maintaining the temperature of transformer to the required level. In order to make oil free from any moisture, tank must be sealed air-tight. This is easy to apply on the small transformers. In case of huge transformer, providing an air-tight sealing is difficult to implement, hence big chambers are used to maintain the temperature of transformers. These chambers refrain the moisture from adding in the oil.
Oil decomposes quickly when it encounters with oxygen during the heating process, leaving a dark material on the transformer, which eventually, can damage the cooling process.
5. Energy Losses in Transformers
Transformers are used for the transformation of electrical energy. The coils used in the transformer are entitled to many energy losses. Some of them are given below:
Heat Loss
Heat loss is a common factor in transformer. Some form of energy is used to reduce the resistance in the transformer in order to provide steady flow of electrical energy from one coil to another. When it escapes from coils of the transformer, this energy is converted into heat which erupts the energy loss.
Heat loss can be minimized by using the good conducting material in the coil or by using wires of high cross sectional area.
Eddy current also pertains to heat loss. When primary coil is connected to the electrical power, it induces the alternating magnetic field in the primary coil. Same magnetic field also passes through the steel core, helps in inducing the small current in the same core which erupts heat losses. In order to overcome heat loss, steel core must be laminated perfectly. This can be achieved by placing an insulating strips in the strips of the core material. Without effecting magnetic field, these insulating strips results in reducing the eddy current.
Hysteresis Loss
Hysteresis Loss also occurs due to magnetic field passing through the core material. When magnetic field passes through the core, the core becomes real magnet with separate north and South Pole. As the magnetic field changes its direction it also allows to magnetize the core material in another direction. Energy loss happens when core is magnetized in one direction and resists the core to magnetize in another direction. Surplus energy is required to magnetize the core material in other direction. Only way to minimize the hysteresis loss is to use the core material that is made up of good magnetizing material such as iron, which can be re-magnetized easily than other materials.
6. Applications of Transformer:
After reading the whole article, you have got the clear idea what is the basic purpose of electrical transformer. It can be used in our homes, apartments, buildings and electrical appliances i.e. where electrical power is required according to our needs and requirements. Following are the some applications of transformer:
- It can be used to alternate the amount of voltage and current. When current increases, voltage decrease and when voltage increases, then current decreases i.e. P = V * I
- Value of reluctance, capacitance and resistance can be controlled by the help of transformer.
- It finds many applications when it prohibits the flow of DC current from one circuit to another.
- Transformer is also used as an impedance device where same amount of voltage is required to the output as implied to the input. Hence, it also allows the two circuit be electrically isolated.
So, that was all about Transformers. I hope you have all enjoyed it. If you have any problem then ask in comments. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)