Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLC PROGRAMMING

Status
Not open for further replies.

EngTist96

Electrical
Jun 23, 2017
2
Hi

I trust you are well. Guy I am looking for help in using a package called concept in writing PLC code. I will be writing code using Functional Body Diagram Programming. I want to write code for boiler water level control.

We have a Differential Pressure Cell and a Water Flow Meter as the new equipment we are adding which need to be part of the control philosophy. The philosophy is as follows, if the DP cell indicates a higher boiler pressure than a lower pump head increase the pump pressure, until pump pressure is greater than boiler pressure so as to ensure flow. We then use the water flow meter to always indicate that there is flow when flow is actually supposed to be occuring. Also if the water flow meter ever indicates absence of flow when flow is required ramp up the pump until the flow monitor indicates flow.

Any heads up

Thanks in advance
 
Replies continue below

Recommended for you

I would have more than one flow meter. You wouldn't want to keep increasing the pump pressure when a meter is malfunctioning. How are you setting up your DPC? What is it transmitting its data to?
 
Boiler level control schemes are well-established. Look up 3-element boiler level control on Google.
 
NModbus4 - Listener event not firing.

Please find my C# NModbus4 console application code. The problem I'm having the that the listener event is not firing after setting the master C0 relay coil to true. I've also included some screen shots below.

Code:
using Modbus.Data;
using Modbus.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace NModbus4ListenerDemo
{
    class Program
    {
        #region "Properties"
        static TcpClient tcpClient = new TcpClient();
        static ModbusIpMaster PLCModbusMaster = ModbusIpMaster.CreateIp(tcpClient);
        static string C0_RelayCoil_Address = "3073";
        static ushort C0_RelayCoil_BitAddress = Convert.ToUInt16(Convert.ToInt16(C0_RelayCoil_Address) - 1);
        #endregion

        #region "Setup Listener"
        static IPAddress MiddlewareSlaveIPAddress = IPAddress.Parse("10.95.11.34");
        static TcpListener MiddlewareSlaveTcpListener = new TcpListener(MiddlewareSlaveIPAddress, Convert.ToInt32("502"));
        static ModbusSlave middlewareslave = ModbusTcpSlave.CreateTcp(Convert.ToByte("255"), MiddlewareSlaveTcpListener);
        #endregion

        static void Main(string[] args)
        {
            string PLCMasterIPAddress = "10.95.11.32";
            tcpClient.BeginConnect(PLCMasterIPAddress, 502, null, null);
            Thread.Sleep(100);

            #region "Set Relay Coit C0 to false"
            PLCModbusMaster.WriteSingleCoil(C0_RelayCoil_BitAddress, false);
            Thread.Sleep(50);
            bool[] C0_RelayCoil_BitValue = PLCModbusMaster.ReadCoils(C0_RelayCoil_BitAddress, 1);
            string C0RelayCoilBitValue = C0_RelayCoil_BitValue[0] ? "True" : "False";
            Console.WriteLine("C0 Relay Coil = " + C0RelayCoilBitValue);
            Thread.Sleep(50);
            #endregion

            #region "Create DataStore and start listing"
            MiddlewareSlaveTcpListener.Start();
            middlewareslave.DataStore = DataStoreFactory.CreateDefaultDataStore();
            middlewareslave.DataStore.DataStoreWrittenTo += ModbusDataStore_DataStoreWrittenTo;
            middlewareslave.Listen();
            Thread.Sleep(50);
            #endregion

            #region "Set Relay Coit C0 to false"
            PLCModbusMaster.WriteSingleCoil(C0_RelayCoil_BitAddress, true);
            Thread.Sleep(50);
            C0_RelayCoil_BitValue = PLCModbusMaster.ReadCoils(C0_RelayCoil_BitAddress, 1);
            C0RelayCoilBitValue = C0_RelayCoil_BitValue[0] ? "True" : "False";
            Console.WriteLine("C0 Relay Coil = " + C0RelayCoilBitValue);
            Thread.Sleep(50);
            #endregion

            Console.ReadLine();

            #region "ModbusDataStore_DataStoreWrittenTo"
            void ModbusDataStore_DataStoreWrittenTo(object sender, DataStoreEventArgs e)
            {
                Console.WriteLine("ModbusDataStore_DataStoreWrittenTo event fired!");
            }
            #endregion

        }
    }
}

This image shows the C0 relay coil set off:
LadderLogicC0Off_h0sobu.png


This image shows the CO relay coil set on after the console application has run:
LadderLogicC0On_k0fndp.png


Here is the console application screen after running. Note the absence of the "ModbusDataStore_DataStoreWrittenTo event fired!" message.
ConsoleApplication_toreco.png


Here is the Wireshark information that shows the TCP Modbus traffic between the master and slave over port 502
WireShark_epgaox.png


Here is the PLC configuration information:
NetEdit3_General_Settings_ugiher.png


NetEdit3_Peer_to_Peer_Config_d1vrbb.png
 
Paul... Are you hijacking EngTist96's thread? I don't see it as a correct response.
Please open your own question thread and delete this entry in this thread.

Keith Cress
kcress -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor