Expansion of the network capabilities of the programmable relay with WI-FI
How it all started
It all began with the development of algorithms for the programmable relay PR20? and often required the visualization or input of information from the computer, for this it is necessary to use the operator panel or SCADA system, but it is not always convenient, and whether it is necessary for simple systems. The solution was found quickly, and over time I tried to improve as much as possible and facilitate my work in this direction, which of these turned out to be read further.
It's about the WI-FI network card and its capabilities.
Since this board is used to debug various projects, the interaction interface is constantly being modified for a more convenient and quick setup. The first modification was a simple converter RS-485 in TCP with a conclusion in WEB, with a ready firmware of the well-known in the community ESP8266. Since then, more than 2 years have passed, and to analyze the processes stretched over time it was required to archive, and since I wanted to combine all this in one device without additional hardware, it was decided to embed support for microSD, which made it much easier to analyze the processes with the ability to quickly access archives. The second modification of the board had a slot, with the ability to extract a microSD card to store recorded files on the computer. It seemed to me not very convenient, and there was a version with the ability to download files via WI-FI. Sometimes downloading does not happen until the end and a second download operation is required, but considering that at this time the equipment remains in operation and the archiving can also work, I think this is not a very big problem. A version with a 16 mB memory chip instead of a microSD card was also tested. Faster downloading, but there is no possibility to save a lot of files, the recording goes in sequence until the entire memory is full.
Purpose and capabilities of the interface board
The board is designed to enhance the access to internal logic variables of the programmable relay PR20? and provides access to both read and write variables.
Thanks to the wireless interface WI-FI, you can access the device without the need for additional equipment. First of all, the solution is focused on simple home automation projects in places with the presence of WI-FI networks. These include lighting automation solutions, both indoor and outdoor, control and monitoring of pumping stations, greenhouses, etc. Due to the built-in WEB server in the board, there is no need to purchase additional equipment for those cases when access to the system is needed infrequently. Basic input is done using a smartphone /tablet or a PC on the same network.
The interface board can work in different modes. When connected to a router with Internet access, it allows you to remotely monitor the state of variables in the logic of the PR20? and also manage the algorithm through network variables in formats supported by the PR200 in Slave mode.
Communication with the programmed algorithm in the device is carried out through network variables, and the interface board can act as a Master or Slave. Standard speeds and network interface settings for the PR200 are supported. Modbus TCP communication is supported, for this purpose a memory area of 100 cells is allocated, which can be accessed both from the WEB interface and via Modbus RTU protocol from the PR200 side.
The choice of the mode of the network card is similar to the choice when working with graphic panels, working in Master mode allows more flexible control of the exchange of variables, for registers whose value is required to be received more often than others, it is possible to set the poll period less. The following commands are available for the Modbus protocol:
03 (0x03) Read Holding Registers Reading.
04 (0x04) Read Input Registers Read
06 (0x06) Preset Single Register Write
16 (0x10) Preset Multiple Registers Write
Variables received from the relay are available for writing to a file (archive), which is placed on a micro SD card, the record is in text format. After downloading, you can view on your computer in a simple text editor. Values recorded in a file can be displayed on a historical graph. Using the options of scaling and selecting a certain period on the timeline, as well as individual display /hide of the graph lines, the analysis of the archive data is carried out.
Files created by the archiver function remain on the microSD card and can be downloaded to the computer, at any given time, only one file is available, it can record historical data, read information for building a historical chart, or read information for saving to a PC .
For archiving, variables from the address space of the network card are available, to which it is necessary to write the data received via Modbus RTU from the PR200 or Modbus TCP from other devices supporting the Modbus TCP protocol in the Master mode.
The interface card can be configured in both Access Point mode and Client mode - Station workstation, or in both modes simultaneously. Most often, the access point has an Internet connection and operates as a bridge between the device and the network.
Wireless connection can be password protected, it is also possible to hide the access point.
The variables received via the RS485 interface from the PR200 can be analyzed by presenting them in a graphical form, in this mode the values will be displayed in real time with a period of ~ 1 sec.
To display the graph, 10 variables are available in integer format, with a floating point or in a bit representation of 16/32 bits. The number, type, addresses of variables and output format are taken from the archive settings.
For quick and convenient operation, it was decided to repeat the form of the "native" network card of the device.
The board is installed in the device.
The network card can be installed in the first or second slot [/b]
The board has two switches, one serves to reset the network card (does not affect the operation of the program in the PR200), the second switch can be programmed to enable archiving (selected through settings from the WEB interface of the board). There are also 2 information LEDs:
1-blue briefly lights up when communicating via RS-485 interface with PR200
2-red briefly lights up when data is written to the micro SD card, and is turned on permanently if there is no card or it is impossible to read data on the card.
The following are the main menus when working in different modes:
Basic network settings for connecting via WEB.
Connection settings for the PR200 network interface and connection settings for Modbus TCP via WI-FI
A map of internal registers common to the Web, Modbus RTU and Modbus TCP
Test WEB page for controlling and monitoring the states of the inputs /outputs of the PR200 with the connected expansion module PRM-1. [/b]
Pages for input /output of values from the PR200 and data transfer to the control outputs of the device. [/b]
When connecting the network card to the router with Internet connection and port forwarding, it is possible to work remotely with the card through the browser.
How it works
The following screenshots are presented when the PR200 is running on a real project, with data archiving. In the PR20? a project is loaded that reads the values of 4 analog channels to which NTC sensors are connected and converts these values to temperature, according to the second network interface configured in Master mode, the PR200 interrogates the MV110-8A module to which 2 Pt1000 PTAs are connected. Thus, data on 4 resistance values from analog inputs of the PR20? 4 temperature values obtained with the NTC macro, and also 2 temperatures obtained from the MV110-8A module via RS-485 are collected. All 10 registers in the format of float on the first network interface configured in Master mode are read out for writing to the archive and WEB visualization.
The menu for working with the SD card, with the archiving off, displays a list of files on the card, with the archiving enabled, it displays the log of the record on the card.
Archiving management menu. [/b]
The timestamps for archiving are read from the registers of the PR200 real-time clock, in this example the clock is not synchronized with the real time.
File archive, downloaded by WI-FI with micro SD installed on the board and open text editor. Ready for plotting. [/b]
The page opened in the browser for plotting the graph from the downloaded file. [/b]
Formed graph on the data from the archive file.
Controlling the visibility of graphs through the legend
Detailing the required areas on the graph.
Access to registers via Modbus TCP (WI-FI)
If the WEB capabilities are not enough to build the visualization, then using access via Modbus TCP, it is possible to organize communication with SCADA systems and quickly create the necessary visualization from the finished blocks. Using various network monitors, you can monitor the status of the internal registers of both the network card and the built-in registers of the PR200. An example of polling using the Modbus Poll program.
Connection using the ModBus TCP protocol using the Modbus Poll program.
Reading registers, and presenting them in various formats.
After installing the network card in the device, additional features and tools appear in the work with the programmable relay PR200. There are various scenarios for use, either individually or in a combined mode.
One example, the recording of archival events in the PR20? at the moment created a variety of macros to record the archived events in the instrument, but they take up a lot of resources in the device and have limited capabilities both in information output and in the depth of archiving, more flexible to configure and record the necessary events. To facilitate analysis, register mode is added in bit mode, thus, the archive gets 16 or 32 bit number decomposed into bits. It supports various modes of starting archiving, via a switch on the board, WEB interface, ModBus register. Using the ModBus register, the device itself determines the moment of recording by writing to the cell a number different from "0", the set point is exceeded, we write it to the register "1" and the logs are written until the value is written to the "0" register, similar to the input signals. Separately, one can distinguish a record with a certain period of various data on temperature, pressure, humidity for subsequent analysis in a graphical representation. A web page in the device is built in to convert the data into a graphic view.
The second scenario is remote control, or monitoring the state of internal variables, changing modes of operation. This option can be divided into local, within the internal network, and via the Internet.
The remaining options are auxiliary, debugging, outputting the variables of interest to the current visualization, viewing network variables, etc.
It is interesting to hear the opinion of the community on this topic, who is solving similar tasks by what means?
It may be interesting
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.Tow truck dublin
Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future alsobest fat burning pills for men
Thankyou for sharing the data which is beneficial for me and others likewise to see.Gulf Coast Western Reviews
Thankyou for sharing the data which is beneficial for me and others likewise to see.Gulf Coast Western Reviews
Wow i can say that this is another great article as expected of this blog.Bookmarked this site.. Agen asuransi allianz
This was a shocking post. It has some look at here fundamental data on this subject.Gulf Coast Western Reviews