Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: How to use PLC with SQL Database? – Basics & Tutorials
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > How to use PLC with SQL Database? – Basics & Tutorials

How to use PLC with SQL Database? – Basics & Tutorials

Everyone knows how to integrate SCADA with various database systems. Learn how to use PLC with SQL database and basic tutorials.

Last updated: January 5, 2024 12:03 pm
Viral Nagda
PLC Tutorials
1 Comment
Share
9 Min Read
SHARE

In today’s world of industrial automation, data is a very important part. Getting instant data from sources and using them for different purposes is as crucial as running a system.

Contents
PLC with SQL DatabaseScheduler PLCSequencingSynchronize multiple PLCsHandshakingPLC Database Basics

Everyone usually knows how to integrate SCADA with various database systems, like SQL servers. However many ignore the power of PLC in integrating with databases. They too can be used for this purpose.

PLC with SQL Database

How to use PLC With SQL Database

If we use PLC, programmers can work with them in emergency situations like SCADA failure and get their work done by coding it appropriately. In this post, we will see how to use PLC with SQL database.

For those who are not familiar with SQL server, it is a database management tool which stores a large amount of data in real time format sequentially, and queries are written in it either through some external source, like a PLC, for retrieving data.

For storing data in it, logic is written in PLC which when executed stores data in SQL. This is a simple concept, which is explained further in the post more briefly for it’s advantages.

Scheduler PLC

Suppose you have a very large-scale system where the operator has to feed hundreds of time schedules for operating particular functions every day. Instead of using vast coding and variables in PLC for storing data entered in SCADA and operating it once the time arrives, just feed all the variable data to the SQL server through PLC every time a new recipe is created.

The SQL will store real-time date and time of the values entered and will give operators option of choosing them according to date and time filtered. For example, the SQL has five entries from 1st Oct to 5th Oct for various types of schedules entered. The benefit is that the operator can choose any one required and then run the system.

If SQL was not there, he would have to run only one option of either 1st Oct or any other date. Or else, he would have to utilize memory of SCADA or PLC, which is waste of data and coding. This same thing becomes easier through SQL server.

Another advantage is that SCADA code size becomes reduced and it would be used for other purposes. Scheduling is used in many applications and using PLC for it along with SQL makes system more efficient.

Sequencing

Consider a plant having 10 sequences. Every sequence has a barcode reader in it for starting the action on the required product. If the barcode is read in SCADA, then the corresponding data feed to PLC or in short, SCADA is the medial intervene for initiating communication between PLC and data; then just directly connect PLC with SQL.

SQL will directly communicate with PLC for determining barcodes and other data for starting or stopping a sequence. Such bulk data from plant sequences helps reduce coding in SCADA and makes system faster to operate. Because PLC is written with coding for sequence operation, why not directly connect it with SQL and use the system.

Synchronize multiple PLCs

There are many applications where one PLC in a location needs data from another PLC location for doing a work. In that case too, traditionally SCADA is used for integrating all the PLC’s and managing them.

In that case, if PLCs are directly connected to the SQL server, data will be synchronized through the date and time of SQL; thus, eliminating problems of multiple RTC (real-time clock) synchronization of PLCs.

Also, PLC will directly communicate with other PLC for asking any data or give any data through the SQL server. Any alarm or event in a PLC will also be communicated to other PLC and would help in tracking real-time records.

Handshaking

Handshaking is a process where one party is acknowledged by the other party that the job has been completed. Basically, it is a response required so that the party can start its other work. This method works well with PLC and SQL servers.

The SQL server can directly communicate with PLC by sending event notifications in real time, or alarm notification data in real-time. This means, suppose that the job has taken 3 days to complete.

Then the completion acknowledgment will be sent as a separate event to the PLC, and as it also has 3 days of data in it, the operator can view the whole process in SCADA reports easily. So, handshaking is an important reason for communicating PLC with SQL directly.

PLC Database Basics

  • Establish a connection between the PLC and the SQL database using middleware or a gateway that facilitates communication between industrial network protocols and database languages.
  • Select a communication protocol that both the PLC and the SQL database can understand, such as OPC UA, Modbus TCP, or any other protocol supported by your PLC and middleware.
  • Configure the PLC to send and receive data by setting up the necessary parameters, registers, or tags that will be read from or written to. This might involve programming the PLC using its respective software to ensure it’s ready for data exchange.
  • Set up the SQL database by creating a new database or configuring an existing one to store data from the PLC. Define tables, columns, and data types that align with the data structure being sent from the PLC.
  • Map each PLC data point to the corresponding field in the SQL database. Ensure that the data types are compatible and that the mapping makes logical sense for the application’s needs.
  • Implement data transfer logic using scripts or database stored procedures. Determine how often data should be transferred, under what conditions, and whether the transfer should be triggered by events or on a schedule.
  • Test the communication between the PLC and the SQL database thoroughly. Check for any errors or data mismatches and ensure that the system behaves as expected under various conditions.
  • Continuously monitor the system for operational integrity, data accuracy, and any anomalies. Set up alerts or notifications for system errors or significant events.
  • Regularly review and update the system as needed to accommodate changes in the PLC setup, database structure, or additional requirements. Keep documentation updated for any system changes.
  • Ensure security measures are in place for both the PLC and the SQL database to protect against unauthorized access and data breaches. Consider implementing encryption, firewalls, and secure access protocols.

If you liked this article, then please subscribe to our YouTube Channel for Instrumentation, Electrical, PLC, and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

  • What is Distributed IO in a PLC?
  • Inputs Sharing Between PLC Systems
  • PLC Multi-Motor Control for Beginners
  • Siemens Communication with I-Device
  • PLC Programming Projects for Beginners
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

RSLogix 5000 PLC Programming Procedure
Types of Script in Intouch Scada
Typical HMI Screen Design for Water Treatment Plant
Latched and Momentary Operation of Motor PLC Program
Basics of 4 to 20 mA analog Signals
Procedure for Reading or Searching the Tag number in Siemens PLC
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
1 Comment
  • Uendel Alvarez da Silva says:
    January 15, 2024 at 8:46 pm

    Amazing this article!!! Thank you so much!!

    Reply

Leave a Reply Cancel reply

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

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
210kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

Difference between Power Cables and Signal Cables
Use of Comments in SCL Language
How to Read the PLC Datasheet? – Important Notes About PLC
Difference between DCS, PLC, and RTU ?
How to Save a PLC Project to a Micro Memory Card?
Two Hand Control Logic using PLC
System Cabinet Health Checks – PLC and DCS Industrial Automation
Check Block Consistency Tools in Simatic Manager

Keep Learning

Classic Control Circuits

Motor Classic Control Circuits using Single Push button

Design Counters in PLC Programming With a Move Instruction

Design Counters in PLC Programming With a Move Instruction

factorytalk view studio hmi

How to Create Templates in FactoryTalk View Studio?

Instrumentation During the Detail Design Phase

Instrumentation Engineer Activities & Documents – Detail Design Phase

PID parameters

PID in Siemens TIA Portal

Compare Servo Motor and Stepper Motor

Compare Servo Motor and Stepper Motor

PLC Program using Counters

PLC Counters Program

Top 100 PLC Objective Questions and Answers

Top 100 PLC Objective Questions and Answers

Learn More

logic-gates-questions-and-answers

Logic Gates Questions and Answers

Three phase inverter Animation

Three Phase Inverter Animation

Thermocouple Standard

Thermocouple Details

Parallel Disk Gate Valve

Classification of Gate Valves

absorption-type optical analyzer

Absorption Type Optical Analyzer

Different Control Modes of Air Handling Unit (AHU)

Control Modes of Air Handling Unit (AHU) – HVAC Basics

PLC Program to Energize & De-energize the Outputs based on Events

PLC Energize or De-energize the Outputs based on Events

Illumination Objective Questions

Illumination Objective Questions

Menu

  • About
  • Privacy Policy
  • Copyright

Quick Links

  • Learn PLC
  • Helping Hand
  • Part Time Job

YouTube Subscribe

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?