Exemple #1
0
        public frm9513Int()
        {
            // 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);


            lblCount      = (new Label[] { _lblCount_0, _lblCount_1, _lblCount_3, _lblCount_4 });
            lblCounterNum = (new Label[] { _lblCounterNum_0, _lblCounterNum_1, _lblCounterNum_3, _lblCounterNum_4 });
            lblIntStatus  = (new Label[] { _lblIntStatus_0, _lblIntStatus_1, _lblIntStatus_3, _lblIntStatus_4 });


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

            // Set aside enough memory to hold the data from all counters (whether enable or not)
            //   IntCount interrupts. We use MaxNumCntrs here in case actual NumCntrs had not been
            //   updated; while allocating too much memory is harmless, not enough could crash system.
            MemHandle = MccDaq.MccService.WinBufAlloc(IntCount * MaxNumCntrs);


            //  Initialize the board level features
            //   Parameters:
            //     ChipNum    :chip to be initialized (1 for CTR5, 1 or 2 for CTR10)
            //     FOutDivider:the F-Out divider (0-15)
            //     Source     :the signal source for F-Out
            //     Compare1   :status of comparator 1
            //     Compare2   :status of comparator 2
            //     TimeOfDayCounting  :time of day mode control
            int FOutDivider = 10;                                                //  sets up OSC OUT for 10Hz signal which can

            MccDaq.CounterSource Source            = MccDaq.CounterSource.Freq5; //  be used as interrupt source for this example
            MccDaq.CompareValue  Compare1          = MccDaq.CompareValue.Disabled;
            MccDaq.CompareValue  Compare2          = MccDaq.CompareValue.Disabled;
            MccDaq.TimeOfDay     TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
            ULStat = DaqBoard.C9513Init(ChipNum, FOutDivider, Source, Compare1, Compare2, TimeOfDayCounting);


            //  Set the configurable operations of the counter
            //   Parameters:
            //     CounterNum     :the counter to be configured (1 to 5)
            //     GateControl    :gate control value
            //     CounterEdge    :which edge to count
            //     CountSource    :signal source
            //     SpecialGate    :status of special gate
            //     Reload         :method of reloading
            //     RecyleMode     :recyle mode
            //     BCDMode        :counting mode, Binary or BCD
            //     CountDirection :direction for the counting operation (COUNTUP or COUNTDOWN)
            //     OutputControl  :output signal type and level

            //  Initialize variables for the first of two counters
            int CounterNum = 1;             //  number of counter used

            MccDaq.GateControl        GateControl    = MccDaq.GateControl.NoGate;
            MccDaq.CountEdge          CounterEdge    = MccDaq.CountEdge.PositiveEdge;
            MccDaq.CounterSource      CountSource    = MccDaq.CounterSource.Freq3;
            MccDaq.OptionState        SpecialGate    = MccDaq.OptionState.Disabled;
            MccDaq.Reload             Reload         = MccDaq.Reload.LoadReg;
            MccDaq.RecycleMode        RecycleMode    = MccDaq.RecycleMode.Recycle;
            MccDaq.BCDMode            BCDMode        = MccDaq.BCDMode.Disabled;
            MccDaq.CountDirection     CountDirection = MccDaq.CountDirection.CountUp;
            MccDaq.C9513OutputControl OutputControl  = MccDaq.C9513OutputControl.AlwaysLow;
            ULStat = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);


            //  Initialize variables for the second counter
            CounterNum = 2;             //  number of counter used
            ULStat     = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);



            //  Load the 2 counters with starting values of zero with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the register for loading the counter with the starting value
            //     LoadValue  :the starting value to place in the counter
            int LoadValue = 0;

            MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1;             //  name of register in counter 1
            ULStat = DaqBoard.CLoad(RegName, LoadValue);


            RegName = MccDaq.CounterRegister.LoadReg2;             //  name of register in counter 2
            ULStat  = DaqBoard.CLoad(RegName, LoadValue);
        }
