private void UpdateButton_Click(object sender, System.EventArgs e) { bool IsValidNumber = true; double frequency = 1000000.0; double dutyCycle = .5; uint pulseCount = 0; double initialDelay = 0; IdleState idleState = IdleState.Low; PulseOutOptions options = PulseOutOptions.Default; try { frequency = double.Parse(txtFrequencyToSet.Text); } catch (Exception) { MessageBox.Show(txtFrequencyToSet.Text + " is not a valid frequency value", "Invalid Frequency ", MessageBoxButtons.OK, MessageBoxIcon.Error); IsValidNumber = false; } try { dutyCycle = double.Parse(txtDutyCycleToSet.Text); } catch (Exception) { MessageBox.Show(txtDutyCycleToSet.Text + " is not a valid duty cycle value", "Invalid Duty Cycle ", MessageBoxButtons.OK, MessageBoxIcon.Error); IsValidNumber = false; } if (IsValidNumber) { double frequencySet = frequency; double dutyCycleSet = dutyCycle; // Parameters: // TimerNum :the timer output channel // Frequency :the frequency to output MccDaq.ErrorInfo ULStat = DaqBoard.PulseOutStart(0, ref frequency, ref dutyCycle, pulseCount, ref initialDelay, idleState, options); if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors) { lblValueSent.Text = "The frequency sent to timer " + CounterNum.ToString() + " was:"; lblFrequency.Text = "The frequency output from timer channel " + CounterNum.ToString() + " is:"; lblShowValue.Text = frequencySet.ToString("0.0######") + " Hz"; lblShowFrequency.Text = frequency.ToString("0.0#####") + " Hz"; lblDCValueSent.Text = "The duty cycle sent to timer " + CounterNum.ToString() + " was:"; lblDutyCycle.Text = "The duty cycle output from timer channel " + CounterNum.ToString() + " is:"; lblDCShowValue.Text = dutyCycleSet.ToString("0.0#####"); lblShowDutyCycle.Text = dutyCycle.ToString("0.0#####"); } } }