예제 #1
0
파일: Form1.cs 프로젝트: haavardnk/IIA2017
        public void HardwareProcess(double dt)
        {
            Tout          = new DaqAi("ai0");
            Tenv          = new DaqAi("ai1");
            ControlSignal = new DaqAo("ao0");

            var    y = Tout.GetCelsiusValue();
            double u;

            if (tabPid.SelectedTab == tabSimPID)
            {
                u = Controller.ControlVariable(y, dt);
            }
            else
            {
                RegOutput = new DaqAi("ai2");
                RegInput  = new DaqAo("ao1");

                RegInput.SetValue(Clamp(Tout.GetVoltValue()));
                u = RegOutput.GetVoltValue();

                textToPID.Text   = Math.Round(Clamp(Tout.GetVoltValue()), 2).ToString();
                textFromPID.Text = Math.Round(u, 2).ToString();
            }

            ControlSignal.SetValue(Clamp(u));

            textTenvh.Text = Math.Round(Tenv.GetCelsiusValue(), 2).ToString();
            textTouth.Text = Math.Round(y, 2).ToString();
            textOuth.Text  = Math.Round(u, 2).ToString();

            UpdateVariables(u, y);
        }
예제 #2
0
파일: Form1.cs 프로젝트: haavardnk/IIA2017
        public void SimulateProcess(double dt)
        {
            double u;
            double y;

            if (tabPid.SelectedTab == tabSimPID)
            {
                u = Controller.ControlVariable(Sim.ProcessVariable, dt);

                y = Sim.Simulate(u, dt);
            }
            else
            {
                RegOutput = new DaqAi("ai2");
                RegInput  = new DaqAo("ao1");

                RegInput.SetValue(Clamp((Sim.ProcessVariable * 4) / 50 + 1));
                u = RegOutput.GetVoltValue();
                y = Sim.Simulate(u, dt);
            }

            UpdateVariables(u, y);
        }