Tag Archives: modbus

Suppanel Android HMI to Click PLC

Suppanel is an Android app that is used to create a human machine interface (HMI). This HMI panel can be created on your computer, tablet or phone using the appropriate operating system or software. You can use this software to create panels that you can control or modify values in your automated system. These panels can be shared with other Suppanel users.

We will be creating a Suppanel Panel to monitor and control a Solo Process Temperature Controller via the Click programmable logic controller (PLC). The Click will be communicating to the Solo with serial RS485 using Modbus RTU protocol. The Suppanel HMI will be communicating to the Click PLC using Ethernet Modbus TCP protocol.

Watch on YouTube : Suppanel Android HMI to Click PLC

Let’s get started. Continue Reading!

BRX PLC AdvancedHMI Communication – Modbus TCP

Advanced HMI is a powerful, adaptable HMI/SCADA (Supervisory Control and Data Acquisition) development package that takes advantage of Visual Studio. There is no coding required and you can simply drag and drop items onto the page. The best thing is that the software is free. We will look at using AdvancedHMI with the BRX Series PLC.

Our sample BRX PLC program will display a digital panel meter and a gauge of a value in the PLC. Stop and start momentary pushbuttons on the HMI will allow this number to increase or stop. An indication will turn green when the number is increasing and red when it has stopped. The AdvancedHMI package will communicate Modbus TCP over Ethernet to the BRX PLC. We will be able to monitor our process via the AdvancedHMI window. Lets get started. Watch on YouTube…
Continue Reading!

Modbus RTU Click PLC Master to BRX PLC Slave Communication

Recently I was asked to demonstrate communication between a Click PLC and BRX PLC using Modbus RTU. Both PLCs are available from automation direct com. Modbus serial communication (Modbus RTU) is a standard protocol used in many automation devices. It works on a Master / Slave configuration. You can have only one master per network on Modbus RTU (Remote Terminal Unit). A maximum of 32 devices (Nodes) on the network can communicate to the master. A review of the Modbus RTU protocol (RTU frames) can be seen at the following URL.
http://www.rtaautomation.com/technologies/modbus-rtu/
Using the Click PLC as a Master we will be communicating to the BRX PLC (Slave). Our example will read 10 registers from the BRX PLC and write 10 registers to the Click PLC. Let’s get started! Keep on Reading!

Implementing the Solo Process Temperature Controller

The SOLO Temperature Controller is a single loop dual output process temperature controller that can control both heating and cooling simultaneously. It is available in 1/32, 1/16, 1/8 and 1/4 DIN panel sizes and is UL, CUL and CE approved. The name of temperature controller is deceiving. This unit will also accept voltage and current into them, which is great for process control.

Recently I was asked: How you can change the pressure value from PSI to Bar?

They were bringing into the controller a voltage signal. This can be scaled using the tP-H (High level signal) and tP-L (Low level signal). The units on the display scaled for you. The default is -999 to 999. See section 11-2 of the following information guide that comes with the controller. Continue Reading!

Click PLC Send and Receive Instructions

Receive and Send instructions will allow you to send and receive serial data to an external device. The communication method that you setup can be ASCII or Modbus. ASCII (American Standard Communication for Information Interchange) can be used to send to devices such as a printer. Receiving ASCII can be used for connecting barcode scanners to the PLC. The barcode will be read as an ASCII string in the PLC. Modbus serial communication (Modbus RTU) is a standard protocol used in many automation devices. We will demonstrate the Send and Receive instruction by communicating Modbus to a Solo Temperature Controller. Our example will read the current process (PV) value and write the set point value (SV) in the controller.  Keep on Reading!

Click PLC Program Control Instructions

The program control instructions will allow us to specify what parts of the logic get solved and when this happens. This will control how the PLC will scan and solve your logic in your program.  Keep on Reading!

Click PLC Installing the Software

Previously we discussed the Click PLC System Hardware. Today we will be installing the free software required to program the PLC. This includes the actual program and communication drivers.  Keep on Reading!

Click PLC System Hardware

Many people ask me what I do when looking at a new PLC model or system. My approach is very straight forward and we will view this in action with this Click PLC series. This series will go from examining the hardware to programming and communicating to the PLC in several ways. If you have questions along the way, please let me know. Keep on Reading!

Modbus TCP Data Logging to Database

Using Visual Basic 2015 we will log three holding registers from the PLC along with time and date into a Microsoft Access Database. We will log every minute into the database with the information that we collect from the PLC via Modbus TCP (Ethernet). All code will be done and shown so you can implement this in your application with different parameters. The information collected in the database can then be distributed or analyzed in the future.ModbusTCP MSAccess 010-min

