/// <summary>
        /// Not support by usb-1208
        /// </summary>
        /// <param name="Chan"></param>
        /// <returns></returns>
        public float ReadTemperature(int Chan)
        {
            MccDaq.TempScale MccScale  = MccDaq.TempScale.Celsius;
            float            TempValue = 0.0f;

            MccDaq.ThermocoupleOptions Options = MccDaq.ThermocoupleOptions.WaitForNewData;
            MccDaq.ErrorInfo           ULStat  = DaqBoard.TIn(Chan, MccScale, out TempValue, Options);

            return(TempValue);
        }
        private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs)
        {
            bool ValidChan;

            tmrConvert.Stop();

            //  Collect the data with Mccdaq.MccBoard.TIn()

            //  Parameters:
            //    Chan       :the A/D and channel number; starts at 16 if using
            //                an EXP (calculated by (ADChan + 1) * 16 + EXPChan)
            //    MccScale   :the temperature scale (F, C or K)
            //    DataValue  :the name for the value collected
            //    ADChan     :usually channel 0 for CIO-EXP16

            short ADChan = 0; //    If using a device with an EXP attached,

            //                      allows access to 16 channels on the EXP board
            //                      increasing this number allows access to upper
            //                      bank on EXP32 and additional EXP boards

            MccDaq.TempScale MccScale = MccDaq.TempScale.Celsius;
            int Chan = 0;

            ValidChan = int.TryParse(txtExpChan.Text, out Chan);
            if (ValidChan)
            {
                if (UsesEXPs > 0)
                {
                    Chan = Chan + (ADChan + 1) * 16;
                }
            }

            float TempValue = 0.0f;

            MccDaq.ThermocoupleOptions Options = MccDaq.ThermocoupleOptions.Filter;
            MccDaq.ErrorInfo           ULStat  = DaqBoard.TIn(Chan, MccScale, out TempValue, Options);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                tmrConvert.Start();
            }

            lblShowData.Text = TempValue.ToString("0") + "°C"; //  print the value
        }
Exemple #3
0
        private void cmdRead_Click(object sender, System.EventArgs e)
        {
            int  SampleNum;
            int  i;
            int FirstPoint;
            MccDaq.ErrorInfo ULStat;
            int Rate;
            MccDaq.ScanOptions Options;
            int Count;
            int PretrigCount;

            MccDaq.DigitalPortDirection Direction;
            MccDaq.DigitalPortType PortNum;

            //configure FirstPortA  for digital input;
            PortNum = (MccDaq.DigitalPortType) ChanArray[1];
            Direction = MccDaq.DigitalPortDirection.DigitalIn;
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);

            // Collect the values with cbDaqInScan()
            //  Parameters:
            //    BoardNum        :the number used by CB.CFG to describe this board
            //    ChanArray[]     :array of channel values
            //    ChanTypeArray[] : array of channel types
            //    GainArray[]     :array of gain values
            //    ChansCount      :the number of elements in the arrays (0=disable queue)
            //    PretrigCount    :number of pre-trigger A/D samples to collect
            //    Count           :the total number of A/D samples to collect
            //    Rate            :sample rate in samples per second
            //    ADData[]        :the array for the collected data values
            //    Options         :data collection options

            PretrigCount = 0;
            Count = NumElements; // Number of data points to collect
            Options = MccDaq.ScanOptions.ConvertData;
            Rate = 100; // Acquire data at 100 Hz

            if(MemHandle == 0)          // check that a handle to a memory buffer exists
                Application.Exit();

            ULStat = DaqBoard.DaqInScan(ChanArray, ChanTypeArray, GainArray, ChanCount, ref Rate, ref PretrigCount, ref Count, MemHandle, Options);

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

            // Convert CJC  and TC reading to temperature
            // Parameters:
            //         BoardNum        :the number used by CB.CFG to describe this board
            //         ChanArray[]     :array of channel values
            //         ChanTypeArray[] : array of channel types
            //         ChanCount       :the number of channels
            //         MemHandle       :the collected raw data values
            //         FirstPoint      :the scan index that holds the first sample of the first channel to be converted.
            //         Count           :the number of samples per channel to be converted.
            //         CBScale         :temperature scale (Celsius, Fahrenheit, Kelvin)
            //         TempValArray[]  :the array for the temperature data values

            CBScale = MccDaq.TempScale.Celsius;
            Count = NumPoints;

            ULStat = DaqBoard.GetTCValues(ChanArray, ChanTypeArray, ChanCount, MemHandle, FirstPoint, Count, CBScale, out TempValArray[0]);

            i = 0;
            for(SampleNum = 0;  SampleNum < NumPoints; SampleNum++)
            {
                lblADData[i].Text = ADData[ChanCount * SampleNum].ToString("D");
                i = i + 1;
                lblADData[i].Text = ADData[ChanCount * SampleNum + 1].ToString("D");
                i = i + 1;
                lblADData[i].Text = TempValArray[TcChanCount * SampleNum].ToString("0.000 °C");
                i = i + 1;
                lblADData[i].Text = TempValArray[TcChanCount * SampleNum + 1].ToString("0.000°C");
                i = i + 1;
            }
        }
 protected override void Init()
 {
     m_buffer = new float[1];
     m_channels = new MccDAQChannel[m_channelsNum];
     m_status = MccService.ErrHandling(ErrorReporting.DontPrint, ErrorHandling.DontStop);
     DaqBoard = new MccDaq.MccBoard(m_board);
     m_status = DaqBoard.BoardConfig.GetUsesExps(out UsesEXPs);
     if (m_status.Value == ErrorInfo.ErrorCode.BadBoard)
     {
         throw new ArgumentException(String.Format("MccDAQBoard number {0} failed to init! Check Instacal for valid board numbers.", m_board));
     }
     m_units = MccDaq.TempScale.Celsius;
     m_options = 0;
 }