private void myTimer() { timeBeginPeriod(1); uint start = timeGetTime(); uint newStart; while (!isTheardCircleClosed) { float positionVoltageValue; endPosition = float.Parse(pc.AnalogInput(0, out positionVoltageValue)); timeCount++; if (timeCount > 100) { if (UpOrDown) { if (endPosition > iniPosition && Math.Abs(endPosition - iniPosition) > 100) { isTheardCircleClosed = true; newStart = timeGetTime(); timeSpent = newStart - start; this.lblTimespan.Text = timeSpent.ToString(); pc.VOutput(0, 2.5f); Close(); timer1.Stop(); t.Abort(); } } else { if (endPosition < iniPosition && Math.Abs(endPosition - iniPosition) > 100) { isTheardCircleClosed = true; newStart = timeGetTime(); timeSpent = newStart - start; this.lblTimespan.Text = timeSpent.ToString(); pc.VOutput(0, 2.5f); Close(); timer1.Stop(); t.Abort(); } } } } }
private void timer3_Tick(object sender, EventArgs e) { float positionVoltageValue; float position = float.Parse(pc.AnalogInput(0, out positionVoltageValue)); int centerValue = 1420; if (backToZeroControlSwitch) { if (Math.Abs((int)position - centerValue) < 30) { pc.VOutput(0, 2.52f); } if (Math.Abs((int)position - centerValue) < 5) { pc.VOutput(0, 2.5f); iniBiasValue = 2.5f; pc.DigitOutput(3, MccDaq.DigitalLogicState.Low); pc.DigitOutput(4, MccDaq.DigitalLogicState.Low); pc.DigitOutput(2, MccDaq.DigitalLogicState.Low); timerForBackToZero.Stop(); } } else { if (Math.Abs((int)position - centerValue) < 30) { pc.VOutput(0, 2.48f); } if (Math.Abs((int)position - centerValue) < 5) { pc.VOutput(0, 2.5f); iniBiasValue = 2.5f; pc.DigitOutput(3, MccDaq.DigitalLogicState.Low); pc.DigitOutput(4, MccDaq.DigitalLogicState.Low); pc.DigitOutput(2, MccDaq.DigitalLogicState.Low); timerForBackToZero.Stop(); } } }
private void myTimer() { timeBeginPeriod(1); uint start = timeGetTime(); uint newStart; bool ifWorkFinished = false; while (true) { if (!ifWorkFinished) { if (circleCount < circle) { if (runLastTime) { if (signCount < 2) { board.DigitOutput(0, MccDaq.DigitalLogicState.High); lblShowSignText = "High"; } else { board.DigitOutput(0, MccDaq.DigitalLogicState.Low); lblShowSignText = "Low"; } if (count < lastTime) { board.VOutput(0, Convert.ToSingle(voltage)); lblShowValueText = voltage.ToString(); lblShowCountText = "LastPhase"; } else { count = 0; runIntervalTime = true; runLastTime = false; signCount = 0; isLastTimeSingCount = false; isIntervalSingCount = true; } if (isLastTimeSingCount) { signCount++; } } if (runIntervalTime) { if (count < intervalTime) { board.VOutput(0, 0); lblShowValueText = "0"; lblShowCountText = "IntervalPhase"; } else { count = 0; runLastTime = true; runIntervalTime = false; signCount = 0; circleCount++; isLastTimeSingCount = true; isIntervalSingCount = false; } } count++; } else { isStart_1 = true; isStart_2 = true; isStart_3 = true; isStart_4 = true; btnStart_1Text = "Start"; btnStart_2Text = "Start"; btnStart_3Text = "Start"; btnStart_4Text = "Start"; lblShowValueText = "NULL"; lblShowCountText = "NULL"; lblShowSignText = "NULL"; isMyTimerFinished = true; board.VOutput(0, 0); t.Abort(); } ifWorkFinished = true; } newStart = timeGetTime(); if (newStart - start >= 100) { ifWorkFinished = false; start = newStart; } } }
private void cbOpenOrClosed_CheckedChanged(object sender, EventArgs e) { if (cbOpenOrClosed.Checked) { cbOpenOrClosed.Text = "Closed"; ClosedLoop(); isOpenCircle = false; } else { cbOpenOrClosed.Text = "Open"; OpenLoop(); isOpenCircle = true; float v = 2.5f; pc.VOutput(0, v); } }
private void btnRotatinBias_Click(object sender, EventArgs e) { pc.VOutput(0, float.Parse(this.tbPrtatingBias.Text)); }