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!

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