Visual Basic 2015 will be used with the EasyModbusTCP client/server library for .net. We will communicate to an Automation Direct – Do-More PLC. Using the free simulation software of the PLC Designer Software, we will retrieve three values of the Modbus Holding Registers using Modbus TCP. Once we have this information out of the programmable logic controller it will be placed in a Microsoft Access (2010) Database. This will be done by using a SQL command to insert the data.

Automation Direct has a powerful simulator with their Do-More PLC. The PLC software is available from Automation Direct as a free download.
http://support.automationdirect.com/products/domore.html

ModbusTCP MSAccess 040-min

We will start with the PLC program. The first  three holding registers will be used. That will be MHR1, MHR2 and MHR3 in the Do-More PLC. This will correspond to register numbers 40001, 40002 and 40003. The following is a table with all of the references for Modbus communications to the Do-More.

Coil/Register Numbers Data Addresses Type Do-More PLC Table Name
00001-09999 0000 to 270E Read-Write MC1 to MC1023 Discrete Output Coils
10001-19999 0000 to 270E Read-Only MI1 to MI1023 Discrete Input Contacts
30001-39999 0000 to 270E Read-Only MIR1 to MIR2047 Analog Input Registers
40001-49999 0000 to 270E Read-Write MHR1 to MHR2047 Analog Output Holding Registers

Note: The Do More PLC uses the Modbus area to communicate. This is because having direct access to the digital I/O can be dangerous when connected via Ethernet to the internet. Data must move in and out of this area via the PLC program.

Here is the PLC program that sets the three registers.
ModbusTCP MSAccess 050-min

The next thing to do is set up our Microsoft Access 2010 Database. Our database will be named ACC_Database and it will be located at the following location: “C:\AccLog”. We will have one table called ACC_Log. In the table we will have five fields; LogDate, LogTime, Register1, Register2, Register3.

ModbusTCP MSAccess 090-min
ModbusTCP MSAccess 100-min

Visual Basic 2015 is free and is part of Visual Studio 2015. It can be downloaded at the following location:
https://www.visualstudio.com/en-us/products/visual-studio-community-vs

ModbusTCP MSAccess 020-min

EasyModbusTCP is free software. It will be referenced in our visual basic program.  It can be downloaded from the following location:
https://sourceforge.net/projects/easymodbustcp/
After downloading you must extract the files.

ModbusTCP MSAccess 030-min

EasyModbusTCP is a Modbus TCP, Modbus UDP client/server library for .NET and Client library for JAVA. .NET (.dll) Client/Server also supports Modbus RTU. It supports the following function codes: – Read Coils (FC1)
– Read Discrete Inputs (FC2)
– Read Holding Registers (FC3)
– Read Input Registers (FC4)
– Write Single Coil (FC5)
– Write Single Register (FC6)
– Write Multiple Coils (FC15)
– Write Multiple Registers (FC16)
– Read/Write Multiple Registers (FC23)

Now we will call up visual studio and create our project. The first thing that we must do is reference our EasyModbus.dll file.
ModbusTCP MSAccess 110-min
ModbusTCP MSAccess 120-min

Our program will log the three registers based upon a timer function. When the time expires we will set the interval to 1 minute and call a subroutine (Button1). This subroutine will communicate to the PLC via Modbus TCP and get our three registers. It will then insert the data from the registers along with the time and date into an access database.

Here is what our visual basic form will look like:
ModbusTCP MSAccess 060-min

Here is the visual basic code for our project. We use the Imports command for the EasyModbusTCP namespacing.

Imports EasyModbus 'Import the EasyModbus 

Here is the part of the subroutine that will communicate to the PLC via the EasyModbusTCP, You will notice that we have used the ‘Try’ command on the ModbusClient.Connect() statement. This way we can track if we are communicating or not to the PLC.

Public Class Form1
  Private Sub Button1_Click() Handles Button1.Click
 'This subroutine will communicate using the EasyModbusTCP to the PLC
 'This will execute when the user clicks the button or at specific intervals from the Timer1
 Dim ComError = 0 'Set communication error flag to 0
 'Specify the IP Address and Port Number that we are connecting
 Dim ModbusClient As EasyModbus.ModbusClient = New EasyModbus.ModbusClient(TextBox1.Text, 502)
 Try
 ModbusClient.Connect() 'Connect to the PLC
 Catch ex As Exception 'What to do when an error occurs
 Label10.ForeColor = Color.Red
 Label10.Text = "Communication Error!"
 ComError = 1 'Set communication error flag to 1
 End Try
 If ComError = 0 Then 'Do the following when communication is OK
 Label10.ForeColor = Color.Black
 Label10.Text = "Logging..."
 Dim Registers As Integer() 'Where to store the information
 Registers = ModbusClient.ReadHoldingRegisters(0, 3) 'Read three registers starting at the first one
 Label1.Text = Registers(0) 'Value of MHR1
 Label2.Text = Registers(1) 'Value of MHR2
 Label3.Text = Registers(2) 'Value of MHR3
 ModbusClient.Disconnect() 'Disconnect from the PLC

