All posts by Avinash

About Avinash

Avinash Gupta is solely focused on free and high quality tutorial to make learning embedded system fun !

Hello World Project With PIC Microcontroller – Part II

Hello Friends, Welcome back. In the last tutorial we started working with MPLab and HI-TECH C Compiler and written our first C program to blink LED. After compiling the program we got the HEX file. Now, in this tutorial we will see how to transfer(burn) the hex file to our Microcontroller chip and then power it up to actually blink the LED. We will use eXtreme Burner – PIC , which is a easy to use GUI programmer for PIC18 MCUs. The burner supports USB connectivity with PC so it is very easy to install and use. Launch eXtreme Burner – PIC from Windows Desktop or Start Menu.   Fig.: eXtreme Burner – PIC, Main Screen.   The software is easy to use. First you need to load the HEX file which was generated by MPLAB+HI-TECH C in previous tutorial. So select Open from File Menu or From the Toolbar. Then select the hex file. Now the HEX file will be loaded and the contents (FLASH,EEPROM,Chip Settings) will be available. Now connect the programmer with your PC by using standard USB Cable the programmer will be automatically detected by software (provided drivers are installed previously) . Apply power to programmer using a 12v DC adaptor. Place a PIC18F4550 chip in the ZIF socket and lock it.   Fig.: eXtreme Burner […]

Hello World Project With PIC Microcontroller – Part I

Hello friends, welcome to this exciting tutorial were we will begin our journey with latest PIC18F micros from Microchip Technologies. This tutorial will give you information on what software/hardware you will require and basic steps on how to get, install, configure and use them. After going through this tutorial you will have a complete setup and knowledge to experiment with these powerful chips !         What you will learn ? MPLab as a powerful IDE. HI-TECH C for PIC18 MCUs as a powerful C Compiler. Creating a new HI-TECH C project in MPLab. Write a C Code to blink LED and compile it to get a HEX code. Configure the MCU for proper oscillator selection. Burn the HEX code to MCU using eXtreme Burner PIC from eXtreme Electronics. Use the programmed MCU to actually blink the LED ! So lets get started !!! First get these stuffs Microchip’s MPLab IDE or Integrated development Environment. This is the central tool from where you can access most of other tools, like the C Compiler. This also lets you create and edit program files and projects. Download this from Microchips Web site and Install it in your computer. Download MPLAB IDE Free. HI-TECH C Pro for PIC18 MCUs – This is will compile the high level human readable programs (in […]

USB PIC Microcontroller Programmer.

Good News for PIC lovers ! Presenting eXtreme Burner PIC, USB Programmer for PIC18FXXXX/PIC18LFXXXX/PIC16FXXXA/PIC16LFXXXA series MCUs. This easy to use programmer with USB connectivity and GUI software can program more than 52 chips of PIC18F/PIC16F family. This programmer support both ZIF socket and ICSP based programming. eXtreme Burner – PIC   Software eXtreme Burner PIC – Main Screen.   eXtreme Burner PIC – Write Device Screen.   eXtreme Burner PIC – PIC Programming Success !   About Microchip PIC18F Series MCUs These are high performance MCUs of popular PIC range of MCUs from Microchip. Main features are high performance CPU core (up to 12 MIPS),hardware multiplier, C language optimized architecture, with Modern peripherals such as USB. See Microchip’s Official PIC18F web page. Getting Started with PIC Microcontrollers. See Also eXtreme Burner 51 – USB Programmer for 89S51/89S52 MCUs. For any queries write to sales@extremeelectronics.co.in or Call 09939369624 (Avinash). More Info | Buy Now

Making a Simple PIC Programmer.

In this tutorial we will make a simple serial port based programmer for PIC microcontrollers. I have tried several easy to make programmers and software, and here I a presenting the programmer that worked the best. The design is based on JDM. The software we will use is PICPgm by Christian Stadler. I liked the performance of the software, its fast and easy to use. The programmer will make uses the COM port of Computer for communication. Components required. S.No Item Value/Part No Qty 01 Transistor BC337-40 or BC337-25 2 02 Capacitor Electrolytic 100uF 16VDC 2 03 Zener Diode 5.1v 0.5Watt 1 04 Zener Diode 6.2v 0.5Watt 1 05 Diode 1N4148 4 06 Resistor 1.5K 1 07 Resistor 10K 1 08 LED RED Colour 1 09 DB9 Female Connector with Cover – 1 10 6 PIN Female Connector with Wire – 1 11 Veroboard, Wires etc – – Circuit Diagram Now assemble the circuit as shown below in a piece of veroboard. Fig. : Simple Serial Port Based PIC Programmer. So our PIC programmer will have two interface A Serial Interface for Connecting it with PC A 6 PIN ICSP Connecter – This will be connected to our PIC which will sit in our project (say in a Breadboard). Fig. : Simple Serial Port Based PIC Programmer.   The technique […]

Easy 24C I2C Serial EEPROM Interfacing with AVR Microcontrollers

In this turorial we will see how we can easily interface a 24C series serial EEPROM with AVR microcontrollers. What is an EEPROM? An EEPROM is kinds of novalatile memory, that means it is used for storing digital data permanently without any power suply. EEPROM stands for Electrically Erasable Programmable Read Only Memory. The advantage of these kind of ROMs is that they can be erased Electrically to make them ready for storing new data. Compare this with a CD R disks they can be recorded only once. A small amount of EEPROM is also available internally on the AVR chips. So if the volume of data you want to store is small (say few user names and password) then you can use it. The internal eeprom makes design small and simple. But if the amount of data you want to store is large, say in order of few tens of kilobytes then you have to interface a External EEPROM chip with your AVR MCU. You can store pictures, sound and long texts in these eeproms. Their are many kinds of EEPROM chip available from many manufactures. One very common family is 24C series serial EEPROMs. They are available upto 128KB in size. They uses I2C interface with host controller (MCU) which is a very popular serial communication standard. I […]

Tutorial 0 – Getting Started with Microchip PIC Microcontrollers.

After my tutorial series on Atmel AVR Microcontrollers and I have planed to start a similar tutorial series on Microchip PIC Microcontrollers. PIC Family of Micros are popular among hobbyists as they are easily available, easy to use and are low cost. In the first couple of tutorial we will make/collect hardware and software tools which will be required to experiment with PIC MCUs. Once you have the basic tools up and running we will proceed to learning how to do basic stuffs with PICs, like setting and using PORTs, Controlling LEDs, Relays, Motors etc. These will help you as building blocks that will help you develop your own project and understand and implement thousands of PIC MCU projects out there in Magazines and Internet. These tutorials assumes that you are a beginner with Microcontroller i.e. having no or little experience with them. What is a Microcontroller? Ans: For information of "What is a microcontroller?" and how it can help you see this link. Selecting A Microcontroller We will start our journey with PIC16F877A and PIC16F628A Microcontrollers. Then we will move to high performance 18F core microcontrollers like PIC18F2550 and PIC18F4550. Tools Required What hardware and software tools you will need is described in this page. The article also gives you the over all process of development with MCUs. The […]

Synchronous Serial Communication Tutorial – The Basics of I2C and SPI.

This tutorial give you the details of synchronous serial communication, which is the basis of data transfer in communication standards like SPI and I2C. The tutorial is aimed for a beginner who has no experience or any idea of serial communication. So intermediate user who already has some idea about serial data transfer can skip this tutorial and jump directly to SPI or I2C tutorials. Data Transfer. Knowledge of data transfer is very important for any embedded system developer. In any embed ed system data is moved between several units like between RAM and CPU. There are many methods and technique for data transfer each having its own pros and cons. So different data transfer technique is used in different situations. Some example of data transfer are Simple parallel transfer. (Used to transfer 8,16,32 … bits of data in the same time) Asynchronous Serial Transfer (USART) – Old but still in use mode of serial communication using only 2 lines (+1 additional line for GND). SPI – Serial Peripheral Interface – Standard Mode of communication between different ICs. Many ICs designed for a Variety of Jobs like Flash Memory, LCD controller, Ethernet Controllers etc uses this standard for communication. So if you want to use any of these functionality you need to have a knowledge of SPI. IIC(or I2C) – […]

PWM Signal Generation by Using AVR Timers. Part II

In this tutorial we will set up the TIMER0 in fast pwm mode and use it to generate PWM signals of varying duty cycles. In this way we would be generating analog signals of voltages between 0 and 5v. In the example we will connect this output to a LED and see how it varies its brightness. Please see the previous tutorials on PWM and TIMERs before reading this tutorial. PWM Introduction to PWM – Pulse Width Modulation PWM Signal Generation with AVR Timers. Timers Introduction To AVR Timers. Timers In Compare Mode Part I Timers In Compare Mode Part II Setting Up TIMER0 in Fast PWM mode Setting up the TIMER0 in fast pwm mode is very easy and just require one line of code. You only need to deal with one register named TCCR0 (Timer Counter Control Register For Timer 0). You just need to set up various bits in it to get the required setting. The various bits of TCCR0 is given below. TCCR0 This register is used for configuring the TIMER0. See Timer Tutorial for more info. The explanation of various bits of this register is as follows. Bit No 7 6 5 4 3 2 1 0 Name FOC0 WGM00 COM01 COM00 WGM01 CS02 CS01 CS00 Initial Val 0 0 1 0 0 0 0 […]

PWM Signal Generation by Using AVR Timers.

In the last tutorial you saw how the PWM technique helps us generate analog signals from a microcontroller. In this tutorial we will see how PWM generation is implemented with microcontrollers. Before you begin please see Introduction to PWM Introduction to AVR Timers Generation of PWM signals is such a common need that all modern microcontrollers like AVR has dedicated hardware for that. The dedicated hardware eliminates the load of generation of PWM signal from software (thus frees the CPU ). Its like asking the hardware to generate a PWM signal of a specific duty cycle and the task of CPU is over. The PWM hardware with start delivering the required signal from one of its PINs while the CPU can continue with other tasks. In AVR microcontrolers PWM signals are generated by the TIMER units. (See AVR Timer Tutorials) . In this tutorial I will give you the basic idea of how PWM signals are generated by AVR timers. Their are two methods by which you can generate PWM from AVR TIMER0 (for ATmega16 and ATmega32 MCUs). Fast PWM Phase Correct PWM Don’t worry from their names they will become clear to you as we go on. First we will be considering the Fast PWM mode. PWM Generation Fundas We will use the simplest timer, TIMER0 for PWM generation.(Note […]

Introduction to PWM – Pulse Width Modulation.

A digital device like a microcontroller can easily work with inputs and outputs that has only two state, on and off. So you can easily use it to control a LED’s state i.e. on or off. In the same way you can use it to control any electrical device on/off by using proper drivers (transistor,triac, relays etc). But sometimes you need more than just "on" & "off " control over the device. Like if you wanna control the brightness of a LED (or any lamp) or the speed of DC motor then digital (on/off) signals simply can’t do it. This situation is very smartly handled by a technique called PWM or Pulse Width Modulation. PWM is the technique used to generate analogue signals from a digital device like a MCU. Almost all modern MCUs have dedicated hardware for PWM signal generation. In this tutorial we will learn the basics of PWM technique and later on we will see how to implement PWM generation with AVR microcontrollers. PWM : Pulse Width Modulation A digital device, like a microcontroller can only generate two levels on its output lines, HIGH=5v and LOW=0V. But what if we want to generate 2.5v or 3.1v or any voltage between 0-5 volt output ? For these kinds of requirement, instead of generating a constant DC voltage output […]

Using the USART of AVR Microcontrollers : Reading and Writing Data

Till now we have seen the basics of RS232 communication, the function of level converter and the internal USART of AVR micro. After understanding the USART of AVR we have also written a easy to use function to initialize the USART. That was the first step to use RS232. Now we will see how we can actually send/receive data via rs232. As this tutorial is intended for those who are never used USART we will keep the things simple so as to just concentrate on the "USART" part. Of course after you are comfortable with usart you can make it more usable my using interrupt driven mechanism rather than "polling" the usart. So lets get started! In this section we will make two functions :- USARTReadChar() : To read the data (char) from the USART buffer. USARTWriteChar(): To write a given data (char) to the USART. This two functions will demonstrate the use of USART in the most basic and simplest way. After that you can easily write functions that can write strings to USART. Reading From The USART : USARTReadChar() Function. This function will help you read data from the USART. For example if you use your PC to send data to your micro the data is automatically received by the USART of AVR and put in a buffer […]