Exemple #2
0
        private void frm9513Ctr_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                lblDemoFunction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                       " has no 9513 counters.";
                lblDemoFunction.ForeColor = Color.Red;
            }
            else
            {
                //  Initialize the board level features
                //   Parameters:
                //     ChipNum       :Chip to be initialized (1 for CTR05, 1 or 2 for CTR10)
                //     FOutDivider   :the F-Out divider (0-15)
                //     FOutSource    :the signal source for F-Out
                //     Compare1      :status of comparator 1
                //     Compare2      :status of comparator 2
                //     TimeOfDay     :time of day mode control
                short FOutDivider = 0;
                int   ChipNum     = 1;
                MccDaq.CounterSource FOutSource        = MccDaq.CounterSource.Freq4;
                MccDaq.CompareValue  Compare1          = MccDaq.CompareValue.Disabled;
                MccDaq.CompareValue  Compare2          = MccDaq.CompareValue.Disabled;
                MccDaq.TimeOfDay     TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
                MccDaq.ErrorInfo     ULStat            = DaqBoard.C9513Init(ChipNum, FOutDivider, FOutSource, Compare1, Compare2, TimeOfDayCounting);


                //  Set the configurable operations of the counter
                //   Parameters:
                //     CounterNum     :the counter to be configured (1 to 5 for CTR05)
                //     GateControl    :gate control value
                //     CounterEdge    :which edge to count
                //     CountSource    :signal source
                //     SpecialGate    :status of special gate
                //     Reload         :method of reloading
                //     RecyleMode     :recyle mode
                //     BCDMode        :counting mode, Binary or BCD
                //     CountDirection :direction for the counting operation (COUNTUP or COUNTDOWN)
                //     OutputControl  :output signal type and level
                MccDaq.GateControl        GateControl    = MccDaq.GateControl.NoGate;
                MccDaq.CountEdge          CounterEdge    = MccDaq.CountEdge.PositiveEdge;
                MccDaq.CounterSource      CountSource    = MccDaq.CounterSource.Freq4;
                MccDaq.OptionState        SpecialGate    = MccDaq.OptionState.Disabled;
                MccDaq.Reload             Reload         = MccDaq.Reload.LoadReg;
                MccDaq.RecycleMode        RecycleMode    = MccDaq.RecycleMode.Recycle;
                MccDaq.BCDMode            BCDMode        = MccDaq.BCDMode.Disabled;
                MccDaq.CountDirection     CountDirection = MccDaq.CountDirection.CountUp;
                MccDaq.C9513OutputControl OutputControl  = MccDaq.C9513OutputControl.AlwaysLow;
                ULStat = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);


                //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
                //   Parameters:
                //     RegName    :the register for loading the counter with the starting value
                //     LoadValue  :the starting value to place in the counter
                MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  name of register in counter 1
                int LoadValue = 1000;
                ULStat = DaqBoard.CLoad(RegName, LoadValue);

                lblLoadValue.Text         = "Value loaded to counter " + CounterNum.ToString() + ":";
                lblShowLoadVal.Text       = LoadValue.ToString("0");
                this.lblDemoFunction.Text = "Demonstration of 9513 Counter Functions using board "
                                            + DaqBoard.BoardNum.ToString() + ".";
                tmrReadCounter.Enabled = true;
            }
        }
Exemple #3
0
        const short ChipNum  = 1;       //  use chip 1 for CTR05 or for first
        //  chip on CTR10

        public frm9513Ctr()
        {
            // 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);


            //  Initialize the board level features
            //   Parameters:
            //     ChipNum       :Chip to be initialized (1 for CTR05, 1 or 2 for CTR10)
            //     FOutDivider   :the F-Out divider (0-15)
            //     FOutSource    :the signal source for F-Out
            //     Compare1      :status of comparator 1
            //     Compare2      :status of comparator 2
            //     TimeOfDay     :time of day mode control
            short FOutDivider = 0;

            MccDaq.CounterSource FOutSource        = MccDaq.CounterSource.Freq4;
            MccDaq.CompareValue  Compare1          = MccDaq.CompareValue.Disabled;
            MccDaq.CompareValue  Compare2          = MccDaq.CompareValue.Disabled;
            MccDaq.TimeOfDay     TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
            ULStat = DaqBoard.C9513Init(ChipNum, FOutDivider, FOutSource, Compare1, Compare2, TimeOfDayCounting);


            //  Set the configurable operations of the counter
            //   Parameters:
            //     CounterNum     :the counter to be configured (1 to 5 for CTR05)
            //     GateControl    :gate control value
            //     CounterEdge    :which edge to count
            //     CountSource    :signal source
            //     SpecialGate    :status of special gate
            //     Reload         :method of reloading
            //     RecyleMode     :recyle mode
            //     BCDMode        :counting mode, Binary or BCD
            //     CountDirection :direction for the counting operation (COUNTUP or COUNTDOWN)
            //     OutputControl  :output signal type and level
            MccDaq.GateControl        GateControl    = MccDaq.GateControl.NoGate;
            MccDaq.CountEdge          CounterEdge    = MccDaq.CountEdge.PositiveEdge;
            MccDaq.CounterSource      CountSource    = MccDaq.CounterSource.Freq4;
            MccDaq.OptionState        SpecialGate    = MccDaq.OptionState.Disabled;
            MccDaq.Reload             Reload         = MccDaq.Reload.LoadReg;
            MccDaq.RecycleMode        RecycleMode    = MccDaq.RecycleMode.Recycle;
            MccDaq.BCDMode            BCDMode        = MccDaq.BCDMode.Disabled;
            MccDaq.CountDirection     CountDirection = MccDaq.CountDirection.CountUp;
            MccDaq.C9513OutputControl OutputControl  = MccDaq.C9513OutputControl.AlwaysLow;
            ULStat = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);


            //  Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //     RegName    :the register for loading the counter with the starting value
            //     LoadValue  :the starting value to place in the counter
            MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1;     //  name of register in counter 1
            int LoadValue = 1000;

            ULStat = DaqBoard.CLoad(RegName, LoadValue);


            lblLoadValue.Text   = "Value loaded to counter:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
        private void frm9513Int_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                lblInstruction.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                      " has no 9513 counters.";
                cmdStartInt.Enabled = false;
            }
            else
            {
                // Set aside enough memory to hold the data from all counters (whether enable or not)
                //   IntCount interrupts. We use MaxNumCntrs here in case actual NumCntrs had not been
                //   updated; while allocating too much memory is harmless, not enough could crash system.
                DataBuffer  = new ushort[NumCtrs];
                CntrControl = new MccDaq.CounterControl[NumCtrs];
                MemHandle   = MccDaq.MccService.WinBufAllocEx(IntCount * NumCtrs);


                //  Initialize the board level features
                //   Parameters:
                //     ChipNum    :chip to be initialized (1 for CTR5, 1 or 2 for CTR10)
                //     FOutDivider:the F-Out divider (0-15)
                //     Source     :the signal source for F-Out
                //     Compare1   :status of comparator 1
                //     Compare2   :status of comparator 2
                //     TimeOfDayCounting  :time of day mode control
                int FOutDivider                        = 10;                         //  sets up OSC OUT for 10Hz signal which can
                MccDaq.CounterSource Source            = MccDaq.CounterSource.Freq5; //  be used as interrupt source for this example
                MccDaq.CompareValue  Compare1          = MccDaq.CompareValue.Disabled;
                MccDaq.CompareValue  Compare2          = MccDaq.CompareValue.Disabled;
                MccDaq.TimeOfDay     TimeOfDayCounting = MccDaq.TimeOfDay.Disabled;
                MccDaq.ErrorInfo     ULStat            = DaqBoard.C9513Init(ChipNum, FOutDivider, Source, Compare1, Compare2, TimeOfDayCounting);


                //  Set the configurable operations of the counter
                //   Parameters:
                //     CounterNum     :the counter to be configured (1 to 5)
                //     GateControl    :gate control value
                //     CounterEdge    :which edge to count
                //     CountSource    :signal source
                //     SpecialGate    :status of special gate
                //     Reload         :method of reloading
                //     RecyleMode     :recyle mode
                //     BCDMode        :counting mode, Binary or BCD
                //     CountDirection :direction for the counting operation (COUNTUP or COUNTDOWN)
                //     OutputControl  :output signal type and level

                //  Initialize variables for the first of two counters
                MccDaq.GateControl        GateControl    = MccDaq.GateControl.NoGate;
                MccDaq.CountEdge          CounterEdge    = MccDaq.CountEdge.PositiveEdge;
                MccDaq.CounterSource      CountSource    = MccDaq.CounterSource.Freq3;
                MccDaq.OptionState        SpecialGate    = MccDaq.OptionState.Disabled;
                MccDaq.Reload             Reload         = MccDaq.Reload.LoadReg;
                MccDaq.RecycleMode        RecycleMode    = MccDaq.RecycleMode.Recycle;
                MccDaq.BCDMode            BCDMode        = MccDaq.BCDMode.Disabled;
                MccDaq.CountDirection     CountDirection = MccDaq.CountDirection.CountUp;
                MccDaq.C9513OutputControl OutputControl  = MccDaq.C9513OutputControl.AlwaysLow;
                ULStat = DaqBoard.C9513Config(CounterNum, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);


                //  Initialize variables for the second counter
                int SecondCounter = CounterNum + 1;

                ULStat = DaqBoard.C9513Config(SecondCounter, GateControl, CounterEdge, CountSource, SpecialGate, Reload, RecycleMode, BCDMode, CountDirection, OutputControl);

                //  Load the 2 counters with starting values of zero with MccDaq.MccBoard.CLoad()
                //   Parameters:
                //     RegName    :the register for loading the counter with the starting value
                //     LoadValue  :the starting value to place in the counter
                int LoadValue = 0;
                RegName = (CounterRegister)Enum.Parse(typeof(CounterRegister), CounterNum.ToString());
                ULStat  = DaqBoard.CLoad(RegName, LoadValue);


                RegName = (CounterRegister)Enum.Parse(typeof(CounterRegister), SecondCounter.ToString());
                ULStat  = DaqBoard.CLoad(RegName, LoadValue);
                this.lblDemoFunction.Text =
                    "Demonstration of 9513 Counter using Interrupts using board " +
                    DaqBoard.BoardNum.ToString() + ".";
                tmrReadStatus.Enabled = true;
            }
        }