解读ATV312变频器modbus协议中地址8501的数据,不用自己对着datasheet一个位一个位的解读了

使用VS2013, 开发语言c#,下载链接

https://download.csdn.net/download/qq_20573423/10862241

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
        public int input_num;
        
        private void button1_Click(object sender, EventArgs e)
        {
            input_num = Convert.ToInt32(input.Text);

            if ((input_num & 0x0001) == 0x0001)
            {
                boxon.Text = "yes";

            }
            else
            {
                boxon.Text = "no";
            }
            if ((input_num & 0x0002) == 0x0002)
            {
                boxdisvolt.Text = "no";

            }
            else
            {
                boxdisvolt.Text = "yes";
            }
            if ((input_num & 0x0004) == 0x0004)
            {
                boxquickstop.Text = "no";

            }
            else
            {
                boxquickstop.Text = "yes";
            }
            if ((input_num & 0x0008) == 0x0008)
            {
                boxenableop.Text = "yes";

            }
            else
            {
                boxenableop.Text = "no";
            }
            if ((input_num & 0x0010) == 0x0010)
            {
                boxres4.Text = "reserved";

            }
            else
            {
                boxres4.Text = "reserved";
            }
            if ((input_num & 0x0020) == 0x0020)
            {
                boxres5.Text = "reserved";

            }
            else
            {
                boxres5.Text = "reserved";
            }
            if ((input_num & 0x0040) == 0x0040)
            {
                boxres6.Text = "reserved";

            }
            else
            {
                boxres6.Text = "reserved";
            }
            if ((input_num & 0x0080) == 0x0080)
            {
                boxfltreset.Text = "yes";

            }
            else
            {
                boxfltreset.Text = "no";
            }
            if ((input_num & 0x0100) == 0x0100)
            {
                boxres8.Text = "reserved";

            }
            else
            {
                boxres8.Text = "reserved";
            }
            if ((input_num & 0x0200) == 0x0200)
            {
                boxres9.Text = "reserved";

            }
            else
            {
                boxres9.Text = "reserved";
            }
            if ((input_num & 0x0400) == 0x0400)
            {
                boxres10.Text = "reserved";

            }
            else
            {
                boxres10.Text = "reserved";
            }
            if ((input_num & 0x0800) == 0x0800)
            {
                boxdir.Text = "reverse";

            }
            else
            {
                boxdir.Text = "forward";
            }
            if ((input_num & 0x1000) == 0x1000)
            {
                boxstopcmd.Text = "stop type";

            }
            else
            {
                boxstopcmd.Text = "no action";
            }
            if ((input_num & 0x2000) == 0x2000)
            {
                boxno13.Text = "no action";

            }
            else
            {
                boxno13.Text = "no action";
            }
            if ((input_num & 0x4000) == 0x4000)
            {
                boxno14.Text = "no action";

            }
            else
            {
                boxno14.Text = "no action";
            }
            if ((input_num & 0x8000) == 0x8000)
            {
                boxno15.Text = "no action";

            }
            else
            {
                boxno15.Text = "no action";
            }

        }
    }
}

 解读ATV312变频器modbus协议中地址8501的数据,不用自己对着datasheet一个位一个位的解读了_第1张图片

 

你可能感兴趣的:(c,sharp,learning)