Interrupt Based Digital Clock with 8051 Microcontroller

Hello friends, hope you all are fine and having fun with your lives. In today's post, I am going to share Interrupt based Digital clock with 8051 Microcontroller. In the previous post, I have explained in detail How to use Timer Interrupt in 8051 Microcontroller. We have seen in that post that we can use two timers in 8051 Microcontroller which are Timer0 and Timer1. Using these timers we can easily generate interrupts. So, before going into details of this post, you must read that timer post as I am gonna use these timer interrupts in today's post.

After reading this post, you will also get the skilled hand on timer interrupt and can understand them more easily. In today's post, I am gonna design a digital clock which will increment after every one second and we will calculate this one second increment using timer interrupt. This clock will be displayed on LCD so if you are not familiar with LCD then must read Interfacing of LCD with 8051 Microcontroller. You can also implement this digital clock with any other microcontroller like Arduino or PIC Microcontroller but today we are gonna implement it on 8051 Microcontroller. The complete simulation along with code is given at the end of this post but my suggestion is to design it on your own so that you get most of it. Use our code and simulation as a guide. So, let's get started with Interrupt based Digital clock with 8051 Microcontroller. :)

Interrupt Based Digital Clock with 8051 Microcontroller

  • First of all, design a circuit as shown in below figure:

  • Now use the below code and get your hex file. I have designed this code in Keil uvision 3 compiler for 8051 Microcontroller.
#include<reg51.h>

//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void WriteCommandToLCD(int);
void WriteDataToLCD(char);
void ClearLCDScreen(void);
void InitTimer0(void);
void UpdateTimeCounters(void);
void DisplayTimeToLCD(unsigned int,unsigned int,unsigned int);
void WebsiteLogo();
void writecmd(int);
void writedata(char);

//*******************
//Pin description
/*
P2.4 to P2.7 is data bus
P1.0 is RS
P1.1 is E
*/
//********************

// Defines Pins
sbit RS = P1^0;
sbit E  = P1^1;

// Define Clock variables
unsigned int usecCounter = 0;
unsigned int msCounter   = 0;
unsigned int secCounter  = 0;
unsigned int minCounter  = 0;
unsigned int hrCounter   = 0;



