예제 #1
0
        private void UpdateButton_Click(object sender, System.EventArgs e)         /* Handles UpdateButton.Click */
        {
            bool  IsValidNumber = true;
            float EngUnits      = 0.0f;

            try
            {
                EngUnits = float.Parse(txtVoltsToSet.Text);
            }

            catch (Exception ex)
            {
                MessageBox.Show(txtVoltsToSet.Text + " is not a valid voltage value", "Invalid Voltage ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsValidNumber = false;
            }

            if (IsValidNumber)
            {
                //  Parameters:
                //    Chan       :the D/A output channel
                //    Range      :ignored if board does not have programmable rage
                //    DataValue  :the value to send to Chan
                ushort           DataValue = 0;
                MccDaq.ErrorInfo ULStat    = DaqBoard.FromEngUnits(Range, EngUnits, out DataValue);


                ULStat = DaqBoard.AOut(Chan, Range, DataValue);

                lblValueSent.Text   = "The count sent to DAC channel " + Chan.ToString("0") + " was:";
                lblVoltage.Text     = "The voltage at DAC channel " + Chan.ToString("0") + " is:";
                lblShowValue.Text   = DataValue.ToString("0");
                lblShowVoltage.Text = EngUnits.ToString("0.0##") + " Volts";
            }
        }
예제 #2
0
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            bool  IsValidNumber = true;
            float EngUnits      = 0.0f;

            IsValidNumber = float.TryParse(txtVoltsToSet.Text, out EngUnits);

            if (IsValidNumber)
            {
                //  Parameters:
                //    Chan       :the D/A output channel
                //    Range      :ignored if board does not have programmable rage
                //    DataValue  :the value to send to Chan

                ushort DataValue = 0;
                float  OutVal;

                MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, EngUnits, out DataValue);

                ULStat = DaqBoard.AOut(Chan, Range, DataValue);

                lblValueSent.Text   = "The count sent to DAC channel " + Chan.ToString("0") + " was:";
                lblVoltage.Text     = "The voltage at DAC channel " + Chan.ToString("0") + " is:";
                lblShowValue.Text   = DataValue.ToString("0");
                OutVal              = ConvertToVolts(DataValue);
                lblShowVoltage.Text = OutVal.ToString("0.0#####") + " Volts";
            }
        }
예제 #3
0
        private void btnSendData_Click(object sender, System.EventArgs e)
        {
            float  volts    = 0.0F;
            ushort daCounts = 0;
            int    chan     = 0;

            foreach (TextBox box in _txtAOVolts)
            {
                if (chan <= MaxChan)
                {
                    //get voltage to output
                    volts = float.Parse(box.Text);

                    // convert from voltage to binary counts
                    DaqBoard.FromEngUnits(Range, volts, out daCounts);

                    // load D/A
                    DaqBoard.AOut(chan, Range, daCounts);
                    ++chan;
                }
            }
        }
예제 #4
0
파일: ULAO02.cs 프로젝트: r4forth/sdkpub
        public frmSendAData()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);



            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);             //  set aside memory to hold data


            //generate waveform
            ushort FScale = 0;

            DaqBoard.FromEngUnits(MccDaq.Range.Bip5Volts, 5.0f, out FScale);
            for (int i = 0; i <= NumPoints - 1; ++i)
            {
                DAData[i] = Convert.ToUInt16((i * FScale) / NumPoints);
            }

            //move waveform to buffer
            FirstPoint = 0;
            ULStat     = MccDaq.MccService.WinArrayToBuf(ref DAData[0], MemHandle, FirstPoint, NumPoints);


            lblAOutData = (new Label[] { _lblAOutData_0, _lblAOutData_1 });
        }
예제 #5
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)         /* Handles cmdStart.Click */
        {
            cmdStart.Enabled = false;

            //  Select the trigger source using Mccdaq.MccBoard.SetTrigger()
            //  Parameters:
            //    TrigType       :the type of triggering based on external trigger source
            //    LowThreshold   :Low threshold when the trigger input is analog
            //    HighThreshold  :High threshold when the trigger input is analog
            float highVal = 1.0F;

            MccDaq.Range Range         = MccDaq.Range.Bip10Volts;     // analog trigger range
            ushort       HighThreshold = 0;

            MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, highVal, out HighThreshold);

            float  lowVal       = 0.1F;
            ushort LowThreshold = 0;

            ULStat = DaqBoard.FromEngUnits(Range, lowVal, out LowThreshold);

            MccDaq.TriggerType TrigType = MccDaq.TriggerType.TrigAbove;
            ULStat = DaqBoard.SetTrigger(TrigType, LowThreshold, HighThreshold);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                //  Collect the values with MccDaq.MccBoard.AInScan()
                //  Parameters:
                //    LowChan    :the first channel of the scan
                //    HighChan   :the last channel of the scan
                //    Count      :the total number of A/D samples to collect
                //    Rate       :sample rate
                //    Range      :the range for the board
                //    MemHandle  :Handle for Windows buffer to store data in
                //    Options    :data collection options
                int LowChan = 0;                        //  first channel to acquire
                HighChan = int.Parse(txtHighChan.Text); //  last channel to acquire
                if (HighChan > 7)
                {
                    HighChan = 7;
                }
                txtHighChan.Text = HighChan.ToString();

                int Count = NumPoints;                                      //  total number of data points to collect
                int Rate  = 390;                                            //  per channel sampling rate ((samples per second) per channel)
                Range = MccDaq.Range.Bip5Volts;                             // set the range
                MccDaq.ScanOptions Options = MccDaq.ScanOptions.ConvertData //  return data as 12-bit values
                                             | MccDaq.ScanOptions.ExtTrigger;
                ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options);

                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange)
                {
                    MessageBox.Show("Change the Range argument to one supported by this board.", "Unsupported Range", 0);
                }


                //  Transfer the data from the memory buffer set up by Windows to an array
                ULStat = MccDaq.MccService.WinBufToArray(MemHandle, out ADData[0], FirstPoint, Count);


                for (int i = 0; i <= HighChan; ++i)
                {
                    lblADData[i].Text = ADData[i].ToString("0");
                }

                for (int j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }
            }
            cmdStart.Enabled = true;
        }
예제 #6
0
파일: ULAIO01.cs 프로젝트: otoauler/sdkpub
        public frmStatusDisplay()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            //  set aside memory to hold A/D data
            ADMemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);

            //  set aside memory to hold D/A data
            DAMemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);

            //  Generate D/A ramp data to be output via MccDaq.MccBoard.AOutScan function
            ushort FScale =0;
            DaqBoard.FromEngUnits(MccDaq.Range.Bip5Volts, 5.00f, out FScale);
            for (int i=0; i<=NumPoints - 1; ++i)
                DAData[i] = (ushort)((FScale*i)/NumPoints);

            // transfer the DAData to the DA buffer
            ULStat = MccDaq.MccService.WinArrayToBuf( ref DAData[0], DAMemHandle, FirstPoint, NumPoints);

            lblADData = (new Label[] {_lblADData_0, _lblADData_1, _lblADData_2, _lblADData_3,
                                    _lblADData_4, _lblADData_5, _lblADData_6, _lblADData_7});
        }
예제 #7
0
파일: ULAO02.cs 프로젝트: otoauler/sdkpub
        private int MemHandle = 0; //  define a variable to contain the handle for

        #endregion Fields

        #region Constructors

        public frmSendAData()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            // Create a new MccBoard object for Board 0
            DaqBoard = new MccDaq.MccBoard(0);

            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints); //  set aside memory to hold data

            //generate waveform
            ushort FScale =0;
            DaqBoard.FromEngUnits(MccDaq.Range.Bip5Volts, 5.0f, out FScale);
            for (int i=0; i<=NumPoints - 1; ++i)
                DAData[i] = Convert.ToUInt16((i * FScale)/NumPoints);

            //move waveform to buffer
            FirstPoint = 0;
            ULStat = MccDaq.MccService.WinArrayToBuf( ref DAData[0], MemHandle, FirstPoint, NumPoints);

            lblAOutData = (new Label[]{_lblAOutData_0, _lblAOutData_1});
        }
예제 #8
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            string TrigSource;

            MccDaq.ErrorInfo   ULStat;
            MccDaq.TriggerType TrigType;
            float LSB, VoltageRange;
            int   FSCounts, Rate;
            bool  ValidChan;

            cmdStart.Enabled = false;

            //  Select the trigger source using Mccdaq.MccBoard.SetTrigger()
            //  Parameters:
            //    TrigType       :the type of triggering based on external trigger source
            //    LowThreshold   :Low threshold when the trigger input is analog
            //    HighThreshold  :High threshold when the trigger input is analog

            float highVal = 1.53F;
            float lowVal  = 0.1F;

            TrigType = MccDaq.TriggerType.TrigAbove;

            TrigSource = "analog trigger input";
            ushort HighThreshold = 0;
            ushort LowThreshold  = 0;

            if (AIOProps.ATrigRes == 0)
            {
                ULStat = DaqBoard.FromEngUnits(Range, highVal, out HighThreshold);
                ULStat = DaqBoard.FromEngUnits(Range, lowVal, out LowThreshold);
            }
            else
            {
                //Use the value acquired from the AnalogIO module, since the resolution
                //of the input is different from the resolution of the trigger.
                //Calculate trigger based on resolution returned and trigger range.
                VoltageRange = AIOProps.ATrigRange;
                if (AIOProps.ATrigRange == -1)
                {
                    VoltageRange = AIOProps.GetRangeVolts(Range);
                    TrigSource   = "first channel in scan";
                }
                FSCounts      = (int)Math.Pow(2, AIOProps.ATrigRes);
                LSB           = VoltageRange / FSCounts;
                LowThreshold  = (ushort)((lowVal / LSB) + (FSCounts / 2));
                HighThreshold = (ushort)((highVal / LSB) + (FSCounts / 2));
            }

            lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                  " collecting analog data on up to " + NumAIChans.ToString() +
                                  " channels using AInScan with Range set to " + Range.ToString() + ".";

            lblResult.Text = "Waiting for a trigger at " + TrigSource + ". " +
                             "Trigger criterea: signal rising above " + highVal.ToString("0.00") +
                             "V. (Ctl-Break to abort.)";
            Application.DoEvents();

            ULStat = DaqBoard.SetTrigger(TrigType, LowThreshold, HighThreshold);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                //  Collect the values with MccDaq.MccBoard.AInScan()
                //  Parameters:
                //    LowChan    :the first channel of the scan
                //    HighChan   :the last channel of the scan
                //    Count      :the total number of A/D samples to collect
                //    Rate       :sample rate
                //    Range      :the range for the board
                //    MemHandle  :Handle for Windows buffer to store data in
                //    Options    :data collection options

                ValidChan = int.TryParse(txtHighChan.Text, out HighChan);
                if (ValidChan)
                {
                    if ((HighChan > MaxChan))
                    {
                        HighChan = MaxChan;
                    }
                    txtHighChan.Text = HighChan.ToString();
                }

                int Count = NumPoints; //  total number of data points to collect
                // per channel sampling rate ((samples per second) per channel)
                Rate = 1000 / ((HighChan - LowChan) + 1);
                MccDaq.ScanOptions Options = MccDaq.ScanOptions.ConvertData  //  return data as 12-bit values
                                             | MccDaq.ScanOptions.ExtTrigger;

                ULStat         = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options);
                lblResult.Text = "";

                if (ULStat.Value == ErrorInfo.ErrorCode.Interrupted)
                {
                    lblInstruction.Text = "Scan interrupted while waiting " +
                                          "for trigger on board " + DaqBoard.BoardNum.ToString() +
                                          ". Click Start to try again.";
                    cmdStart.Enabled = true;
                    return;
                }
                else if (!(ULStat.Value == ErrorInfo.ErrorCode.NoErrors))
                {
                    lblInstruction.Text = "Error occurred on board " +
                                          DaqBoard.BoardNum.ToString() +
                                          ": " + ULStat.Message;
                    cmdStart.Enabled = false;
                    return;
                }

                //  Transfer the data from the memory buffer set up by Windows to an array
                if (ADResolution > 16)
                {
                    ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, Count);

                    for (int i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData32[i].ToString("0");
                    }
                }
                else
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, Count);

                    for (int i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData[i].ToString("0");
                    }
                }

                for (int j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }
            }
            cmdStart.Enabled = true;
        }