industrial networks industrial networks - 11 days ago
88 0

Youtube Channel: Industrial Networks
https://www.youtube.com/c/industrialNetworks

S7 PLC SIEMENS WITH VISUAL C#(S7.Net Library)
https://www.youtube.com/watch?v=nSnGKm3FSbk&list=PLRCEJ0bGSS1ZlU34IXsIKS62IHH5FcgU1

Open Source C#: The Industrial Networks Library
https://www.youtube.com/watch?v=ZxfNXitkVJI&list=PLRCEJ0bGSS1Y-X44VOzdYsdi9RQ6ccHt-

Programming Modbus RTU with .Net (C#/VB.Net)
https://www.youtube.com/watch?v=wVYA5m6pAGc&list=PLRCEJ0bGSS1Z31_EJnVLjSfo38kH8klvI

Programming Modbus ASCII with .Net (C#/VB.Net)
https://www.youtube.com/watch?v=8_UcAkTCLlc&list=PLRCEJ0bGSS1YlKPZx1By8ieVsUUoEueB9

Programming Modbus TCP/IP with .Net (C#/VB.Net)
https://www.youtube.com/watch?v=TXXJZpbkL1I&list=PLRCEJ0bGSS1aTbj9wjsC5HmlV_vKOWPR4

S7-1200 Modbus TCP/IP With Visual C#
https://www.youtube.com/watch?v=vou86F2WR90&list=PLRCEJ0bGSS1ad731eTNjy9nCp7-F7XJnw

C#

Modbus RTU, Modbus ASCII, Modbus TCP/IP With C#/VB.NET

Cyclical Redundancy Check (CRC)  Modbus RTU
         private byte[] CalculateCRC(byte[] data)
        {
            ushort CRCFull = 0xFFFF; // Set the 16-bit register (CRC register) = FFFFH.
            byte CRCHigh = 0xFF, CRCLow = 0xFF;
            char CRCLSB;
            byte[] CRC = new byte[2];
            for (int i = 0; i < (data.Length) - 2; i++)
            {
                CRCFull = (ushort)(CRCFull ^ data[i]); // 

                for (int j = 0; j < 8; j++)
                {
                    CRCLSB = (char)(CRCFull & 0x0001);
                    CRCFull = (ushort)((CRCFull >> 1) & 0x7FFF);

                    if (CRCLSB == 1)
                        CRCFull = (ushort)(CRCFull ^ 0xA001);
                }
            }
            CRC[1] = CRCHigh = (byte)((CRCFull >> 8) & 0xFF);
            CRC[0] = CRCLow = (byte)(CRCFull & 0xFF);
            return CRC;
        }


Longitudinal Redundancy Check (LRC) Modbus ASCII
        private byte LRC(byte[] data)
        {
            if (data == null)
                throw new ArgumentNullException("Parameter is null or empty");
            byte lrc = 0;
            foreach (byte b in data)
                lrc += b;
            lrc = (byte)((lrc ^ 0xFF) + 1);
            return lrc;
        }