How to Use Timers in Ladder Logic Programming?

Hello friends! I hope you are doing very well, today we have a very crucial topic which is “timers”. Yes! Exactly like what comes to your mind. For running equipment i.e. motor at a specific time and/or for some amount of time we need timers. Timers are used even before PLC in classic or relay logic conventional control. However, there is a big difference between capabilities and limitations between using physical timers in classic or old fashion relay logic and using software timers in PLC. By completing this article you will be able to know what are timers and their types and applications. In addition, we are going to show off how to use timers in ladder logic programming with examples.

What are timers used for in industrial applications?

Well! This is a very good question to start and its answer can be taken as a motive to learn timers comprehensively. Timers are used to turn on actuators i.e. motors for a specific amount of time or turn off them after a specific amount of time. They are used for scheduling tasks on and off based on the process sequences.

How do timers work?

There are many types of timers based on the functions. However, all timers are working in the same principle that they are preset to a specific amount of time. Then when their coils are energized, the timers’ contacts are changing over to the opposite of their initial states i.e. from ON to OFF or from OFF to ON based on the delay time and the timer type. Therefore, we can imagine the main components of timers are the coil and contacts as shown in figure 1 [1]. It shows a relay timer for Telemecanique type showing the setting for the time delays, coil, and the contacts.

Figure 1: physical relay timer

Advantages of Timers in PLC over relay timers

The relay timers are limited in time setting i.e. for 24 hours and a specific amount of physical NO and NC contacts. While timers in PLC are logical software components with the unlimited setting of time which makes them very flexible with logic requirements. In addition, using physical relay timers costs us more space and wiring. While we can use soft timers in ladder logic with no limitations. Types of timers as we are going to describe in detail later, are limited to basic functions in the relay timers while all types of timers can be implemented in PLC using ladder logic programming.

Timers types

All timers have a coil and contacts and the latter will be changed over their states by energizing their coil based on the preset time and the type of timer. In the following subsection the most common timer types are introduced:

ON-DELAY timer

This type of timer is used to postpone the start of running. Figure 2 depicts the timing diagram of the On-Delay timer. As shown in this timer delayed the output from the input by the preset delay time. The figure shows that, after the input gets started, the time counts up until the preset amount of time elapsed, then the output starts as long as the input is ON. However, in the second pulse of the input, we can notice the output was not started because there was no chance to reach the amount of delay time that is preset in designing the timer.

Figure 2: The timing diagram of the On delay timer [2]

OFF-DELAY timer

In this type of timer, we aim at delaying the shutdown of the output. Figure 3 depicts the timing diagram of the OFF delay timer in which, the output starts at the time input starts and the output lasts after a specific time delay after the input gets off. You can notice that, in the second pulse of the input, the output did not shut down after the second pulse of the input due to the incoming of another input pulse before the delay time reached the preset value.

Figure 3: The timing diagram of the Off delay timer [2]

Pulse timer

This timer type energizes the output in each rising edge of the input for a fixed amount of time. Figure 4 shows the timing diagram of a pulse-type timer. It shows the output comes active each time it finds a rising edge of the input and keeps active for a fixed amount of time which is preset for the timer.

Figure 4: Timing diagram of, the pulse timer [2]

 

Accumulative timer

In an on-delay timer, if the input does not stay on for the preset time delay period there would not be a chance for the output to be energized. So there should be another modified timer to accumulate the period each time the input is ON and activate the output when reaching the preset value. This timer is called an accumulative timer and its timing diagram is depicted in figure 5. In this example, assume the preset values of 12 s, the first input pulse shown in blue resumes for 4 seconds and it goes on for another 8 seconds. The time is accumulated from the first and the second pulse until reached the preset value which is 12 seconds. The output gets ON as long as the preset time has reached and the input is ON.

Figure 5: on-delay accumulative timer

Timers in PLC and ladder logic program

Timers of different types can be used in PLC with great flexibility. Now let’s learn and practice timers with our simulator. But before we get to start we just need to introduce ourselves to the timer blocks in the ladder logic program.

Generate ON delay timer instruction

Figure 6 shows the instruction for generating an ON Delay timer. As you can see the instruction has two inputs and two outputs. The first input “IN” is the input contact of type Boolean. This input contact triggers the timer and initiates it to start counting the time. The second operand is the “PT” by which we set the required time delay. Moving to the outputs, the first output is “Q” this is the main output of the timer and it turns to true when the timer reaches the preset time delay. The second output is the “ET” which reports the time elapsed so far since the timer started to count time. The “PT” and “ET” are of time data type format and can be in milliseconds, seconds, minutes, hours, days et cetera.

Figure 6: Generate ON delay instruction

ON-Delay timer example ladder program

Figure 7 shows a very simple example program that uses an ON Delay timer for delaying the running of a motor. The ladder code is shown on the right part of figure 7. It shows that one input contact connected to address “I0.0” and its tag named “trigger_timer” is connected to the timer input. And the preset value is set to be one minute “T#1m” which means one minute. Notice the format is very simple. You type T denoting the time format and then “#” followed by the amount of time and at last the unit of time which could be “MS” for milliseconds, “S” for seconds, “m” for minutes, “d” for days … et cetera. Moving to the outputs, the timer output “Q” is connected to the motor meaning that the motor will be running after the timer counts complete one minute. The other output is “ET” which tells the time elapsed so far since the timer set to start counting time. Let’s go to the simulator window on the left side. We added all inputs and outputs to control the inputs and show the output as well. You can notice that, by setting the input “trigger_timer” to true, the timer starts counting the time as you can read in the “ET” variable that shows the time spent so far “T#29S_335MS” meaning 29 seconds and 335 milliseconds have been elapsed since input set to true. Since the PT time is not reached, the output is still false as shown in blue color.

Figure 7: ON-Delay timer sample program with a simulator

Figure 8 shows the moment when the timer reached the PT value which is one minute in our example. You can notice on the left window, the ET value becomes one minute which is equal to the PT value. Therefore, the timer output turned to true and the motor is switched on consequently. To sum up, this example shows how the output has become ON after one minute delay of the input.

Figure 8: ON-Delay timer energized the output after one minute delay

OFF delay timer example ladder program

After we have shown how we can delay the start of a motor by using the On Delay timer. Here we are going to show how to delay the shutdown. Figure 9 shows an example of a very simple ladder program that uses an OFF delay timer to delay the shutdown of an output. As you can see on the left the input is ON and the output starts running with the input at the same time. Let's try to set the input OFF as in figure 10, you can notice the output is still ON and the time counter is incrementing until it reaches the PT value which is set to one minute in our example. Figure 11 reports the moment at which the time counter reached the PT value which is one minute. At that moment the output or the motor is shut down. In a conclusion, the Off delay timer is our tool to delay the shutdown of output or terminate a process.

Figure 9: OFF delay timer example

Figure 10: The input is off while input is still run

Figure 11: the output shutdown delayed one minute

Pulse timer example

In this example, we are going to start and stop the motor in a pulsative operation mode thanks to the pulse timer type. That means the input to the timer will start the output to run for a specific amount of time that is present in the PT value regardless of receiving any other input pulses. In figure 12, the pulse timer example is shown. The very simple ladder logic program is displayed on the left window and the simulation is shown on the left window. You can notice that, once the timer received a high state of the input, it energized the output and started counting the time. However, when the input went OFF the output keep running ON for the designated while represented in PT value which is one minute for this example as shown in figure 13. Let’s test the condition of having another input signal as shown in figure 14. When the input goes again high which the last pulse does not complete, the output continues running and the timer does not reset its timing count. However, when the pulse time is reached as in figure 15, the output is shut down and the timer now is ready to start another pulse by noticing a rising edge of the input.

Figure 12: pulse timer example

Figure 13: the output continue running for its pulse period

Figure 14: another pulse does not reset the timer until complete one pulse period

Figure 15: output shutdown after completing pulse period

Accumulative timer ladder example

In this ladder example, we are going to show you how to continue accumulating the time until reaching the PS value at which the timer energizes its output as shown in figure 16. The example shows a very simple ladder code that has two inputs connected in parallel to OR logic. So any of these two inputs will trigger the counter to count up the time. On the left window, all inputs and outputs including timer operand and outputs are listed in simulating table to show the values while the program is executing.

Figure 16: an accumulative timer ladder example program

Let us start triggering the timer by one of the inputs as shown in figure 17. As you can notice the timer starts counting the time as shown in the ET value on the left window showing the simulation. What if we set the inputs OFF? In the ON Delay timer, the time will be reset. But in this timer, it does not and instead, it waits for another input signal to accumulatively increment the time till reaching the PT value as shown in figure 18. Let’s verify the concept by setting one of the inputs ON as shown in figure 19, the timer accumulates the timing counter until it reached the PT value which is set to one minute in this example. At that moment the output is energized as shown in figure 20. And finally, figure 21 shows how the timer is reset by switching on a reset button. One good practical example for using this type of timer is the maintenance schedule. For example, we can schedule the maintenance to be conducted after one year or after a specific amount of time or number of operating hours. So the timer will keep accumulating the time of operation regardless of the downtime and raise a flag to notify it is the time for performing maintenance.

Figure 17: starting the timer by enabling one of the inputs

Figure 18: setting the inputs off does not reset the timer

Figure 19: timer accumulates the time

Figure 20: the output goes ON after reaching the PT value

Figure 21: timer reset its timing count

What next

I would like to thank you so much for following up with our tutorial that far. So far you are familiar with timers types and how to utilize the suitable one for your task based on the logic you want to perform. Next tutorial we are going to go through counters showing their types and functionalities and for what reasons we need counters how we can use them appropriately.

Real-Life Applications of Internet of Things

In our previous article, we grasp knowledge about real-life examples of the Internet of things. Now in this article, we try to elaborate on real-life applications of the Internet of things. Now a question may arise in your mind what’s the difference between the application of the Internet of things and examples of the Internet of things. I would be happy if you may elaborate on your question in addition. Simply associate degree example shows how applications are also created. Like there are several functionalities on the market in terms of arthropod genus and strategies however with examples it might be additional clear. Even so these functionalities are also wont to produce one thing awe-inspiring. In short, examples of the Internet of things is a task that is performed to develop a skill while the application is the action of putting something into operation.

Now a put a little throwback to our article. What is the Internet of Things? This is for our new readers who are unable to read our previous article.

Internet of things

There have been loads of sites on the "Internet of Things" (IoT). But, what specifically will that term mean within the realms of cyberspace? For humankind, that is comparatively upset naturally, the "Internet of Things" could be a nice innovation. However, for those that price their privacy, the "Internet of Things" may be thought about as a colossal intrusion.

Usually, the internet of things means several devices are connected with each thorough internet. By having everything categorized this manner through the net "cloud," the reasoning goes, you will be ready to organize your life higher by not desirous to pay "time-consuming" attention to your life.

Why is it important?

Just like the web is here to attach individuals, the web of Things is here to attach devices that may currently act with an alternative bunch of them, it's calculable that since 2008 there are a lot of devices connected to the web than individuals. it's straightforward to assume perceive then why of the importance of the net of Things and why ought to we care to understand regarding and find use thereto as an integral a part of our lives. The Internet of Things is aimed to facilitate our daily activities and tasks by taking up some basic selections on our behalf, wherever there's a network of devices connecting to the web to require faraway from America repetitive actions or to finish tasks by learning from our condition and preferences. Those artistic movement self-driving cars we tend to watch in movies are nearer than ever to be a reality, let's get comfortable and look ahead to a lot of because it comes obtainable. True is, the IoT has simply been born, there are masses for all parties to be told and develop to form it grow in an exceedingly structured and economical method. For it to be realizable, its development must be thought to permit an association among devices to be feasible, a plug-n-play construct.

Applications of IoT

Now back to our article which is the application of the Internet of things.

  • Application of IoT in home automation ( HVAC, watch out for retailer, lighting)
  • IoT in smart cities
  • IoT application in Environment
  • Application in smart retails
  • In infrastructure business
  • In safety business (child or pet finder)
  • To trim the traffic problems
  • In welcome business

Application of IoT in HVAC home-automation

The home automation system is accessible these days by the businesses United Nations agency are trying forward to introducing the sensible devices. The industries are trying forward to victimization them for HVAC, retailers, and even for the lighting system of one's home. several firms are providing these services, and lots of others are on the point of introducing them in their sensible home services' section. allow us to cross-check the performance of sensible devices within the residential homes.

Making the sensible HVAC System

The sensible home conception can add convenience within the lives of the folks, as they'll be ready to save additional on energy and price. this can conjointly add convenience to the operating of the folks however before that, they have to travel through many aspects of this newer technology. Most of the homes have air conditioners, centralized heating or instrumentality, lighting, water heaters, retailers, and far additional. because the firms are providing sensible HVAC systems these days, thus it plays a vital role within the homes.

Most of the owners are passionate about HVAC because it is should have in each zero in today's days as a result of one desires the cooling and ventilation for the summers and heating for the winters. With the usage of the IoT for this technique, it'll create the sensible home conception, and therefore the improvement is shown in its operating.

Here are a number of the positive aspects that the IoT goes to gift for the HVAC system:
  • The sensible device is ready to regulate the space temperature, sensible thermostats are adjusted with the cooling temperature, and therefore the diminution and saving of energy are there.
  • The users' are educated concerning the cooling and heating temperatures at the same time, and therefore the app is watching the sensible devices.
  • The IoT also will advise the owners concerning saving energy and providing data on saving additional energy usage.
  • This is conjointly a cheap approach as sensible devices can facilitate in saving the energy and reciprocally, the value is slow down too.
  • Top firms have factory-made several sensible home devices which will facilitate in adjusting the space temperature and can be employing a detector to see the temperature and therefore the time of users' location. It will even work well with the most recent voice-activated assistants.

Watch out for the retailers

Not only, are the sensible devices designed to figure well with the HVAC system but conjointly the retailers that comprise of the facility usage in your home. The IoT helps the house owners to bear in mind the facility consumption of the home and the way to save lots of it because the sensible thermostat will it. The advanced Outlet devices can facilitate within the period watching of the facility usage that's tired the house. Such devices react in an associate degree economical manner and avoid any quiet electrocutions or consumption.

Here are a number of the uses of sensible devices for the retailers of the home:
  • An automated feature can keep a check on the consumption of power by the previous and therefore the new appliances and can warn the house owner concerning a similar.
  • The cheap and progressive plugs from the businesses are used with the voice assistants to state concerning the facility consumption of the house.
  • With the addition of wireless controls, advanced power sockets, etc., the facility usage within the home has taken a more modern state of affairs.

Lighting and using the web of Things

The sensible home lighting conception also will create the work of the owners straightforward, as there are several firms engaged in delivering the most recent technology lighting devices. varied high firms are providing the foremost moneymaking shades and therefore the kit for sensible lighting. there's a bridge offered by most of the businesses that handle nearly fifty lights at the same time. this can be a good investment for the larger homes, and even some residences like taking sensible light-emitting diode bulbs. Here are a number of its helpful effects:

With the usage of advanced lighting devices, the owners will get convenience, and that they will save additional on power and price of the lighting system. The options of such devices enable the residential homeowners to urge the lights removed from any place in their home. They even provide colors, and these progressive lights will prove useful throughout power disruption too.

Most of the owners these days create investments within the sensible bulbs to save lots of energy by turning off the lights mechanically once nobody is around. Therefore, to reduce facility consumption, sensible lighting may be an efficient plan. The package that's developed for the lighting system is compatible with automaton and iOS systems, and one will management the bridge or light-emitting diode bulbs through this package.

Outcome of HVAC

While seeing this system, the sensible homes are being most well-liked by the owners as this reduces the facility consumption and saving of energy is being done. The machine-driven lighting, Outlet, and therefore the HVAC system is getting the necessity of associate degree hour. Therefore, owners can take the services from the businesses for the sensible home devices.

Smart Cities

Once in your automotive, you will be transported through the good town you decision home to your workplace. as a result of you reside in an exceedingly good town, your commute is currently 15-30 minutes quicker than it is accustomed be. Transit knowledge, as an example, will tell a town once it has to increase transit schedules on a specific subway line to scale back congestion and lower commute times. stoplight cameras will alert a town to the necessity to regulate light temporal order to stay cars moving and reduce congestion, and if a collision happens, inform emergency response instantly. additional economical transit and control contribute to lower carbon emissions, creating towns airless contaminated for inhabitants.

Through the ability of IoT, whole cities are getting digitally networked and so smarter. By aggregating and analyzing mass amounts of knowledge from IoT devices throughout varied town systems, cities are up the lives of voters. good cities will build higher selections through the info it collects concerning infrastructure desires, transit demands, and crime and safety. A study showed that by exploiting current good town applications, cities are up against the quality of life indicators (like crime, traffic, and pollution) by between 10-30%. IoT technologies in the standard of living as a part of your home, transportation, or city, hook up with build an additional economical and pleasurable life expertise. IoT guarantees a more robust quality of life by doing mundane chores and increasing health and health.

web of Things Applications

To avoid a tie-up, the machine operation calculates the typical speed once the application exceeds one vehicle and mechanically determines the gap to the vehicle ahead and rear.

Internet of Things Applications In good Retail

The Current Retail system can simply rework to the good Retail with IoT technology. One nice example of good retails is tagging merchandise, by tagging merchandise one merchandiser will get large edges. consistent with specialists of this field, this can facilitate retailers to urge ninety-nine inventory accuracy. for example, the sectors wherever IoT has affected tons square measure – Home renewal, computer game, Wireless sensing and chase, Home hubs, etc. Also, IoT features a feature that helps it combine public and personal knowledge sources. this can sure facilitate the retailers to urge a lot of knowledge (information) regarding the merchandise.

In Safety business

Electronic equipment helps people at large cut back personnel efforts in regular activities.

Child and Pet Finder

The feeling once you lose your dear ones, whether or not it's your kid or a four-legged loved one, is terrible. However, you'll track their location in the period with an associate IoT-linked device hooked up to the smartphone. Thus, IoT permits you to remain in peace even once far from your dear ones.

In Infrastructure business

IoT provides insights into everything from the machine to the provision chain and provision activities from the producing floor through to client doors. The crucial infrastructure that keeps cars moving through the city and pumping the water into your home is a daily task for America, and most people square measure utterly ignorant. IoT allows businesses to change processes and save on labor. It conjointly lowers waste and enhances service delivery, creating production and distribution of things less expensive and guaranteeing client interactions transparency. It allows organizations to decrease prices, improve safety, and improve end-to-end quality, which could be a win-win for everybody. This reduces the price of producing client things, makes shipping a lot of sure, and allows enterprises to develop, boosting our economy whereas giving a way of happiness.

Touchless dealings Devices

Touchless dealings Devices:

The best IoT gadgets embody those who permit while not bit, e.g. contactless payment, gathering, and chase of information. Cleanliness includes all measures that minimize germ transmission and facilitate stopping the epidemic.

In welcome business

The internet of things (IoT) transforms the welcome business by basically dynamical the gathering of information and computer program and automation processes by hotels, resorts, cruise ships, casinos, restaurants, and alternative recreation enterprises

Climate management Devices:

The crucial challenge for humanity nowadays is temperature change. The worst climatic conditions and record-setting temperatures have created States and countries' expertise higher frequency and protracted power outages. To combat temperature change, IoT will facilitate managing peak demand, together with network stability, victimization joined devices like the Thermostat. associated example for the usage of climate management devices within the accommodation sector.

Heating system:

Central heating systems during a room flip the energy into heat and transfer this energy into heat that's equipped during a building to several areas. The thermostat controls to control the temperature, which is performed by an associate embedded system, square measure essential for these systems.

Application of Internet of things in Environment

In recent times, we tend to are getting a lot of and a lot of consciousness of the atmosphere and therefore the injury that human activities have caused. Now, we tend to square measure slowly attempting to correct our mistakes and tackle environmental problems. we can create a North American nation of IoT applications to assist us with this goal. One of the square measures wherever IoT is operating is the preservation of bees. Honey Bees face a threat during this contaminated world. temperature change has effects on them in addition. However, by implanting IoT devices, beekeepers will take higher charge of protective hives. victimization IoT with connected sensors, it's attainable to stay track of the hive temperature, the quantity of food gift within the hives, and additionally, the spore assortment. IoT will be employed in waste management additionally, serving North American nations take higher care of our surroundings.

That’s All today. I hope you can understand the difference between examples and applications. Keep tuned and thanks for reading our tutorial.

Signal Edge Detection in Ladder Logic

Hello friends, How are you doing? Today, we have a very interesting topic of PLC ladder programming which is how to detect the transition between true and false and from low to high?. I know you are asking why do we need that? Well! Imagine my friends, we want to start a motor when the input signal state changes from high to low or from false to true. Let us give two examples to highlight the edge detection techniques. Good examples of using edge detection-based logic are timers and counters. In counters, they are energized to count up or down when a signal appears and the same for timers. Figure 1 shows the difference between using the edge to control a motor. In the top part, the motor is controlled by an input switch. the output is ON and OFF based on the status of the input. But, in the second example, the rising edge is used to energize a motor. So, the motor comes to true when the switch state changes from false to true. On the other hand, imagine my friends if you want to activate a protection relay or safety function based on the result of the logic operation (RLO) for output, in that case, we can control the running of the output for one scan cycle to be based on the change in the state of the RLO.

Fig. 1: Rising edge logic

Signal Edge Types

There are two edge types:

  1. Falling edge.
  2. Rising edge.
Figure 2 shows the falling and rising edge signal. It shows the falling edge happens when the signal turned from true to false while the rising edge when it signals changes from false to true.

Fig. 2: The falling and rising edge of a signal

Rising Edge in PLC Ladder Logic

Figure 3 shows the general symbol of a rising edge. The letter “P” denotes a positive edge. while fig. 4. Depicts the rising edge in ladder logic in the TIA portal of siemens software.

Fig. 3: the general symbol of a positive or rising edge

In ladder programming, the rising edge shows a positive rising edge received for the signals. In fig. 4, the rising edge is for the signal tagged as “TagIn_4” and the previously saved value is stored in “Tag_M”. the system can recognize a rising edge by comparing the buffered value stored in “Tag_M” and the current value in “TagIn_4”. For example, if the previous value stored in “Tag_M” is False, and the current value in “TagIn_4” shows high logic, this would mean a rising edge is received.

Fig. 4: the rising edge in a plc ladder program

Falling edge in PLC ladder

Figure 5 shows the general symbol of a falling edge. The letter “N” denotes a negative edge. while fig. 6. Depicts the falling edge in ladder logic in the TIA portal of siemens software.

Fig. 5: the general symbol of a negative or falling edge

In ladder programming, the rising edge shows a negative or falling edge received for the signals. In fig. 6, the falling edge is for the signal tagged as “TagIn_4” and the previously saved value is stored in “Tag_M”. the system can recognize a falling edge by comparing the buffered value stored in “Tag_M” and the current value in “TagIn_4”. For example, if the previous value stored in “Tag_M” is True, and the current value in “TagIn_4” shows low or false logic, this would mean a falling edge is received.

Fig. 6: the falling edge in a plc ladder program

Set Output on a Positive Edge

Now let’s do the same concept on the output side, fig. 7 shows the set output ladder instruction on a rising or positive edge. In this instruction, the result of the logic operation (RLO) which represents the left part before the output is evaluated to check the transition in its state. If the RLO changes from false to true then the output will be set for one scan cycle.

Fig. 7: the set output on positive edge instruction

Figure 8 shows an example of the set output on a positive edge. On the most left, the coil with the letter “P” inside represents the instruction. The instruction works by saving the previous value of RLO into “Tag_M” and verifying the changes in a state with “TagOut”. For example, if the “Tag_M” holds a true state while the previously stored value in “Tag_M” was false. That would show a positive edge and the output will be set to true for the complete scan cycle.

Fig. 8: example of set output on a rising edge

Set Output on a Negative Edge

Figure 9 shows the set output ladder instruction on a falling or negative edge. In this instruction, the result of the logic operation (RLO) which represents the left part before the output is evaluated to check the transition in its state. If the RLO changes from true to false then the output will be set for one scan cycle based on detecting a falling edge of RLO.

Fig. 9: instruction of set output on falling edge

Figure 10 shows an example of the set output on a falling or negative edge. On the most left, the coil with the letter “N” inside represents the instruction. The instruction works by saving the previous value of RLO into “Tag_M” and verifying the changes in a state with “TagOut”. For example, if the “Tag_M” holds a false state while the previously stored value in “Tag_M” was true. That would show a negative or falling edge of the RLO. Consequently, the output will be set to true for the complete scan cycle.

Fig. 10: example of set output instruction base don falling edge

Simulating edge detection

Now let’s go to our lab and open a simulator to enjoy practicing very critical points in ladder logic programming. Yes, my friends, these are very critical points and are used smartly in solving very hard problems to solve. But, by comprehensive these points, you will be superb in your field as a prospective ladder logic programmer. Two points we are going to simulate, the first one is the ringing and falling edge of the inputs and their effects on activating and energizing the output for a complete pulse. And the rising and falling edge cases of the result of logic output (RLO) and its effects on energizing the output for a complete pulse.

Simulating rising edge

Now, let’s assume we have a situation in the factory that, when specific action occurred, the output will be energized. In the example represented by fig. 11, when and only when input A, turned on, we need to start the output. That means the only scenario in which the output is turned on is when input A state changed from false to true. So let us simulate three scenarios, the first one shown in fig. 11, in this scenario the input previous status is saved in input B, while the current or new state is saved in input A. notice when the input does not change and it is false, the output is turned off.

Fig. 11: the rising edge scenario 1

Now let’s turn on input A, so now input changed from false to true as shown in Fig. 12. Ohh, notice the output comes true and that’s the rising edge at when the input changes from false to true.

Fig. 12: the rising edge scenario 2

And in the last scenario, when the input keeps true meaning the previous status was true and the current state is true, then the output is false as shown in Fig. 13.

Fig. 13: the rising edge scenario 3

In a conclusion, in rising edge, the output only gets true when the input changed from false to true.

Falling Edge in PLC Simulator

Now, let’s assume we have another situation in the factory that, when an input or sensor turns off or changed from true to false, the output will be energized. In the example represented by fig. 14, when and only when input A, turned out from ON to off, the output will be energized. That means the only scenario in which the output is turned on is when input A state changed from true to false. So let us simulate three scenarios, the first one shown in fig. 14, in this scenario the input previous status is saved in input B, while the current or new state is saved in input A. notice when the input does not change and it is false, the output is turned off.

Fig. 14: the falling edge scenario 1

Now let’s turn on input A, so now input changed from false to true as shown in Fig. 15. Ohh, notice the output is false because that’s not a falling edge as the input changes from false to true.

Fig. 15: the falling edge scenario 2

And in the last scenario, when the input changed from true to false which is a falling edge. Therefore, the output turned on as in fig. 16.

Fig. 16: the falling edge scenario 3

In a conclusion, in a falling edge, the output only gets true when the input changed from true to false.

Simulating set output on the rising edge

Now, my friends, we need to run the output for one pulse based on the result of logic output (RLO). Figure 17 shows the scenario of having a false state of the RLO, the output is false because there is no falling edge detected for the RLO.

Fig. 17: set output on rising edge scenario 1

Figure 18 shows the case when the RLO is turned from false to true, the output comes true but for one pulse notice the previous status represented by buffer has become false but the output after pulse time returns to false. However, the pulse of the output has been detected thanks to energizing output tag_5.

Fig. 18: set output on rising edge scenario 2

Simulating set output on falling edge

Figure 19 shows the very initial case of set output with a falling edge. To show, the case of the falling edge of RLO, we use another rung that would energize another output at Q0.6 when and only when the falling edge of the RLO occurs. In Fig. 19, the RLO was false. Therefore, there is no cause for a falling edge when RLO changed from true to false. So the output shows a false state.

Fig. 19: set output on falling edge when RLO was initially false

Now let’s turn on the RLO, so the RLO changed from false to true which is still not a case of a falling edge of the RLO. SO the output is still false as shown in Fig. 20 represented by output Q0.6.

Fig. 20: set output on falling edge when RLO turned to on

Figure .21 shows the scenario of the RLO turning from true to false which is a falling edge. In that case, the output will be turned on for one pulse and as a result, latching output at Q0.6 as shown in rung 2 of fig. 21.

Fig. 21: set output on falling edge when the RLO turned back to false (falling edge)

What’s Next

Once more I would like to thank all my friends for continuing with our learning and practicing our PLC ladder logic series. Now we have learned the concept of edge detection, its importance, and how we can utilize the rising and following edge in some critical and accurate cases of logic. The rising and falling edge of the inputs can energize an output in a pulsative way or for only one pulse. This scenario exists in the industry and is very common. For example, when you want to energize a safety device by the occurrence of some conditions like increase of liquid level or temperature or pressure et cetera. Also, the result of logic output (RLO), can be used to set or reset output for one pulse. In the next tutorial, we are going to introduce the latching in more detail showing why we need to latch an output, the ways of latching with examples, and for sure enjoying our practicing with the PLC ladder logic simulator.

ESP32 Capacitive Touch Sensor in Arduino IDE

Hello readers, I hope you are all doing great. Welcome to the 2nd lecture of Section 5(ESP32 Sensors) in the ESP32 Programming Series. In the previous tutorial, we discussed the built-in ESP32 Hall Effect Sensor. In this tutorial, we will discuss another inbuilt sensor of the ESP32 i.e. Capacitive Touch Sensor.

ESP32 Board has 10 built-in capacitive touch pins, which generate an electrical signal when someone touches these pins. These ESP32 touch pins are normally used to wake up the board from deep sleep mode. These touch pins are also used to replace the normal mechanical buttons with touch pads, improving the presentation of the IoT projects.

Here's the video demonstration of the ESP32 Capacitive Touch Sensor:

Before going forward, let's first understand how this touch sensor works:

Where To Buy?
No.ComponentsDistributorLink To Buy
1ESP32AmazonBuy Now

What is a Capacitive Touch Sensor?

Capacitance is determined by the geometry of the conductors and the dielectric materials used. Changing any of these factors will result in changing the capacitance.

C = Ad

As we know, the human body also carries a small electric charge. So, when a body approaches the metallic plates(of a capacitor), the mutual capacitance between the two metal plates decreases. This change in capacitance is used to detect the touch in these capacitive sensors.

Capacitive touch sensor in ESP32

  • ESP32 offers 10 Capacitive-sensitive GPIO pins, operating at a normally HIGH state.
  • So, at open state, these pins provide +5V at the output but when someone touches any of these pins, the respective pin voltage drops to 0.
  • These ESP32 Capacitive Touch Sensor Pins are labeled in the below figure:(for detailed pinout, please read ESP32 Pinout)

So, if someone touches any of these pins, ESP32 can easily detect it. The pin mapping of touch-sensitive pins in DOIT ESP32 DevKit V1 with GPIO pins is shown below:

ESP32 Capacitive Touch Pins
No. Parameter Name Parameter Value
1
Touch0 GPIO4
2
Touch1 GPIO0(not available in DOIT ESP32 Dev-kit V1 30-pin module but available in the 36-pin module)
3
Touch2 GPIO2
4
Touch3 GPIO15
5
Touch4 GPIO13
6
Touch5 GPIO12
7
Touch6 GPIO14
8
Touch7 GPIO27
9
Touch8 GPIO33
10
Touch9 GPIO32

Programming ESP32 Capacitive Sensor

We are using the Arduino IDE development environment for programming ESP32. If you are new to Arduino IDE, read out How to Install ESP32 in Arduino IDE. Let's use the builtin Touch Sensor example in Arduino IDE:

  • Open the Arduino IDE, go to File > Examples > ESP32 > Touch. An image from Arduino IDE is attached below for your reference:

In Arduino IDE there are two example codes available for the ESP32 touch sensor. We will discuss and implement both example codes in this tutorial. So, let's first open the TouchRead Code:

ESP32 TouchRead Example

Here's the code for the TouchRead Example:

// ESP32 Touch Test
void setup()
{
    Serial.begin(115200);
    delay(1000); // give me time to bring up serial monitor
    Serial.println("ESP32 Touch Test");
}

void loop()
{
    Serial.println(touchRead(T0)); // get value using T0
    delay(1000);
}

Code Description

  • This is a basic code to test/understand the touch sensor feature of ESP32.
  • In this code, we are using a touch-sensitive pin to read the variation in capacitance and print the respective readings on the serial monitor.

Setup() Function

Inside the setup() function, the serial monitor is initialized at a baud rate of 115200 to display the sensor readings. Finally, we printed the message(ESP32 Touch Test) on the Serial Monitor:

void setup()
{
    Serial.begin(115200);
    delay(1000); // give me time to bring up serial monitor
    Serial.println("ESP32 Touch Test");
}

Loop() Function

  • Inside the loop function, the touchRead(T0) function takes the T0 capacitive sensor pin as an argument and reads the output of T0(GPIO Pin4).
  • The observed output is continuously printed on the serial monitor with a delay of 1 sec.
void loop()
{
    Serial.println(touchRead(T0)); // get value using T0
    delay(1000);
}

Testing/Result

  • Upload the above code into the ESP32 development board and connect a jumper wire to the T0 capacitive sensor pin(GPIO4).
  • To open the serial monitor in Arduino IDE, go to Tools > Serial monitor or use the Ctrl+Shift+M shortcut key.
  • Select the 115200 baud rate on the serial monitor.
  • Now hold the metal end of the jumper wire connected to the GPIO4.
  • To check the results, open the serial plotter, go to Toole > Serial Plotter or use Ctrl+Shift+L shortcut keys.
  • As you can see in the above figure, the sensor's value drops to 0 when we touch the metallic part of the capacitive sensor pin.
  • When we are not touching the sensor pin, the normal sensor output is around 107.
  • Here's the Serial Monitor showing the touch results:

ESP32 Touch Interrupt Example

These capacitive touch sensor pins are mainly used to generate an external interrupt for waking up ESP32 from low power modes(deep sleep mode). Moreover, can also be used to control external peripherals like LED blinking or tuning on a DC motor, when a capacitive touch-interrupt is observed. So, let's have a look at How to Generate external interrupt by touching the ESP32 capacitive touch pins:

ESP32 Touch Interrupt Code

Here's the ESP32 Touch Interrupt Code:

const int CAPACITIVE_TOUCH_INPUT_PIN = T0; // GPIO pin 4
const int LED_OUTPUT_PIN = LED_BUILTIN;
const int TOUCH_THRESHOLD = 40; // turn on light if touchRead value < this threshold
volatile boolean _touchDetected = false;

void setup()
{
    Serial.begin(115200);
    pinMode(LED_OUTPUT_PIN, OUTPUT);
    pinMode(LED_OUTPUT_PIN, LOW);
    touchAttachInterrupt(CAPACITIVE_TOUCH_INPUT_PIN, touchDetected, TOUCH_THRESHOLD);
}

void touchDetected()
{
    _touchDetected = true;
}

void loop()
{
    if(_touchDetected)
    {
        Serial.println("Touch detected.");
        _touchDetected = false;

        Serial.println("blink the LED");
        digitalWrite(LED_OUTPUT_PIN, HIGH);
        delay(1000);
        digitalWrite(LED_OUTPUT_PIN, LOW);
        delay(1000);
    }
}

Let's understand the code by parts:

Variables Initialization

  • The first step is to select the GPIO or touch sensor input pin to trigger an interrupt. We are using T0 or GPIO4 as an interrupt pin.
  • Select the LED output pin which will react or blink on the occurrence of an interrupt.
  • In the code, we are using the threshold value of 40. When a body, containing an electric charge touches a touch-sensitive pin, the threshold value decreases below 40.
  • The default state of the touchDetect variable is set to false.
const int CAPACITIVE_TOUCH_INPUT_PIN = T0; // GPIO pin 4
const int LED_OUTPUT_PIN = LED_BUILTIN;
const int TOUCH_THRESHOLD = 40; // turn on light if touchRead value < this threshold
volatile boolean _touchDetected = false;

Setup() Function

  • In the Setup Function, we initialized the serial monitor with a baud rate of 115200 so that you can display the results on the serial monitor for debugging purposes.
  • Set the LED pin as output and set the default state to LOW.
  • Attach the interrupt with the capacitive touch pin T0 using touchAttachInterrupt(), it takes the T0 pin, touchDetected and threshold value as arguments.
void setup()
{
    Serial.begin(115200);
    pinMode(LED_OUTPUT_PIN, OUTPUT);
    pinMode(LED_OUTPUT_PIN, LOW);
    touchAttachInterrupt(CAPACITIVE_TOUCH_INPUT_PIN, touchDetected, TOUCH_THRESHOLD);
}
  • touchDetected() function will be called when an interrupt is triggered i.e. someone touches the T0 Pin.
  • This Function will change the state of the "_touchDetected" variable to true.
void touchDetected()
{
    _touchDetected = true;
}

Loop() Function

  • Inside the loop() function, we are using the ‘if’ statement which is continuously checking the state of variable "_touchDetected".
  • Once the variable state is changed to true, an interrupt is triggered and the output LED (inbuilt LED) will start blinking with a delay of 1 second.
  • The result will be printed on the serial monitor.
void loop()
{
    if(_touchDetected)
    {
        Serial.println("Touch detected.");
        _touchDetected = false;

        Serial.println("blink the LED");
        digitalWrite(LED_OUTPUT_PIN, HIGH);
        delay(1000);
        digitalWrite(LED_OUTPUT_PIN, LOW);
        delay(1000);
    }
}

Testing of ESP32 Touch Sensitive Pin

  • Open the serial monitor with a 115200 baud rate.
  • Connect a male-to-female jumper wire with T0 or GPIO 4 of ESP32.
  • Hold the metallic end of the jumper wire.
  • LED will blink with a delay of 1 sec.
  • See the results displayed on the serial monitor.

This concludes the tutorial; I hope you found this helpful and also hope to see you again with a new tutorial on ESP32.

Real Life Examples of Internet of Things

There's a flock of noise at the instant concerning the Internet of Things(IoT) and its impact on everything from the method we travel and do our looking to the method makers keep track of inventory. However, what's the web of Things? how will it work? And is it genuinely that important?

Introduction to Internet of things

What is the Internet of Things?

In short, this technology connects any device to the net and plenty of different devices. In easy terms, this can be a classy network of things connected with one another. This network collects and shares information and data.

The devices embody a variety of objects, like good microwaves, self-driving cars, wearable devices, and complicated sensors, to call many.

How will it work?

Devices that feature constitutional sensors connect with the IoT platforms that integrate data and information from a variety of ordinarily used devices. Then powerful analytics square measure wont to share helpful data so as to resolve specific desires.

IoT platforms will determine helpful data and also the data which will be unheeded. Then the data are often employed in order to spot patterns, offer suggestions and imply issues before their incidence.

For instance, if you deal during an automotive creating business, you'll ascertain the nonobligatory and necessary components.

Based on the insight and analytics offered, you'll simply build the processes heaps additional economical. Moreover, good systems and objects may also assist you to build some tasks automatically, particularly once these tasks square measure mundane, repetitive, and long naturally. Let's take a glance at some real-world examples.

Examples of IoT in everyday life

At the stuff-user level, the IoT is conveyance connected intelligence to our homes, offices, and vehicles. sensible speakers just like the Amazon Echo and Google Home create it fast and convenient to play music set timers or get info, mistreatment voice commands, or mobile app controls. Systems usually integrate with in-car amusement and remote observation applications.

Home security systems with integrated cameras, sensible protection mechanisms, and remote controls permit householders to watch what’s occurring within and outdoors or to ascertain and discuss with guests from miles away.

Environment regulators like sensible thermostats will facilitate the North American nation to heat our homes before we tend to arrive back from the workplace, whereas sensible light-weight bulbs will create it appear as if we’re reception, even once we’re out. Noise and pollution sensors will unceasingly monitor the areas we tend to routinely inhabit, and modify the North American nation to arrange wherever and the way to pay our time with the best level of safety.

Another net of Things Examples

As we tend to mention antecedently, IoT examples currently span all walks of life and sectors of business. makers, for instance, square measure adding sensors to their products’ parts to transmit knowledge concerning how they're operating. This could facilitate organizations to determine once a part is probably going to fail and swap it out before it can cause harm. Enterprise applications of the IoT typically take 2 forms: industry-specific applications like sensors in a very generating plant or period location devices for health care, and IoT devices capable of the application altogether industries, like sensible air-con or security systems.

TOP INTERNET-OF-THINGS (IoT) EXAMPLES to understand

  • Connected appliances
  • Smart home security systems
  • Autonomous farming instrumentation
  • Wearable health monitors
  • Smart mill instrumentation
  • Wireless inventory trackers
  • Ultra-high-speed wireless web
  • Biometric cybersecurity scanners
  • Shipping instrumentality and provision chase
  • Home automation

The entire world is evolving with new technologies and IoT is that the current trend. Not all, however, people who are awake to it, are wanting forward to home automation victimization IoT. There are several IoT answer suppliers UN agency will assist you with expertise IoT based mostly home automation.

Home Automation using IoT

The idea of IoT primarily based on home automation could appear fictitious at first, however not anymore; due to the advancements in the net of Things. it's currently quite potential to own automatic house using this technology; here is a way to explain.

There are broadly three speaking categorized parts of associate degree IoT machine-controlled house: hardware, software, and communication protocol. These 3 parts area unit is indispensable as every of that area units is crucial for building a wise home. mobilization the IoT network with the right hardware ensures prospering IoT epitome development. it'll additionally facilitate in managing technological changes.

It is crucial to pick the correct communication protocol. A handy and tested protocol can facilitate avoiding performance bottlenecks and problems with device integration. at the side of the communication protocol, another crucial part of the IoT network is that the microcode.

What are the Applications of Home Automation?

IoT primarily based on home automation will revive the method individuals use technology. there's a substantial vary of prospects once we talk about applications of home automation.

  • Controlled electrical fixtures like lights and air conditioners
  • Simplified garden or field management
  • HVAC
  • Controlled good home appliances
  • Enhanced safety and security reception
  • Water and air internal control and watching
  • Voice primarily based home assistant supporting linguistic communication
  • Smart locks and switches

We discus each of them briefly in our next articles, you need to engaged with our website for more information about IoT.

These are little, however not all the potential applications of home automation victimization IoT. As technology advances, there'll be a lot of else on the list.

Benefits of Home Automation IoT

Home security: With IoT home automation you're less disquieted regarding home security. you'll management the protection of your home along with your phone. If something goes wrong, you will receive notifications on your phone and you will in all probability operate your lights or locks through your phone. Energy potency and savings: you'll increase the energy potency by dominant your electrical fixtures through IoT. If you're unsure whether or not your kid has left lights on before departure, you'll check and manage it through your phone.

Wearable Health Monitors

Wearable health monitors area unit each fascinating and helpful. They embody good garments, good wristwear, and medical wearables that offer the United States of America high-quality health services. they're designed to trace activities like rate, step count, heart rate, etc. This knowledge is recorded and may be sent to the doctors for elaborated fitness analysis. These IoT-based mostly good wearable devices area unit influencing our lifestyles tons. with the exception of playacting these basic operations, they'll conjointly raise alarm, they have the capacity to send alert just in case of a medical pinch like bronchial asthma, seizures, etc.

Smart Refrigerator:

Have you ever fully-fledged a scenario after you have some friend's reception and you opened the electric refrigerator for a few cold drinks and there have been no cold drinks within the refrigerator! therein scenario you want to have wanted that, somebody would have educated you regarding the cold drinks and you had bought them before. however don’t worry, currently, this can be attainable with IoT, a good refrigerators area unit there, that does not solely inform you regarding the consumed things or empty bottles within the electric refrigerator however conjointly organize them online before they run out. These refrigerators will do far more than this though the assembly has not started at a huge scale nevertheless.

Smart Cars

IoT is utilized to connect cars with one another so as to exchange data like location, speed, and dynamics. An approximation shows that by 2020, there'll be twenty-four billion connected cars within the world. we have a tendency to use IoT in our everyday life while not even realizing its presence. for instance, whereas finding the shortest route, whereas driving semi-automatic good cars, etc. IoT is additionally employed in vehicle repair and maintenance. It doesn't solely prompt the client concerning the regular pairing date however conjointly assists the buyer in repair and maintenance by providing correct steering. On the premise of options provided, the communication technique of connected vehicle technology is assessed into 2 broad categories:

Vehicle-to-infrastructure (V2I)

It permits the good automobile to run a diagnostic check and supply an in-depth analysis report back to the user. it's conjointly accustomed to conclude the shortest route and to find the empty parking spot.

Vehicle-to-vehicle (V2V)

V2V communication of good cars makes use of high-speed information transfer and high bandwidth. It lets the automobile perform hefty tasks like avoiding collisions, clipping supernumerary traffic, etc.

Agriculture and farming

Due to temperature change and water crisis, farmers bear a lot of troubles like crop flattening, wearing away, drought, etc. These issues are often simply suppressed by mistreatment IoT based mostly farming systems. for instance, the IoT-based mostly irrigation system makes use of a variety of sensors to observe the wetness content of the soil. If the wetness level drops below an explicit vary, it mechanically activates the irrigation pump. apart from this, IoT conjointly helps farmers to look at soil health. Before about to farm a brand new batch of crops, a farmer has to recover the soil nutrients. The IoT enriched software system permits the user or the farmer to pick out the simplest nutrient restoring crops. It conjointly helps in sensing the necessity of fertilizer and diverse different farming desires.

IoT permits preciseness agriculture and good farming.

Wireless chase technology

The Internet of Things (IoT) starts with property, however since IoT could be a wide various, and many-sided realm, you actually cannot realize a one-size-fits-all communication answer. continued our discussion on mesh and star topologies, during this article we’ll practice the six commonest varieties of IoT wireless technologies.

Local power wide space network

LAPWAN area unit the new development in IoT. By providing long-range communication on little, cheap batteries that last for years, this family of technologies is purposeful to support large-scale IoT networks sprawling over immense industrial and business campuses.

LPWANs will virtually connect every type of IoT sensors

Cellular (3G/4G/5G)

Well-established within the client mobile market, cellular networks supply reliable broadband communication supporting varied voice calls and video streaming applications. On the drawback, they impose terribly high operational prices and power needs.

Zigbee and alternative Mesh Protocols

Zigbee could be a short-range, low-power, wireless commonplace (IEEE 802.15.4), normally deployed in topology to increase coverage by relaying detector information over multiple detector nodes.

Bluetooth and BLE

Defined within the class of Wireless Personal space Networks, Bluetooth could be a short-range communication technology well-positioned within the client marketplace. Bluetooth Classic was originally supposed for point-to-point or point-to-multipoint (up to seven slave nodes) information exchange among client devices. Optimized for power consumption, Bluetooth Low-Energy was later introduced to deal with small-scale client IoT applications.

Wi-Fi

There is just about no have to be compelled to make a case for Wi-Fi, given its crucial role in providing high-throughput information transfer for each enterprise and residential environment. However, within the IoT house, its major limitations in coverage, quantifiability, and power consumption create the technology abundant less prevailing.

Imposing high energy needs, Wi-Fi is usually not a possible answer for giant networks of battery-operated IoT sensors, particularly in industrial IoT and good building eventualities. Instead, it a lot pertains to connecting devices that will be handily connected to an influence outlet like good home gadgets and appliances, digital signages, or security cameras.

RFID

Radio Frequency Identification (RFID) uses radio waves to transmit little amounts of information from AN RFID tag to a reader within an awfully short distance. Till now, technology has expedited a significant revolution in retail and supply.

Searching Malls

IoT finds its major application in searching malls. In most shops, a barcode scanner is employed to scan the barcode gift on each product. once scanning, it extracts the required info and sends the information to the host pc. the pc is additionally connected to an asking machine that hands over the bill to the client once the correct process. of these devices area unit connected alongside the assistance of the net of Things

IoT Sensors

Manual or digital sensors are connected to circuit boards, which can be programmed to live a variety of variables. Sensors will collect info like carbon monoxide gas levels (from vehicle emissions), temperature, humidity, pressure, vibration, and motion.

IoT sensors don’t solely gather info from completely different physical environments — they will additionally send information to connected devices. this permits enterprises to use them for prophetic maintenance, potency sweetening, and value reduction.

Smart Utility Grids

Smart IoT grids provide the time period watching of knowledge relating to the provision and demand of utilities like electricity and water. employing a good grid, utility corporations will interconnect all of their assets, as well as meters and substations. they'll use IoT applications to spot load distribution, improve responsibility, and help in fault detection and repairs. this can be an awfully useful

Smart IoT grids provide the time period watching of knowledge relating to the provision and demand of utilities like electricity and water. employing a good grid, utility corporations will interconnect all of their assets, as well as meters and substations. they'll use IoT applications to spot load distribution, improve responsibility, and help in fault detection and repairs. this can be an awfully useful example of IoT.

That’s All today. I hope it might be helpful for you. If you have any query then mention them in the comment session. We make an effort to respond to your problem.

Simple Arduino Calculator

Hello geeks, I hope you all are doing well and looking forward to making something new yet interesting. So, today we have come up with our new project which is a calculator using Arduino.

We all use calculators in our daily life, whether you are working in an office or counting money at the bank, you are buying your daily grocery or doing shopping online, you will find calculators in different forms everywhere. In fact, the computer was initially considered a giant calculator. So if it is that common, why do we not make our own calculator?

Before going into the details of the project, it is good to know some history of that, let’s know some facts about the calculator. So the first known device for calculation is Abacus. And the first digital calculator was made by Texas Instruments in 1967 before that all calculators were mostly mechanical and they did not need any electronic circuits. The first all-transistor calculator was made by IBM and it is claimed that the calculator performed all the four basic operations such as addition, subtraction, multiplication, and division.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Keypad 4x4AmazonBuy Now
2LCD 16x2AmazonBuy Now
3Arduino Mega 2560AmazonBuy Now

Software to Install :

In this, we will be going to use the Proteus simulation tool and we will make our whole project using this software only. But no need to worry while using the actual components because if our project works perfectly with simulation, it will definitely work with actual hardware implementation. And the best part of the simulation is, here we will not damage any components by making any inappropriate connections.

If you don’t have an idea about Proteus, Proteus is a software for the simulation of electronic circuits and here we can use different types of microcontrollers and run our applications on them.

So for this project, we need to install this software. This software has a big database for all electronics components but still, it lacks some, therefore we have to install some libraries for modules which we are going to use in this project.

Project overview :

In this project, we will take input from the user using a keypad and perform the operation using Arduino UNO and display the result on an LCD display.

  • Arduino UNO - It is used for performing calculation-related operations, other user-related operations like interfacing with keypad module and LCD module.
  • 16x4 LCD module- It is used to display user-related messages such as input digits and selected arithmetical operations and calculated results.
  • 4x4 Keypad- It is used for user input. From this module, the user can enter the numerical values and arithmetic operations.

Our project will work the same as a normal digital calculator such that the user will enter two numerical values and select arithmetic operations which she/he wants to perform on the given values. Once the user clicks on the equal button, thereafter Arduino UNO will calculate the output and display the result on the LCD module.

Components required :

  1. Arduino UNO
  2. 16x2 LCD module
  3. 4x4 Keypad module

Components details:

  1. Arduino UNO

  • Arduino UNO is an open-source development board that we have used in this project.
  • It works on the ATMega328P microcontroller developed by Atmel.
  • It has an 8-bit RISC based processing core and up to 32 KB of flash memory
  • It has 14 digital input/output pins from D0 - D13 with a resolution of 8 bits, these pins can be used for taking any digital input or can be used as output pins for controlling peripherals.
  • In the 14 digital pins, there are 6 PWM pins.
  • It is suggested that you do not use the D0 and D1 pins of Arduino UNO for digital read or write purposes because they have an extra functionality of UART communication.
  • Arduino UNO has 6 analog input/output pins from A0-A5, which can be used to read analog values.
  • Analog pins have 10 bits of ADC (Analog to Digital convertor) resolution ranging values from 0 - 1023.
  • Arduino UNO has one hardware UART peripheral (D0, D1), one I2C peripheral, and one SPI peripheral.
  • We can use the power supply from 7 to 12 volts to power the Arduino UNO, but it is suggested to use a voltage supply of less than or equal to 9 volts but not below 5 volts.
  • We will use the Arduino IDE for writing and uploading the code on Arduino UNO. It is an open-source software developed by Arduino.
Note-: Whenever uploading the code on the Arduino UNO, disconnect any wire which is connected to Rx(D0) and Tx(D1) pins, otherwise it will give an error while uploading the code.
  1. LCD Module

  • LCD stands for Liquid Crystal Display, and this display is made using liquid crystal technology.
  • For more knowledge of how LCD works, prefer this link Working of LCD display.
  • In this project, we have a 16x2 LCD display which means we can display a max of 32 ASCII characters on this at a time.
  • The LCD module has 16 pins but we will not use all the pins in this project.
  • The LCD module can be used in two different modes, the first is 4-bit mode and the second is 8-bit mode.
  • We will use the 4-bit mode in this project, therefore, we have to connect only 4 data pins of the LCD module.
  • The major difference between 8-bit mode and 4-bit mode is, an ASCII character is 8 bit long so when we use 8-bit mode, LCD will process the data in single instruction but in 4- bit mode, microcontroller will send 2 chunks of 4 bits and the LCD will process that in two instructions.
  • To read more about the difference between 8-bit mode and 4-bit mode refer to this link Different modes of the LCD module
  • There are two registers in the LCD module: The Data register and the Command register.
  • When the RS(Register Select) pin is set to logic high, the data register mode is selected, and when it is set to logic low, the command register mode is selected.
  • The RS pin will be set to logic high to display the data on the LCD.
  • The operating power supply will be 5 volts for the LCD module.
  1. 4x4 Keypad

  • It is a membrane-based push keypad.
  • We have used a 4x4 keyboard which means it has 4 rows and 4 columns.
  • It has 0-9 numbers and basic arithmetic operations like addition, subtraction, multiplication, and division.
  • It has four pins for each row and 4 pins for each column.
  • The switch between a column and a row trace is closed, when a button is pressed, which completes the circuit and allows current to pass between a column pin and a row pin.

Circuit diagram and working:

Now, let’s start designing our circuit diagram for the calculator.

  • Make sure we have the correct and updated version of the Proteus software.
  • And make sure we have all the required libraries for the modules which we will be using in this project.
  • Now click on the new project (Ctrl+N) to start a new project of the Arduino calculator.
  • Import all the required components in the workspace.

Now we have all the required components in the workplace as follows.

Let's start connecting them.

  • First, we will connect the LCD module with the Arduino UNO module.
  • As we are using the LCD module in the 4-bit mode, therefore, we will have 4 pins for data, 1 pin for enable pin, and 1 pin for register status pin.
  • For data pins, connect the D4, D5, D6, and D7 pins of the LCD module to the D2, D3, D4, and D5 pins of Arduino UNO respectively. And connect the RS pin with D0 and Enable with D1 pin.
  • To use the LCD module in write mode, the R/W pin must be connected to the ground.
  • Now connect the keypad with the Arduino UNO board. As it is a 4x4 keypad, it will use 8 pins of the Arduino UNO board.
  • For row lines, we will use D13, D12, D11, and D10 pins and for column lines, we will use D9, D8, D7, D6 pins respectively.

That is all for connection. Make sure all the connections are correct, especially for keypad’s row and column connections otherwise we will get the wrong values from the keypad input.

And while working on the actual components, power the backlight of the LCD module and set the appropriate contrast, else nothing will be visible even if that has been displayed.

Arduino code for calculator:

Downloading and including libraries

  • Before going to write application code, we need libraries for the 16x2 LCD module and 4x4 keypad module.
  • We can download the library for the LCD module using this link LCD module library.
  • And use this link Keypad module library for keypad module.
  • Most of the Arduino related libraries are available on the Arduino official website.
  • We can add libraries in the Arduino using zip file or the manage libraries option.
  • If you have downloaded the libraries from the link then we have to click the option of “Add Zip Library” otherwise click on the manage libraries option and search for the required library.
  • After adding all the required libraries, include them in our application code.

Code declaration

  • We will declare the pins in the code as per we have connected them in the circuit diagram.
  • So first create the object for the LCD module and enter the pins we have used for LCD module connections.
  • While entering the pins in the LCD module object parameters, maintain the sequence as follows:

In the above-mentioned image, the first argument for RS pin, second for Enable pin, and rest four for data pins.

  • Now declare the variables for the Keypad module. We will use a 2D char array for storing keypad values, 2 arrays for storing pins used for rows and columns. And declare a ‘mykeypad’ name object for keypad class.
  • After that, declare some general variables which we will use to store the values like user input, output of calculation and operation.
  • After declaring and initialising all the variables and objects, we will start writing in the “void setup()” function.

Void setup function

  • This is one of the most important functions of Arduino programming.
  • As per the structure of Arduino programming, we can not remove this function from our code.
  • It will execute only once when the controller starts the execution.
  • Here, we will declare the modes of pins which we are going to use and setup functions related to the LCD module.
  • Display the welcome message on boot up of our calculator.
  • Here, we will begin the LCD module and set the cursor at 0,0 position and print the welcome message “The Engineering Projects Presents Arduino Calculator”.
  • As this message is written in the setup function, it will run every time once when the controller reboots and after 5 second delay, the LCD display will be cleared.

Void loop function

  • This is the second most important function of Arduino coding.
  • As per the structure of Arduino code, it must be in the code otherwise it will raise errors.
  • We will write our main application code here which we want to run in a continuous loop.
  • First, we will get the pressed key from the user, using the “myKeypad.getKey()” function and store that value in the variable named ‘key’.
  • And if the ‘key’ variable is one of the numbers, we will store that in the first number variable “num1”. And display that on the LCD display.
  • Now there can be two conditions, first if the user wants to perform the operation on a single digit number, in that case enter the operation which the user wants to perform. Then ‘key’ will be equal to ‘+’, ‘-’, ‘/’, ‘*’.

And required operation will be stored in the ‘op’ variable and a flag will be set for taking the second number.

  • Now the loop runs and control reaches to where ‘key’ is equal to number but this time it will go in the else condition of ‘presentValue’ variable because this variable is set ‘true’ from the operation condition.
  • And in this condition, the value will be stored in the ’num2’ variable. And here we will set the flag ‘final’.
  • Now the user will click the equal button to get the result. And the control reaches that condition and performs the operation on the values entered by the user and the same is stored in the ‘op’ variable.
  • Hence, the answer will be displayed on the LCD display.
  • After that, to clear the display, click the ‘C’ button. It will clear the LCD display and reset all the variables to their initial value.
  • Above mentioned condition is the first condition but in the second condition, when the user will enter more than one digits, then we shift the LCD cursor as per the length of the number entered.
  • To handle that situation, we will get the length of the entered digits and shift the LCD display cursor accordingly.

That is all the code, we need to run an Arduino Calculator.

Results/Working

Now, we have completed the coding and circuit part, it is time to run the simulation in the Proteus.

  • The first step to start the simulation, to add the hex file of our application code in the Proteus simulation.
  • To add the hex file, click on the Arduino UNO module and a new window will pop up then click on the Program Files option. Afterwards, browse to the folder of application code.
  • Now it is ready to start the simulation, click on the ‘Play’ button.
  • When simulation starts, the LCD display will show the welcome message.
  • Let’s suppose, we want to add two numbers 7 and 5. So click the same on the keypad.
  • After entering the values, click on the “=” button, it will display the result.
  • This is the same way we can operate different calculations using this calculator.
  • After that, click on this button which will clear the LCD display.

I hope we have covered everything related to Arduino calculator i.e. Simulation, Code, Working etc. but still if you find anything confusing, ask in the comments.

Thanks for reading this project out. All the best for your projects!

Smart 4 Way Traffic Signal Control with Variable Delay

Hello guys! I hope you’re all in a good mood today because we are going to review the design of an interesting project today. We’ll be looking to design 4-way traffic lights in such a way that their delay is variable and is dependent upon the traffic density. This project is of intermediate difficulty level for people studying in undergrad engineering school with electronics, electrical and mechatronics as their major. It is also for the people learning Arduino and basic circuit design on their own or through some course. We have already designed a Simple 4-Way Traffic Light Control using Arduino and today we will make it smart by adding a variable delay.

Where To Buy?
No.ComponentsDistributorLink To Buy
1LEDsAmazonBuy Now
2ResistorAmazonBuy Now
3LCD 16x2AmazonBuy Now
4Arduino Mega 2560AmazonBuy Now

Variable 4 Way Traffic Light:

As you all already know the importance of traffic lights and their usage has solved a number of traffic problems, traffic is becoming denser on each road in the whole world by the hour. This leads us to consider traffic density at such roads as well. A number of different solutions have been developed in recent times to help with this problem such as roundabouts. This is done so to ensure the safety of vehicles on road and of people walking on pedestrian walks. With the world going towards automation and autonomous systems, this is the right time to switch traffic lights to an autonomous traffic light system too and make the system intelligent.

Software to Install:

We will be going through how to make an autonomous traffic system by using Arduino as a microcontroller. However, we’re not making an actual system rather we will be making a simulation of the said traffic system on a circuit simulating software Proteus. So make sure you already have the latest version of Proteus installed on your PCs and laptops. If not, you should first install the Proteus Software by following the embedded link. Proteus is open database software, meaning people can easily make their own circuit simulating libraries for the software and can easily integrate those libraries. This helps in making the software versatile and easy to use. You can easily add your own components or download libraries of components and place them within the software.

To start working with this project, you need to install and include the following libraries on your Proteus software:

  • Arduino Library for Proteus: This library includes all the microcontroller-based programming boards made by the company Arduino.cc. This allows you to program on the Arduino software and after that, you can see the implementation of this code in Proteus simulation.
  • LCD Library for Proteus: LCDs are displays that can be used to display text or values being used in a certain code. These LCDs come in two sizes, namely a 16x2 and 24x4. LCDs are controlled by the Arduino board.
  • Ultrasonic Sensor Library for Proteus: Since we are using an ultrasonic sensor as well in this project for which Proteus does not have a built-in component, you would need to download its library as well.

Project Overview:

This is a smart 4-way traffic light system. The pedestrian lights work such that whenever a certain traffic light is green its opposite pedestrian lights turn on. An addition of ultrasonic sensors have been made in the traffic light sequence. One ultrasonic sensor is placed at each traffic light. Each ultrasonic sensor controls the time of their respective green traffic light. When the ultrasonic sensor output is high, the traffic light opens for one second, when the ultrasonic sensor output is intermediate the traffic light opens for two seconds and when the ultrasonic sensor output is low the traffic lights open for 3 seconds.

The main components and their use in this project is given below:

  • Arduino Mega: We have used Arduino mega in this project and recommend using an Arduino mega as well. This is because there are about 40 digital pins required to perform communication between the microcontroller and only an Arduino Mega fulfills that requirement.
  • Traffic Light Module: Proteus provides an in-built module for simulating traffic lights and we will use this instead of using RGB lights to create a better effect.
  • Ultrasonic Module: This module is not built-in, but information to integrate this module with Proteus has been given above. This module has a test pin in order to simulate it and works just like real life.
  • LCD: Liquid crystal display will be used to show the time in which the traffic light remains on.

Components Needed:

  • Arduino Mega
  • Traffic Lights
  • Green and Red LEDs
  • Variable resistors
  • LCD
  • Ultrasonic Sensor

Component Details:

We will go through the details of some of the important components being used in this project.

Arduino Mega:

Arduino is an open-source programmable board that serves as a microcontroller and processes information based upon inputs and gives information to actuators in terms of output. Arduino Mega is based upon the chip ATmegaGA2560 and has 53 digital I/O pins.

Figure 1: Arduino Mega

LCD:

Liquid Crystal Displays used in electronics are of two basic sizes, 16x2 and 24x2. These represent the number of columns and rows of the LCD. Each pixel can store one character in it. It is also known as a character LCD. It comes equipped with a backlight. The intensity or glow of the backlight can be controlled by attaching a potentiometer at specified pins.

Figure 2: LCD display

Ultrasonic Sensor:

An ultrasonic sensor uses SONAR technology to identify objects. It is basically used to find the distance of objects from the sensor. The ultrasonic sensor works by sending out ultrasonic waves and when these waves or parts of waves hit an object, they are reflected backward and the time from their propagation to their return is then noted. This time is then converted into the distance because we already know the speed by which those waves are traveling.

Figure 3: Ultrasonic Sensor

Proteus Simulation of Variable Traffic Lights:

In order to simulate this project on Proteus software, we will first make the circuit diagram on Proteus. After that, we will write our code on Arduino IDE software and integrate it with the circuit made in Proteus.

Open Proteus and open a new project. Import the following components in your Proteus worksheet.

Figure 4: List of components

Place the component in your worksheet as illustrated in the figure below:

Figure 5: Placement of components

After placing the components, make the connections as follows:

  • Connect 0,1 and 2 digital pins of Arduino to red, yellow and green of traffic light 1 respectively.
  • Connect 3,4 and 5 digital pins of Arduino to red, yellow and green of traffic light 2 respectively.
  • Connect 6,7 and 8 digital pins of Arduino to red, yellow and green of traffic light 3 respectively.
  • Connect 9,10 and 11 digital pins of Arduino to red, yellow and green of traffic light 4 respectively.
  • Connect 12and 13 digital pins of Arduino to red and green LEDs of pedestrian light 1 respectively.
  • Connect 14 and 15 digital pins of Arduino to red and green LEDs of pedestrian light 2 respectively.
  • Connect 16 and 17 digital pins of Arduino to red and green LEDs of pedestrian light 3 respectively.
  • Connect 18 and 19 digital pins of Arduino to red and green LEDs of pedestrian light 4 respectively.
  • Ground the negative terminals of all LEDs.
  • Connect one end of a variable resistor to the Vss pin of LCD.
  • Connect the other end of the variable resistor to the input.
  • Connect the input pin of the variable resistor with the Vee pin of LCD.
  • Ground the RW pin of LCD.
  • Connect RS pin of LCD to 22 digital pin of Arduino.
  • Connect E pin of LCD to 23 digital pin of Arduino.
  • Connect D4, D5, D6 and D7 pin of LCD to 24, 25, 26 and 27 digital pins of LCD respectively.
  • Connect the test pin of ultrasonic sensors to their respective potentiometers.
  • Connect the trigger pin and echo pin of the ultrasonic sensor of traffic light 1 to 28 and 29 digital pins of Arduino respectively.
  • Connect the trigger pin and echo pin of the ultrasonic sensor of traffic light 2 to 30 and 31 digital pins of Arduino respectively.
  • Connect the trigger pin and echo pin of the ultrasonic sensor of traffic light 3 to 32 and 33 digital pins of Arduino respectively.
  • Connect the trigger pin and echo pin of the ultrasonic sensor of traffic light 4 to 34 and 35 digital pins of Arduino respectively.

With this, your circuit connections are complete and we will now move on to the firmware setup of this circuit.

Arduino Code:

We have divided the Arduino code in 3 segments:

  • Declaration Code
  • Void setup
  • Void loop

We will look at these sections separately now.

Declaration Code:

The first step in the code is the declaration of variables that we will utilize in our program. At first is the declaration of ultrasonic sensor pins and setting them up with their respective pins of Arduino board. The syntax of this code is as follows.

Figure 6: Ultrasonic declaration code

Now we will include the library of LCD into our Arduino program, you can download this library from within the software. After that we will declare the LCD by defining the LCD pins. The syntax for which is as follows:

Figure 7: LCD declaration

In the next step, we will declare traffic light variables and define their Arduino pins.

Figure 8: Traffic light variable declaration

Now, we will declare the variables of pedestrian LEDs and then allot them their Arduino pins being used in the circuit.

Figure 9: Declaration of pedestrian LEDs

Now, there are two variables being used for each ultrasonic sensor for the calculation of their distance and time duration. We will declare those variables now.

Figure 10: Declaration of variables being used for calculations

Void Setup:

Void setup is the part of Arduino program that only runs once, in this section the program that only needs to run once is put, such as declaring pins as output pins or input pins.

Only the echo pins of ultrasonic sensor are input pins while all other pins are going to be output pins for this project.

We will first set up ultrasonic pins as follows:

Figure 11: Defining Ultrasonic pins as I/O for the Arduino Board

Now we will declare traffic light pins as output pins. The syntax for this is given as follows:

Figure 12: Setup of Traffic light Pins as Output

Now we will setup our pedestrian LEDs.

Figure 13: Setup of Pedestrian LEDs as Output

Now we will initialize our LCD, this basically tells the microcontroller to start the LCD and give power to it. The syntax is given below.

Figure 14: Initializing LCD

Void Loop:

This part of Arduino Program runs in a loop and consists of the main code of the program in which all the calculations are being done.

In the first part of the program, we will set the trigger pin of the first ultrasonic sensor to low and high. This would generate a pulse and send out a wave. After that we will read a pulse input from the echo pin. This will give us the duration in which the wave was propagated and returned. After that we will calculate the distance from the duration of the wave.

Figure 15: Syntax of 1st Ultrasonic Sensor

This distance calculation is for our first traffic light. Now we will use the if loop to check our distance value.

Figure 16: If Loop for Signal 1

If the value falls between our set limit for the loop, the signal will turn green for three seconds. This will also be displayed on the LCD.

Figure 17: Arduino Code

After that in our if loop, the yellow lights 1 and 2 will turn on to indicate transition.

Figure 18: Arduino Code

Now we will use the if loop to check our distance value.

If the value falls between our set limit for the loop of intermediate traffic, the signal will turn green for two seconds. This will also be displayed on the LCD.

Figure 19: Arduino Code

After that in our if loop, the yellow lights 1 and 2 will turn on to indicate transition.

Figure 20: Arduino Code

Now we will use the if loop to check our distance value again.

If the value falls between our set limit for the loop of low traffic, the signal will turn green for one second. This will also be displayed on the LCD.

Figure 21: Arduino Code

After that in our if loop, the yellow lights 1 and 2 will turn on to indicate transition.

Figure 22: Arduino Code

Now we will set the trigger pin of the second ultrasonic sensor to low and high. This would generate a pulse and send out a wave. After that we will read a pulse input from the echo pin. This will give us the duration in which the wave was propagated and returned. After that we will calculate the distance from the duration of the wave.

Figure 23: Arduino Code

This distance calculation is for our Second traffic light. Now we will use the if loop to check our distance value.

Figure 24: Arduino Code

If the value falls between our set limit for the loop, the signal will turn green for three seconds. This will also be displayed on the LCD.

Figure 25: Arduino Code

After that in our if loop, the yellow lights 2 and 3 will turn on to indicate transition.

Figure 26: Arduino Code

Now we will use the if loop to check our distance value.

If the value falls between our set limit for the loop of intermediate traffic, the signal will turn green for two seconds. This will also be displayed on the LCD.

Figure 27: Arduino Code

After that in our if loop, the yellow lights 2 and 3 will turn on to indicate transition.

Figure 28: Arduino Code

Now we will use the if loop to check our distance value again.

If the value falls between our set limit for the loop of low traffic, the signal will turn green for one second. This will also be displayed on the LCD.

Figure 29: Arduino Code

After that in our if loop, the yellow lights 2 and 3 will turn on to indicate transition.

Figure 30: Arduino Code

Now we will set the trigger pin of the third ultrasonic sensor to low and high. This would generate a pulse and send out a wave. After that, we will read a pulse input from the echo pin. This will give us the duration in which the wave was propagated and returned. After that we will calculate the distance from the duration of the wave.

Figure 31: Arduino Code

This distance calculation is for our third traffic light. Now we will use the if loop to check our distance value.

Figure 32: Arduino Code

If the value falls between our set limit for the loop, the signal will turn green for three seconds. This will also be displayed on the LCD.

Figure 33: Arduino Code

After that in our if loop, the yellow lights 3 and 4 will turn on to indicate transition.

Figure 34: Arduino Code

Now we will use the if loop to check our distance value.

If the value falls between our set limit for the loop of intermediate traffic, the signal will turn green for two seconds. This will also be displayed on the LCD.

Figure 35: Arduino Code

After that in our if loop, the yellow lights 3 and 4 will turn on to indicate transition.

Figure 36: Arduino Code

Now we will use the if loop to check our distance value again.

If the value falls between our set limit for the loop of low traffic, the signal will turn green for one second. This will also be displayed on the LCD.

Figure 37: Arduino Code

After that in our if loop, the yellow lights 3 and 4 will turn on to indicate transition.

Figure 38: Arduino Code

Now we will set the trigger pin of the fourth ultrasonic sensor to low and high. This would generate a pulse and send out a wave. After that, we will read a pulse input from the echo pin. This will give us the duration in which the wave was propagated and returned. After that, we will calculate the distance from the duration of the wave.

Figure 39: Arduino Code

This distance calculation is for our fourth traffic light. Now we will use the if loop to check our distance value.

Figure 40: Arduino Code

If the value falls between our set limit for the loop, the signal will turn green for three seconds. This will also be displayed on the LCD.

Figure 41: Arduino Code

After that in our if loop, the yellow lights 4 and 1 will turn on to indicate transition.

Figure 42: Arduino Code

Now we will use the if loop to check our distance value.

If the value falls between our set limit for the loop of intermediate traffic, the signal will turn green for two seconds. This will also be displayed on the LCD.

Figure 43: Arduino Code

After that in our if loop, the yellow lights 4 and 1 will turn on to indicate transition.

Figure 44: Arduino Code

Now we will use the if loop to check our distance value again.

If the value falls between our set limit for the loop of low traffic, the signal will turn green for one second. This will also be displayed on the LCD.

Figure 45: Arduino Code

After that in our if loop, the yellow lights 4 and 1 will turn on to indicate transition.

Figure 46: Arduino Code

Results/Working:

At first, after writing the code, generate its hex file and put that hex file on the Arduino board on your Proteus software. After that, run the simulation. The results of the simulation are shown below thoroughly.

At first, when sensor one gives the output within 500 cm, the traffic light will turn on for one second only.

Figure 47: Simulation Results

However, if the sensor one value is between 500 and 900 cm, the traffic light 1 will be green for 2 seconds with the LCD displaying the remaining time.

Figure 48: Simulation Results

If the sensor values are above 900 cm, then the lights will be green for 3 seconds.

Figure 49: Simulation Results

When the sensor two gives the output within 500 cm, traffic light 2 will turn on for one second only.

Figure 50: Simulation Results

However, if the sensor two value is between 500 and 900 cm, the traffic light 2 will be green for 2 seconds with the LCD displaying the remaining time.

Figure 51: Simulation Results

If the sensor values are above 900 cm, then the lights will be green for 3 seconds.

Figure 52: Simulation Results

When sensor three gives the output within 500 cm, traffic light 3 will turn on for one second only.

Figure 53: Simulation Results

However, if the sensor three value is between 500 and 900 cm, the traffic light 3 will be green for 2 seconds with the LCD displaying the remaining time.

Figure 54: Simulation Results

If the sensor values are above 900 cm, then the lights will be green for 3 seconds.

Figure 55: Simulation Results

When sensor four gives the output within 500 cm, traffic light 4 will turn on for one second only.

Figure 56: Simulation Results

However, if the sensor four value is between 500 and 900 cm, the traffic light 4 will be green for 2 seconds with the LCD displaying the remaining time.

Figure 57: Simulation Results

If the sensor values are above 900 cm, then the lights will be green for 3 seconds.

Figure 58: Simulation Results

Phew! I know that this was an extremely long project, but that is a part of an engineer’s life. Multiple receptions and running recurring patterns smoothly requires skill and patience only an engineer can possess. I hope you guys made it through. Kudos to your nerves of steel. Thanks for reading.

How Technology has evolved the Online Casino Industry?

Hello everyone, welcome to today article which we are going to have a look at how technology has evolved the online casino industry. Some of you might be having knowhow on what casino industry is and some might be having partial or no knowledge at all. So, we are going to start with simple things as we advance our topic of discussion further. You should also have a look at the Technology behind Online Casinos.

Definition of the global casino industry

The global casino industry is an industry that is made of facilities that involves predictions of outcomes of the final result that will be obtained after an invent has passed. The predictions are made before the event has started. It is made up of the gambling activities such as the gaming machines and the table wagering boards. it is also a common thing for some of these facilities to provide dinning, lodging and the beverage services to their customers. This industry has evolved to an online modernized activity. The online facility has become the most used one especially in this era of corona virus where lockdowns have really affected the physical appearances in the normal global casinos. Online facilities have offered players and bookies a very momentous offer where they can play the game at any place of their comfort.

The first online casino which was referred to as Inter-casino was launched in 1996 and at this time nobody had an idea of what awaited the casino industry. Bookies never thought that one day the industry would evolve to what it is today. Currently, the online casino industry is worthy over 45 billion US dollars something that is still forcing more investors to put their capital in this new area of business and entertainment. You can imagine after the launch of the first online casino industry, in the same month, there was a raise in the number to 15 and a year later, more than 150 online casinos had been launched. Actually, this was the area where investors had started seeing some great potential.

Since the industry crossed the one billion net worth mark in 1998, there have been new inventions and innovations that have led to drastic change and growth in the online casino industry. More technological advances have been made which has led to more players feeling comfortable in joining the industry. This article will focus on how technology has impacted on the online casino industry.

Multiple payment options

Multiple payment option is one of the areas that have greatly improved the online casino industry. Players can now deposit and withdraw money from sites within seconds. This payment systems introduction has lowered the cost incurred by clients and also fastened the process. Several cashless payment methods have also hit the market. These payment methods such as PayPal, Skrill, mobile money and Wire Transfer, etc have impacted greatly on how customers receive their winnings from the booking sites. You can check on OBLG to take note of all the casinos that offers their payment through PayPal which is the most commonly used universal payment methods by the majority of the bookies especially in Europe and America. Moreover, because of this online payment system, casinos also offer no deposit free spins offers, in order to attract customers.

Although landless betting has a limited amount that a client can play with, the online casino has offered a lot of options that can be used in the process and this has led to the expansion of the casino industry. One greatest thing that happens in technology is that you can adapt to new trend very quickly. Currently, cryptocurrency is taking over as the means of payment because with it you are guaranteed of great financial security and anonymity. Most popular cryptocurrency is the Bitcoin and it has offered very strong facility where even governments are unable to track owners of the casinos or even the players. With this cryptocurrency being used as a mode of payment, the casino industry has grown internationally simply because players from restricted countries can play in anonymity and get their winnings in form of cryptocurrency.

There has also been a shift in focus where most online casinos are introducing casinos that operate in the blockchain technology whereby there is an outcome of better features and makes the future of the casino industry look great.

Choice and variety

With new trend in the area of technology, there have been development of the multi-dimensional approach across the casino industry. There has been great input in the development of the games that offers great and clear features to the players and the viewers.

With online gambling, bookers can feel a redefined industry. When you look at the betting sites, you will realize that they have been customized in a manner that it has a very powerful interface which offers the gamers a very welcoming experience while carrying out the gambling at the comfort of their wish. The introduction cool visuals and the tense atmosphere which tries to mimic the situations in real-life has made the online casino industry more and more beautiful. This actually evidence from the growth of the numbers on the gamblers who are who prefer doing their gambling online as compared to those who prefer doing it manually or in the traditional land-based gambling. For example, most online gambling industry have decided to introduce the eSports games in their online gambling platform and this shows the potential of that innovation has made in the gambling industry.

The variety of the games available in the online casino platform has also led to the increased number of gamers joining the gambling industry where some online casinos offer more than 2000 games that a gamer can choose from. The vast options of the games that are available ensure that gamers are never bored due to the availability of too many games options to choose. In some occasions, virtual reality has been involved in making this online gaming industry a reality. The use of this high technology glasses has made gamblers experience more entertainment as they feel inserted into the world of different reality. Users are able to have a real time interaction that is based on the traditional land-based casino interactions.

Customer support system and security

Despite the great growth in the online gaming industry, it comes home with some disadvantages especially on matters security since it is accompanied with a lot of attacks that are directed towards the gamers. This frequent security attacks are more as compared to what is experienced in the traditional land-based casino. Since the digital information is always very sensitive, it is the duty of the casino site to keep the information very safe lest it falls in the hands of the wrong person. The sensitive personal information that is required for online casino can be used for identity where the client can lose a lot of money through hacking. Online casinos have been forced to use new technology in securing their sites in order to protect their clients from insecurity that might occur.

Some online casinos have even gone a step higher whereby they use the artificial intelligent to improve the security of the site and ensure that they monitor every movement that is made on the sites. There has also been a way where users have to provide the 2FA authentication to ensure that only authorized members get access to the sites.

Customer support has also moved a notch higher with the advent of new advanced ways of solving customer issues in the online casino platforms. In the online casino platforms, you will come across emails, call centers and even live chats which have been introduced in the recent years to improv on customer care services. Some of these casinos have a way of offering 24/7 customer care services and this is done to prove to the customers that they are gambling in a very safe place. This proper customer care services have led to the expansion of the casino industry globally.

The mobile casino industry

The advent of the smartphone industry has also increased the growth in the online industry. Today, the largest population of the world have a smartphone in their pocket and this has led to the people participation more in the online casino games and gambling. Online casinos have taken advantage in the growth of the smartphone owners and have come up with sites that are mobile friendly giving their players a very fascinating environment to entertain themselves. The mobile casino games are very revolutionary as players can get access to the games at any time and any locations and this has made it very convenient to the gamers the mobile phones have introduced portability to this industry.

Better marketing

Some few years ago, the gamers used to visit the betting shops to play games. With the introduction of the online casino, it has become do possible for the games to rich people easily and in any location of this world. Some companies have moved the impact higher by organizing gaming competitions that involves millions of people which could not be achieved in the traditional hall because of the spacing and difficulty in managing the outcome. The online casino has actually introduced the new investment opportunity for the people. This online casino has actually introduced new technology trends in order to place itself in a position which can rival the competitors and also give the pundits an improved gaming experience. They have come up with very user -friendly interfaces that come in with several important features. Some of these sites use artificial intelligent to settle and update results and games too. All these activities are being done to ensure that the online casino site has more clients joining.

Artificial intelligent

Modern online casinos have gone into another level whereby the use of artificial intelligent have revolutionized the industry. Artificial intelligence such as the use of the chatbots have been used to help the gamblers in placement of the bets. The same artificial intelligence has been used by the sites to help customers in the processing of their payments from the bookies and also process withdrawal request for the clients. The bot is very important in this industry because they can offer unlimited customer support. The artificial intelligence has also found use in the online casino industry where the gamers have an interest in playing against the machines instead of playing against the other gamers. Also, the Sportbooks have been using various artificial intelligence mechanism to help the users of the various websites find the various icons and learn how to use the sites.

Mobile phone applications

The smartphone, tablets and the internet industry has made major technological impact in the area of the online casino industry. Statistics show that in 2012 there was a great improvement in the use of the online casino by 12% globally. This improvement was introduced due to the revolutionization of the smartphone and the internet industry. Now close to over one hundred and sixty million pundits visit online casinos on their phones using the mobile phones applications. The mobile gambling is said to be contributing at least 50% of the revenue that is generated from the gambling industry. The mobile applications have greatly impacted on the growth of the online casinos industry.

In conclusion, the online casino industry has grown to a greater extent through the introduction of so many trends in the areas of money transfer, online payment methods, the introduction of artificial intelligence, the great extent to which the mobile phone application industry has grown higher, the introduction of better marketing strategies, better customer support and security systems. With all these, the industry has grown to something else, something better and something magnificent attracting more bookies worldwide.

Simulating Advanced Logic Gates using Ladder Logic Programming

Hello friends! I hope you are all very well! I am so happy to meet you today to continue learning and practicing PLC ladder logic programming. In an earlier part, we already have gone through the very basic logic gates of “AND”. “OR”, and “NOT”. Today we are going to resume the simulation of logic gates. We have started and gone through simulating the basic logic gates which are “AND”, “OR”, and “NOT” as they are the most important basic logic gates by which we can form other logic gates. However, because the logic of large-scale projects is getting more and more complicating, a lot of time we have to use the other functions to do tasks faster. For example, we have shown in the logic gates article that, XOR can be used to compare two inputs and check if they are equal or not. On the other hand, someone may say, oh we can do XOR by using the basic three gates of “AND”, “OR”, and “NOT”. That’s correct. So why do we need to go learning other logic gates when we can implement them by using that three basic logic gates. Well! That is a very good question.

Working in ladder logic programs is getting further complicated especially for large-scale projects. So, it is very beneficial to know shortcuts for writing ladder logic simpler, more readable, and easier for others to develop. Using this variety of logic gates, enrich the logic and fluency of writing the logic in different situations. For example, using XOR logic is very common for comparing two inputs to decide if they are equal or different. Therefore, we found that it is crucial to go through all logic gates and do simulations for them all in this tutorial. for coherently we get the knowledge to use them fluently in ladder logic programming to solve different logical problems and scenarios. There are seven basic logic gates which are: “AND”, “OR”, “NOT”, “NAND”, “NOR”, “XOR”, and “XNOR”. We have gone through “AND”, “OR”, and “NOT” logic gates including simulation work. So let us go through the other four gates for learning and practicing all basic logic gates.

The "NAND" Logic Gate

The “NAND” logic gate is the invert of the “AND” gate like you invert the output of an “AND” logic gate as shown in Fig. 12. Table 5 lists all combinations of the inputs and the output of the “NAND” logic gate.

Fig. 12: NAND symbol

Table 5: the truth table of the “NAND” logic gate

Input A Input B Output
0 0 1
0 1 1
1 0 1
1 1 0
 

In addition, the timing diagram of a “NAND” logic gate is shown in fig. 13, it shows the output goes low when both of the inputs A and B are true which is the inverse of the “AND” logic gate. Also, Fig. 14 shows a ladder logic of a “NAND” logic.

Fig. 13: The timing diagram of the “NAND” logic gate

Fig. 14: Ladder logic sample of a “NAND” logic

NAND Logic in PLC simulator

The NAND logic gate can be considered as the invert of the “AND” logic gate. So as listed in table 1, the truth table of AND and NAND logic gates shows how the NAND gate is the reverse of the AND gate. Also, it shows the NAND gate should come out to your mind when you want the output always low except when both inputs A and B are high.

Table 1: the truth table of the AND versus NAND logic gate

The NAND gate can be implemented by connecting the negate of the output in series to the inputs A and B. Another way to implement NAND is by inverting both inputs and connecting them in parallel as shown in fig. 1. Rung 1 and rung 2 respectively.

Fig. 1: The NAND ladder logic in two ways

 

Let’s test our ladder logic in both methods. According to the truth table of NAND gate, we have four test cases. figure 2 shows the first test case when both inputs A and B are false. In this case, the output should be true as shown in fig. 1.

Fig. 2: NAND ladder logic when both inputs are false

figure 3 shows the second test case when inputs A goes true while B is false. In this case, the output should be true as shown in fig. 3.

Fig. 3: NAND ladder logic when input A is false and input B is true

Figure 4 shows the third test case when inputs B goes high while B is low. In this case, the output should be true as shown in fig. 4.

Fig. 4: NAND ladder logic when input A is true and input B is false

Figure 5 shows the last test case when both inputs A and B become high so the output goes false as shown in fig. 5.

Fig. 5: NAND ladder logic when both inputs are true

Thanks to performing the simulation of the NAND gate, we now can conclude that we should be looking for a NAND logic when we want to shut down an actuator i.e. motor whenever two inputs are in a true logical state simultaneously. For a practical example, when we have three pumps and we want to run them in the mode of two of three. There should be only two of the three pumps to run at any time. In that case scenario, the run condition of any motor can be a NAND of the status of the other two motors.

The “NOR” Logic Gate

The “NOR” logic gate receives two inputs and has one output. It is the same as the invert of the “OR” logic gate. Like you follow the output of an “OR” gate by a “NOT” logic gate. Fig. 15 shows the symbol of a “NOR” gate. In addition, the truth table is expressed in table 6. It shows the output becomes false only when one of the input A or input B or both goes high which is the reverse logic of the “OR” logic gate.

Fig. 15: The symbol of “NOR” gate

The “NOR” logic gate can be formed by connecting the “OR” logic gate to the inverter “NOT” logic gate. Or by inverting the inputs by using “NOT” logic gates and connecting them to the “AND” logic gate as shown in Fig. 16.

Fig. 16: structure of “NOR” logic gate

Table 6: the truth table of the “NOR” gate

Input A Input B Output
0 0 1
0 1 0
1 0 0
1 1 0
 

Figure 17 shows an example of a ladder program for implementing the “NOR” logic gate. It shows that the “NOR” gate can be implemented in ladder logic by connecting two contacts of type NC in series.

Fig. 17: A sample ladder for a “NOR” logic gate

On the other hand, the timing diagram of the “NOR” logic gate is depicted in Fig. 18. It shows the output is false as long as either input A or input B or both are true.

Fig. 18: The timing diagram of the “NOR” logic gate

NOR logic gate in PLC Simulator

This logic gate can be considered as the negate of OR as you can notice in the truth table as listed in table 2. You can now feel when we may need to use the NOR logic? Yes! Exactly you want it when you design for output which is all time off except when both inputs are false.

Table 2: the truth table of NOR versus OR

Input A Input B OR NOR
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
 

Figure 6 shows two ways to implement the NOR logic in ladder logic. To make that happen, we connect the invert of the two inputs in series to the output as shown in the top part of fig. 6. The other way is to connect the two inputs in parallel to form OR and then connect to negate the output as shown in the lower part of fig. 6.

Fig. 6: The ladder logic of NOR logic gate

Let’s practice simulation of the NOR gate, in fig. 7, the first test case is when both inputs are false, the output is true as shown in fig. 7.

Fig. 7: The Simulation of NOR ladder when both inputs are false

Figure 8 shows the second case when input A is true and input B is false, the output is false as shown in fig. 8.

Fig. 8: The Simulation of NOR ladder when input A is true and input B is false

Figure 9 shows the third test case when input B is true and input A is false, the output is false as shown in fig. 9.

Fig. 9: the Simulation of NOR ladder when input B is true and input A is false

Figure 10 shows the last test case of NOR ladder logic, it shows the output is false

Fig. 10: The Simulation of NOR ladder when both input A and B are true

One practical example of using the NOR logic is that, imagine friends we drive some machine with two motors. And it is required to have at least one of them or both are running all the time otherwise alarm should be energized. The NOR logic is the best to manage that alarm to get energized if and only if both motors are off.

The Exclusive OR "XOR" Logic Gate

Despite this logic gate having two inputs and one output like the “AND” and “OR” logic gates, this logic gate is a bit more complicated than the previous logic gates. Table 4 lists the truth table including all combinations of the inputs and the output. By noticing the truth table of the XOR logic gate, you can see the output becomes low when the two inputs are equal like both are high or both are low. But the output goes high when there is a difference in the state of the two inputs. Imagine my friend, how much this logic gate is very beneficial for comparing two signals.

Table 4: The truth table of XOR logic gate

Input A Input B Output
0 0 0
0 1 1
1 0 1
1 1 0
 

On the other hand, Figure 10 shows the symbol of the XOR logic gate and its schematic. See how the basic logic gates OR, AND, and NOT can be utilized to build the logic of XOR logic gate.

Fig. 10: The XOR logic gate symbol

Figure 11 shows a sample of a ladder logic program that implements XOR logic. In addition, it shows the timing diagram of the inputs and output, it shows the output goes high when there is a difference between the two inputs and becomes low when they are equal i.e. both are low or both are high.

Fig 11: Sample of the ladder logic for XOR logic and the timing diagram

XOR Logic Gate in PLC Simulator

The XOR is used to compare two signals if they are equal or different. Table 3 lists the truth table of the XOR. It shows that the output comes to true when inputs are different and becomes false when they are equal.

Table 3: The truth table of XOR logic

Figure 11 shows the construction of XOR ladder logic. It shows that it is composed of, two parallel branches and each branch is forming AND logic of the two inputs in the opposite logical state.

Fig. 11: The ladder logic of XOR

Figure 12, shows the simulation results of XOR when input A and B are false, the output is false.

Fig 12: Simulation of XOR ladder when both inputs are false

Figure 13, shows the simulation results of XOR when input A is true and input B is false, the output is true. Fig 13: The Simulation of XOR ladder when input A is false and input B is high

Figure 14, shows the simulation results of XOR when input B is true and input A is false, the output is true.

Fig 14: The Simulation of the XOR ladder when input B is true and input A is false.

Figure 15, shows the simulation results of XOR when input A is true and input B is true, the output is false.

Fig 15: The Simulation of XOR ladder when both inputs are true

In a conclusion, the XOR logic in simulation shows that the output is low whenever both inputs are equal and goes high when the inputs are different in the logical state. A very good practical example for utilizing the XOR logic is that imagine friends we have a motor that is energized by two different destinations, and it should be requested by only one at a time. So we can get the run signal from the XOR of the two input switches. So, the only case to run the motor is by requesting from one source.

The “XNOR” Logic Gate

This logic gate is the invert of the XOR gate. So it is equivalent to applying an inverter to the “XOR” logic gate. Table 7 lists the combination of its two inputs and its output. It shows clearly that, the output becomes true when inputs are equal i.e. both inputs are true or both are false.

Table 7: the truth table of the “XNOR” logic gate

Input A Input B Output
0 0 1
0 1 0
1 0 0
1 1 1

Fig. 20 shows the symbol of the “XNOR” logic gate, it shows clearly how it is the invert of the XOR logic gate. This logic gate is very useful to validate if two signals are equal or not.

Fig. 20: The symbol of the “XNOR” logic gate

On the other hand, Fig. 21 shows a sample ladder logic of an “XNOR” logic gate implementation. It shows that there are only two ways to have the output in the TRUE state which are by setting both inputs TRUE or set both FALSE.

Fig. 21: A sample ladder logic for “XNOR” logic

Fig. 22 depicts the timing diagram of the inputs and output of the “XNOR” logic gate and clearly shows the output goes high when both inputs have the same state.

Fig. 22: the timing diagram of the “XNOR” logic gate

XNOR Logic in PLC Simulator

The XNOR is the invert of the XOR and it is used to compare two input signals. Table 4 lists the cases of the truth table of XNOR logic. It shows the output goes high when both inputs are equal i.e. both are high or both of them are low.

Table 4: the truth table of XNOR logic

Figure 16 shows the construction of XNOR ladder logic. It shows that it is composed of, two parallel branches and each branch is forming AND logic of the two inputs in the same logical state.

Fig 16: XNOR ladder logic

Figure 17, shows the simulation results of XNOR when input A and B are equal i.e. both are false, the output is high.

Fig. 17: The Simulation of XNOR ladder when both inputs are false

Figure 18, shows the simulation results of XNOR when input A is true and input B is false i.e. they are different. So the output goes false.

Fig. 18: The Simulation of XNOR ladder when input A is false and input B is high

Figure 19, shows the simulation results of XNOR when input A is false and input B is true i.e. they are different. So the output goes false.

Fig. 19: The Simulation of the XNOR ladder when input B is true and input A is false.

In the last case when both inputs A and B are high as shown in Fig. 20, the output becomes true.

Fig. 20: The Simulation of XNOR ladder when both inputs are true

We can conclude that the XNOR is marked by the true status of its output whenever both inputs are equal and vice versa. One of the most common scenarios for the best practice of XNOR is the protection of the operator's hands in the cutting machine. In that machine, the command for running the knife driving motor is an XNOR of two switches on the left and right hand of the operator. In that way, it is guaranteed that to run the motor, the operator should use both hands at the same time.

What’s next

I am very pleased to see you up to this point of our tutorial, Now you are familiar with all logic gates and practiced their logic on the simulator. In addition, you can feel the importance of mastering all these logic gates to ease your programming and enrich your programming skills. In the next tutorial, we are going to go deeply through the edge signal including rising and falling edge. We are going to introduce the benefits of these edge signals and how they can be utilized in ladder logic programming to solve a lot of problems. So be ready for more learning and practice with simulation in ladder logic series.

ESP32 Hall Effect Sensor in Arduino IDE

Hello readers, I hope you all are doing great. Welcome to Section 5 of the ESP32 Programming Series. In this section, we are going to interface different Embedded Sensors with the ESP32 Microcontroller Board. ESP32 development board is featured with some inbuilt sensors(i.e. hall effect sensor, capacitive touch sensor) so, in the initial tutorials of this section, we will explore these built-in ESP32 sensors and in the later lectures, we will interface third-party sensors with the ESP32.

In today's lecture, we will discuss the working/operation of the ESP32 built-in Hall Effect Sensor. Hall Effect sensor is used to detect the variation in the magnetic field of its surroundings. So, let's first understand What's Hall Effect:

Where To Buy?
No.ComponentsDistributorLink To Buy
1ESP32AmazonBuy Now

What is the Hall Effect?

The Hall Effect phenomenon was first discovered by Edwin Hall in 1879. When current passes through a conductor, the electrons move in a straight line and thus the voltage difference across the conductor's surface remains zero, as shown in the below figure:

However, when a magnet is placed near the current-carrying conductor in a way that the direction of the magnetic field is perpendicular to the flow of current, the electrons get diverted and don't follow a straight line, which results in generating a small potential difference across the conductor's surface, as shown in the below figure:

This small potential difference generated because of magnetic field presence is called Hall Voltage. This magnetic field influence over the current-carrying conductor is termed the Hall Effect.

Hall Effect Sensor

A Hall Effect Sensor is a non-contact type embedded sensor, used to detect the presence & intensity of a magnetic field in its surroundings. Different third-party Hall Effect Sensors available in the market are shown in the below figure:

  • A normal Hall Effect Sensor Pinout consists of 3 Pins i.e.
  1. Vcc: Normally +5V, few +3.3V are also available.
  2. GND: We need to provide Ground here.
  3. OUT: The Output Pin to give the sensor's response.
  • When a perpendicular magnetic field is placed near a Hall-effect sensor, it changes the status of its Output Pin.
  • The analog Hall Effect Sensors can also detect the strength of the magnetic field i.e. greater the magnetic field greater will be the sensor's output or voltage deviation.

Applications of Hall Effect sensor

  • In an Automotive system, Hall Sensors are used to detect speed, distance, position etc.
  • Used in Proximity sensing.
  • Used in Current sensing.
  • Used in Anti-lock braking system.
  • Used in Internal combustion engines to assist with ignition timing.
  • To switch an electric circuit ON and OFF.

Hall Effect Sensor in ESP32

In ESP32, the Hall effect sensor is located inside the ESP-WROOM-32 metallic cover. As the Hall Effect sensor is a non-contact type, it doesn't have to be in contact with the magnet. We just need to place the magnet above this metallic sheet and the ESP32 Hall Effect sensor will detect it.

Programming ESP32 Hall Effect Sensor using Arduino IDE

To understand the working of the Hall sensor with ESP32, let's test the builtin ESP32 example:

  • You can find the code through File> Examples> ESP32 > Hall Sensor, as shown in the below figure:

Arduino IDE code

Here's the code for this ESP32 Hall Sensor example:

int val = 0;

void setup()
{
   Serial.begin (9600);
}

void loop() 
{
   val = hallRead();
   Serial.print ("sensor value = ");
   Serial.println (val);//to graph

   delay(100);
}

Code Description

The code is quite simple, where the hallRead() function is called to read the hall sensor value, store it into a variable and then print it on the Serial monitor. Finally added a small delay to get the next value. Let me explain the code line by line for the beginners:

Variables Declaration

  • The first step will be the declaration of an integer-type variable to store the hall sensor value. The initial value assigned to the variable is zero.
int val = 0;

Setup() Function

  • Inside the setup function, the only task is to initialize the serial port at a 9600 baud rate for serial communication.
void setup()
{
   Serial.begin (9600);
}

Loop() Function

  • Inside the loop function, we called a function ‘hallRead()’ to read the sensor value and store those readings into the variable ‘val’.
  • Printed the sensor readings on the serial monitor or serial plotter using serial.println() function.
  • A delay of 0.3 sec is added at the end.
void loop() 
{
   val = hallRead();
   Serial.print ("sensor value = ");
   Serial.println (val);//to graph

   delay(100);
}

ESP32 Hall Effect Sensor - Testing

  • After successfully uploading the code into ESP32, open the serial plotter or serial monitor to monitor the results.
  • Place a magnet near the ESP32 board.
  • The sensor reading will increase/decrease depending on the magnet pole(i.e. North or South Pole) facing the Hall sensor.
  • Now click on Tools > Serial Plotter to visually analyze the sensor's output.
  • The Serial Plotter of our project is shown in the below figure:
  • As you can see in the above figure, the sensor is giving negative output when facing the North Pole of the magnet.
  • In the case of a South Pole, the sensor's output is positive.
  • In the absence of a magnetic field, the sensor's output is almost 0.
  • The distance between the magnet and the Hall sensor decides the amount of potential difference generated.
  • The greater the distance between the two, the smaller the hall voltage or potential difference will be.
  • We have attached an image from the Arduino IDE serial monitor for your reference.

This concludes the tutorial. I hope you found this helpful, test it out and if feel any difficulty, let me know in the comments. In the next tutorial, we will have a look at another built-in sensor of ESP32 i.e. Capacitive Touch Sensor. Thanks for reading.

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