// ***********************************************************
// Main program
//
void main(void)
{
   cct_init();             // Make all ports zero
   lcdinit();              // Initilize LCD
   InitTimer0();           // Start Timer0
  // WebsiteLogo();			
	while(1)
	{
		if( msCounter == 0 )                                       // msCounter becomes zero after exact one sec
		{
			DisplayTimeToLCD(hrCounter, minCounter, secCounter);   // Displays time in HH:MM:SS format
		}

		UpdateTimeCounters();                                      // Update sec, min, hours counters
  	}
}
void writecmd(int z)
{
   RS = 0;             // This is command
   P2 = z;             //Data transfer
   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void writedata(char t)
{
   RS = 1;             // This is data
   P2 = t;             //Data transfer
   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void cct_init(void)
{
	P0 = 0x00;   //not used 
	P1 = 0x00;   //not used 
	P2 = 0x00;   //used as data port
	P3 = 0x00;   //used for generating E and RS
}


void InitTimer0(void)
{
	TMOD &= 0xF0;    // Clear 4bit field for timer0
	TMOD |= 0x02;    // Set timer0 in mode 2
	
	TH0 = 0x05;      // 250 usec reloading time
	TL0 = 0x05;      // First time value
	
	ET0 = 1;         // Enable Timer0 interrupts
	EA  = 1;         // Global interrupt enable
	
	TR0 = 1;         // Start Timer 0
}


void Timer0_ISR (void) interrupt 1     // It is called after every 250usec
{
	usecCounter = usecCounter + 250;   // Count 250 usec
	
	if(usecCounter==1000)              // 1000 usec means 1msec 
	{
		msCounter++;
		usecCounter = 0;
	}

	TF0 = 0;     // Clear the interrupt flag
}

void WebsiteLogo()
{
   writecmd(0x95);
   writedata('w');                                 //write
   writedata('w');                                 //write
   writedata('w');                                 //write
   writedata('.');                                 //write
   writedata('T');                                 //write
   writedata('h');                                 //write
   writedata('e');                                 //write
   writedata('E');                                 //write
   writedata('n');                                 //write
   writedata('g');                                 //write
   writedata('i');                                 //write
   writedata('n');                                 //write
   writedata('e');                                 //write
   writedata('e');                                 //write
   writedata('r');                                 //write
   writedata('i');                                 //write
   writedata('n');                                 //write
   writedata('g');                                 //write
 
   writecmd(0xd8);
 
   writedata('P');                                 //write
   writedata('r');                                 //write
   writedata('o');                                 //write
   writedata('j');                                 //write
   writedata('e');                                 //write
   writedata('c');                                 //write
   writedata('t');                                 //write
   writedata('s');                                 //write
   writedata('.');                                 //write
   writedata('c');                                 //write
   writedata('o');                                 //write
   writedata('m');                                 //write
   writecmd(0x80);
}

void UpdateTimeCounters(void)
{
	if (msCounter==1000)
	{
		secCounter++;
		msCounter=0;
	}

	if(secCounter==60)
	{
		minCounter++;
		secCounter=0;
	}

	if(minCounter==60)
	{
		hrCounter++;
		minCounter=0;
	}

	if(hrCounter==24)
	{
		hrCounter = 0;
	}
}


void DisplayTimeToLCD( unsigned int h, unsigned int m, unsigned int s )   // Displays time in HH:MM:SS format
{
	ClearLCDScreen();      // Move cursor to zero location and clear screen

	// Display Hour
	WriteDataToLCD( (h/10)+0x30 );
	WriteDataToLCD( (h%10)+0x30 );

	//Display ':'
	WriteDataToLCD(':');

	//Display Minutes
	WriteDataToLCD( (m/10)+0x30 );
	WriteDataToLCD( (m%10)+0x30 );

	//Display ':'
	WriteDataToLCD(':');

	//Display Seconds
	WriteDataToLCD( (s/10)+0x30 );
	WriteDataToLCD( (s%10)+0x30 );
}


void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   //null statement
}

void WriteDataToLCD(char t)
{
   RS = 1;             // This is data

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (t&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((t<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}


void WriteCommandToLCD(int z)
{
   RS = 0;             // This is command

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= (z&0xF0);     // Write Upper nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);

   P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
   P2 |= ((z<<4)&0xF0);// Write Lower nibble of data

   E  = 1;             // => E = 1
   delay(150);
   E  = 0;             // => E = 0
   delay(150);
}

void lcdinit(void)
{
  ///////////// Reset process from datasheet /////////
     delay(15000);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(4500);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(300);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x30&0xF0);    // Write 0x3
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

     delay(650);

	 P2 &= 0x0F;		   // Make P2.4 to P2.7 zero
	 P2 |= (0x20&0xF0);    // Write 0x2
	
	 E  = 1;               // => E = 1
	 delay(150);
	 E  = 0;               // => E = 0
	 delay(150);

	 delay(650);

  /////////////////////////////////////////////////////
   WriteCommandToLCD(0x28);    //function set
   WriteCommandToLCD(0x0c);    //display on,cursor off,blink off
   WriteCommandToLCD(0x01);    //clear display
   WriteCommandToLCD(0x06);    //entry mode, set increment
}

void ClearLCDScreen(void)
{
	WriteCommandToLCD(0x01);   // Clear screen command
	delay(1000);
}
  • Now run your simulation and if everything goes fine then you will get results as shown in below figure:
  • The above figure is taken after 10 seconds of start of simulation in Proteus ISIS.
  • As the simulation keeps on running the clock will also keep on ticking.
  • The code is self explanatory but let me explain the interrupt function.
  • I have used Timer0 interrupt in this digital Clock.
  • The timer interrupt function is incrementing the userCounter variable by 250 which is in micro seconds. So we need 1000us as it will become 1 second. That's why I have placed the check that when userCounter == 1000 then increment the second.
  • I have added comments in the code so read it in detail and still if you stuck somewhere then ask in comments and I will resolve them.
  • You can download the complete code along with Proteus Simulation by clicking the below button:

Download Proteus Simulation and Code for Digital Clock

That's all for today. Hope you have enjoyed today's project. Will meet you guys soon in the next post. Till then take care !!! :)

Interfacing of LM35 with PIC Microcontroller

Hello friends, I hope you all are fine and having fun with your lives. In today's post, I am going to share How to interface LM35 with PIC Microcontroller. I have already shared Interfacing of LM35 with Arduino so now we are gonna interface this same temperature sensor with PIC Microcontroller. Interfacing LM35 with PIC isn't much difficult as its a simple sensor which gives us analog output and we just need to read this output and convert it into temperature format. Before going into details, you should first read the Interfacing of LM35 with Arduino as I have given the basic details of this LM35 sensor in that post. You should also have a look at How to use 18B20 in Proteus.

So, today I am not gonna go into the details of this temperature sensor. Instead let's start with Interfacing of LM35 with PIC Microcontroller. I have used Proteus software for simulation purposes but you can also test it on hardware. It will work fine on hardware as I have already tested it. I have used PIC 16F876A Microcontroler for this simulation and the PIC Compiler used for writing the programming code is MikroC Pro for PIC. If you have any problem then as k in comments and I will try to resolve them as soon as possible.

I have already posted the tutorial on Arduino and today we are having a look at interfacing of LM35 with PIC Microcontroller and soon I will also post the tutorial on Interfacing of LM35 with 8051 Microcontroller. ITs a simple sensor which you can interface with any kind of Microcontroller like PIC, Atmel, Arduino or 8051 Microcontroller. Anyways let's get started with interfacing of LM35 with PIC Microcontroller.

Interfacing of LM35 with PIC Microcontroller

  • You can download the complete simulation along with programming code by clicking on the below button:

Download LM35 Code and Simulation

  • First of all, design a simple circuit as shown in the below figure:
  • You should also try our New LCD Library for Proteus, it will give a better look to your project.
  • As you can see in the above figure, we have used LM35 sensor in Proteus which is connected with PIC Microcontroller.
  • Moreover, we have also connected LCD with PIC Microcontroller.
  • PIC Microcontroller we have used is PIC16F876A, but you can use any other PIC Microcontroller here.
  • LCD is used to display the Termperature Sensor LM35 value.
  • Now copy the below code and place it in your MikroC Pro For PIC Compiler and get the hex file.
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections


char display[16]="";

void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}

void main() {
unsigned int result;
float volt,temp;

trisb=0;
trisa=0xff;
adcon1=0x80;
lcd_init();
lcd_cmd(_lcd_clear);
lcd_cmd(_LCD_CURSOR_OFF);
lcd_out(3,2,"www.TheEngineering");
lcd_out(4,5,"Projects.com");
while(1)
{
result=adc_read(0);
volt=result*4.88;
temp=volt/10;

lcd_out(1,1,"Temp = ");

floattostr(temp,display);
lcd_out_cp(display);
lcd_chr(1,14,223); //print at pos(row=1,col=13) "°" =223 =0xdf
lcd_out_cp("C"); //celcius
//delay_ms(1000);
//Lcd_Cmd(_LCD_CLEAR);
}

}
  • When you get the hex file upload it in your Proteus software and run your Proteus simulation.
  • If everything goes fine then you will get something as shown in below figure:
  • As you can see in the above figure, LCD is displaying the same temperature values as in LM35 temperature sensor.
  • Now you can change this temperature value and the updated value will be displayed in LCD as you can see in below figure:
  • Now you can see in above figure that the temperature sensor LM35 value is 100 and same is displayed on LCD.
  • You should also have a look at How to use 18B20 in Proteus, which is another temperature sensor.
  • You should also try 18B20 with PIC Microcontroller.
  That's all for today. That's how you can interface LM35 with PIC Microcontroller and can get the temperature of your room. Will meet you guys in the next tutorial, till then take care and have fun!!! :)

How to use Timer Interrupt in 8051 Microcontroller

Hello friends, hope you all are fine and having fun with your lives.In today's post, we are gonna see How to use timer interrupt in 8051 Microcontroller.8051 Microcontroller comes with timer as well. They normally have two timer in them named as Timer0 and Timer1. These timers are used for counting purposes like you want to start some countdown in your project then you can use these timers or you wanna create some clock then in that case as well you need timers. So, in short there are numerous uses of timers in a project. Timers are also used for delays like you wanna create some delay of 10 sec but you dont wanna use the delay function in your project so you can use timers. You start the timer and then when it comes to 10 seconds then you can do your work. So, these are different uses of a timer and clearly we can't neglect its importance, so today we are gonna see How to use these timer interrupt in 8051 Microcontroller.

Now coming towards interrupt, interrupt is interrupt :P Yeah really, we call it interrupt because its an interrupt. In programming codes there are many things which needs to run in background and appear when its time for them to appear. Here where interrupt comes handy. Interrupt is kind of a background code which keeps on running in the background while the main code keeps on running in front but when the interrupt condition is fullfilled then it interrupts the main program and executes the functions defined in it. For Timer interrupts, suppose I wanna blink my LED after every 2 seconds then what will I do is I will start a timer for 2 seconds and when this timer completes I will generate an interrupt. So, in this way after every two seconds the led will blink. So, let's start with timers interrupt in 8051 Microcontroller and see how we are gonna do this.

How to use Timer interrupt in 8051 Microcontroller ???

As I explained earlier, we are gonna use Timer interrupt in 8051 Microcontroller. so, now before gong into the details, let me first throw some light on how we are gonna implement this. Timers count from 0 to 255 in 8 bit mode as in 8 bit 255 is the maximum value and when timer hits the 255 number then we say that our timer is overflowed. Now when timer overflows, then it sends us a indication using which we generate our intterupt. In timers, there are few registers in which they store their value. If we are talking about Timer0 then timer0 stores its value in TL0 register. Now suppose I want my timer to start counting from 10 instead 0 then I will store 10 in my TL0 register and it will count from 10 instead 0 and when it reaches 255 it will overflow. Now when Timer0 will overflow then it will make TF0 bit HIGH. TF0 is another register value, if its 1 then it means that our timer is full and if its 0 then it means our timer is still counting. So, that's how we count from our timer and check the pin TF0. Now first of all, I am gonna use Timer0 and then we will have a quick look at Timer1.

Timer0 Interrupt
  • First of all, design a simple circuit as shown in below figure:
  • Now upload the below code in your Keil software and get the hex file.
#include<reg51.h>

// Out Pin
sbit Out = P2^0;		   // Pin P2.0 is named as Out

//Function declarations
void cct_init(void);
void InitTimer0(void);


int main(void)
{
   cct_init();   	       // Make all ports zero
   InitTimer0();           // Start Timer0
 
   while(1)                // Rest is done in Timer0 interrupt
   {
   }
}

void cct_init(void)
{
	P0 = 0x00;   
	P1 = 0x00;   
	P2 = 0x00;   
	P3 = 0x00;  
}


void InitTimer0(void)
{
	TMOD &= 0xF0;    // Clear 4bit field for timer0
	TMOD |= 0x02;    // Set timer0 in mode 2
	
	TH0 = 0x05;      // 250 usec reloading time
	TL0 = 0x05;      // First time value
	
	ET0 = 1;         // Enable Timer0 interrupts
	EA  = 1;         // Global interrupt enable
	
	TR0 = 1;         // Start Timer 0
}


void Timer0_ISR (void) interrupt 1   // It is called after every 250usec
{
	Out = ~Out;  // Toggle Out pin

	TF0 = 0;     // Clear the interrupt flag
}

  • In the above code, the main function is our InitTimer0 function.
  • In this function what I have done is I simply set the timer 0 to mode 2. In mode 2, it will auto reload means once the timer0 overflows then it will comes back to its original value and will start again.
  • TL0 has 0x05 in it which is the initial value of timer0 and it will count for 250 micro seconds.
  • TH0 also has the 0x05. On reload timer uploads the vlaue from TH0 into TL0 so thats why we have given the same value to TH0.
  • After that we make ET0 bit enabled which will enable the timer, if you dont set this pin HIGH then our timer will not work.
  • EA bit will enable the global interrupt. if we dont enable this pin then timer will work but it wont generate the interrupt.
  • Finally after setting all configurations, we started our timer.
  • Now when the Timer0 overflows after every 250 micro seconds, it will generate the interrupt and it will come to Timer0_ISR function.
  • In Timer0_ISR function, I simply toggled the OUt pin which is Pin2.0 and then I again set the interrupt bit to 0 which is TF0.
  • That's how our timer is working and if we check the P2.0 pin on oscilloscope then it will look something as shown in below figure:
  • You can see in the above figure that our pin is toggling with an interval of 250 usec.
  • One important thing to note is there's no function written in while(1) loop and still its working because its running on background and performing the interrupt routine. You can add any function in your MAin code and it will keep on working and meanwhile at the background your interrupt will also keep on generating.
  • You can download this Simulation and programming code by clicking on below button.

Download Timer0 Code and Simulation

  • Now, lets have a quick look on Timer1 interrupt in 8051 Microcontroller.
Timer1 Interrupt
  • Now let's have a quick look on Timer1 interrupt in 8051 Microcontroller. For that, design the same simulation in Proteus as we did for Timer 0.
  • Now, upload the below code in your Keil software and get the hex file.
#include<reg51.h>

// Out Pin
sbit Out = P2^0;		   // Pin P2.0 is named as Out

//Function declarations
void cct_init(void);
void InitTimer1(void);


int main(void)
{
   cct_init();   	       // Make all ports zero
   InitTimer1();           // Start Timer1
 
   while(1)                // Rest is done in Timer1 interrupt
   {
   }
}

void cct_init(void)
{
	P0 = 0x00;   
	P1 = 0x00;   
	P2 = 0x00;   
	P3 = 0x00;  
}


void InitTimer1(void)
{
	TMOD &= 0x0F;    // Clear 4bit field for timer1
	TMOD |= 0x20;    // Set timer1 in mode 2
	
	TH1 = 0x05;      // 250 usec reloading time
	TL1 = 0x05;      // First time value
	
	ET1 = 1;         // Enable Timer1 interrupts
	EA  = 1;         // Global interrupt enable
	
	TR1 = 1;         // Start Timer 1
}


void Timer1_ISR (void) interrupt 3   // It is called after every 250usec
{
	Out = ~Out;  // Toggle Out pin

	TF1 = 0;     // Clear the interrupt flag
}

  • Now you can see in the above code that its exactly the same as we used for Timer0 with a slight difference that now we are using registers for Timer1.
  • Instead of TL0, now we are using TL1 and similarly TH1 instead of TH0 and TR1 instead of TR0.
  • Rest of the code is exactly the same and hence it will give the same result as for Timer0 and is shown in below figure:
  • You can download the code for Timer1 along with simulation by clicking the below button.

Download Timer1 Code and Simulation

That's all for today, I hope you guys have got something out of today's post and gonna like this one. In the coming post, I am gonna design some simple project on 8051 Microcontroller in which I will use these Timers, then you will get know more about them. So, stay tuned and subscribe us by email. Take care !!! :)

8051 Microcontroller Projects

Hello everyone, hope you all are fine and having fun with your lives. Today, I am going to share 8051 Microcontroller Projects. Recently, I have shared quite a lot of tutorials on 8051 Microcontroller which are not much arranged as a whole. So, today, I thought to arrange all those tutorials and place them here so that you can get all of them quite easily. I will upload more 8051 Microcontroller Projects and I am gonna add their links in this post so stay subscribed to this post if you are interested in learning 8051 Microcontroller.

8051 Microcontroller, as we all know, is another Microcontroller series just like PIC Microcontroller or Arduino etc. The benefit of 8051 Microcontrollers is that they are quite cheap and easily available so if you are going to design some product then its better to use 8051 Microcontroller instead of PIC Microcontroller or Arduino etc. As they are cheap so they also come with a disadvantage which is that they are not much rich with features. Few of 8051 Microcontrollers doesn't even support Serial Communication. So, before choosing it for your project, must check their datasheet to confirm that they are suitable for your projects.

In most of these below projects, I have designed the complete simulation in Proteus and the code is also given but my suggestions is don't simply download the simulation and run it. Instead design the simulation from scratch and then design your code and run the simulation on your own. Consider my codes and simulations as a guide but dont get dependent on them as then you are not gonna get anything. Anyways let's get started with 8051 Microcontroller Projects.

8051 Microcontroller Projects

Below are mentioned all the 8051 Microcontrollers Projects, which I have shared on this blog. You can check these projects and can also download their simulations designed in Proteus. I have given codes for most of these projects but few are paid, which you can buy from our shop at a quite minimal rate.

Basic Projects

These are basic projects and are best for beginner level programmers. If you are new to 8051 Microcontroller then first read these projects. These all projects contain complete codes as well as the Proteus simulation so you can quite easily test them in Proteus software and can edit the codes and learn from it.

Intermediate Projects

These are Intermediate level 8051 Microcontroller Projects. If you wanna do these projects then you must first learn or atleast have a look at basic 8051 Microcontroller projects as they are using same components as we interfaced in basic level. If you feel any problem then ask in comments.

That's all for today, but I am gonna add more projects in it and will keep on updating the list. Subscribe us and get these exciting tutorials straight to your mail box.

PIR Sensor Library for Proteus

Update: Here are the latest versions of this library: PIR Sensor Library for Proteus V3.0 and PIR Sensor Library for Proteus V2.0.


Hello friends, hope you are doing well.  Today, I will share a new PIR Sensor Library for Proteus. PIR Sensor module is not available in Proteus so we can't use it in our simulations. But today, I will share a new PIR Sensor Library for Proteus which can easily simulate PIR Sensor in Proteus software. We are quite happy that we are helping engineers by sharing these new Proteus Libraries.

We all know about PIR Sensor but if you don't know then first read Interfacing of PIR Sensor with Arduino.

As a quick review, a PIR sensor is used to detect motion in the environment and is commonly known as a motion sensor. It's quite helpful in security projects where you need to detect motion. For example in some bank vault where there's no possibility of motion, you can place this sensor and can check if there's any movement. It is also used in home automation i.e. if there's no movement in some room, turn off its appliances. So, in short, the PIR sensor has numerous uses and is used quite a lot in engineering projects.

First of all, I will show you today, How to download this PIR Sensor Library for Proteus and then we will also design a small simulation in Proteus in which I will interface this PIR Sensor with Arduino UNO. You can interface it with any microcontroller i.e. PIC Microcontroller or 8051 Microcontroller. But today, I will interface it with an Arduino microcontroller. As homework, you guys interface it with a PIC Microcontroller or 8051 Microcontroller and share it in comments, it may help others. So, let's get started with the PIR Sensor Library for Proteus:

PIR Sensor Library for Proteus

  • First of all, click on the below button to download the PIR Sensor Library for Proteus:
PIR Sensor Library for Proteus
  • Once you download it, you will get three files in it, named:
    • PIRSensorTEP.LIB
    • PIRSensorTEP.IDX
    • PIRSensorTEP.HEX
  • Place all these three files in the library folder of your Proteus software.
Note:
  • Now open your Proteus software and search for PIR Sensor, you will get a total of four models in it.
  • Place these models in your Proteus workspace and it will look something as shown in the below figure:
  • I have added four models of this PIR Sensor in Proteus Library and you can use any of them.
  • As working is concerned they are all the same but they differ in color.
  • The first color is our normal color, which I always use for my Proteus Libraries while the second one is green, the third is pinkish and the fourth one is blue.
  • This PIR Sensor has a total of four Pins, among which one is Vcc so you need to give +5V at this pin, then there's GND which you need to ground.
  • The OUT pin is our main pin through which we will be getting our output like whether it detects the motion or not.
  • Now, obviously, we can't detect real motion in Proteus Simulation that's why I have placed a TestPin which will be working as a simulation Pin.
  • If TestPin is HIGH, it means the motion is detected and if it's LOW then it means the motion is not detected.
  • Now we have our module in Proteus so one last thing we need to do is add its functionality.
  • So, in order to do so, double-click this PIR sensor and in the Program File section give a path to the file PIRSensorTEP.HEX, which you have placed in the library folder of your Proteus software as shown in the below figure:
  • Now click OK and your PIR Sensor is ready to be used in the Proteus Simulation.
  • So, now let's design a simple example for this PIR Sensor which will help you in understanding this sensor.

PIR Sensor simulation in Proteus

  • Design a simple circuit in Proteus software as shown in the below figure:
  • Now you can see in the above figure that I have placed a PIR Sensor along with Arduino UNO and a Virtual terminal.
  • PIR Sensor is connected to Pin # 2 of Arduino UNO.
  • Now upload the below code in Arduino software and get the hex file. You should read How to get Hex File from Arduino, if you don't know already.
    #define pirPin 2

    int calibrationTime = 30;
    long unsigned int lowIn;
    long unsigned int pause = 5000;
    boolean lockLow = true;
    boolean takeLowTime;
    int PIRValue = 0;

    void setup()
    {
    Serial.begin(9600);
    pinMode(pirPin, INPUT);
    }

    void loop()
    {
    PIRSensor();
    }

   void PIRSensor()
{
     if(digitalRead(pirPin) == HIGH)
     {       
         if(lockLow)
         {    
             PIRValue = 1;
             lockLow = false;
             Serial.println("Motion detected.");
             
             
             delay(50);
         }         
         takeLowTime = true;
       }

       if(digitalRead(pirPin) == LOW)
       {       
           
           if(takeLowTime){lowIn = millis();takeLowTime = false;}
           if(!lockLow && millis() - lowIn > pause)
           {
               PIRValue = 0; 
               lockLow = true;                        
               Serial.println("Motion ended.");
               
               delay(50);
           }
       }
}
  • Now run your simulation, and click the logic button to 1, which will indicate that motion is detected and you will get something as shown in the below figure:
  • Now let's make the logic state to 0, which will indicate that no motion detected, as shown in below figure:
  • So that's how our PIR Sensor is gonna work in Proteus. I hope you are going to like this PIR Sensor Library for Proteus.
  • You can download the simulation by clicking on the below button:
Download PIR Proteus Simulation
  • Here's a YouTube video where I have explained this PIR Sensor Library for Proteus in more detail, so check it out:

That's all for today, hope you have enjoyed it and gonna use it in your projects. If you get into any trouble, ask in the comments and I will try to resolve them as soon as possible. Take care !!! :)

XBee Library for Proteus

