
Ultrasonic Sensor Library for Proteus

Hello friends, hope you all are fine and having good health. In today's post, I am going to share an Ultrasonic Sensor Library for Proteus. A few days ago, I posted a tutorial on Arduino Library for Proteus, and today I am going to share the new Ultrasonic Sensor Library for Proteus. Using this library, you can easily interface Ultrasonic Sensors with different Microcontrollers like Arduino, PIC Microcontroller etc.
First of all, let's have a brief introduction to ultrasonic sensor. In an ultrasonic sensor, there are two nodes available, one is the transmitter while the other is the receiver. The transmitter sends an ultrasonic wave and this wave strikes 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 the path and also to find the distance between the sensor and the obstacle. The ultrasonic sensor normally used is HC-SR04, which we have designed 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 an object is because it's a simulation and we can't place an actual object in front of the simulated sensor. Moreover, you should also have a look at this Home automation Project using XBee & Arduino, I have used this ultrasonic sensor in that project.
I hope you are going to enjoy this library. This library is designed by our team after a lot of effort, if you have any feedback to improve, please let us know. So, let's get started with Ultrasonic Sensor Library for Proteus and its interfacing with Arduino.
Note:
- Other Proteus Libraries are as follows:
- Moreover, for hardware implementation of the Ultrasonic Sensor with Arduino, check below posts:
- I have also posted more examples of Ultrasonic Sensor Simulation in Proteus, have a look at them and you will get a complete understanding of this sensor.
Ultrasonic Sensor Library For Proteus
- First of all download this Ultrasonic Sensor Library for Proteus, by clicking on the below button.
- In this ultrasonic sensor library for Proteus, you will find three files which are:
- UltrasonicTEP.IDX
- UltrasonicTEP.LIB
- UltrasonicTEP.HEX
- Now, place these three files in the library folder of your Proteus software.
Note:
- If you are new to Proteus 7 or 8 Professional, then you should read How to add new Library in Proteus 8 Professional.
- Now start your Proteus software and in the components list, search for the Ultrasonic sensor and place it in your workspace as shown in the below figure:
- 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 an ultrasonic sensor, so that you get an idea of how to use it in Proteus.
Ultrasonic Simulation in Proteus
- After adding the Ultrasonic Sensor Library for Proteus, open your Proteus ISIS 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 the below figure.
Components Used
Here's the list of components, which I have used for designing this Proteus Simulation:- Arduino UNO
- Ultrasonic Sensor HC-SR04
- LED
- Variable Resistor
Proteus Simulation
- After adding these components, now design a simulation as shown in the below figure:
- Now in this example, I am receiving data from Ultrasonic Sensor and then printing this data over Virtual Terminal in Proteus, if you are not much familiar with Virtual Terminal, then read How to use Virtual Terminal in Proteus ISIS.
- Now open your Arduino software and paste the below code in it and compile it 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.
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 the comments and I will reply to 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 the below figure:
- 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. You can download it by clicking on the below button but I would suggest you to design it on your own, it will help you in learning.
- You should also have a look at these Arduino Projects for Beginners.
That's all for today, in the coming post I am gonna share some more examples of how to use ultrasonic sensor in Proteus. Till then take care and have fun.
Getting this error
2 replies
Hi,
Check our next post http://www.theengineeringprojects.com/2015/02/ultrasonic-sensor-simulation-proteus.html , you will get the complete example simulations on ultrasonic sensor, download and run them. They will work for you.
Thanks.
1 reply
Yes buddy,,how r u???can we make an educational video using these components in proteus,,,,,,,??I also made water flow sensor as a custom component,,,,,,,
tengo el mismo problema. help
Yes, they worked
Thanks.
Could you please help me calculating speed of a diecast car from same sensor
1 reply
Hi,
Good to know that it worked for you. Now regarding your project, yeah we can help you in it and can provide you the complete project. Give me a call on my number +92-332-6062060 and we can discuss it in detail.
Thanks.
Can you help out that problem.
1 reply
It says that you haven't uploaded the hex file in Arduino, so go to properties and upload the hex file into arduino and it will start working. Moreover, also download ready to run examples from here http://www.theengineeringprojects.com/2015/02/ultrasonic-sensor-simulation-proteus.html ,easy to start.
1 reply
i faced problems her can some body help me please
will this sensor work with pic in proteus? thx
1 reply
Hi,
Yeah it will work with PIC Microcontroller as well.
Thanks.
hi
thank u for ur information
I have a question,can I use ultrasonic sensors with Atmega32 to design a controlling system for example is a smart home?actually I wanna design a controlling system and I search on internet to understand that how I can simulate this controlling system by proteus
could u please help me?
thank u
when i simulate this its shows a message like this unable to open hex file now what should i do for this
I am using proteus 8.In that I cant find the Data and Library folder. Where shall i paste the documents.
1 reply
if u have found the answer help me too ,i m having this issue too
Thanks for this contribution is very useful.
I'm getting a problem in the ultrasonic sensor.. It says the UltraSonicSensor.Hex is not found..
Where can I get the hex file of the ultrasonic sensor? Not the hex file of the arduino board.. Thanks :D
Do these libraries only work with the pro version, I have a student edition and I'm getting an error saying product key not found, I only get it when I try to run the above simulation would I need to have a cracked version of proteus for it to work.
1 reply
I think you are gonna need the cracked version. You can buy the Proteus 7 Patch from us for $5. Thanks.
PLEASE HELP ME OUT.VIOLATION ERROR..PROTEUS PROBLEM OR SOMETHING ELSE. I ALREADY INCLUDE HEX FILE. PLEASE GIVE DETAILS SOLUTION.
Your UltraSonic Sensor is a micro-controller in itself.. Can you please tell me where is the HEX file of that controller.
It keeps giving error that "UltraSonicSensor.HEX" not found in ../../../../../chipkit/workspace/
It will be really appreciated if you reply early..
Thank You
Hi Syed Zain Nasir, I'm a french student and i work on a project which use that Sonar, I followed your instructions to use it. Thanks for all. I have just a little lack of understanding about the Arduino code. So can you explain to me the operating of it ?
Can you send me an e-mail at : ralec.a@stjolorient.fr
Usual greeting.
1 reply
Hi,
Kindly add me on Skype and we will discuss it in detail. My Skype id is theenggprojects.
Thanks.
Can you give me any sites that describe how we can define a component for simulation please. I have not seen any good tutorials about how to describe the functionality
that downloaded file is not opening, can any one help me....
what is pulseIn() function ???why we use ??
mixed model PIC16EX.DLL failed to authorize - Product Key not found. [SONAR1]
I have proteus 8 pro (legal)
in MODEL , pic16hex is, but i have this error
Can you help me ?
Thanks
1 reply
Hi,
I have tested it on Proteus 7 & 8 Professional and it worked great. Either you haven't run the simulation properly or it creating error because of genuine Proteus. :P Our components are third party so may be that's why. You should download Proteus 7 from our website and then test it.
Thanks.
i am working on self balancing robot. for that i need mpu6050 library for proteus to simulate it... you might help me sir.

























Comments
33