Ejemplo n.º 1
0
        const short CounterNum = 1;         //  Counter number

        public frm7266Ctr()
        {
            // 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 the configurable operations of the counter
            //  Parameters:
            //          CounterNum     :the counter to be configured (0-5)
            //          Quadrature     :Select type of counter input
            //          CountingMode   :Slects how counter will operate
            //          IndexMode      :Selects what index signal will control
            //          InvertIndex    :Set to ENABLED id index signal is inverted
            //          FlagPins       :Select which signals will drive Flag pins
            //          GateEnable     :Set to ENABLED to use external gating signal */
            MccDaq.Quadrature   Quadrature   = MccDaq.Quadrature.X1Quad;
            MccDaq.CountingMode CountingMode = MccDaq.CountingMode.ModuloN;
            MccDaq.DataEncoding DataEncoding = MccDaq.DataEncoding.BinaryEncoding;
            MccDaq.IndexMode    IndexMode    = MccDaq.IndexMode.IndexDisabled;
            MccDaq.OptionState  InvertIndex  = MccDaq.OptionState.Disabled;
            MccDaq.FlagPins     FlagPins     = MccDaq.FlagPins.CarryBorrow;
            MccDaq.OptionState  GateEnable   = MccDaq.OptionState.Disabled;
            ULStat = DaqBoard.C7266Config(CounterNum, Quadrature, CountingMode, DataEncoding, IndexMode, InvertIndex, FlagPins, GateEnable);



            //  Send a starting value to the counter with Mccdaq.MccBoard.CLoad32()
            //   Parameters:
            //     RegName    :the counter to be loaded with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 1000;

            //  Convert the value of the counter number to MccDaq.CounterRegister
            MccDaq.CounterRegister RegName = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadCount1 + CounterNum - 1);
            ULStat = DaqBoard.CLoad32(RegName, LoadValue);

            lblShowLoadVal.Text = LoadValue.ToString("0");

            LoadValue = 2000;
            RegName   = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadPreset1 + CounterNum - 1);

            ULStat             = DaqBoard.CLoad32(RegName, LoadValue);
            lblShowMaxVal.Text = LoadValue.ToString("0");

            tmrReadCounter.Enabled = true;
        }
Ejemplo n.º 2
0
        private void frm7266Ctr_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                   " has no 7266 counters.";
            }
            else
            {
                //  Set the configurable operations of the counter
                //  Parameters:
                //          CounterNum     :the counter to be configured (0-5)
                //          Quadrature     :Select type of counter input
                //          CountingMode   :Slects how counter will operate
                //          IndexMode      :Selects what index signal will control
                //          InvertIndex    :Set to ENABLED id index signal is inverted
                //          FlagPins       :Select which signals will drive Flag pins
                //          GateEnable     :Set to ENABLED to use external gating signal */
                MccDaq.Quadrature   Quadrature   = MccDaq.Quadrature.X1Quad;
                MccDaq.CountingMode CountingMode = MccDaq.CountingMode.ModuloN;
                MccDaq.DataEncoding DataEncoding = MccDaq.DataEncoding.BinaryEncoding;
                MccDaq.IndexMode    IndexMode    = MccDaq.IndexMode.IndexDisabled;
                MccDaq.OptionState  InvertIndex  = MccDaq.OptionState.Disabled;
                MccDaq.FlagPins     FlagPins     = MccDaq.FlagPins.CarryBorrow;
                MccDaq.OptionState  GateEnable   = MccDaq.OptionState.Disabled;
                MccDaq.ErrorInfo    ULStat       = DaqBoard.C7266Config(CounterNum, Quadrature,
                                                                        CountingMode, DataEncoding, IndexMode, InvertIndex, FlagPins, GateEnable);


                //  Send a starting value to the counter with Mccdaq.MccBoard.CLoad32()
                //   Parameters:
                //     RegName    :the counter to be loaded with the starting value
                //     LoadValue  :the starting value to place in the counter
                int LoadValue = 1000;

                //  Convert the value of the counter number to MccDaq.CounterRegister
                RegName = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadCount1 + CounterNum - 1);
                ULStat  = DaqBoard.CLoad32(RegName, LoadValue);

                lblShowLoadVal.Text = LoadValue.ToString("0");

                LoadValue = 2000;
                RegName   = (MccDaq.CounterRegister)(MccDaq.CounterRegister.QuadPreset1 + CounterNum - 1);

                ULStat             = DaqBoard.CLoad32(RegName, LoadValue);
                lblShowMaxVal.Text = LoadValue.ToString("0");
                lblInstruct.Text   = "Reading 7266 counters on board "
                                     + DaqBoard.BoardNum.ToString() + ".";

                tmrReadCounter.Enabled = true;
            }
        }