Example #1
0
        private void frmCountTest_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                CounterType = Counters.clsCounters.CTRSCAN;
                NumCtrs     = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            }
            if (NumCtrs == 0)
            {
                lblNoteFreqIn.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                     " has no event counters.";
            }
            else
            {
                //  Clear the counter to zero with MccDaq.MccBoard.CClear()
                //   Parameters:
                //     CounterNum :the counter number to be cleared to zero

                MccDaq.ErrorInfo ULStat = DaqBoard.CClear(CounterNum);

                lblCountLoaded.Text = "Counter starting value cleared to zero:";
                lblShowLoadVal.Text = "0";
                lblNoteFreqIn.Text  =
                    "NOTE: There must be a TTL frequency at the counter "
                    + CounterNum.ToString() + " input on board " +
                    DaqBoard.BoardNum.ToString() + ".";
                this.lblCountRead.Text = "Value read from counter "
                                         + CounterNum.ToString() + ":";
                tmrReadCount.Enabled = true;
            }
        }
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            bool   IsValidNumber = true;
            double frequency     = 1000000.0;

            try
            {
                frequency = double.Parse(txtFrequencyToSet.Text);
            }

            catch (Exception)
            {
                MessageBox.Show(txtFrequencyToSet.Text + " is not a valid frequency value",
                                "Invalid Frequency ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsValidNumber = false;
            }

            if (IsValidNumber)
            {
                double frequencySet = frequency;
                //  Parameters:
                //    TimerNum       :the timer output channel
                //    Frequency      :the frequency to output
                MccDaq.ErrorInfo ULStat = DaqBoard.TimerOutStart(0, ref frequency);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblValueSent.Text = "The frequency sent to timer "
                                        + CounterNum.ToString() + " was:";
                    lblFrequency.Text = "The frequency output from timer channel "
                                        + CounterNum.ToString() + " is:";
                    lblShowValue.Text     = frequencySet.ToString("0.0##") + " Hz";
                    lblShowFrequency.Text = frequency.ToString("0.0##") + " Hz";
                }
            }
        }
        private void UpdateButton_Click(object sender, System.EventArgs e)
        {
            bool            IsValidNumber = true;
            double          frequency     = 1000000.0;
            double          dutyCycle     = .5;
            uint            pulseCount    = 0;
            double          initialDelay  = 0;
            IdleState       idleState     = IdleState.Low;
            PulseOutOptions options       = PulseOutOptions.Default;

            try
            {
                frequency = double.Parse(txtFrequencyToSet.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(txtFrequencyToSet.Text + " is not a valid frequency value", "Invalid Frequency ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsValidNumber = false;
            }

            try
            {
                dutyCycle = double.Parse(txtDutyCycleToSet.Text);
            }

            catch (Exception)
            {
                MessageBox.Show(txtDutyCycleToSet.Text + " is not a valid duty cycle value", "Invalid Duty Cycle ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsValidNumber = false;
            }

            if (IsValidNumber)
            {
                double frequencySet = frequency;
                double dutyCycleSet = dutyCycle;


                //  Parameters:
                //    TimerNum       :the timer output channel
                //    Frequency      :the frequency to output
                MccDaq.ErrorInfo ULStat = DaqBoard.PulseOutStart(0, ref frequency, ref dutyCycle, pulseCount, ref initialDelay, idleState, options);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblValueSent.Text = "The frequency sent to timer "
                                        + CounterNum.ToString() + " was:";
                    lblFrequency.Text = "The frequency output from timer channel "
                                        + CounterNum.ToString() + " is:";
                    lblShowValue.Text     = frequencySet.ToString("0.0######") + " Hz";
                    lblShowFrequency.Text = frequency.ToString("0.0#####") + " Hz";

                    lblDCValueSent.Text = "The duty cycle sent to timer "
                                          + CounterNum.ToString() + " was:";
                    lblDutyCycle.Text = "The duty cycle output from timer channel "
                                        + CounterNum.ToString() + " is:";
                    lblDCShowValue.Text   = dutyCycleSet.ToString("0.0#####");
                    lblShowDutyCycle.Text = dutyCycle.ToString("0.0#####");
                }
            }
        }
Example #4
0
        private void tmrReadCounter_Tick(object eventSender, System.EventArgs eventArgs)
        {
            tmrReadCounter.Stop();

            // Read the counter value
            //  Parameters:
            //    CounterNum	:the counter to be read
            //    Count			:the count value in the counter
            ushort Count = 0;

            MccDaq.ErrorInfo ULStat = DaqBoard.CIn(CounterNum, out Count);

            lblReadValue.Text   = "Value read from counter " + CounterNum.ToString() + ":";
            lblShowReadVal.Text = Count.ToString("0");

            tmrReadCounter.Start();
        }
Example #5
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)
        {
            // Send a starting value to the counter with MccDaq.MccBoard.CLoad()
            //   Parameters:
            //      RegName    :the counter to be loading with the starting value
            //      LoadValue  :the starting value to place in the counter
            int LoadValue = 1000;

            RegName = (CounterRegister)Enum.Parse(typeof(CounterRegister), CounterNum.ToString());
            MccDaq.ErrorInfo ULStat = DaqBoard.CLoad(RegName, LoadValue);


            // Start a timer to read counter at 500ms interval
            lblCountLoaded.Text = "The value loaded into LOADREG1 was: ";
            lblShowLoadVal.Text = LoadValue.ToString("0");

            tmrReadCounter.Enabled = true;
        }
Example #6
0
        private void frmCountTest_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                lblNoteFreqIn.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                     " has no 8254 counters.";
            }
            else
            {
                //  Configure the counter for desired operation
                //   Parameters:
                //     CounterNum :the counter to be setup
                //     Config     :the operation mode of counter to be configured
                MccDaq.C8254Mode Config = MccDaq.C8254Mode.HighOnLastCount;
                MccDaq.ErrorInfo ULStat = DaqBoard.C8254Config(CounterNum, Config);

                //  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
                int LoadValue = 1000;

                RegName = (CounterRegister)Enum.Parse(typeof(CounterRegister), CounterNum.ToString());
                ULStat  = DaqBoard.CLoad(RegName, LoadValue);

                lblNoteFreqIn.Text =
                    "NOTE: There must be a TTL frequency at the counter " +
                    CounterNum.ToString() + " input on board " +
                    DaqBoard.BoardNum.ToString() + ".";
                this.lblCountRead.Text = "Value read from counter " + CounterNum.ToString() + ":";
                lblCountLoaded.Text    = "Counter starting value loaded:";
                lblShowLoadVal.Text    = LoadValue.ToString("0");
                tmrReadCount.Enabled   = true;
            }
        }
Example #7
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;
            }
        }
Example #8
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;
            }
        }