Hello everyone, today I am going to share a new XBee Library for Proteus. I am quite excited while sharing it as we are the first developer for this XBee Library. Now you can quite easily use XBee module in your Proteus software using this XBee Library for Proteus.Wehave spent quite a lot of time in developing this and that's the reason I couldn't share new tutorials in the past few days. Anyways we are done with this new exciting XBee Library for Proteus, hope you are gonna enjoy this one. I have already sharede two libraried for Proteus which are Arduino Library for Proteus and GPS Library for Proteus. You can also interface this XBee module with Microcontrollers like Arduino, PIC Microcontroller and 8051 Microcontroller quite easily.

As its the first version of our XBee Library for Proteus so its not quite perfect and can't do the complex tasks such as analog inputs etc. It will just do the serial communication. This xbee module has two pins TX and RX and you can do your communication with it quite easily. We have designed this XBee Library for Proteus, after quite a lot of effort and we are quite proud that we are presenting it first time for Proteus. Other bloggers are welcome to share this library on their blogs to share the knowledge but do mention our blog post link in your post. :) You should also have a look at XBee Arduino Interfacing. So, let's get started with it.

XBee Library for Proteus

  • First of all, download this XBee Library for Proteus by clicking on the below button:
XBee Library for Proteus

  • Now once you click it you will get a zip file to download so download this zip and open it.
  • In this zip file you will get two files named as:
    • XBeeTEP.LIB
    • XBeeTEP.IDX
  • So, now place these two files in the libraries folder of your Proteus software.
Note:
  • Now, start your Proteus ISIS software or restart it if its already running.
  • Go to your components library and search for XBee Module as shown in below figure:
  • Now place it in your workspace and it will look something as shown in below figure:
  • If you don't know much about xbee module then you should also have a look at Introduction to XBee Module.
  • As you can see in the above figure, its our xbee module in Proteus for the first time.
  • As, I mentioned earlier, its a first version of xbee module so its not very advanced and it will do just the basic serial communication i.e. sending and receiving data.
  • It has two pins on it which are TX and RX and using these two pins you can send and receive data quite easily.
  • So, let's design a simple example and we will see How to do the Serial communication using this new XBee library for Proteus.
  • Design a simple circuit as shown in below figure:
  • Now what I did is, I simply place a Virtual terminal with both of these xbee modules.
  • Now we need to change the Properties of one of these XBee module so double click on any one of these and you will get the below window:
  • You should also have a look at Interfacing of XBee with Computer.
  • Now, I have simply changed the Physical Port of this module to COM2 while the other module is at COM1.
  • So, now one of my XBee module is at COM1 while the second module is at COM2.
  • Now when I run my simulation then both XBee will start sending and receiving data on their respective COM Ports.
  • So, what I need to do is to virtually combine these two ports and for that I have used a software named as Virtual Software Driver from Eltima and I combine these two ports.
  • Now, run your simulation and whatever you type in the Virtual Terminal of first xbee will appear in the virtual terminal of second xbee. as shown in below figure:
  • You can also interface this XBee modue with other microcontrollers like Arduino, PIC Microcontrollers or 8051 Microcontrollers etc.
  • I have explained this whole tutorial in below video as well.
I hope you have enjoyed it and are gonna like it. Let me know if you got into any trouble and have problems in using this library. Also share your suggestions about improvement in this XBee Library for Proteus. :)

GPS Library for Proteus

Hello friends, hope you all are fine and having fun with your lives. In today's tutorial, I am gonna share another awesome library designed by our team for Proteus, which is GPS Library for Proteus. It's my second library for Proteus, the first one was Arduino Library for Proteus which I have already shared. I am really enjoying designing these modules in Proteus because its a new and quite challenging thing. I haven't found even a single website who has designed these modules in Proteus already. So, now for the first time, you can have the GPS Library for Proteus using which you can easily simulate your GPS module in Proteus and can design your code for Arduino, PIC Microcontroller or 8051 Microcontroller.

Other bloggers are welcome to share this library and its my humble request that do mention our blog in credits. :) The GPS module, I have designed for Proteus is a simple GPS which has TX and RX pins and when you start the simulation, this module starts sending the NMEA data on its TX pin, which you can easily check using Virtual Terminal. I am gonna show you how to check it in today's post. Another important thing, obviously in Proteus Simulation we can't get the actual values of longitude,latitude etc, so in our model, I have used the dummy values for all these data. The benefit of this module is that you can easily design your code for GPS and can test it in your simulation. Plus, its design is cool as well. ;)

Note:

GPS Library for Proteus

  • First of all, click on the below button and download GPS Library for Proteus.
GPS Library for Proteus
  • After downloading, you will get a zip file containing three files in it.
  • Now extract all these three files named as:
    • GpsTEP.LIB
    • GpsTEP.IDX
    • GpsTEP.HEX
  • Place these files in Libraries folder of your Proteus software.
Note:
  • Now open your Proteus software, if you have already opened it then restart your Proteus software.
  • Now in components list search for GPS Module and place it in your workspace.
  • If everything's fine then you will get your module as shown in below figure:
  • As you can see in the above figure, it has two pins in total which are TX and RX.
  • Now double click this GPS module and you will get to its properties as shown in below figure:
  • Now, one last thing you need to do is to upload the GpsTEP.HEX file, which you got in the downloaded zip file, in the Program File section.
  • This GpsTEP.HEX file is essential for this model as its adding the functionality of GPS in this model.
  • So, after adding the link of GpsTEP.HEX file in the Program File section, now your Gps module is ready to use in your circuit.
  • So, now let's add a Virtual terminal and check the output of this GPS Module. If you haven't worked on Virtual Terminal before then you should read How to use Virtual Terminal in Proteus ISIS.
  • Design a small circuit as shown in below figure:
Note:
  • The baud rate of this GPS Module is 9600.
  • The data sent by this GPS module is dummy as we can't get these values in simulation.
  • Now let's run the simulation and check the Virtual Terminal and if everything goes fine then you will get results as shown in below figure:
  • The first line is just the intro for this module and after that you will start receiving data which is in NMEA format.
  • NMEA data will remain constant but will keep on coming.
  • Now, instead of using this Virtual Terminal, you can use any microcontroller here like Arduino, PIC Microcontroller or 8051 Microcontroller etc. and can write your code easily and test it.
  • In my coming tutorials, I am gonna share examples for this GPS module in which I will interface it with different Microcontroller.
  • In the below video, I have explained this tutorial again so if you got any trouble then watch it as well.
That's all for today. You should also have a look at Interfacing of GPS Module with Arduino in Proteus ISIS. I hope you guys have enjoyed today's post and are gonna get benefit from it. Let me know your views about today's tutorial and also give your suggestions and help us in making this GPS Library for Proteus more smarter. :)

Arduino Library for Proteus

Update: Here are the latest versions of this library: Arduino Library for Proteus V3.0 and Arduino Library for Proteus V2.0.


Hello friends, I hope you all are fine. In today's tutorial, I am going to share a new Arduino Library for Proteus. I am quite excited about today's post as it's my first complete Arduino Library for Proteus. In my previous tutorials, I have shared these Arduino boards in separate Proteus libraries but today I have combined all the boards together in a single library. You just need to download the Proteus library zip file and install it in Proteus software. You will get all the Arduino boards in your Proteus workspace. You should also give a try to Genuino Library for Proteus.

We have tested all the boards with different types of sensors. So, now you can easily use Arduino in Proteus and can simulate any kind of project. If you have any issues, you can ask in the comments or use our forum to post your queries. Here's the video tutorial on How to install and use this Arduino Proteus Library:

This Arduino Library for Proteus is unique in its kind because there's no such library posted before that has as many boards as we have in our Library. We have added almost all the basic Arduino boards to it and we are also working on advanced boards i.e. Arduino DUE, Arduino YUN etc. You should also have a look at the Arduino Tutorial for Beginners. This Proteus Arduino Library consists of the following boards:

So, let's get started with Arduino Library for Proteus:

Note:

You should also download these Proteus libraries of different sensors & modules. Other Proteus Libraries are as follows:

Arduino Library for Proteus

  • First of all, download Arduino Library for Proteus by clicking the below button:
Arduino Library for Proteus
  • After downloading the Proteus library zip file, unzip it and you will get two files in it.
  • These two Proteus library zip files are named as:
    • ArduinoTEP.LIB
    • ArduinoTEP.IDX.
  • Copy these two files and place them in the Library folder of your Proteus software.
Note:
  • Now, restart your Proteus software and in components section search for ArduinoTEP as shown in below figure:
  • These are all the boards designed by our team in Arduino Library for Proteus.
  • In the Proteus workspace, these boards will appear as shown in the below figure:
  • So, these are the boards available in this Arduino Library for Proteus.
  • Arduino Mega 1280 is missing in this figure because it's the same as Arduino Mega 2560 so I haven't posted it here but it's included in the library.
  • So, now you have all the Arduino boards in your Proteus software and you can simulate them as you want them.
  • Let's design a simple Arduino UNO led blinking circuit for better understanding.
  • So, design a circuit as shown in below figure:
  • Now open your Arduino software, open the LED blinking Example and get your hex file.
Note:
  • Now upload your hex file to your Arduino board.
  • Hit the Run button on your Proteus software and you will get the result as shown in the below figure:
  • So, you can easily simulate any of your above-mentioned Arduino boards quite easily in Proteus software using our Arduino Library for Proteus.
  • If you are new to Arduino then you should try these Arduino Projects for Beginners, they will help you to get your hands on this marvelous creation. :P

That's all for today. I hope you have enjoyed this Arduino Library for Proteus and will benefit from it. Share your opinions about it in the comments below and help us to help you out. :)

Arduino Pro Mini Library for Proteus

Update: We have created a new version of this library, which you can check here: Arduino Pro Mini Library for Proteus V2.0.
Hello friends, hope you all are fine and having fun with your lives. In today's post, I am gonna share Arduino Pro Mini Library for Proteus. Recently, I have shared Arduino Nano Library for Proteus, and before that I have also posted Arduino UNO Library for Proteus as well as Arduino Mega 2560 Library for Proteus, and now I am gonna share Arduino Pro Mini Library for Proteus. Arduino Pro Mini is another Arduino board which also uses the same Atmega328 Microcontroller and has almost the same number of pins as Arduino UNO and Arduino Nano. Arduino Pro Mini is even more smaller than Arduino Nano board. It doesn't have the programmer on it so if you need to program it you have to use some TTL to Serial converter or you can also use Arduino UNO board in order to burn programming code in it. So, in today's tutorial, I am gonna share the Arduino Pro Mini Library for Proteus, which is the first library ever made for this board. You won't find the Arduino Pro Mini Library for Proteus anywhere. I am quite proud that our blog is sharing this library for the first time. You can download this library freely from the link below and can now simulate your circuits quite easily. So, now let's get started with this new Arduino Pro Mini Library for Proteus. I have added all the Arduino boards in a single library. This library contains six Arduino boards which are Arduino UNO, Arduino Mega 2560, Arduino Mega 1280, Arduino Nano, Arduino Mini and Arduino Pro Mini. You can download this complete Arduino Library by checking Arduino Library for Proteus.

Arduino Pro Mini Library for Proteus

  • First of all, download the Arduino Pro Mini Library for Proteus by clicking the below button.
Arduino Pro Mini Library for Proteus

  • Now when you click it, you will get a zip file so extract this zip file and you will get two files named as ArduinoProMiniTEP.LIB and ArduinoProMiniTEP.IDX.
  • So download these two files and place it in the libraries folder of your Proteus software.
Note:
  • Now, after getting the Arduino Pro Mini Library for Proteus files and placing it properly in your Proteus software. Open your Proteus software and make a search for Arduino Pro Mini.
  • Once you get this board, place it in your Proteus workspace and it will look like something as shown in below figure:
  • Now next thing you need to do is to read How to get hex Fie from Arduino, so that you can get the hex file, which we are gonna upload in this Arduino Pro Mini board.
  • So, once you get the link for your hex file, simply double click this board to open its properties.
  • Now place this hex file in the Program File section of its Properties section as we have seen in Arduino Nano Library for Proteus tutorial.
  • That's all, now using this Arduino Pro Mini Library for Proteus, you can easily simulate your circuits in Proteus and can test your codes.
  • Now, let's design a simple blinking example as we have done for previous libraries.
  • So, in order to dos so, design a simple circuit in Proteus as shown in below figure:
  • So, now as usual, use the blink example from the Arduino software and get your hex file as described in How to get hex file from Arduino.
  • So, after uploading the hex file, run your simulation. If everything goes fine then you will get results as shown in below figure:
  • So, now that's how you can simulate Arduino Pro Mini in Proteus using Arduino Pro Mini Library for Proteus.

Arduino Nano Library for Proteus

Update: Here are the latest versions of this library: Arduino Nano Library for Proteus V3.0 and Arduino Nano Library for Proteus V2.0.


Hello friends, hope you all are fine and having fun with your lives. In today's post, I am going to share a new Arduino Nano Library for Proteus. Arduino Nano is also a microcontroller board just like Arduino UNO but the advantage of Arduino Nano over Arduino UNO is its small size.

Arduino Nano is quite small in size and hence can be used in such projects where we need to use smaller PCBs. For example, I once worked on a project in which I needed to design a test cricket bat.

In that project, I used IMU along with Arduino Nano and placed the complete kit over the bat. As I need to place the electronic kit over the bat so it has to be quite small, that's why I have used Arduino Nano instead of Arduino UNO board. So, now I hope you got the idea of where to use Arduino Nano instead of Arduino UNO.

Now, coming to Proteus software, in Proteus we don't have the default board for Arduino Nano so that's why I have designed this Arduino Nano Library for Proteus, using which you can quite easily use the Arduino Nano board in Proteus and can test your code quite easily. I have already posted the Arduino UNO Library for Proteus and have also posted the Arduino Mega 2560 Library for Proteus. So, today I am posting the third Arduino Library for Proteus. Hope you are going to like it as well.

In the next tutorials, I will share more Arduino Libraries for Proteus. I am working on Arduino Mini and Arduino Pro Mini as well. So, I will post their libraries too once I get them completed. I am also planning on designing the Sim900D Library for Proteus but till now I haven't started it. I am planning to post a complete Arduino Library at the end in which you just need to install one library and all the Arduino boards will come in Proteus. Anyways, let's get started with the Arduino Nano Library for Proteus.

Note: I have added all the Arduino boards in a single library. This library contains six Arduino boards which are Arduino UNO, Arduino Mega 2560, Arduino Mega 1280, Arduino Nano, Arduino Mini and Arduino Pro Mini. You can download this complete Arduino Library by checking the Arduino Library for Proteus.

Arduino Nano Library for Proteus

  • First of all, download Arduino Nano Library for Proteus files, by clicking the below button:
Arduino Nano Library for Proteus
  • After clicking this button, you will get a zip file containing two files named as ArduinoNanoTEP.LIB and ArduinoNanoTEP.IDX, so extract these two files and place these files in the Library folder of your Proteus software.
Note:
  • After placing these files in the Library folder of your Proteus software then open your Proteus software.
  • In Proteus software search for Arduino Nano and place it in your workspace.
  • The Arduino Nano board in Proteus will look like something as shown in below figure:
  • It has the same ATMEGA328 Microcontroller as in Arduino UNO and has almost the same pins.
  • So, now next thing we need to check is the hex file. So in order to upload the hex file in Arduino Nano, simply double-click it to open the Properties panel and it will look like something as shown in the below figure:
  • Now, you can upload the hex file by clicking the browse button in the Program File Section.
  • The crystal oscillator we are using here is 16MHz which is the default for Arduino boards.
  • You should also read How to get hex File from Arduino so that you can get the hex file easily.
  • So, now let's design a simple LED blinking circuit with this Arduino Nano board to test it.
  • Design a simple circuit as shown in below figure:
  • So, now simply use the blink example from the Arduino software and compile it to get the hex file.
  • Upload this hex file in the PROGRAM FILE section and hit the RUN button.
  • If everything goes fine then you will get the results as shown in the below figure:
  • So, now that's how you can simulate Arduino Nano in Proteus quite easily using Arduino Nano Library for Proteus.

That's all for today. In the coming post, I will share the Arduino Mini and Arduino Pro Mini Library for Proteus. You should also have a look at these Arduino Projects for Beginners. So stay tuned and have fun!!! :)

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir