Beckhoff#TwinCAT3 TF6420 x MongoDB_Part1

Did you know that TwinCAT can support the NOSQL Database?

This time we will use Beckhoff TwinCAT3 and TF6420 to connect to MongoDB installed on Raspberry pi4 and send commands.

First, we will have a brief introduction to TF6420 and how to add a DB to TwinCAT3.

Let’s start!

TF6420?

Here is an overall structural drawing of the TF6420 TwinCAT.

Basic concept

The TwinCAT Database is designed so that all TwinCAT Users can easily connect Controller and Database.

Configure mode

Connect the Database from a graphical configuration without having to implement a program.In Configuration Mode, the bulk of the work is done by the configuration tool. Once the necessary Database and AutoLog groups are configured, communication is automatically established directly with the configured Database when TwinCAT is started. If Manual Mode is selected, it can be enabled with Function Block “FB_PLCDBAutoLog” or “AutoLog.

PLC Expert mode

This is a Solution for PLC Programmers, which connects to a Data base based on the PLC Function Block, and almost all Database commands are automatically generated from the Database Server.

In this mode, only Database settings are configured from the Configurator, while other functions are implemented in the PLC code.

And with the Function Block FB_PLCDBCreate, the database itself can also be configured from the PLC without using the Configurator. Of course, TwinCAT also provides Function Blocks for reading and writing data.

SQL Expert mode

SQL Expert Mode allows you to assemble SQL commands such as Insert, Select, and Update in the PLC and send them to the database via TwinCAT Database Server. This is a very flexible and powerful option. Stored procedures in the database can also be called from the PLC.

NoSQL Expert mode

NoSQL Expert Mode allows you to compile NoSQL Queries such as Insert, Find, and many other database-specific Queries and send them to the Database via TwinCAT Database Server. New data schemas such as hierarchies and arrays can also be supported.

Implementation

The first MongoDB Connection Tutorial introduces the settings and notes for connecting TwinCAT’s Database Server and MongoDB.

Reference Link

Mongodb#Let’s install Mongodb in your Pi4
MongoDB#Install in Ubuntu
MongoDB#Basic Operation

Configuration

Add TwinCAT Database Server Project

From Solution, right-click>Add>New Item.

Select Installed>TwinCAT Connectivity>Empty TwinCAT Database Server Project>Ok.

Done!New TcDbServer has been added.

Add New Database

Next, let’s add a new Database from TcDbServer: TcDbServer>Right click>Add New Database.

Done!A new DB has been added.

Double-click DB to add a DB Server and other detailed settings.

Select Database Type

First select the Database Type type.

This article uses MongoDB, so let’s configure as MangoDB.

Done!MongoDB’s Configuration has appeared.

Connection String Type

Standard Connection String Format You can leave it at Default.

Server

Server is the IP:port of the device on which MongoDB is installed. In this example, it is 192.168.5.144:27017. (27017 is the Default port for MongoDB).

In fact, if you want to check the MongoDB connection path, it is more convenient to use VSCode’s MongoDB plugins:Go to  CONNECTIONS>Right click>Copy Connection String.

In practice, you can get a Path like this.

mongodb://192.168.5.144:27017/

Database

This is the Database name to access the TwinCAT TF6240. If the corresponding Database is not found, TwinCAT will create a new one on the Server.。

Autherication

This time, there is no authentication, so the Authorisation Field is left as None.

Check

When the DB connection settings are complete, the Connection String displays the DB access Path.

Click the CHECK button to test the connection.

Done!The connection was made without any problems.

If Error…

If you cannot connect TwinCAT to the Database Server, you can find the relevant error information in the Error List.

DBID

This DBID is very important when programming the next Implementation.

Download

Download Configuration to Runtime. TcDbServer>Right click>Active Configuration. 

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする