HOW TO USE USE ULTRASONIC SENSORS IN PROTEUS ?

Hello friends, hope you all are fine. In today’s post, I am going to share an Ultrasonic Sensor Library for Proteus.Using this library you can perform any kind of function with an ultrasonic sensor.
                                                                          First of all, let's have a short introduction of an ultrasonic sensor. In the ultrasonic sensor, there are two nodes in which one is transmitter while the other is a receiver. The transmitter sends an ultrasonic wave and this wave strikes to any hindrance present in front of it and then bounces back. This bounced ultrasonic sensor is then captured by the receiver and on the basis of the time taken by this wave to return, the sensor calculates the distance of that obstacle from that sensor. The ultrasonic sensor is usually used for detecting the obstacle in a path and also to find the distance between a sensor and the obstacle. Ultrasonic sensor normally used is HC-SR04, which is also used here in this library. Let’s get started with Ultrasonic Sensor Library for Proteus, in this library, we have used an extra pin on the ultrasonic sensor, which is an analog pin. The voltage on that pin is used to detect how close object is because of its a simulation and we can’t place an actual object in front of our laptop or prototype. 

ULTRASONIC SENSOR LIBRARY FOR PROTEUS 

  • 1) First of all download this Ultrasonic Sensor Library for Proteus, find the attachment in the last of this post.
  • 2) In this ultrasonic sensor library for Proteus, you will find three files which are:

  a)  UltrasonicTEP.IDX


 b) UltrasonicTEP.LIB
   c) UltrasonicTEP.HEX


  • 3)Now, place these three files in the library folder of your Proteus software.

Note:

  • If you are using Proteus 7 Professional, then the library folder link will be something like this: 
                C:\Program Files (x86)\Labcenter ElectronicsProteus 7 Professional\LIBRARY

  • If you are using Proteus 8 Professional, then the library folder link will be something like this: 
                C:\Program\Data\Labcenter\ElectronicsProteus 8 Professional\Data\LIBRARY


Let's Start Setup for Sensor: 

  • Now start your Proteus software and in components list, search for Ultrasonic sensor and place it in your workspace as shown in below figure:
ultrasonic library for proteus,ultrasonic simulation for proteus,ultrasonic library proteus,proteus simulation for ultrasonic,ultrasonic library in proteus,ultrasonic proteus library
  • Now we have our ultrasonic sensor in Proteus but if you run it then it won’t work as we haven’t yet added any functionality in it.
  • So, in order to add the functionality double click this ultrasonic sensor and open its properties.
  • In properties, select the Program File section and browse to UltrasonicTEP.HEX file and upload it as shown in below figure:

  • Now our ultrasonic sensor is ready to be used.
  • Now let’s make a simple example for the ultrasonic sensor so that you get an idea how to use it in Proteus.

ULTRASONIC SIMULATION IN PROTEUS

  • After adding the Ultrasonic Sensor Library for Proteus, open your Proteus software or restart it if it's already open.
  • Now search for the below components in the Proteus Components Library and add them in your workspace as shown in below figure.

  • After adding these components, now design a simulation as shown in below figure:


  • Now in this example, I am receiving data from Ultrasonic Sensor and then printing this data over Virtual Terminal in Proteus.
  • Now open your Arduino software and paste the below code in it and compile to get the hex file, read Arduino Library for Proteus to know how to get the Arduino Simulation in Proteus.
  • You must also read How to get the hex file from Arduino Software.You can go through with my last post.
Program : 

const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 6; // Echo Pin of Ultrasonic Sensor
void setup()
{
Serial.begin(9600); // Starting Serial Terminal
}
void loop()
{
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}



  • It's quite a simple code and is self-explanatory if you still got some trouble then ask in comments and I will reply them. I have simply used the ping example in Arduino Examples and slightly modified it.
  • After getting the hex file, now upload it to Arduino in Proteus by clicking the properties.
  • Click on the Start button and if everything’s gone fine then you will see an output as shown in below figure:
ultrasonic library for proteus,ultrasonic simulation for proteus,ultrasonic library proteus,proteus simulation for ultrasonic,ultrasonic library in proteus,ultrasonic proteus library
  • As you can see in the above figure, the virtual terminal is showing distance values, now this value depends on the variable resistance attached to the ultrasonic sensor.
  • As you change the value of the variable resistance, the voltage on that particular pin will also change and on the basis of that you will get the distance in inches and centimeters on the virtual terminal.
  • Arduino code and hex file along with the Proteus Simulation for this ultrasonic example are attached below.Download both attachments and enjoy learning.







Thank You 

Ref: TEP

Comments


  1. Proteus LicenseI am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me


    ReplyDelete

Post a Comment

Popular posts from this blog

ARDUINO LIBRARY FOR PROTEUS AND HOW WE CAN USE ???

ECG Monitoring System by Using Arduino and AD8232