What’s The Difference Between Edge Computing And Cloud Computing?

Public cloud computing systems enable businesses to complement their data centers with worldwide servers that can scale processing capabilities up and down as required. In terms of value and security, hybrid public-private clouds are unparalleled.

However, real-time AI applications demand substantial local processing capacity, frequently in areas distant from centralized cloud servers. speedpak tracking is among the services including AI for the safety of your goods and parcels.

Moreover, some workloads demand low latency or data residency and must stay on-premises or specified locations.

That is why many businesses use edge computing to implement AI applications.

Instead of storing data in a centralized cloud, edge computing saves data locally in an edge device. Moreover, the gadget may function as a stand-alone network node without an internet connection.

Cloud and edge computing offer many advantages and application cases.

Cloud Computing; Overview

Cloud computing is a computing approach in which scalable and elastic IT-enabled capabilities are supplied as a service through the Internet.

Cloud computing's popularity is growing as a result of its many advantages. Cloud computing, for example, has the following benefits:

  • Lower initial investment
  • Price Variability
  • On-demand computation with no bounds
  • IT management has been simplified.
  • Simple updates
  • The dependability is excellent.
  • Time is money

Edge Computing; Overview

Edge computing is the process of physically bringing computational capacity closer to the source of data, which is generally an Internet of Things device or sensor. Edge computing, so named because of how computing power is delivered to the network's or device's edge, enables quicker data processing, higher bandwidth, and data sovereignty.

Edge computing lowers the need for huge volumes of data to travel between servers, the cloud, and devices or edge locations to be processed by processing data at the network's edge. It is especially relevant for current applications like data science and artificial intelligence.

Cloud Vs. Edge Computing

Edge and cloud computing have unique advantages, and most businesses will utilize both. Here are some things to think about when deciding where to deploy certain workloads.

In contrast, cloud computing is ideal for non-time-sensitive data processing, but edge computing is ideal for real-time data processing.

Also, the former requires a dependable online connection, while the latter should encompass rural regions with little or no internet access.

Furthermore, cloud computing stores data in the cloud, but edge computing includes very sensitive data and tight data rules.

Medical robotics is one example of when edge computing is superior to cloud computing because surgeons want real-time data access. These systems include a significant amount of software running on the cloud.

Still, the sophisticated analytics and robotic controls increasingly used in operating rooms cannot tolerate latency, network stability difficulties, or bandwidth limits. In this case, edge computing provides the patient with life-saving advantages.

A Blend Of Both; Hybrid Cloud Architecture

Convergence of cloud and edge is required for many enterprises. Organizations centralize when possible and disseminate when necessary.

Firms may benefit from the security and management of on-premises systems with hybrid cloud architecture. It also makes use of a service provider's public cloud resources.

For each firm, a hybrid cloud solution implies something different. It might imply training in the cloud and deploying at the edge, training in the data center and deploying at the edge using cloud management tools, or training at the edge and deploying in the cloud to centralize models for federated learning. There are several options to connect the cloud and the edge.

Conclusion

Though both the computing systems are equally important, each carries distinctive perks. As the world is moving toward the hybrid approach, understanding the right computing choice will ease your process. Our guide will assist in this regard.

IoT Based Motion Detection with Email Alert using ESP32

The IoT is the interconnection of physical objects or devices with sensors and software accessing capabilities to communicate data or information over the internet.

To build an IoT network, we need an interface medium that can fetch, control, and communicate data between sender and receiver electronics devices or servers.

Espressif Systems created the ESP32 Wi-Fi chip series. The ESP32 module is equipped with a 32-bit Tensilica microcontroller, 2.4GHz Wi-Fi connectivity, an antenna, memory, and power management modules, and much more. All of these built-in features of this ESP32 module make it ideal for IoT applications.

Hello readers, I hope you all are doing great. In this tutorial, we will learn another application of ESP32 in the field of IoT (Internet of Things). We are using a PIR sensor to detect motion and an Email alert will be generated automatically whenever a motion is being detected.

Fig.1

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

Overview

The HCSR-501 sensor module is used with ESP32 to detect the motion. So whenever a motion is detected, the PIR sensor will generate a HIGH output signal which will act as an input to the ESP32 module. In the absence of motion, the output of the PIR sensor will remain LOW. If a HIGH input signal is generated from the PIR sensor module, the LED (either peripheral or inbuilt) will be turned ON and along with that, an Email will be generated to the receiver’s email address as per the program instructions.

Software and Hardware requirements

  • ESP32 development board
  • HCSR-501 PIR sensor module
  • LED
  • Resistor
  • Connecting Wires
  • Sender’s email account details
  • Receiver’s email address
  • ESP-Mail-Client Library

What is HCSR-502 PIR sensor module and how does it work?

Fig. 2 PIR Motion Sensor

PIR stands for Passive Infrared sensors. It detects heat energy in the surrounding environment using a pair of pyroelectric sensors. Both sensors are placed next to each other, and when motion is detected or the signal differential between the two sensors changes, the PIR motion sensor returns a LOW result (logic zero volts). It means that in the code, you must wait for the pin to go low. The desired function can be called when the pin goes low.

There are two potentiometers available in the HCSR-501 PIR motion sensor module. One of the potentiometers is to control the sensitivity to the IR radiations. Lower sensitivity indicates the presence of a moving leaf or a small mouse. The sensitivity can be changed depending on the installation location and project specifications.

The second potentiometer is to specify the duration for which the detection output should be active. It can be programmed to turn on for as few as a few seconds or as long as a few minutes.

PIR sensors are used in thermal sensing applications such as security and motion detection. They're commonly found in security alarms, motion detection alarms, and automatic lighting applications.

SMTP

The simple mail transfer protocol (SMTP) is an internet standard for sending and receiving electronic mail (or email), with an SMTP server receiving emails from email clients.

SMTP is also used to establish server-to-server communication.

Gmail, Hotmail, Yahoo, and other email providers all have their own SMTP addresses and port numbers.

Fig. 3 SMTP

How does SMTP work?

To send emails, the SMTP protocol, also known as the push protocol, is used, and IMAP, or Internet Message Access Protocol (or post office protocol or POP), is used to receive emails at the receiver end.

The SMTP protocol operates at the application layer of the TCP/IP protocol suite.

When the client wants to send emails, a TCP connection to the SMTP server is established, and emails are sent over the connection.

SMTP commands:

  • HELO – This command is sent only once per session and it is used to identify the qualified domain names and the client to the server.
  • MAIL – used to initiate a message
  • RCPT – Identifies the address
  • DATA – This command is responsible for sharing data line by line

SMTP server parameters for email service

There are various email service providers available like, Gmail, Yahoo, Hotmail, Outlook etc. and each service provider have unique service parameters.

In this tutorial, we are using the Gmail or Google Mail service.

Gmail is the email service provided by Google and Gmail SMTP server is free to access and anyone can access this service, who has a Gmail account.

  • SMTP server: smtp.gmail.com
  • SMTP port: 465
  • SMTP sender’s address: Gmail address
  • SMTP sender's password: Gmail Password

Create a new Gmail account (Sender)

It is recommended to create a new email account for sending emails using ESP32 or ESP8266 modules.

If you are using your main (personal) email account (for sending emails) with ESP and by mistake something goes wrong in the ESP code or programming part, your email service provider can ban or disable your main (personal) email account.

In this tutorial we are using a Gmail account.

Follow the link to create a new Gmail account : https://accounts.google.com

Fig. 4 create new gmail account

Access to Less Secure apps

To get access to this new Gmail account, you need to enable Allow less secure apps and this will make you able to send emails. The link is attached below:

https://myaccount.google.com/lesssecureapps?pli=1

Fig. 5 permission to less secure apps

Interfacing ESP32 and HCSR-501

Table 1

Fig. 6 ESP32 and HCSR-501 connections

Arduino IDE Programming

We are using Arduino IDE to compile and upload code into ESP32 module. To know more about ESP32 basics, Arduino IDE and how to use it, follow our previous tutorial i.e., on ESP32 programming series. Link is given below:

https://www.theengineeringprojects.com/2021/11/introduction-to-esp32-programming-series.html

Necessary Library

To enable the email service in ESP32 it is required to download the ESP-Mail-Client Library. This library makes the ESP32 able to send email over SMTP server.

Follow the steps to install the ESP-Mail-Client library:

  1. Go to the link and download the ESP-Mail-Client library:

https://github.com/mobizt/ESP-Mail-Client

  1. Open your Arduino IDE.
  2. Then to add the ZIP file go to Sketch >> Include Library >> Add.ZIP Library and select the downloaded ZIP file.

Fig. 7 Adding ESP-Mail-Client Library

  1. Click on

Arduino IDE Code

//To use send Email for Gmail to port 465 (SSL), less secure app option should be enabled. https://myaccount.google.com/lesssecureapps?pli=1

//----Add the header files

#include <WiFi.h>

#include <ESP_Mail_Client.h>

//-----define network credentials

#define WIFI_SSID "public"

#define WIFI_PASSWORD "ESP32@123"

//--add the Server address and port number with respect to a particular email service provider

#define SMTP_HOST "smtp.gmail.com"

#define SMTP_PORT esp_mail_smtp_port_587 //port 465 is not available for Outlook.com

 

//----The log in credentials

#define AUTHOR_EMAIL "techeesp697@gmail.com"

#define AUTHOR_PASSWORD "Tech@ESP123"

//----The SMTP Session object used for Email sending

SMTPSession smtp;

//---Declare the message class

SMTP_Message message;

//---Callback function to get the Email sending status

void smtpCallback(SMTP_Status status);

const char rootCACert[] PROGMEM = "-----BEGIN CERTIFICATE-----\n"

"-----END CERTIFICATE-----\n";

int inputPin = 4; // connect with pir sensor pin

int pir_output = 0; // variable to store the output of PIR output

void setup()

{

pinMode(inputPin, INPUT);

pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);

pir_output = digitalRead(inputPin);

Serial.println();

Serial.print("Connecting to AP");

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

while (WiFi.status() != WL_CONNECTED)

{

Serial.print(".");

delay(200);

}

Serial.println("");

Serial.println("WiFi connected.");

Serial.println("IP address: ");

Serial.println(WiFi.localIP());

Serial.println();

/** Enable the debug via Serial port

* none debug or 0

* basic debug or 1

*

* Debug port can be changed via ESP_MAIL_DEFAULT_DEBUG_PORT in ESP_Mail_FS.h

*/

smtp.debug(1);

/* Set the callback function to get the sending results */

smtp.callback(smtpCallback);

/* Declare the session config data */

ESP_Mail_Session session;

/* Set the session config */

session.server.host_name = SMTP_HOST;

session.server.port = SMTP_PORT;

session.login.email = AUTHOR_EMAIL;

session.login.password = AUTHOR_PASSWORD;

session.login.user_domain = "mydomain.net";

/* Set the NTP config time */

session.time.ntp_server = "pool.ntp.org,time.nist.gov";

session.time.gmt_offset = 3;

session.time.day_light_offset = 0;

/* Set the message headers */

message.sender.name = "ESP Mail";

message.sender.email = AUTHOR_EMAIL;

message.subject = "Email Alert on Motion detection";

message.addRecipient("Anonymous",

"replace this with receiver email adderss");

String textMsg = "Motion Detected!!!!!";

message.text.content = textMsg;

message.text.charSet = "us-ascii";

message.text.transfer_encoding = Content_Transfer_Encoding::enc_7bit;

message.priority = esp_mail_smtp_priority::esp_mail_smtp_priority_low;

/* Set the custom message header */

message.addHeader("Message-ID: <abcde.fghij@gmail.com>");

/* Connect to server with the session config */

if (!smtp.connect(&session))

return;

}

void loop()

{

if (pir_output == HIGH)

{

//----Start sending Email and close the session

if (!MailClient.sendMail(&smtp, &message))

Serial.println("Error sending Email, " + smtp.errorReason());

digitalWrite(LED_BUILTIN, HIGH);

Serial.println("Motion detected!");

Serial.println("Email sent");

}

else {

digitalWrite(LED_BUILTIN, LOW);

Serial.println("No Motion detected!");

}

delay(1000);

ESP_MAIL_PRINTF("Free Heap: %d\n", MailClient.getFreeHeap());

//to clear sending result log

smtp.sendingResult.clear();

}

/* Callback function to get the Email sending status */

void smtpCallback(SMTP_Status status)

{

/* Print the current status */

Serial.println(status.info());

/* Print the sending result */

if (status.success())

{

Serial.println("----------------");

ESP_MAIL_PRINTF("Message sent success: %d\n", status.completedCount());

ESP_MAIL_PRINTF("Message sent failled: %d\n", status.failedCount());

Serial.println("----------------\n");

struct tm dt;

for (size_t i = 0; i < smtp.sendingResult.size(); i++)

{

/* Get the result item */

SMTP_Result result = smtp.sendingResult.getItem(i);

time_t ts = (time_t)result.timestamp;

localtime_r(&ts, &dt);

ESP_MAIL_PRINTF("Message No: %d\n", i + 1);

ESP_MAIL_PRINTF("Status: %s\n", result.completed ? "success" : "failed");

ESP_MAIL_PRINTF("Date/Time: %d/%d/%d %d:%d:%d\n", dt.tm_year + 1900, dt.tm_mon + 1, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec);

ESP_MAIL_PRINTF("Recipient: %s\n", result.recipients);

ESP_MAIL_PRINTF("Subject: %s\n", result.subject);

}

Serial.println("----------------\n");

//You need to clear sending result as the memory usage will grow up as it keeps the status, timstamp and

//pointer to const char of recipients and subject that user assigned to the SMTP_Message object.

//Because of pointer to const char that stores instead of dynamic string, the subject and recipients value can be

//a garbage string (pointer points to undefind location) as SMTP_Message was declared as local variable or the value changed.

smtp.sendingResult.clear();

}

}

Note: The exact code cannot be used. As a result, before uploading the code, you must make some changes such as replacing the SSID and password with your network credentials, email address of sender and receiver, SMTP setting parameters for respective email service providers, and so on. We'll go over these details as well during the code description.

Code Description

  • The first step is adding the required header files or libraries.
  • Here we are using two libraries:
    • The first one is h, which is used to enable the Wi-Fi module and hence wireless network connectivity.
    • Another library file required is the h to enable email service over SMTP (simple mail transfer protocol).

Fig. 8

  • Enter the network credentials in place of SSID and PASSWORD.

Fig. 9

  • Enter the SMTP parameter of the respective email service provider like, Gmail, Yahoo, Outlook, Hotmail etc. (In this tutorial we are using Gmail service).
  • Parameters used below are for Gmail.

Fig. 10

  • Enter the sender’s email login details (email address and password ).

Fig. 11

  • Insert recipient’s email address.

Fig. 12

  • SMTPSession object is used for sending emails.

Fig. 13

  • Next step is declaring a message

Fig. 14

  • This smtpCallback() function is used to get the email sending status.

Fig. 15

  • This function also includes printing the results like success and failure of email sent.

Fig. 16

  • Next we are defining a variable to store the GPIO pin number to which the PIR sensor is to be connected.
  • Next variable pir_output is used to store the current state of PIR output and initially it is fixed to zero.

Fig. 17 Variable for PIR sensor

Setup()

  • Initialize the serial monitor at 115200 baud rate for debugging purpose.
  • Set the mode as INPUT for the GPIO pin to which PIR module is to be connected i.e., GPIO 4.
  • We are using the built-in LED (LED turns ON when a motion is detected.
  • The digitalRead() function is used to read the output of PIR sensor module, by passing the GPIO pin (to which PIR sensor is connected) as an argument and results will be stored inside pir_output

Fig. 18

  • begin() function is used to initialize the Wi-Fi module with Wi-Fi credentials used as arguments.
  • The While loop will continuously run until the ESP32 is connected to Wi-Fi network.

Fig. 19

  • If the device is connected to local Wi-Fi network then print the details on serial monitor.
  • localIP() function is used to fetch the IP address.
  • Print the IP address on serial monitor using println() function.

Fig. 20

  • debug() is used to enable the debug via Serial port where ‘0’ and ‘1’ are used as arguments where;
    • 0 - none debug
    • 1 - basic debug
  • Inside ESP_Mail_FS.h header file, ESP_MAIL_DEFAULT_DEBUG_PORT can be used to change the Debug port.
  • Set the callback() function to get sending results.

Fig. 21

  • Setting session configuration includes, assigning the server address, port number of the server (here we are using Gmail services), email login details of the sender etc.

Fig. 22

  • Next step is setting the message header.
  • Message header will be set inside the setup() function which includes, sender’s name, subject, sender’s email address, receiver’s email address and name.
  • A string type variable textMsg is defined to to store the message to be transferred over email.

Fig. 23

  • connect() function.is used to connect to server with session configuration.

Fig. 24

Loop

  • ESP32 is continuously checking for the input from PIR sensor inside the loop function.
  • If the input received from pir sensor is HIGH the ESP32 will generate an email to the client for that sendMail() function is used and if mail transmission is failed then that will be printed on the serial monitor along with the reason.
  • The inbuilt LED on ESP32 will be turned ON and the respective results will be printed on the serial monitor.

Fig. 25 ‘If motion detected’

  • If the input received from the PIR sensor is LOW then the LED will remain LOW/OFF and no email alert will be generated.

Fig. 25 No motion detected

  • Finally, clear the email log to avoid excessive memory usage.

Fig. 26 Clear the email log

Testing

  • Open the Arduino IDE.
  • Paste the above code into your Arduino IDE.
  • Make the required changes in the code like, network credentials, email service parameters of the respective email service provider, sender and receiver email address and define the message you want to share over SMTP server.
  • Select the right development board and COM port for serial communication.

Fig. 27 select development board and COM port

  • Compile and upload the program into the ESP32 development board.
  • Connect the HCSR-501 module with the ESP32 as per the circuit/connect details given above.

Fig. 28 ESP32’s Inbuilt LED is turned ON when a motion is detected

  • Open the serial monitor with 115200 baud rate.

Fig. 29 Serial monitor

  • Check the receiver email account.

Fig.30 received email on motion detection

This concludes the tutorial. We hope you found this of some help and also hope to see you soon with a new tutorial on ESP32.

What is Edge Computing?

 Hi Friends! Hope you’re well today. In this post, I’ll walk you through What is Edge Computing?

Edge computing is the extension of cloud computing. Cloud computing is used for data storage, data management, and data processing. While Edge Computing does serve the same purpose with one difference: edge processing is carried out near the edge of the network which means data is processed near the location where it’s produced instead of relying on the remote location of the cloud server.

Confused?

Don’t be.

We’ll touch on this further in this article.

Curious to know more about what is edge computing, the difference between edge computing and cloud computing, benefits, and applications?

Keep reading.

What is Edge Computing?

Edge computing is the process where data is processed near or at the point where it’s produced. The word computing here is used for the data being processed. Simply put, Edge computing allows the data to be processed closer to the source of data (like computers, cell phones) rather than relying on the cloud with data centers. This process is used to reduce bandwidth and latency issues.

For instance, Surveillance cameras. When these cameras are required simultaneously to record a video, if you use cloud computing and run the feed through the cloud, it will increase its latency (latency is the time delay between actual data and processed data) and reduce the quality of the video.

This is where edge computing comes in handy. In this particular case, we can install a motion detector sensor that will sense the movement of the physical beings around the camera. This motion-sensing device will act as an edge device that is installed near the data source (camera). When live feed data is processed near the edge devices instead of the cloud or data centers, it would increase the video quality and practically reduce the latency to zero.

Cloud storage takes more time to process and store data, while edge computing can locally process data in less time. The market of edge computing is expected to grow from $3.5 billion to $43.4 billion by 2027, according to experts in Grand View Research. Many mobile network carriers are willing to apply edge computing into their 5G deployment to improve their data processing speed instead of picking the cloud server.

How does Edge Computing Work?

Normally in cloud computing, two components are used: the device and the cloud server. In edge computing an intermediate node is introduced between the device and the cloud server, this node is called an edge device.

How data was stored in data centers before edge computing stepped in? Yes, this is the main question to discuss before we explain how edge computing works.

Before edge computing, data was gathered from distributed locations. This data was then sent to the data center which could be an in-house facility or the public cloud. These data centers were used to process the stored data.

In edge computing that data processing is carried out near or at the point from where data originates. This is very useful for making real-time decisions that are time-sensitive. Like in the case of automatic cars interacting with each other.

Plus, less computing power is required in edge computing since we don’t need to push back all data to the data center. Like in the case of a motion-detecting sensor installed near the camera. In case we require a video of a particular instance, we need to pull out the entire information recorded inside the camera to reach that particular instant clip. However, when the motion sensor is installed near the camera that acts as an edge device, we only require that information where that sensor has detected the movement of any physical beings, and we can easily discard the rest of the information and we don’t need to store that information into the cloud server.

Know that edge data centers are not the only way to store and process data. Rather, edge computing involves the network of different technologies. Some IoT devices can become a part of this edge computing and can process data onboard and send that data to the smartphone or edge server to do the difficult calculations and efficiently handle the data processing.

Cloud Computing Vs Edge Computing

An edge computing environment is developed using a network of data centers spread across the globe. The data centers in edge computing are different than the data centers at cloud computing. In former data centers store and process information locally and comes with the ability to replicate and transfer that information to other locations. While in the latter, data centers are located hundreds of thousands of miles away. The network latency issues and unpredictable pricing model of the cloud storage allow the organizations to prefer private data centers and edge locations over public cloud.

Google Cloud, Amazon Web Services, and Microsoft Azure are the best examples of cloud computing. They use cloud computing infrastructure which is developed to transfer the data from data source to one centralized location called data centers.

While facial recognition lock feature of the iPhone uses an edge computing model. If the data in this feature runs through cloud computing, it would take too much time to process data, while the edge computing device, which is the iPhone itself, in this case, does this processing within a few seconds and unlocks the mobile screen.

For massive data storage or for software or apps that don’t require real-time processing needs, cloud computing is the better solution and is commonly called the centralized approach. And if you require less storage with more real-time processing power that is carried out locally, edge computing is the answer and is called a decentralized approach where not a single person is making a decision, rather decision power is distributed across multiple individuals or teams.

Know that companies typically harness the power of both cloud computing and edge computing to develop advanced IoT frameworks. These two infrastructures are not opposite but are complementary for designing a modern framework.

Difference between Edge Computing and IoT

Edge computing is a form of distributed computing infrastructure that is location-sensitive while IoT is a technology that can use edge computing to its advantage. Edge computing is a process that brings the processing data as near to an IoT device as possible.

Don’t confuse an edge device with an IoT device. The device is the physical device where data is stored and processed while the IoT device, on the other hand, is the device connected to the internet. It is nothing but the source of the data.

Benefits of Edge Computing

Edge computing is changing the way how data is stored and processed. This gives a more consistent and reliable experience at a significantly lower cost.

  • With cloud computing, you require more bandwidth to transfer and communicate the data between the device and cloud server. With edge computing, on the other hand, you’ll require reduced bandwidth since edge devices are installed near the data source.
  • Edge computing guarantees low latency, better quality with better control over the transmission of sensitive data.
  • Moreover, edge computing allows conducting on-site big data analytics which helps in real-time decision making. This process keeps the computing power local which means you are not dependent on the centralized system, rather this creates a decentralized approach where decision power is distributed across the local edge data centers.
  • Edge computing comes in handy where bandwidth is reduced and the connectivity is unreliable. Such as in the places like a rainforest, remote farms, ships at sea, oil rigs, and desert. In such cases, edge computing does the processing work on the site or in other cases on the edge device itself – for instance, water sensors that check the quality of the water in remote villages. When the data is computed locally, the amount of required data you need to send can be reduced significantly, requiring less bandwidth, time, and cost which may otherwise be compulsory if data is processed remotely on a centralized location.

Challenges and Risks of Edge Computing

With new technology comes new security issues and edge computing is no different. From a security point of view, data at the edge computing can become vulnerable because of the involvement of local devices instead of the centralized cloud-based server. A few ricks of edge computing include:

Hackers always seek to steal, modify, corrupt, or delete data when it comes to edge computing. They strive to manipulate edge networks by injecting illegal hardware or software components inside the edge computing infrastructure. The common practice followed by these hackers is node replication where they inject malicious node into the edge network that comes with an identical ID number as assigned to the existing node. This way they can not only make other nodes illegitimate but also can rob sensitive data across the network.

Tampering of connected physical devices in edge networks is another malpractice carried out by potential hackers. Once they approach the physical devices they can extract sensitive cryptographic information, change node software and manipulate node circuits.

Routing attach is another security risk in edge computing. This approach can affect the way how data is transferred within the edge network. The routing information attacks can be categorized into four different types:

  • Wormholes
  • Grey holes
  • Hello Food
  • Black holes

In wormholes attach, hackers can record packets at one location and tunnel them to another. In grey holes attach, they slowly and selectively delete the data packets within the network. In a hello food attack, they can introduce a malicious node that sends hello packets to other nodes, creating routing confusion within the network. While in black holes attach the outgoing and incoming packets are deleted which increases the latency.

Know that these practices can be avoided by establishing reliable routing protocols and incorporating effective cyber security practices within the network. It’s wise to put your trust in manufacturers who have proper policies in practice to guarantee the effectiveness of their edge computing solutions.

Edge Computing Examples

Edge computing comes in handy where quick data processing is required. With computing power near the data source, you can make better and quick real-time decisions.

A few edge computing examples include:

  • Facial recognition
  • Virtual or augmented apps
  • Remote monitoring of assets in the oil & gas industry
  • In hospital patient-monitoring
  • Cloud gaming
  • Content delivery
  • Traffic management
  • Smart homes
  • Surveillance or security cameras
  • Alexa or Google assistant
  • Industrial automation

Predictive maintenance is another example where edge computing can play a key role. It helps to identify if the instrument needs maintenance before its major failure or total collapse. This saves both time and money which would otherwise require for entire instrument replacement.

Conclusion

Edge computing becomes common practice among many organizations since it provides more control over processed data.

This trend will continue to grow with time and it is expected by 2028 edge services will become widely available across the globe.

Wireless technologies such as WiFi 6 or 5G will work in favor of edge computing, giving chance to virtualization and other automation capabilities, at the same time making the wireless network more economical and flexible. Many carriers are now working to incorporate edge computing infrastructure into their 5G developments to provide fast real-time processing capabilities, particularly for connected cars, mobile devices, and automatic vehicles.

It is not about which one is better cloud computing or edge computing. It’s about the requirement. If you want data to be processed quickly near the source, you’ll adopt edge computing and if you want more data storage and data management, you will pick cloud computing.

The prime goal of edge computing is to reduce bandwidth and practically reduce the latency to zero. With the extension of real-time applications that require local computing and storage power, edge computing will continue to grow over time.

That’s all for today. Hope you find this article helpful. If you have any questions, you can reach out in the comment section below. I’d love to help you the best way I can. Thank you for reading this article.

What is Industrial IoT (Internet of Things)

Hi guys! Hope you’re well today. In this post today, I’ll cover What is Industrial IoT (Internet of Things?)

IIoT is now a talk of mainstream conversation. This term has blown up in the past couple of years. Before we move further to describe IIoT, it is evident that industries are no longer dependent on the traditional production processes that happened to be costly and guaranteed no optimal results. Now companies are willing to incorporate automation in manufacturing and production processes. Smart systems, no doubt, are dangerous for the traditional labor workforce, but on the other hand, they create more opportunities for the people equipped with the latest business trends.

Curious to know more about Industrial IoT, how does it work, the difference between IoT and IIoT, examples of IIoT, the impact of IIoT on jobs and workers, and the advantages of IIoT?

Keep reading.

What is Industrial IoT?

The Industrial Internet of Things, also known as Industry 4.0 or Industrial Internet, is the use of smart connected machines, embedded sensors, and actuators mainly used to enhance the overall efficiency and productivity of manufacturing and production processes.

At its core, it is used to automate processes for the production of optimal products that build a strong connection with the customers and create new revenue streams. Automation leads to accuracy and better efficiency and removes the likelihood of error that is difficult to attain by a simple human workforce. The Industrial IoT is used across a range of industries including manufacturing, oil and gas, logistics, mining and metals, transportation, aviation, energy/utilities, and more.

How does Industrial IoT work?

The smart devices deployed in Industrial IoT are used to capture, store and analyze data in real-time and that data is delivered to the company leaders to make faster, smarter business decisions.

A typical Industrial IoT system contains:

  • Intelligent systems are used to store and capture data.
  • Connected internet devices are used as a data communication structure.
  • Analytical applications that guarantee optimized processes by using that raw data.
  • Tools that allow managers and decision-makers to use that data for better decisions.

For example, I own a PCB manufacturing industrial unit. And I want to know which types of PCBs are most popular among customers. With IoT technology I can:

  • Use sensors to find out which areas of the industry are most crowded by the customers.
  • Hunt down the sales data to figure out which types of PCBs are selling faster.
  • Make sure demand and supply align so popular PCBs don’t go out of stock.

The information gathered by the smart devices helped me to make better decisions on which items to stock up on which ultimately helped me save both time and money.

Difference between IoT and IIoT

  • Both IoT and IIoT work on the same principle: using a network of intelligent devices and sensors for collecting, storing, monitoring, and analyzing data.
  • IIoT is nothing but an extension of IoT. The IoT is mainly used for commercial and domestic purposes, making the consumers’ life more easy and convenient. You can see its applications in wearable devices, smart microwaves, fitness devices, self-driving cars, and smart home automation systems.
  • While IIoT, on the other hand, is employed for increasing the productivity and overall efficiency of the industrial units. The set of smart devices and sensors used in IIoT collect and analyze data, automate production processes and guarantee a secure atmosphere by providing information in advance about industrial units that need maintenance.
  • The IIoT can be employed in supply chain robots, transportation and construction vehicles, agricultural systems, solar and wind power and smart irrigation system, and more.

Industrial IoT Examples

You’ll find a range of Industrial IoT examples. A few of them include:

  1. Predictive Maintenance

When a certain industrial process or a piece of instrument is at the brink of total failure, preventive and proactive maintenance is applied to allow a quick fix to the problem beforehand. This saves both time and money which otherwise results in costly instrument replacement. Traditional methods are obsolete to identify the problem in advance since they often required access of labor to remote places to perform manual testing. With IIoT, you get an alert when the problem starts developing, which provides a valuable insight into whether the instrument requires overhauling or complete replacement.

  • For instance, industries that manufacture elevators now install multiple sensors inside the product to make sure any problem can be identified before it halts the business operations. These sensors communicate with the cloud environment through data points that provide earlier automated notifications to the company technicians. This way any issue can be fixed in advance before it escalates to serious consequences.
  1. Process Automation

Automating the process is the main takeaway of employing IoT in industrial settings. When industrial processes are automated and involve no human intervention, it removes the likelihood of errors and improves operational productivity, and reduces overall production costs.

  • Only those industries excel and grow, that can produce maximum output with the minimum cost. In most industries, the energy cost is 30 to 50 % of the total cost of production processes. With process automation, the computer programs take inputs from the installed sensors and streamline the process that guarantees the optimal strategy for the plant. What makes these computer programs super important is their ability to learn from the given data and predict future trends to speed up the production process tailored to the changing conditions. The software directly controls the industrial equipment and allows it to move at a speed requiring minimum energy. Moreover, it also predicts if preventive maintenance is required, hence less energy, cost, and time is required to stop and restart the industrial unit for the regular inspection.
  • A smart irrigation system is another great example of IIoT used by farmers. Soil moisture and weather conditions are key factors to identify when watering is required for the crops. Soil moisture sensors are installed that provide moisture readings and send alerts to the system that automate the watering process. This way resources are used properly and more efficiently.
  1. Remote Monitoring

Remote monitoring is challenging for the industries. With traditional methods, not only is it difficult but also inefficient and risky. The businesses require consistent monitoring of the instruments working out in the field. Manual testing is risky since the field environment is often occupied with lots of heat, vibration, or humidity. And the access of humans is not recommended to those places.

  • For instance, tanks at production oil wells require consistent monitoring to identify if there is overflow which can be dangerous and often result in expensive cleanup costs. To minimize the risk and ensure a secure working environment, the company can install an IoT system that comes with an automated tank monitoring solution that monitors level readings and sends this data to the on-field engineer for managing pickups and deliveries. Moreover, it sends alerts for predictive maintenance based on the level readings and actual data. Using this method, companies don’t require any consistent physical existence of the human being on the field except when required.
  • In agriculture, it is often required to evenly distribute water across crop fields. Center pivots are mainly used for this purpose where water is sprinkled on the crops when center pivots move in a circle. Any damage to this center pivot can cause a loss of millions of dollars in revenue. Remote monitoring of the water pressure inside the center pivots can provide an insight into the disconnected fittings and leakage. Alerts and notifications are then sent to the farmers that take proper steps to nurture crop growth and avoid issues in advance before they aggravate a serious problem.

Impact of IIoT on workers and jobs

With the inception of digital technology, workforce transformation is on the rise. This new wave of technology, no doubt, removes the need for certain jobs but it also creates the possibility of generating new ones. According to the survey of business leaders in Accenture, this new digital era will create more jobs than it will eliminate.

The Industrial IoT provides scores of opportunities in optimization, automation, smart industry, intelligent decision making, industrial control, asset performance management, and in the sectors directly dealing with the customer’s behavior. They strive to create an environment tailored to the exact customer’s needs and demands so they keep coming back for what industries have to offer.

The IIoT makes the processes more efficient and improves productivity. It advocates for smart work, not hard work. Plus, the smart devices in IIoT removes the possibility of errors that may otherwise affect the production process if the traditional workforce is employed. Automation can gather data from hard-to-reach places, even reducing the risks to human lives. When a worker knows, they will get a notification on the smartphone about the tank leakage or the certain equipment that needs replacement, which means danger can be predicted in advance before it goes catastrophic.

This leads us to the conclusion: to survive in the ocean of digital transformation, it’s obligatory to equip yourself with the latest trends in engineering and information technology and liberate yourself from traditional research and development processes.

Advantages of Industrial IoT

There are many advantages of industrial IoT and low operating cost tops the list. With IIoT, you no longer need the physical presence of a human that requires monthly wages, paid leaves, healthcare costs, and holidays. Moreover, it doesn’t require commissions, monthly bonuses, and pensions that are compulsory if you induct human employees into your industry. More advantages of IoT include:

  1. To run production units consistently, companies need hundreds of employees in rotation for all three shifts and the plant still shuts down for maintenance and holidays. With IIoT, industrial units can run all day without any break 24/7 and 365 days a year. The plant only closes down when the maintenance is needed which is different than the regular maintenance since in this case maintenance is only needed when IoT sends alerts about the critical process or a piece of unit risks failure.
  2. When humans are employed in the industrial unit, there is always a likelihood of error no matter how hard they try to thwart it. With smart systems, no such errors occurred which guarantee the uniform and optimum quality of the products.
  3. With IIoT, manufacturing processes are more flexible. If you employ a worker for any task, you need to give them training in advance to get a hang of the entire instrument. Robots don’t require such training. They only need a program to perform any task.
  4. Industrial automation ensures the safety and security of human beings. Companies no longer need humans to send them to hard-to-reach places that are subjected to high risks like high temperature, vibration, and pressure. With IIoT you can remotely check the status of instruments on the field.
  5. Automated processes come with high precision and accuracy. They depend on the data gathered by sensors and streamline the overall industrial process based on the given information. Everything is done and controlled by the connected devices and no human intervention is involved which removes the possibility of error.

Conclusion

Industries have been incorporating automation into their production and manufacturing processes.

And this trend will increase over time and you’ll witness more industries are stepping into the realm of automation.

Industries are committed to upgrading their system and instruments to keep up with the modern trends and to make a footing in disruptive technologies.

This process is, no doubt, more efficient, delivers better results, maintains product quality, and is more economical. Even though it requires a high initial cost, it doesn’t need a regular labor force, reducing the overall operating cost of the processes.

If you want to make your worth in the industry, it is wise to keep you updated with the latest industry trends to make sure you’re not left out in the traditional industry jobs.

That’s all for today. Hope you find this article helpful. If you have any questions regarding IIoT, you are most welcome to ask in the section below. I’d love to help you the best way I can. Thank you for reading this article.

How to use Strings in Python?

Welcome to the fourth lesson of this python course. Our previous session taught us how to utilize the print function in python, so we have a firm grasp of the terminology and the functions themselves. In this lesson, we'll cover a few more Python terms, such as:

  • Strings
  • Operators
  • Input function

Also, we'll build a simple program to print out an imagined dog so that we may better grasp how these concepts are employed. So, let's get started now.

Why do we need to understand these terms?

Programming is a lot like building a structure out of blocks. Even with just a few types of children's toy blocks and some time and imagination, you can build anything. Because we'll be utilizing these phrases all the time in programming, it's critical that you know what they mean and how to use them.

What exactly are the strings?

An alphabet, word, or other character collection is referred to as a "string." As one of the most fundamental data structures, it serves as a framework for manipulating data. An in-built string class called "str" is available in Python. After they've been produced, strings are "immutable," which means that they can't be rewritten. Because of the immutability of strings, we must generate new ones each time we want to represent newly computed values.

Quotes are used to denote a string. There are a variety of ways to accomplish this:

  • Single quotation marks, as in the following example: For "double" quotations in your string, use "single" quotes."
  • Use double quotation marks. Using single quotations in your string is easy with double-quotes.

"Double quotes allow you to embed 'single' quotes in your string."

  • If you want to use triple quotes, you can do so in the following way: (""" """), (''' ''')

Triple quoted strings to make it possible to work with a set of multiple-line strings and include all of the whitespaces that accompany them.

The fact that a string cannot be changed results in an error if you try to do so. The adjustments require the creation of a new string.

Instead, use this method.

The built-in len() function can be used to determine the length of a string:

String slicing in python

Strings can be sliced and indexed since they are a sequence of characters. A string's indexing starts at 0 and is based on each character in the string.

The initial character in the string is C, which is located at position 0 of the index. The final syllable is a period, which is the string's sixteenth character. When you want to access characters in the opposite direction, you can use -1 as an index. when it's strung together, Chocolate and cookie are separated by a whitespace, which has its own index, 9 in this example. Slicing is a good way to verify this.

For the same reason as for other sequential data types, you can read and manipulate Python strings using their associated index numbers. It is possible to slice an object using its index values in Python to select a specific element or a subset of elements. You don't have to write a loop expression to identify or access specific substrings in a string. Slicing does this for you automatically.

Suppose you were trying to find the cookie substring in the following string. What's the best way to go about it?

Range slicing is used in these situations. The range slicing syntax is as follows:

Alternatively, you might use a negative stop index:

In this case, when you slice a sentence without giving an end index, you get characters from the first index to its last. In the same way, slicing a string without a starting index indicates that you begin at the beginning and end at the end.

Additionally, the stride parameter can be accepted by string-slicing as a third argument, which specifies the number of characters to advance once the initial one is picked from the string. In the default configuration, stride has a value of 1.

stringnu = "1020304050"

print (stringnu [0:-2:2])

Striding allows you to reverse a string, which is a really cool feature. With a stride of -1, you can begin at the end of the string and move forward one character at a time. With a value of -2, you can start at the end and move two characters at the same time.

String operations

String operations such as slicing and range slicing are frequent. As simple as adding, string concatenation is also available.

Concatenating a string with another data type, on the other hand, will fail.

You attempted to concatenate an integer value with a string, which is not permitted. Integer addition or string concatenation is not understood implicitly by the interpreter. However, give this a try:

The reason for this is that you used concatenation after you turned the integer into a string.

A string can be repeated using the * method.

wordsig = 'hip '

line1 = wordsig * 2 + 'hurray! '

print (line1 * 3)

To manipulate strings, Python comes with several built-in methods and utility functions. It is possible to use these built-in techniques to replace substrings, to put some words in a paragraph in capital letters, and to locate the position of a string within another text.

  • capitalizes the first character in the string returned by capitalize().
  • islower(): will return true/false when all characters in the string are lowercase/uppercase.
  • If a substring is passed to find(substring), it will be returned at the string's lowest index. When searching for substrings, you may optionally specify a start and end index for each location in the string that you want to search for. If the substring is not found, it returns -1.
  • count(substring) returns the number of times a substring appears in the string. The string's start and stop indexes are also programmable.
  • isspace() When the string has a whitespace character, the value is true. Otherwise, it is false. A space, a tab, and a new line are all whitespace characters. When working with real-world datasets, this can come in handy because the proper spacing may not be encoded properly during format conversion.
  • A function called lstrip() eliminates all leading whitespace from a string. It's a feature that comes in handy when dealing with real-world datasets.
  • If the string contains just digits, isdigit() returns true; otherwise, it returns false.
  • All instances of the substring are replaced with new using replace (sub-strings, new). A third argument, max, can be specified to replace as many of the substring occurrences as the value of max allows in the string. This is not an in-place replacement, so the immutable attribute of the string remains intact.
  • split(delimiter="") provides a list of substrings based on the specified delimiter (or a space if none is provided).

Python string formatting

Multiple string formatting options are available in Python. To better understand these formatting strings, let`s dive right in.

% Format

Python has a built-in modulo percent operation. The interpolation operator is the name given to it. There is a percent followed by the data type that must be prepared or transformed. This operation then replaces the word "percent datatype" with one or more components of that type:

Percent d is used for integers, whereas percent s is used for strings; you've seen both. Octal values can be converted to octal equivalents with this type of conversion, as can Hexadecimal values with this type, and Floating-Point Decimal Format with this type.

Python string formatter class

One of the built-in string classes is the formatter class. The format () method can be used to perform sophisticated variable substitutions and value formatting. Rewriting public methods such as format () and vformat () allows you to build your own string formatting techniques (). There are a number of methods that are designed to be replaced by subclasses, such as parse (), get field, get value, check unused arguments, format field, and convert field ().

Template strings

Templates allow substitutions based on dollars rather than percentages. A major reason for template syntax creation in Python Version 2.4 was that, despite the strength of percent string formatting, errors are easy to make, because the forms that follow '%'are extremely restrictive. This is a common blunder when it comes to percent formatting: forgetting to include the e in percent (variable).

substitution () and safe_substitute() are two methods specified within templates (). You can use them in the following ways:

Safe substitution () is an advantage to employing a template, in addition to other advantages.

String literal formatting

In Python 3, this is yet another way to format strings. A prefixed 'f' or 'F' string literal is known as a formatted string literal or f-string. Within curly brackets, you may include identifiers that will be utilized in your string.

What's the point of adding another string formatting option? well, this is because practicality and simplicity are appealing.

To demonstrate why f-strings are the best way to format strings in Python, check out the examples below.

Please note that the preceding code is only compatible with Python 3.6 and above. With f-strings, Python expressions can be used inside curly braces, which is a significant benefit of using them.

What's the point of having so many string formatting options?

Syntax is the most important consideration here. For the most part, it boils down to the trade-off between simplicity and the amount of verbosity you're willing to sacrifice. People with a C programming background will find it easy to use the percent sign to format strings, for example. Using the format () function can be more verbose, but it provides a wider range of options.

Input function with strings

While your application is running, you can utilize input routines to get data from the user. A key benefit of this approach is that it does not rely on preexisting values or file content to function. The syntax for the input function is as follows.

input([prompt])

Input functions will cause our application to pause. After the user inserts the text into the Python shell or command line, the application resumes.

input(message)

In order to prompt the user for text, you'll need to provide a message. It's important that a user understands what they need to do by reading this message. As a result, a user may wonder why the software isn't progressing. For example,

input ("Enter email address: ")

print ("Confirm it is your email address:")

In order to request an email address from a user, we've implemented the input () method. Messages in brackets are displayed on the same line where a user is expected to enter text in the command line.

Note that as soon as a user inputs data into the input () function, it is automatically converted to a string.

How to draw an imaginary dog.

Using the fundamentals of strings that we've learned in this lesson; we'll construct a simple program that prints out an image of a dog.

Let's open up our favorite coding editor, Atom, and get started. Before looking at the solution, I advise you to give it a shot on your own.

  • Step 1: In the code editor where the hello.py file is loaded, write the print function () to print out the upper body of our dog image.
  • Step 2: Insert double quotes or single quotes inside the print function. This shows the output will be a string.
  • Step 3: Write "o" in the speech marks.
  • Step 4: Close the speech marks and reopen the speech marks. This is because we want to add another string to the same print function. Add hyphens to represent the neck and upper body.
  • Step 5: Add a plus sign between the strings to concatenate the strings.
  • Step 6: Create another function to print the legs. Same way we did the upper body, we will now print the legs. Inside this function, we create a string and write four slashes to represent legs. Now our dog program is complete, save the file and run the code using one of the methods we learnt in the previous tutorial. The results should be:

Conclusion

Congratulations! You've made it this far. You have learned about string slicing, what strings are, and explored a variety of string-related processes. Many approaches to formatting strings have also been discussed. But don't forget that practice is the key to mastering any skill! I'll see you in the next tutorial.

ESP32 with 16x2 LCD in Arduino IDE | Data Mode & I2C Mode

Hello readers, we hope you all are doing great. Welcome to the 1st lecture of Section 4 in the ESP32 Programming Series. In this section, we will interface the ESP32 module with common Embedded modules(i.e. LCD, Keypad, RTC etc.).

In today's tutorial, we will interface ESP32 with a 16x2 LCD and will display data using both Data Mode and I2C Mode. LCD is the most commonly used embedded module in IoT Projects. It is used to display different types of data i.e. sensor readings, warning messages, notifications etc.

Before going forward, let's first have a look at what is LCD and How it works:

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

16x2 LCD Module

LCD(Liquid Crystal Display) is a type of electronic display module that is used in a wide variety of applications and devices such as calculators, computers, mobile phones, TVs, etc. There are different types of LCDs available for commercial use. Today, we are going to use the most simple one i.e. 16x2 LCD, shown in the below figure:

This 16x2 LCD has 16 columns and 2 rows, so in total of 32 blocks to display characters. Each Block can display a single character at a time. We can display text in different styles on this LCD i.e. blinking, scrolling etc. Another variant of this LCD is 20x4 LCD and as the name suggests, it has 20 columns and 4 rows and so can display 80 characters at a time. The operating principle of both of these LCDs is quite similar. So, if you are working with a 20x4 LCD, you can still follow this tutorial.

Let's have a look at the LCD pinout:

LCD Pinout

Both 16x2 and 20x4 LCDs have 16 pins each, used to control 7 write on these LCDs. Among these 16 pins, we have:

  • 8 Data Pins(Pin7-14)
  • 2 LCD Power Pins(Pin1 and 2)
  • 2 Backlight LED Power Pins(Pin15 and 16)
  • 1 Contrast Pin(Pin3)
  • 1 Enable Pin(Pin6)
  • 2 Selection Pins(Pin4 and 5)

LCD Pinout and its working is shown in the below table:

LCD Pinout
Pin No. Name Working
1
GND(Ground)
Connected to Ground Terminal.
2
Vcc(+5V)
Connected to +5V.
3
VE
To Control the LCD Contrast.
4
RS(Register Select) If RS=0(GND), LCD operates in Data Mode and we can write characters on the LCD.
If RS=1(+5V), LCD Command Mode gets activated and we can send commands to LCD i.e. erase, new line etc..
5
R/W(Read & Write) R/W=0(GND) enables the write operation on the LCD. (So, we normally keep this pin LOW, as we are interested in printing on the LCD).
R/W=1(+5V) enables the read operation on the LCD.
6
EN(Enable)
Enables the LCD to operate, so it should be kept HIGH.
7
Data Pin 0
LCD has a total of 8 Data Pins(D0-D7)
8
Data Pin 1
9
Data Pin 2
10
Data Pin 3
11
Data Pin 4
12
Data Pin 5
13
Data Pin 6
14
Data Pin 7
15
LED+
Connected to +5V. Turn on the backlight LED.
16
LED-
Connected to GND.

Now, let's interface the LCD with ESP32:

Interfacing LCD with ESP32

There are two methods to interface ESP32 with a 16x2 LCD:

  • Data Mode
  • I2C Mode

In the Data Mode, we use the LCD Data Pins and send data serially, while in the I2C mode, we solder an I2C adapter with the LCD, which acts as a bridge and maps I2C data coming from the microcontroller to the Data Pins. Let's first interface ESP32 and LCD via Data Pins:

LCD with ESP32 in Data Mode

As we discussed earlier, LCD has 8 Data Pins used to communicate with the Microcontroller. There are two ways to send data from the Microcontroller to the LCD:

  1. 4-Pin Method: In this method, we use 4 Data Pin of LCD(D0-D3) to get data from the microcontroller.
  2. 8-Pin Method: In this method, we use all the 8 Data Pins of LCD(D0-D7) to communicate with the microcontroller.

In complex projects, where you are dealing with multiple sensors & modules, its quite difficult to spare 8 Pins for LCD interfacing. So, normally 4-Pin method is preferred, which we are going to design next:

    Components Required

    Here are the components required to interface LCD with ESP32:

    1. ESP32 Development Board
    2. 16x2 LCD
    3. Potentiometer(To set the LCD Contrast)
    4. Jumper wires
    5. Breadboard

    Now, let's design the ESP32 LCD Circuit Diagram:

    Circuit Diagram

    • The circuit diagram of LCD interfacing with ESP32 via data pins is shown in the below figure:

    [Image]

    As you can see in the above figure:

    • Pin1 of the LCD is connected to the GND of ESP32.
    • Pin2 of the LCD is connected to the VIN of ESP32.
    • Pin3 of the LCD is connected to the Output Pin of the potentiometer,  the other two Pins of the Potentiometer are connected to Vcc and GND. So, we can change the voltage at this Pin3 from 0-5V by rotating the potentiometer's knob. You have to manually set its value to make the LCD text visible.

    Here's our hardware setup for ESP32 LCD Interfacing:

    [Image]

    Now let's design the Programming Code to print a simple message on the LCD:

    ESP32 Code for LCD

    We are using Arduino IDE to compile and upload code in the ESP32 module. If you haven't installed it yet, please read How to Install ESP32 in Arduino IDE. Here's the code to print a message on the LCD:

    #include 
    LiquidCrystal lcd(22,23,5,18,19,21);
    
    void setup()
    {
        lcd.begin(16, 2);
        lcd.clear();
    
        // go to row 0 column 5, note that this is indexed at 0
        lcd.setCursor(5,0);
        lcd.print("ESP32");
    
        // go to row 1 column 0, note that this is indexed at 0
        lcd.setCursor(0,1);
        lcd.print (" TheEnggProjects");
    }
    
    void loop()
    {
    }

    Code Description

    • The first step is to include the required library files. LiquidCrystal is the official Arduino Library to control the LCD.
    #include 
    • Next, we are initializing an "lcd" object of type "LiquidCrystal",  it takes the data and control pins as arguments.

    LiquidCrystal lcd(22,23,5,18,19,21);
    

    Setup() Function

    In the Setup() Function:

    • First of all, we initialized the 16x2 LCD using the begin() function. It takes the no of columns & rows of the LCD as an argument.

    lcd.begin(16, 2);
    

    So, if you are using a 20x4 LCD, you should change its arguments to 20 and 4, as shown below:

    lcd.begin(20, 4);
    • Next, we cleared the LCD screen, so if there's any garbage data printed on the LCD, it will be removed:

    lcd.clear();
    • setCursor command is used to set the LCD cursor at the specified position. Its first argument is "column position" and the second argument is "row position". In our case, we have set the Cursor at 6th Column and 1st Row. So, now when we print our message, it will be printed from this position.

    lcd.setCursor(5,0);
    • Finally, we printed our first message on the LCD using the print() command. The message string to be printed on the LCD is provided as an argument.

    lcd.print("ESP32");
    • At the end, we set the cursor.at 1st column & 2nd row, and printed the text:

    lcd.setCursor(0,1);
    lcd.print (" TheEnggProjects");
    

    As you can see, the LCD code is quite simple and I hope now you can easily print on the LCD. So, let's check the results:

    Results

    • Select the right development board from Tools >> Boards >> DOIT ESP32 DevKit V1 in Arduino IDE.
    • Compile and upload the code into ESP32 using Arduino IDE.
    • IF everything goes fine, your text messages will get printed on the LCD at the specified locations, as shown in the below figure:

    Common Errors faced while working on 16*2 LCD:

    • Texts are not visible: Backlight is ON but the texts are not visible (after uploading the code) as shown in the image below. To resolve this issue:
      • Check the potentiometer, whether it is connected properly or not.
      • Adjust the value of potentiometer to control brightness of the display.

    Fig. 6

    Only a single row with dark blocks is visible.

    Sol. : Check the EN pin.

    Fig. 7

    This concludes the tutorial. We hope you found this of some help and also hope to see you soon with a new tutorial on ESP32.

    Common Mistakes to Avoid When Investing in Technology for Your Venture

    Hello friends, I hope you all are doing great. In today's tutorial, we will have a look at the Common Mistakes to Avoid When Investing in Technology for Your Venture.

    Tech tools can make or break a business in this day and age, regardless of the industry or niche a venture is in. As such, it’s vital to source the best possible technologies that will help you make your organization the best it can be and the most likely to reach its goals. As you invest in technology, it pays to avoid some common mistakes.

    Mistake: Not Having a Plan

    Many entrepreneurs have a detailed business plan they created when they began or bought their business, but they fail to plan much for technology. It’s essential to have a vision and strategy for your technological needs so you don’t keep jumping from one system, app, or product to another with no clarity on why you need certain programs.

    A lack of planning can add to your total costs, too, since you’re more likely to have to keep buying new software to try to find the right things to suit your needs, rather than understanding from the start what’s required. Consider the various areas of your business and what you need in each.

    For example, think about your sales and marketing processes, HR and payroll requirements, finance and accounting needs, where you’re up to with strategic sourcing in 2022, customer service plans, and more. Where possible, invest in tech tools that can be used across different parts of your organization and that will integrate well, too.

    Mistake: Focusing on Trends Not the Best Fit

    With so many different tech products coming out all the time, it’s easy to be like a bowerbird and get distracted by shiny new objects in this field that seem fun and interesting. However, focusing on trends and the latest gear rather than what’s actually the best fit for your company and needs is a common mistake.

    Going down this path will mean you likely end up spending a lot more money than you need to on technology and buying devices or programs that aren’t suited to your business or are simply irrelevant. Instead, refer back to your tech plan to see if new products will provide the solutions you’re after and, if not, appreciate what they offer but don’t bother buying them.

    If you feel called to test a new offering, at least sign up for a free trial so you don’t have to outlay money on it. You can always cancel after the zero-cost introductory period if you can tell you really won’t use the software or that it doesn’t do enough for your needs.

    Mistake: Failing to Create a Budget

    Another common mistake many business owners and managers make is not creating a budget for technological items at the start of the calendar or financial year. When you have a budget in place, you stop and think twice before signing up for a subscription service when it releases or the latest gadget you hear other entrepreneurs talking about.

    A set budget specifically for tech goods keeps you on track financially and keeps you and your team accountable. Keep in mind, too, that every new tool you buy needs setting up and learning in some way, which is time-consuming. When you adhere to a budget, you’re less likely to end up getting bogged down with too many things to wrap your head around.

    Mistake: Not Taking Security Seriously Enough

    These days, hackers galore are continually working, and in ever-sophisticated ways, to break into networks and devices, steal data, lock and crash systems, and otherwise cause issues for individuals and organizations alike. As such, no matter the size of your business, it’s vital to take cybersecurity incredibly seriously.

    Unfortunately, though, many people get so busy with general day-to-day tasks that they forget about this area or think it’s something they can consider later (a time that never really comes until the worst happens). If you want to protect your firm’s and customers’ data from prying eyes and stop hackers from charging you ransom or stealing money, you need to spend plenty of time and energy upgrading your company’s security processes.

    Invest in quality, comprehensive security software and firewalls that protect devices and accounts. Ensure all computers and programs are kept updated at all times so there are fewer security gaps for hackers to take advantage of. Train your staff to be very careful about what links they click on and emails they open. They should choose solid passwords that can’t be easily guessed. Proper codes are at least eight characters in length, made up of a mixture of numbers, letters, and symbols, and changed every so often.

    Other mistakes to avoid include rushing into purchases, neglecting free downloadable tools, and not testing systems enough before going live or otherwise implementing them. Be wary of considering price only when evaluating products, as customer support, security, scalability, and other factors also matter.

    Technology can help us considerably to run our ventures but only when we invest in suitable options. Think about all these errors that others have made before you when buying tech tools so you can save yourself cash, headaches, and time.

    Writing First Code in Python (Hello World)

    The "Hello, World!" program is a computer programming classic that has stood the test of time. For beginners, "Hello, World!" is a simple and full first program that introduces the basic syntax of programming languages and can be used to evaluate systems and programming environments.

    The more you learn about Python, the more you may use it for your own purposes. Data analyst, application developer, or the ability to automate your work processes are all examples of jobs that can be automated.

    This Python 3 tutorial will show you how to create a simple "Hello, World" program. Python's basic syntax and components include the following:

    • Variable-types
    • Data structures
    • Math operators
    • loops
    • Different function calls
    • Input and output functions
    • Interfaces and classes
    • APIs memorize the syntax.

    Python`s IDE

    An IDE (Integrated Development Environment) is a software development tool. Integrated development environments (IDEs) include a variety of software development-specific tools. Examples of these instruments include:

    • Build, execution, and debugging tools
    • An editor intended to handle code (such as syntax highlighting)
    • The use of some type of version control

    There are many distinct programming languages supported by IDEs, as well as a wide range of additional functionality. Because of this, they can be very huge and take a long time to download and install. Using them correctly may necessitate additional training.

    Definition of function?

    A function is a piece of code that serves a single purpose and can be reused multiple times. Functions provide for greater modularity and code reuse in your program. Functions have the benefit of being well-known by a variety of names. Functions, methods, subroutines, procedures, etc. are all referred to in different ways by different programming languages. Think about what we'll be talking about later in this session if you come across any of these terms.

    Print function – What is it?

    Since you all learned Python by printing Hello, World! you might think that there is nothing new to learn about the Python Print function. As with any language, learning to use the Print function in Python or any other is like taking your first baby steps into a new world of programming. When studying a programming language, it's easy to get caught up in the more advanced concepts and lose sight of the simplicity and usefulness of basic functions.

    Today's tutorial is all about Python's Print function; you'll learn about one of the most underappreciated functions.

    For example, in Python3, parenthesis is required or else you'll get a syntax error as illustrated in the image below.

    In Python3, print () is not a statement but a function, as demonstrated by the above output. First things first, let's see what the print () function returns.

    Built-in functions and methods are returned by this method, which indicates that it is a Python function.

    A new line or vertical space between the two outputs can be added by simply using the print () function without sending any arguments in.

    The command Palette

    The Command Palette, which is possibly Atom's most essential command, is shown to us on that welcome page. The command palette will appear if you press Ctrl+Shift+P while in an editor pane.

    Writing the first Program

    Packages from the Atom community are available to help you assemble and run programs. We'll be utilizing "script" to run our application in this example.

    go to file>settings>install

    Install script by searching for it in the search bar. It should appear under "Packages" in the Settings menu after installation. Please be aware that script does not support human input. The "apm" package manager can be used to install packages on Mac OS or Linux.

    Creating our first project

    Go to File > Add Project Folder in atom and pick a directory to serve as the project's root directory.

    In the folder, right-click the folder and select "New File," type "hello."py," and click "OK."

    Now that you've made your adjustments, you can open the new file in the editor by clicking on it and then saving it.

    Then, in the Print dialog box, type "hello, world!"

    To execute the script, use CTRL+SHIFT+B. You may also use View > Toggle Command Palette and type Script: Run to execute a script.

    You can also use your terminal to run the python file by navigating to the file directory containing your hello.py file and running this command

    python hello.py

    How to edit and save files in atom

    File editing is rather simple. You can use your mouse and keyboard to navigate and edit the content of the page. A separate editing mode or key commands are not provided. Take a look at the list of Atom packages if you prefer editors that have modes or more advanced key commands. Many programs are available that mimic popular design elements.

    You may save a file by selecting File > Save from the menu bar or by pressing Ctrl+S. There are two ways to save the current material in your editor: by selecting File > Save As or using Ctrl+Shift+S. Finally, you can save all open files in Atom by selecting File > Save All.

    How to open directories in atom

    The majority of your time will be spent working on projects with numerous files, not just single files. Take advantage of the File > Open Folder menu option and select an appropriate folder from the drop-down menu. File > Add Project Folder or hitting Ctrl+Shift+A can also be used to add other directories to your current Atom window.

    The command line utility, atom, allows you to open unlimited number of directories by supplying their paths to it. The command atom./hopes./dreams, for example, can be used to simultaneously open the hopes and dreams directories.

    An automated Tree View will be displayed on the side of Atom if one or more directories are open.

    When you use the Tree View, it's a breeze to see the whole file and directory structure of your project. You can open, rename, and delete files, as well as create new ones, using this window.

    In order to toggle between concealing and showing it, use Ctrl+, use the tree-view: toggle command from the Menu Bar, or press Alt+ to bring focus to it. The A, M, and Delete keys can be used to add, move, or remove files and directories in the Tree view. It's also possible to access these choices by right-clicking on a file or folder in the Tree view, as well as copying or pasting its path into your clipboard.

    How is python executed?

    Unlike functional programming languages that used a single long list of instructions, Python uses code modules that may be switched out. Cpython is the default Python implementation. It is the most often used Python implementation.

    Python does not translate its code into a form that hardware can understand, known as machine code. As a result, it turns it into byte code. Python does have a compiler, but it doesn't compile to a machine language. CPUs are unable to decode the byte code (.pyc or.pyo). We'll run the bytes through Python's virtual machine interpreter.

    To convert a script into an executable, the Python source code follows these steps:

    First, the python compiler reads a python source code or instruction from the command line. It ensures proper formatting of the instruction by inspecting the grammar of each line. The translation is immediately interrupted if an error is found, and an error message is presented.

    Assuming there are no errors and the Python source code or instructions are properly formatted, the compiler proceeds to translate them into a form known as "Byte code," which is an intermediate language.

    The Python interpreter is invoked by executing bytes of code in the Python Virtual Machine (PVM). PVM is a Python virtual machine (PVM) that turns bytecode into machine code. If there is a problem with the interpretation, the conversion will be interrupted and an error notice will be displayed.

    Conclusion

    Congratulations for completing your first program. Beginners who want to learn Python can benefit greatly from this guide. To get the most out of this lesson, you may want to play around with the Print function a little more and discover more features that were not covered.

    High Density Interconnect PCB

    The printed circuit board is a type of plastic where electrical and electronic components lie, laminated and fixed. In modern days, there has been increasing in the complexity of electronic components and devices and this has also led to high demand for more complex PCBs that can make this achievable. This exclusive board that has been introduced in the market includes HDI, rigid-flex, Aluminium clad, buried and blind or even a blend of all the listed types.

    There is a list of so many PCB types that a designer can choose for any type of electronic project ranging from single layer PCB to other complex types like the multilayered PCBs. In general, the simplest type of PCB contains copper tracks and interconnection between the elements and components on one side of the board. These types of boards are classified as single-sided boards or one-layer side of boards. However, there are other types of boards that are complicated and will require complex methods to do their designs. These boards are probably double-layered or even multilayered.

    Multilayered boards are such complex boards that will require advanced technology for their manufacturing. This is where HDI boards come into play. HDI stands for High-Density Interconnect Boards. When addressing high density interconnect boards, we are focused on higher wiring density, the smaller vias, the thinner spaces and the higher pad density that accompany this type of board. This type of board has a lot of advantages over the typical circuit boards.

    Definition of HDI Boards

    PCBs are made up of components that are interconnected and fixed on them. The components are connected by wiring them on the board. The wiring is in form of tracks and traces. Some boards involve small low density of wiring capacity per unit area while others involve very high density wiring capacity per unit area. HID which is an abbreviation of the high density connect boards are boards that have a high density of the wiring capacity per the unit area when you compare with the normal PCBs.
    • These boards are very special as they come with finer lines, tiny vias and a high connection density of the pads than the one that is utilized in the normal boards.
    • A good HDI PCB should have one or all of the following;
    1. Blind and buried vias
    2. Micro vias
    3. Build-up lamination
    4. Considerations of high signal performance.
    • The HDI boards are very compact with small vias, micro-vias, spaces, pads and copper traces.

    How to manufacture HDI PCB?

    There are many online PCB companies that offer to manufacture High-Density PCBs. The one we highly recommend is PCBWay, china based PCB Manufacturing House. They offer the best quality product, within a specified time and have an excellent support team, ready to guide you throughout the process.
    • In order to manufacture HDI PCB, log in to the PCBWay official site.
    • Now click on the PCB Calculator, and at the top click on Advanced PCB, as shown in the below figure:
    • In the PCB Type, select the HDI option, I have encircled it in the above figure.
    • AS you can see for a single piece HDI PCB of size 100x100mm, the price is $333 and the shipping cost is $22 to USA.
    • HDI PCBs are highly cost PCBs and are thus used in industrial products.

    Variations in HDI PCBs.

    HDI PCBs use vias and laser-drilled microvias to connect components between different multilayers. The microvias are the most preferred to offer the connections because they are much smaller and very effective when it comes to space utilization.

    • We have at least five variations of the vias and microvias that can be used in the process of manufacturing the HDI PCBs.

    Stacked vias

    This can be either buried or blind vias which have a very important function of connecting circuits between different layers of the printed circuit board and in this case across three or more circuit layers as shown in the figure below;

    Stacked microvias

    They can either be blind or buried but they are conical in shape. They are vert small and they still do the function of connecting circuits between layers of the PCB as shown in the figure below.

    Staggered vias

    When we have vias of a certain PCB layer connected without overlapping, they actually form a staggered via as shown in the figure below.

    Staggered microvias

    They are conical in shape but they are connected without overlapping hence forming a staggering structure as shown in the figure below;

    Via in Pad

    This are vias that are connected to the pad where component is lied. They are very common in HDI PCBs.

    HDI structure

    There are mainly two structures that aren used in the manufacturing of the HDI;

    1. Buildup structure
    2. Any-layer structure

    Buildup structure

    This is the basic structure of the high-density interconnect PCB and uses the manual mechanical drilling as well as the laser drilling.

    • The first step is the lamination of the core, it is drilled by the use of the mechanical drilling, platting is done before it is finally filled.
    • Microvias are added to the core, followed by the drilling, filling and the whole process is repeated.
    • The N- buildup structure is made up of the formular N+C+N where N and C represents the number of the microvia in each side of the core and the core respectively.
    • The figures below shows an example of the N-buildup structures using the 1-buildup and the 2-Buildup

    Any layer interconnect technology

    This is an advanced technology that is used in the manufacturing of the HDI PCBs. The method is highly preserved for the high-level interconnection use since we can make connection of any of the two layers of the PCB without any form of restrictions. This means that any-layer connection has a lot of flexibility when it comes to doing these connections.

    • Because there is no any restriction on how the connections should be made, this leads to the saving of the board spacing to about 30%.
    • However, the cost of doing this board is higher and this is due to the complexity regarding the technology involved.
    • Unlike what was done in the buildup, here the micro-via is drilled first by the use of the laser drilling, followed by the repeated copper platting process, transfer and pressing of the inner image, and finally transferring of the outer layer imaging.
    • The figure below is a simple demonstration of the simple any-layer manufacturing process.
    • The drilling process is done by the use of the carbon dioxide laser drilling machine
    • The micro-via are made by the copper filling technology which will do the coper filling by the process known as the vertical continuous platting line and the horizontal plate line.

    Benefits of the HDI printed circuit boards.

    This technology has found great importance in the smartphone and the tablet manufacturing. Apart from that, they have become of great use in the laptops and desktop computers. The following id the great benefits of the HDI PCBs;

    1. Tighter designs; when we have a look at the high density interconnect PCB, we will realize that the board has very high intensity nature of circuit network connection. This high intensity implies that, the board takes literally less physical space. Utilization of design features such as blind and buried vias enables the designers to come up with more compact builds and this will make the HDI circuits very versatile.
    2. Reliability; the connectivity that is employed in the design of the HDI boards such as the use of the blind vias and the buried vias makes them more physical reliable. This is because such types of connection are less likely to get compromised.
    3. Lighter material; the material used is very light and cooler. The traditional and other PCBs use different variety of materials but the common one is the combination of copper, aluminium, fiber glass and other metals which might prove to be bulk. This is not the case with the HDI boards.
    4. Sharper signals; since these types of the PCB has more compact systems, then the outcome is that the signals will have a very short distance to travel hence avoiding much disturbances that comes in with the long-distance travel. This advantage makes the signal rich their destination undisturbed hence sharper performance of the board.
    5. Pocket friendly; four layers of the HDI boards are enough to perform all the functions of the standard PCB layer. The board having reduced size, it implies reduction in the coast too.
    6. Low power consumption; these types of boards have high number of transistors and also signals travel a very short distance. These features play a greater role in reduced power consumption in these types of boards.

    Common uses of the HDI boards.

    These types of boards have found many areas of use in the modern world of technology. Let us have a look at a few areas where the high-density interconnect boards are used;

    Healthcare

    Due to the smaller size of the HDI boars, medical designers have found great interest in this type of board. The medicals equipment are compatible with HDI because they are very small and can fit into them for example in implants and also in the imaging equipment. The equipment play a very significant role in the treatment of the ailments and therefore smaller chips that require less intervention have to be used. Let us take an example of a heart pacemaker that is implanted in the heart to regulate the speed of the heart bit. The pacemaker should be very tiny and therefore the HDI has provided boards that can solve the size of the pacemaker issue. another good example is the colonoscopy which is passed through the colon of a human to carry out the colon examination. It is evident through research that so many people avoid the colonoscopy examination due to the painful experience but the availability of the HDI technology has drastically reduced the size of the camera and improved the visual quality of the same camera which has made the colonoscopy process less painful hence triggering the increased number of people searching for the service.

    Aerospace and military.

    Military use strategic equipment such as the missile and some other defense communication devices. This equipment utilizes the HDI technology in their boards since it is the only efficient available method. there have been greater changes in the aerospace technology and HDI have always provide the need solution. Communication devices such as the wireless pones and trackers are becoming very tiny in size and this is due to the involvement of too many tiny layers of the HDI boards.

    Automotive industry.

    The car and other automotive manufacturers are falling in love with the HDI boards simply because with this type of board you are assured of greater discoveries and innovations. This boards allows the saving of more space in the vehicle and also have an increased performance of the same vehicle. To be specific, Tesla uses the HDI technology to run the electric car system where it helps in extending the battery life of the system. Other driver assistants such as cameras, tables etc fit on the dashboard without much problems.

    Digital devices.

    Let us make a comparison of todays digital devices like the smartphone with what we had 10 years ago and you will make note that there is a very big improvement in size, thickness and weight. This has been made possible by the use of the HDI boards in this area. Thinner and more compatible smartwatches are also a product of the HDI boards.

    Advantages of the HDI PCBs

    • Compact design; the strategic use of the burred and blind microvias makes the board compact and this leads to spacing.
    • High reliability; the preferred use of the stacked vias makes the board to have a super shield against the harsh environmental conditions.
    • Phenomenal versatility; this board is ideal where weight, size and the performance are of great consideration.
    • Cost effective; the functionality of a 6- layer standard PCB can be reduced to 4-layer HDI board without altering on its intended purpose.
    • Better signal integrity; vias and pads and blind technology is what is mostly used in the HDI. It also has very short compact trucks or traces and this reduces the chance of the signals being interfered by the external forces hence achieving of very high signal integrity.

    Mathematical Calculations in Ladder Logic

    Hi friends, today we are going to explore mathematical computations in ladder logic. Like in any programing language you should find logic and mathematic computations, here in PLC programming you often need to process the input data that is collected from reading analog devices like temperature, level, flow et cetera. Then you need to run some calculations on this data to derive some other variables for deciding to run or stop some device or even to determine analog output to output to analog device i.e. valve or actuators. In the following sections, we are going to explore the mathematical functions and their input operators and outputs as well. Then we will show how to utilize such functions in ladder logic with simple examples and as usual enjoy practicing them thanks to the PLC simulator.

    What are mathematical operations we have

    You may find some minor changes in the set of mathematical functions from brand to brand of PLC controllers. However, you will find in most of them are common in every controller. For example, you will find the basic mathematical functions are available like addition, subtraction, multiplication, division, negation by applying two’s complement, modulus, increment and decrement, absolute, maximum, and minimum. In addition, trigonometric functions like sine, cosine, tangent are included. Let us go over these functions and explore their operators and output and how they can be utilized in PLC ladder logic programming.

    Functions operators and outputs

    For all these functions, they have input operators and one or more returned outputs. Most of them have two inputs like addition, subtraction, multiplication, and division. While some have only one input parameter like negating function, maximum, and minimum. And they all have only one input. Table 1 lists all these functions and their input operators and output.

    Table 1: the functions’ input parameters and outputs

     

    Operator and Output values data types

    It is very important to be familiar with the type of data you are trying to process using these mathematical functions. So, simply you just need to know that the smallest size data type is a bool data type which is true or false or “1” or “0” and it uses only one single bit. Then character “char” or byte data type which is 8 bits while word data type is formed of 2 bytes or 16 bits and that is the word size in PLC. Also, there are doubleword data types that occupy 4 bytes or 32 bits. Moving to mathematical data types there are integer data types that can be stored in one word and the double integer “DINT” which can be stored in two words or 32 bit for holding numbers up to = 4294967296 for unsigned integers and half of that value for signed integers. Also, there is a real data type for holding numbers with floating-point. It needs 2 words or 32 bits and for a long real LREAL data type extends to 4 words or 64 bits.

    How to use the mathematical function in ladder logic

    In the TIA portal for siemens, there are two ways to add mathematical functions in a rung of ladder logic program. Figure 1 shows the first method which uses an empty box in the block interface and then you can select the function and its inputs and outputs parameters.

    Fig. 1: Adding an empty box for including math functions

    Figure 2 shows a list of functions from which you can choose the mathematical function you want to use.

    Fig. 2: A list of math functions to select

    Figure 3 shows another way to add a mathematical function by going to the basic instructions and then going over the math functions on the most right part of the window as shown and selecting the function you want to use.

    Fig. 3: The second way to add a mathematical function

    Figure 4 shows how to define the input and output parameters of the used mathematical function. For example, in figure two input parameters are defined as the function’s input operators which are literal number five and variable “x” which is predefined as an integer in the variable declaration section in the middle top section. Also, the Variable sum is defined as an integer. So the add function will add X to 5 and assign the result to variable Sum.

    Fig. 4: Defining function parameters and outputs

     

    Mathematical function ladder example

    In this example, we are going to show how mathematical functions can be used in a ladder logic program and also show the simulation results. As in fig. 5, we design a simple calculator that uses the mathematical functions and each function can be triggered by a switch on a contact that is connected in series to the enable line of the function box.

     

    Addition function math example

    Figure 5 shows an additional example in ladder logic. It shows two operators A and B of integer data types. The variable A is located at address MW2 and variable B is located at address MW4 while the result is stored in variable RES which is located at address MW6. All of these variables are of type integer and size one word or 32 bits. The figure show simulation results on the PLC simulator and shows the RES variable holds summation of A and B.

    Fig. 5: Addition function example

     

    Subtraction math function example

    Figure 6 shows a subtraction example in ladder logic. It shows two operators A and B of integer data types. The variable A is located at address MW2 and variable B is located at address MW4 while the result is stored in variable RES which is located at address MW6. All of these variables are of type integer and size one word or 32 bits. The figure shows simulation results before triggering the subtraction function on the PLC simulator. So, the RES variable holds zero before enabling the function.

    Fig. 6: Subtraction function example not triggered

    Figure 7 shows the simulation results after enabling the subtraction by switch or the “SUB” command contact. The Res variable now reflects the results of subtraction.

    Fig. 7: Subtraction function example in ladder logic programming

    Multiplication math example

    Similarly, Fig. 8 shows an example for performing the multiplication process. First, the “MUL” is selected and two input operators of multiplications are given and output. The simulation result shows the RES variable holds the result of multiplication of the input operators.

    Fig. 8: Multiplication function example in ladder logic programming

       

    Division function example

    Similarly, Fig. 9 shows an example for performing the Division process. The “DIV” is selected as an instruction to be executed and two input operators of division are provided and output. The simulation result shows the RES variable holds the result of the division of the input operators.

    Fig. 9: Division function example after triggering

     

    MOD function example

    Similarly, Fig. 10 shows an example for performing the MOD function process. The MOD function determines the remainder of the division process, in this example we are dividing 25 by 10 which gives 2, and the remainder of 5. “MOD” function firstly is selected as an instruction to be executed and two input operators of MOD function are provided and output. The simulation result shows the RES variable holds the remainder of the division of the input operators.

    Fig. 10: MOD function example in ladder logic programming

    General calculation

    Now, one may ask how I need to do the calculation in form of an equation that has many processes? This is a very smart question! Many programming tools support this, fortunately. For example, in Siemens, there is a function called “calculate” which can take two inputs and perform mathematical equations on these two variables and return the result in an output variable as shown in Fig. 11. It shows the function which is called “CALCULATE” and it has two inputs “IN1” and “IN2” and one output “OUT”. I triggered the help to show you an example that states OUT can be determined from the equation in inputs and also shows all functions that can be used including logic and mathematical functions. So we can use this function, in general, to act like any mathematical or logical function separately or by combining two or more functions in one equation.

    Fig. 11: Using equations in ladder logic

     

    Example of performing equation in Ladder logic

    As you can see in the given example in fig. 12, the output variable can be determined based on multiplying the summation and subtraction of the input parameters as an equation. The result of the program is validated with a calculator.

    Fig. 12: Using equations in ladder logic

    Combining mathematical function

    There is another way to perform combine many mathematical functions as shown in fig. 13. As you can notice, the output variable “out” can be determined by multiplying the summation of input variables “in1” and “in2” by “in1”.

    Fig. 13: Combination mathematical function in ladder logic

    Negate function

    Negate function is one example of a single operator function in ladder logic programming. it reverses the sign of the input variable. For instance, fig. 14 shows an example of converting the sign of input variables “in1” to show the negative value reflected in the result in “res”.

    Fig. 14: Single operator mathematical function in ladder logic programming

    Absolute function

    Figure 15 shows an example of getting the absolute of variable “RES” and saving it in variable “b”.

    Fig. 15: Absolute function in ladder logic

    Minimum and maximum in ladder logic

    Getting minimum and maximum is one of the most frequently used in the mathematical operation. Figure 16 shows an example for getting a minimum of two input variables “in1” and “in2” while fig. 17 shows an instance of getting the maximum of two input variables as well.

    Fig. 16: Getting a minimum of two input variables in ladder logic programming

    Fig. 17: Getting a maximum of two input variables in ladder logic programming

     

    Decrement and increment in ladder logic

    One of the most commonly used functions is incrementing and decrementing one variable. For example, the counter variable all the time gets incremented and decremented through the logic of the program. Figure 18 shows an example for decrementing and incrementing an input variable. First, the initial value of the variable was 15, and then after incrementing it. The variable became 6 and then by applying decrementing operation it return to 5. It is very crucial to notice that, the user variable in increment and decrement operation works as input and output at the same time. Therefore, you can see in the increment and decrement blocks, it is defined as input-output “input”.

    Fig. 18: Increment and decrement operation in ladder logic

    Limiting variable in ladder logic

    Now, let us use one of the very useful functions to secure a variable at specific limits. Figure 19 shows an example of limiting the value of one variable “in” to be sited between the specified minimum and maximum values. In that very example, the input variable has had a value of 5 and because it exceeds the set limit of maximum it is set to 4 which is the maximum allowed value to the variable thanks to the limit function.

    Fig. 19: limiting variable in ladder logic programming

    Trigonometric functions in ladder logic

    Also, trigonometric functions like sine and cosine and other related functions can be executed in ladder logic. Figure 20 shows one example of how to use a sine function in ladder logic. The first rung in the example shows how to convert the degree into rad thanks to mathematical functions multiply and division. Ultimately, the sin function block is used to determine the sine of the given angle in rad.

    Fig. 20: Triogonometrical function in ladder logic programming

     

    What’s next

    I am so happy that you be that patient to reach these points of tutorial and you know got familiar with most of the mathematical functions and how to use them flexibly through your program. The next round will go with the comparison operators and more deeply in mathematical logic flow using operators such as >,<,>=,<=, and ==. So please be ready for our next session of that ladder logic tutorial.

    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