Here is the code to open the database connection and insert the data into our ACC_Database file. We use the ‘Try’ command to ensure that if errors occur it will not stop our program. The connection string ( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\AccLog\ACC_Database.accdb) may be different then yours. In order to get your connection string, please review the following from a previous post and search for connection string.

'Log values into an Access Database
 'We will use a SQL instruction to insert a record into the table
 Try
 Dim SQL As String 'SQL Command String
 Dim objCmd As New OleDb.OleDbCommand 'Command
 'Connection String to the Access Database
 Dim Con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\AccLog\ACC_Database.accdb")
 'SQL Statement - All values must be set for the table
 SQL = "INSERT INTO ACC_Log VALUES ('" & Now.ToString("yyyy/MM/dd") & "', '" & Now.ToString("hh:mm:ss") & "', '" & Registers(0) & "', '" & Registers(1) & "', '" & Registers(2) & "')"
 Con.Open() 'Open the database connection
 objCmd = New OleDb.OleDbCommand(SQL, Con) 'Set the command
 objCmd.ExecuteNonQuery() 'Execute the SQL command
 Con.Close() 'Close the database connection
 Catch ex As Exception 'What to do when an error occurs
 Label10.ForeColor = Color.Red
 Label10.Text = "Database Error!"
 End Try
 End If
 End Sub

This timer is originally set for 100ms. When the program starts, it will log the first time and then set the timer interval to 1 minute. (60000ms)

 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
   Label9.Text = Now 'Display time and date
 Timer1.Interval = 60000 'Set interval for 1 minute
 Timer1.Enabled = True
 Call Sub() Button1_Click() 'Call the routine to get the PLC information and store in a database
 End Sub

This will handle the LinkLabel on the form.

 Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
   ' Specify that the link was visited.
 Me.LinkLabel1.LinkVisited = True
 ' Navigate to a URL.
 System.Diagnostics.Process.Start("http://www.accautomation.ca")
 End Sub
 End Class

ModbusTCP MSAccess 070-min

Running the program:
The status will show ‘Initializing..’ so that the imports can be loading in the program. This will happen each time the software starts.
ModbusTCP MSAccess 083-min

Logging will be displayed in the status to indicate that everything is working correctly.
ModbusTCP MSAccess 080-min

Error messages will show in the status when an error has occurred. We have programmed two errors:
Communication Error! – Information is not being received from the PLC. This could be due to the wrong IP address or communications links have been broken.
Database Error! – Information cannot be written into the database, the database is not present, etc.
ModbusTCP MSAccess 085-min

Here is what our database looks like after collecting a few samples.
ModbusTCP MSAccess 105-min

As you can see, collecting information from the PLC via ModbusTCP and inserting it into an Access database can be easily done. The next steps would be to ensure that the data is always collected. What happens when the communication to the PLC is cut? Robust logging is required. This is when we create a buffer in the PLC of the logged values. Please refer to our EBook ‘Robust Data Logging for Free’ .

Download the sample database, visual basic and PLC code for this project here.

Watch on YouTube : Modbus TCP Data Logging to Database
If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.

AdvancedHMI to Solo Process Temperature Controller

Modbus RTU will be the serial (RS485) method in which we will communicate between the AdvancedHMI Screen and the Automation Direct Solo Process Temperature Controller.
We can address up to 247 (Solo 1 to 247) devices on this master – slave protocol. A maximum of 32 devices (Nodes) on the network can communicate to the master. A review of the Modbus RTU protocol can be seen at the following URL.
http://www.rtaautomation.com/technologies/modbus-rtu/

AdvancedHMI is a free HMI programming package the runs on Microsoft Visual Studio. It can be downloaded at the following URL.
https://sourceforge.net/projects/advancedhmi/

Connections:
We will be running the AdvancedHMI software on the computer. One of the USB ports will have an USB to RS485 adapter and communicate RS485 to the Solo process temperature controller.
Solo Process Temp Controller 010 Communication Diagram-min
See the following post to install the USB to RS485 adapter.
http://accautomation.ca/usb-to-rs485-pc-adapter-installation/

Solo Controller Settings:
In the Initial Setting Mode we will change the on line configuration to on and make the changes to the Modbus settings as follows: 9600 Baud, Even, 7 Data Bits, 1 Stop Bit, Modbus ASCII Format. We will leave the default unit number as 1. See the following post to set the controller:
http://accautomation.ca/solo-process-temperature-controller/

Modbus RTU (Addresses)
The following address will be used in our project:
AdvancedHMI to Solo 050-min

AdvancedHMI to Solo 055-min
AdvancedHMI will use the Modbus Decimal value in the PLCAddressValue to determine the information that you want to get. For a list of all Modbus addresses that can be used in your project, refer to the Solo Manual located a the following URL:
https://www.automationdirect.com/adc/Manuals/Catalog/Process_Control_-a-_Measurement/Temperature_-z-_Process_Controllers

Screen Display: (AdvancedHMI)
Here is what our screen will look like:
AdvancedHMI to Solo 010-min
We have mimicked the look of the solo process temperature controller. Our PV and SV values are DigitalPanelMeters from the AdvancedHMI toolbar.  The eight output indicators are just labels.

Our ModbusRTUCom1 settings are as follows:
AdvancedHMI to Solo 030-min
Settings: 9600, 8, Even, One StopBit and Station 1 should all match the settings in the Solo process temperature controller that we did previously.
PollRateOverride will allow us to determine how often the communication will take place to the controller. (250msec)
The PortName will be the same port number that the computer will communicate out of. This will be set when you install the USB to RS485 adapter. It may change if a different USB port is used.

The DataSubsciber1 will be used to determine the status of the controller.
AdvancedHMI to Solo 040-min
PLCAddressValue = 44139

We read the value of the eight status bits and convert this into a string so we can determine the status of each of the individual bits. Here is the code that is used to do this. It is the only code required for this application.

Private Sub DataSubscriber1_DataChanged(sender As Object, e AsDrivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        Dim i As Integer = DataSubscriber1.Value
        Dim Status As String
        Status = Convert.ToString(i, 2).PadLeft(8, "0") '8 bits
        'There are 8 bits that we need to check and account for on our screen. 
        'Modbus Decimal - 44139
        'Bit 0 - ALM3 - Alarm 3
        'Bit 1 - ALM2 - Alarm 2
        'Bit 2 - C degrees
        'Bit 3 - F degrees
        'Bit 4 - ALM1 - Alarm 1
        'Bit 5 - OUT 2 
        'Bit 6 - OUT 1
        'Bit 7 - AT - Auto Tuning

The complete AdvancedHMI code for this application can be downloaded at the end of the post.

The PV and SV indicators are DigitalPanelMeters as mentioned above.
AdvancedHMI to Solo 060-min

AdvancedHMI to Solo 065-min
They both have four digits with a decimal position of 1. This will give us a value between 000.0 and 999.9.
The SV includes a keypad to change the set value. KeypadScaleFactor is set to 0.1 to allow for the decimal place.

Included in our display is a BasicTrendChart from the AdvancedHMI toolbar.
AdvancedHMI to Solo 075-min

AdvancedHMI to Solo 070-min
You want to make sure that the YMaximum and YMinimum settings are set so the values will not go past these settings. If they do then the graph line will disappear from the chart at that point and time.
This will show a running trend for the last 5 minutes.
Polling rate is 250msec x 1200 points in the chart = 300 000msec
300 000msec / 1000 = 300 seconds
300 seconds / 60 (seconds in minute) = 5 minutes

Notes: Displaying Extended ASCII Symbols in Visual Studio (VB.NET)
You can display any symbol in the visual studio environment by holding the ‘Alt’ key down and typing the decimal number of the symbol that you want. In our example the degrees symbol is Alt 248.
Here are the extended ASCII symbols:
AdvancedHMI to Solo 020-min
http://www.asciitable.com/

Running the Application:
AdvancedHMI to Solo 085-min

You will notice that the response rate is very quick. (250msec) As the PV, SV or indication values change, the screen will get updated.AdvancedHMI to Solo 090-min

The trend chart will show the last 5 minutes of the PV value. AdvancedHMI to Solo 095-min

As you can see, programming the AdvancedHMI to communicate to the Solo process temperature controller is very easily done.

Download the AdvancedHMI code for this project here.

Watch on YouTube : AdvancedHMI to Solo Process Temperature Controller
If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.