How to Add And Simulate Ultrasonic Sensor Library in Proteus ? | 2018 Edition

 

 

 

The Ultrasonic Sensor also called “Ping Sensor” is used to detect the objects in front and measure the distance between sensor and object.

Check out project on Ultrasonic Sensor:  “How to measure distance using Ultrasonic Sensor

 

How to add Ultrasonic Sensor Library to Proteus?

 

You can also watch this video for easy reference:

 

STEP 1: First of all download Arduino Library from the link given below:

 

Ultrasonic Sensor Library For Proteus (Ed. 2018)

 

**Don’t have Arduino library? Click here to download that library.

 

 

STEP 2: Download the file to desktop

 

 

STEP 3: Unzip the .zip file to desktop

 

 

STEP 4: You will obtain these three files:

 (A) 1.UltrasonicTEP.LIB

       2.UltrasonicTEP.IDX

 (B) 3.UltraSonicTEP.HEX

 

 

STEP 5: Cut first two files and paste them in:

 Go to “C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\LIBRARY”

                 Cut  .HEX file and paste it in:

Go to “C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\BIN”

 

STEP 6: Open proteus and click on “pick from libraries”

 

STEP 7: Search for “ultrasonic”, you will see ultrasonic sensor. Select it and then place it anywhere on the front panel!

 

STEP 8: Double-click on sensor and then click on Ultrasonicsensor.HEX as shown in figure.

 

 

 

 

 

 

 

 

 

STEP 9: Select “UltraSonicTEP.HEX” file from BIN and hit enter as shown in figure.

 

 

 

 

 

 

 

 

 

STEP 10: Now you are good to go!  You can Start simulating Ultrasonic Sensor right away.

 

How to simulate Ultrasonic Sensor with Arduino in Proteus?

 

Before going further be sure to check out ” How to add and simulate Arduino in Proteus?

 

PROJECT:  Measuring distance using Ultrasonic Sensor Library with Arduino Library in Proteus.

 

STEP 1: Connect all components as shown in simulation figure.

Ultrasonic Sensor With Arduino in Proteus

 

 

 

 

 

 

 

 

 

 

 

 

 

STEP 2:  Download this “UltraSonic ” program to your Arduino IDE:

const int echoPin = 2; // Echo Pin of Ultrasonic Sensor
const int pingPin = 3; // Trigger Pin of Ultrasonic Sensorvoid setup()
{
Serial.begin(9600); // Starting Serial Communication
pinMode(pingPin, OUTPUT); // initialising pin 3 as output
pinMode(echoPin, INPUT); // initialising pin 2 as input
}void loop()
{
long duration, inches, cm;digitalWrite(pingPin, LOW);
delayMicroseconds(2);digitalWrite(pingPin, HIGH);
delayMicroseconds(10);digitalWrite(pingPin, LOW);duration = pulseIn(echoPin, HIGH); // using pulsin function to determine total time
inches = microsecondsToInches(duration); // calling method
cm = microsecondsToCentimeters(duration); // calling methodSerial.print(inches);
Serial.print(“in, “);
Serial.print(cm);
Serial.print(“cm”);
Serial.println();delay(100);
}long microsecondsToInches(long microseconds) // method to covert microsec to inches
{
return microseconds / 74 / 2;
}long microsecondsToCentimeters(long microseconds) // method to covert microsec to centimeters
{
return microseconds / 29 / 2;
}

 

DOWNLOAD THIS CODE

 

STEP 3: Go to preferences

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

STEP 4: Check “Compilation” CheckBox

 

 

 

 

 

 

 

 

 

STEP 5:  Click on verify (compile)

 

 

 

 

 

 

 

 

 

 

 

STEP 6: After compilation is complete copy HEX file path from the bottom corner:

 

STEP 7: Open Proteus and double click on Arduino. Paste the file path and click ok

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

STEP 8: Double-click on sensor and then click on Ultrasonicsensor.HEX as shown in figure.

 

 

 

 

 

 

 

 

 

 

STEP 9: Select “UltraSonicTEP.HEX” file from BIN and hit enter as shown in figure.

 

 

 

 

 

 

 

 

 

STEP 10: Run the simulation! Change potentiometer’s wiper terminal position to test the distance value on virtual terminal

 

Read Similar Articles:

How To Change Frequency On PWM Pins Of Arduino UNO

How to Add Microphone library to Proteus and generate audio waveforms

How to add Arduino Library to Proteus and Simulate Arduino Projects

4 Comments

4 Replies to “How to Add And Simulate Ultrasonic Sensor Library in Proteus ? | 2018 Edition”

  1. I got proteus 8.7 SP1 pro (legal) and try to simulate, I got this error :
    mixed model PIC16EX.DLL failed to authorize – Product Key not found. [SONAR1]

    Do you know tis error, can you help me
    Thank you

  2. I haven¦t checked in here for a while because I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: