Beispiel #1
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            int j;
            int i;

            MccDaq.ErrorInfo ULStat;
            int Rate;
            int Count;
            int FirstCtr;

            MccDaq.ScanOptions Options;

            cmdStart.Enabled = false;

            //  Collect the values by calling MccDaq.MccBoard.CInScan function
            //  Parameters:
            //    FirstCtr   :the first counter of the scan
            //    LastCtr    :the last counter of the scan
            //    Count      :the total number of counter samples to collect
            //    Rate       :sample rate
            //    MemHandle  :Handle for Windows buffer to store data in
            //    Options    :data collection options
            FirstCtr = 0;                          //  first channel to acquire
            LastCtr  = int.Parse(txtLastCtr.Text); //  last channel to acquire
            if ((LastCtr > 3))
            {
                LastCtr = 3;
            }
            txtLastCtr.Text = LastCtr.ToString();

            Count   = NumPoints;                //  total number of data points to collect
            Rate    = 390;                      //  per channel sampling rate ((samples per second) per channel)
            Options = MccDaq.ScanOptions.Ctr32Bit;

            ULStat = DaqBoard.CInScan(FirstCtr, LastCtr, Count, ref Rate, MemHandle, Options);

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

            for (i = 0; i <= LastCtr; ++i)
            {
                lblCounterData[i].Text = CounterData[Count - 1 - LastCtr + i].ToString("D");
            }

            for (j = LastCtr + 1; j <= 3; ++j)
            {
                lblCounterData[j].Text = "0";
            }

            cmdStart.Enabled = true;
        }
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            MccDaq.ErrorInfo ULStat;
            int Rate;
            int Count;
            int FirstCtr;

            MccDaq.ScanOptions Options;

            MccDaq.CounterMode          Mode;
            MccDaq.CounterDebounceTime  DebounceTime;
            MccDaq.CounterDebounceMode  DebounceMode;
            MccDaq.CounterEdgeDetection EdgeDetection;
            MccDaq.CounterTickSize      TickSize;
            int MappedChannel;

            cmdStart.Enabled = false;

            FirstCtr = 0; //  first channel to acquire
            LastCtr  = 0;

            // Setup Counter 0
            // Parameters:
            //   BoardNum       :the number used by CB.CFG to describe this board
            //   CounterNum     :counter to set up
            //   Mode           :counter Mode
            //   DebounceTime   :debounce Time
            //   DebounceMode   :debounce Mode
            //   EdgeDetection  :determines whether the rising edge or falling edge is to be detected
            //   TickSize       :reserved.
            //   MappedChannel     :mapped channel

            // Counter 0
            Mode          = MccDaq.CounterMode.Encoder | MccDaq.CounterMode.EncoderModeX1 | MccDaq.CounterMode.ClearOnZOn;
            DebounceTime  = MccDaq.CounterDebounceTime.DebounceNone;
            DebounceMode  = 0;
            EdgeDetection = MccDaq.CounterEdgeDetection.RisingEdge;
            TickSize      = 0;
            MappedChannel = 2;

            ULStat = DaqBoard.CConfigScan(CounterNum, Mode, DebounceTime, DebounceMode,
                                          EdgeDetection, TickSize, MappedChannel);

            //  Collect the values by calling MccDaq.MccBoard.CInScan function
            //  Parameters:
            //    FirstCtr   :the first counter of the scan
            //    LastCtr    :the last counter of the scan
            //    Count      :the total number of counter samples to collect
            //    Rate       :sample rate
            //    MemHandle  :Handle for Windows buffer to store data in
            //    Options    :data collection options

            Count   = NumPoints; //  total number of data points to collect
            Rate    = 10;        //  per channel sampling rate ((samples per second) per channel)
            Options = MccDaq.ScanOptions.Ctr32Bit;

            ULStat = DaqBoard.CInScan(FirstCtr, LastCtr, Count, ref Rate, MemHandle, Options);

            //  Transfer the data from the memory buffer set up by Windows to an array
            ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, CounterData, FirstPoint, Count);

            string NL = Environment.NewLine;

            txtEncoderValues.Text = " Counter Data" + NL + NL;

            for (int sample = 0; sample < Count; sample++)
            {
                txtEncoderValues.Text += CounterData[sample].ToString("d").PadLeft(6) + NL;
            }

            cmdStart.Enabled = true;
        }
Beispiel #3
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            int i;

            MccDaq.ErrorInfo ULStat;
            int Rate;
            int Count;
            int FirstCtr;

            MccDaq.ScanOptions Options;

            int CounterNum;

            MccDaq.CounterMode          Mode;
            MccDaq.CounterDebounceTime  DebounceTime;
            MccDaq.CounterDebounceMode  DebounceMode;
            MccDaq.CounterEdgeDetection EdgeDetection;
            MccDaq.CounterTickSize      TickSize;
            int MapCounter;

            cmdStart.Enabled = false;

            FirstCtr = 0; //  first channel to acquire
            LastCtr  = 0;

            // Setup Counter 0 for decrement mode mapped in from counter 1
            // Parameters:
            //   BoardNum       :the number used by CB.CFG to describe this board
            //   CounterNum     :counter to set up
            //   Mode           :counter Mode
            //   DebounceTime   :debounce Time
            //   DebounceMode   :debounce Mode
            //   EdgeDetection  :determines whether the rising edge or falling edge is to be detected
            //   TickSize       :reserved.
            //   MapCounter     :mapped counter


            CounterNum    = FirstCtr;
            Mode          = MccDaq.CounterMode.DecrementOn;
            DebounceTime  = MccDaq.CounterDebounceTime.DebounceNone;
            DebounceMode  = 0;
            EdgeDetection = MccDaq.CounterEdgeDetection.FallingEdge;
            TickSize      = 0;
            MapCounter    = 1;

            ULStat = DaqBoard.CConfigScan(CounterNum, Mode, DebounceTime, DebounceMode, EdgeDetection, TickSize, MapCounter);

            //  Collect the values by calling MccDaq.MccBoard.CInScan function
            //  Parameters:
            //    FirstCtr   :the first counter of the scan
            //    LastCtr    :the last counter of the scan
            //    Count      :the total number of counter samples to collect
            //    Rate       :sample rate
            //    MemHandle  :Handle for Windows buffer to store data in
            //    Options    :data collection options

            Count   = NumPoints; //  total number of data points to collect
            Rate    = 390;       //  per channel sampling rate ((samples per second) per channel)
            Options = MccDaq.ScanOptions.Ctr32Bit;

            ULStat = DaqBoard.CInScan(FirstCtr, LastCtr, Count, ref Rate, MemHandle, Options);

            //  Transfer the data from the memory buffer set up by Windows to an array
            ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, CounterData, FirstPoint, Count);

            for (i = 0; i <= 4; ++i)
            {
                lblCounterData[i].Text = CounterData[i].ToString("D");
            }

            cmdStart.Enabled = true;
        }