Example #1
0
        private void initialize_device_Click(object sender, EventArgs e)
        {
            relayBoard = new MccDaq.MccBoard(0);
            errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.DontStop);

            board_name.Text = relayBoard.BoardName;
        }
Example #2
0
        private void hsbSetDOutVal_Change(int newScrollValue)
        {
            //  get a value to write to the port
            ushort DataValue = (ushort)newScrollValue;

            txtValSet.Text = DataValue.ToString("0");

            //  write the value to the output port
            //   Parameters:
            //     PortNum    :the output port
            //     DataValue  :the value written to the port

            MccDaq.ErrorInfo ULStat = DaqBoard.DOut(PortNum, DataValue);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                lblShowValOut.Text = DataValue.ToString("0");
            }
        }
Example #3
0
        private void InitUL()
        {
            //  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

            clsErrorDefs.ReportError = MccDaq.ErrorReporting.PrintAll;
            clsErrorDefs.HandleError = MccDaq.ErrorHandling.StopAll;
            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling
                                          (ErrorReporting.PrintAll, ErrorHandling.StopAll);

            //  This gives us access to labels via an indexed array
            lblADData = (new Label[] { this._lblADData_0, this._lblADData_1,
                                       this._lblADData_2, this._lblADData_3, this._lblADData_4,
                                       this._lblADData_5, this._lblADData_6, this._lblADData_7 });
        }
Example #4
0
        //constuctor for the dyno
        public Dyno()
        {
            isDynCon = false;

            //Initialize Error Handling
            ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            //Create an object for board 0
            DaqBoard = new MccDaq.MccBoard(0);

            //Set the range
            Range = MccDaq.Range.Bip10Volts;
            //  return scaled data
            Options = MccDaq.ScanOptions.ScaleData;

            // creating and defining the objects for the moving average
            filterLength = 5;
            averager     = new MovingAverage(filterLength);

            // Try to initialize the dyno control port and catch any errors
            try
            {
                //Set up port for controlling the dyno
                DynoControlPort          = new SerialPort();
                DynoControlPort.PortName = "COM3";
                DynoControlPort.BaudRate = 4800;
                DynoControlPort.Parity   = Parity.None;
                DynoControlPort.StopBits = StopBits.One;
                DynoControlPort.DataBits = 8;
                DynoControlPort.Open();
            }
            catch (System.IO.IOException e)
            {
                //MessageBox.Show("Open device manager in windows and the 'Setup Serial Ports' section of the C# code and check the serial port names and settings are correct\n\n" + e.ToString(), "Serial Port Error");
                //Process.GetCurrentProcess().Kill();
            }
            catch (System.UnauthorizedAccessException e)
            {
                //MessageBox.Show("Something is wrong? maybe try to restart computer?\n\nHere is some error message stuff...\n\n" + e.ToString(), "Serial Port Error");
                //Process.GetCurrentProcess().Kill();
            }
        }
Example #5
0
        private void tmrStartConvert_Tick(object eventSender, System.EventArgs eventArgs) /* Handles tmrStartConvert.Tick */
        {
            ushort DataValue;
            int    Chan      = int.Parse(txtShowChannel.Text);
            float  EngUnits  = float.Parse(txtShowTrigSet.Text);
            ushort TrigValue = GetTrigCounts(Range, EngUnits);

            MccDaq.TriggerType TrigType;
            if (chkNegTrigger.Checked == true)
            {
                TrigType = MccDaq.TriggerType.TrigBelow;
            }
            else
            {
                TrigType = MccDaq.TriggerType.TrigAbove;
            }

            tmrStartConvert.Stop();

            //  Monitor the channel with MccDaq.MccBoard.ATrig
            //   The input value that meets the threshold will become DataValue
            //   The data value will be updated and displayed until a Stop event occurs.
            //   Parameters:
            //     Chan       :the input channel number
            //     TrigType   :specifies whether the trigger is to be above
            //                 or below TrigValue
            //     TrigValue  :the threshold value that will cause the trigger
            //     Range      :the range for the board
            //     DataValue  :the input value read from Chan
            MccDaq.ErrorInfo ULStat = DaqBoard.ATrig(Chan, TrigType, TrigValue, Range, out DataValue);


            //  print the value that meets the threshold
            lblTrigStatus.Text    = "The value that caused the last trigger was:";
            lblShowTrigValue.Text = DataValue.ToString("D");

            ULStat            = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits);
            lblShowVolts.Text = EngUnits.ToString("0.00###") + "V";

            tmrStartConvert.Start();
        }
Example #6
0
        private void tmrConvert_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrConvert.Tick */
        {
            tmrConvert.Stop();

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

            //  Parameters:
            //    Chan       :the A/D and channel number; starts at 16
            //                 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;             //  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;

            if (UsesEXPs > 0)
            {
                Chan = int.Parse(txtExpChan.Text) + (ADChan + 1) * 16;
            }
            else
            {
                Chan = int.Parse(txtExpChan.Text);
            }

            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
        }
Example #7
0
        public frm8536Count()
        {
            // 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);


            // Init the counter for desired operation
            //   Parameters:
            //      ChipNum     :the chip to be setup
            //      Ctr1Output  :how the counter output is used
            short ChipNum = 1;

            MccDaq.CtrlOutput Ctr1Output = MccDaq.CtrlOutput.NotLinked;
            ULStat = DaqBoard.C8536Init(ChipNum, Ctr1Output);


            // Configure the counter for desired operation
            //   Parameters:
            //      CounterNum    :which counter
            //      OutputControl :which counter output signal is used
            //      RecycleMode   :reload at 0 ?
            //      TrigType      :trigger type
            CounterNum = 1;
            MccDaq.C8536OutputControl OutputControl = MccDaq.C8536OutputControl.ToggleOnTc;
            MccDaq.RecycleMode        RecycleMode   = MccDaq.RecycleMode.Recycle;
            MccDaq.C8536TriggerType   TrigType      = MccDaq.C8536TriggerType.HWStartTrig;
            ULStat = DaqBoard.C8536Config(CounterNum, OutputControl, RecycleMode, TrigType);
        }
Example #8
0
        public frmDataDisplay()
        {
            // 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);

            //  Determine if the board uses EXP boards for temperature measurements
            UsesEXPs = 0;
            ULStat   = DaqBoard.BoardConfig.GetUsesExps(out UsesEXPs);
        }
Example #9
0
        private void frmInfoDisplay_Load(object sender, EventArgs e)
        {
            //  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);

            LF = Environment.NewLine;

            // Get the max number of boards installed in system
            MaxNumBoards      = MccDaq.GlobalConfig.NumBoards;
            CurrentBoard      = 0;
            txtBoardInfo.Text = LF + LF + LF +
                                "        Click on 'Print Info' to display board information.";

            NumBoards = 0;
        }
Example #10
0
        public frmSendAData()
        {
            // 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);

            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);             //  set aside memory to hold data


            //generate waveform
            ushort FScale = 0;

            DaqBoard.FromEngUnits(MccDaq.Range.Bip5Volts, 5.0f, out FScale);
            for (int i = 0; i <= NumPoints - 1; ++i)
            {
                DAData[i] = Convert.ToUInt16((i * FScale) / NumPoints);
            }

            //move waveform to buffer
            FirstPoint = 0;
            ULStat     = MccDaq.MccService.WinArrayToBuf(ref DAData[0], MemHandle, FirstPoint, NumPoints);


            lblAOutData = (new Label[] { _lblAOutData_0, _lblAOutData_1 });
        }
Example #11
0
        MccDaq.CounterRegister RegName = MccDaq.CounterRegister.LoadReg1; //  register name of counter 1


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


            //  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;
            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;

            ULStat = DaqBoard.CLoad(RegName, LoadValue);

            lblCountLoaded.Text = "Counter starting value loaded:";
            lblShowLoadVal.Text = LoadValue.ToString("0");
        }
Example #12
0
        public frmManualConvert()
        {
            // 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);

            lblGainCode.Text    = "BIP5VOLTS";          // initialize gain
            lblGainCodeVal.Text = MccDaq.Range.Bip5Volts.ToString("D");
            lblMinVal.Text      = "-5";
            lblMaxVal.Text      = "5";
        }
Example #13
0
        public frmSendAData()
        {
            // 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);


            DaqBoard = new MccDaq.MccBoard(0);

            cmbRange.Items.Insert(0, MccDaq.Range.Bip10Volts);
            cmbRange.Items.Insert(1, MccDaq.Range.Bip5Volts);
            cmbRange.Items.Insert(2, MccDaq.Range.Uni10Volts);
            cmbRange.Items.Insert(3, MccDaq.Range.Uni5Volts);
            cmbRange.SelectedIndex = 1;
        }
Example #14
0
        private void PrintDigInfo(MccDaq.MccBoard pBoard)
        {
            // get the number of digital devices for this board
            int numDIPorts = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetDiNumDevs(out numDIPorts);

            int numBits = 0;

            for (int portNum = 0; portNum < numDIPorts; ++portNum)
            {
                // For each digital device, get the base address and number of bits
                numBits = 0;
                ULStat  = pBoard.DioConfig.GetNumBits(portNum, out numBits);

                Info += "     Digital Device #" + portNum.ToString("0") +
                        " : " + numBits.ToString("0") + " bits" + LF;
            }
            if (numDIPorts > 0)
            {
                Info += LF;
            }
        }
Example #15
0
        private void cmdSendData_Click(object eventSender, System.EventArgs eventArgs)         /* Handles cmdSendData.Click */
        {
            //  Parameters:
            //    LowChan    :the lower channel of the scan
            //    HighChan   :the upper channel of the scan
            //    Count      :the number of D/A values to send
            //    Rate       :per channel sampling rate ((samples per second) per channel)
            //    DAData     :array of values to send to the scanned channels
            //    Options    :data send options
            FirstPoint = 0;
            int LowChan  = 0;                                        // First analog output channel
            int HighChan = 1;                                        // Last analog output channel
            int Rate     = 100;                                      // Rate of data update (ignored if board does not support timed analog output)

            MccDaq.Range       Gain    = MccDaq.Range.Bip5Volts;     // Ignored if gain is not programmable
            MccDaq.ScanOptions Options = MccDaq.ScanOptions.Default; // foreground mode scan
            MccDaq.ErrorInfo   ULStat  = DaqBoard.AOutScan(LowChan, HighChan, Count, ref Rate, Gain, MemHandle, Options);

            for (int i = 0; i <= NumPoints - 1; ++i)
            {
                lblAOutData[i].Text = DAData[i].ToString("0");
            }
        }
Example #16
0
        // *----------------------------------------------------------------*
        // *     Initialisation and configuration of the card               *
        // *----------------------------------------------------------------*
        /// <summary>
        /// Constructor that initialise the card
        /// </summary>
        public Card()
        {
            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.
            //              -> PrintAll  : all warnings and errorsencountered will be printed
            //              -> DontPrint : No error printing (in production)
            //     MccDaq.ErrorHandling.
            //              -> StopAll  : If an error is encountered, the program will stop
            //              -> DontStop : No stop (in production)
            ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            // select the first card (the only connected)
            DaqBoard = new MccDaq.MccBoard(0);
            ULStat = DaqBoard.FlashLED();

            //  looking if the card is connected
            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                // if no errors, configuring the card
                GlobalVariables.mode = "normal";

                // FirstPortA as output for heating control
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortA, MccDaq.DigitalPortDirection.DigitalOut);
                ULStat = DaqBoard.DOut(MccDaq.DigitalPortType.FirstPortA, 0); // All is off at startup

                // FirstPortB as input for door and windows
                ULStat = DaqBoard.DConfigPort(MccDaq.DigitalPortType.FirstPortB, MccDaq.DigitalPortDirection.DigitalIn);
            }
            else
            {
                // if error, simulation mode and blocking the card
                GlobalVariables.mode = "simulation";
            }
        }
Example #17
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 #18
0
        private void InitUL()
        {
            //  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



            clsErrorDefs.ReportError = MccDaq.ErrorReporting.PrintAll;
            clsErrorDefs.HandleError = MccDaq.ErrorHandling.StopAll;
            this.gpio_board          = new MccDaq.MccBoard();
            this.err = MccDaq.MccService.ErrHandling
                           (ErrorReporting.PrintAll, ErrorHandling.StopAll);

            this.err = this.gpio_board.BoardConfig.GetDiNumDevs(out this.numChannels);



            if (this.numChannels != 0)
            {
                this.Connected = true;
                for (int i = 0; i < (numChannels - 1); i++)
                {
                    err = this.gpio_board.DConfigPort(Ports[i], DigitalPortDirection.DigitalOut);
                    this.setPort(Ports[i], 0);
                }
            }
            else
            {
                //GPIO is not configured
                this.Connected  = false;
                this.gpio_board = null;
            }
        }
Example #19
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)
        {
            tmrReadInputs.Stop();
            string PortName;
            int    LastBit;

            int BitNum;

            MccDaq.DigitalLogicState BitValue;
            MccDaq.DigitalPortType   BitPort;

            BitPort = DigitalPortType.AuxPort;
            BitNum  = FirstBit;
            if (PortNum > BitPort)
            {
                BitPort = DigitalPortType.FirstPortA;
            }
            for (int i = 0; i < NumBits; ++i)
            {
                //  read the bits of digital input and display

                //   Parameters:
                //     PortNum    :the type of port (must be AUXPORT
                //                 or FIRSTPORTA for bit input)
                //     BitNum     :the number of the bit to read from the port
                //     BitValue   :the value read from the port

                BitNum = FirstBit + i;
                MccDaq.ErrorInfo ULStat = DaqBoard.DBitIn(BitPort, BitNum, out BitValue);
                lblShowBitVal[i].Text = Convert.ToInt32(BitValue).ToString("0");
            }
            PortName       = BitPort.ToString();
            LastBit        = (FirstBit + NumBits) - 1;
            lblBitVal.Text = PortName + ", bit " + FirstBit.ToString() +
                             " - " + LastBit.ToString() + " values:";
            tmrReadInputs.Start();
        }
Example #20
0
        private void frm8536Count_Load(object sender, EventArgs e)
        {
            InitUL();
            NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
            if (NumCtrs == 0)
            {
                lblNoteFreqIn.Text = "Board " + DaqBoard.BoardNum.ToString() +
                                     " has no 8536 counters.";
                cmdStart.Enabled = false;
            }
            else
            {
                // Init the counter for desired operation
                //   Parameters:
                //      ChipNum     :the chip to be setup
                //      Ctr1Output  :how the counter output is used
                short             ChipNum    = 1;
                MccDaq.CtrlOutput Ctr1Output = MccDaq.CtrlOutput.NotLinked;
                MccDaq.ErrorInfo  ULStat     = DaqBoard.C8536Init(ChipNum, Ctr1Output);


                // Configure the counter for desired operation
                //   Parameters:
                //      CounterNum    :which counter
                //      OutputControl :which counter output signal is used
                //      RecycleMode   :reload at 0 ?
                //      TrigType      :trigger type
                CounterNum = 1;
                MccDaq.C8536OutputControl OutputControl = MccDaq.C8536OutputControl.ToggleOnTc;
                MccDaq.RecycleMode        RecycleMode   = MccDaq.RecycleMode.Recycle;
                MccDaq.C8536TriggerType   TrigType      = MccDaq.C8536TriggerType.HWStartTrig;
                ULStat = DaqBoard.C8536Config(CounterNum, OutputControl, RecycleMode, TrigType);
                this.lblNoteFreqIn.Text =
                    "NOTE: There must be a TTL frequency at counter 1 input on board "
                    + DaqBoard.BoardNum.ToString() + ".";
            }
        }
Example #21
0
        public frmStatusDisplay()
        {
            // 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);

            MemHandle = MccDaq.MccService.WinBufAlloc(NumPoints);             //  set aside memory to hold data


            //  Note: Any change to label names requires a change to the corresponding array element below
            lblADData = (new Label[] { _lblADData_0, _lblADData_1, _lblADData_2, _lblADData_3,
                                       _lblADData_4, _lblADData_5, _lblADData_6, _lblADData_7 });
        }
Example #22
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalOut; //  program digital port A for output


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

            //  configure FirstPortA for digital output
            //   Parameters:
            //     PortNum    :the output port
            //     Direction  :sets the port for input or output
            ULStat = DaqBoard.DConfigPort(PortNum, Direction);
        }
Example #23
0
        private void InitUL()
        {
            //  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

            clsErrorDefs.ReportError = MccDaq.ErrorReporting.PrintAll;
            clsErrorDefs.HandleError = MccDaq.ErrorHandling.StopAll;
            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling
                                          (ErrorReporting.PrintAll, ErrorHandling.StopAll);


            //  Note: Any change to label names requires a change to the corresponding array element
            lblConvData = (new Label[] { _lblConvData_0, _lblConvData_1,
                                         _lblConvData_2, _lblConvData_3, _lblConvData_4, _lblConvData_5,
                                         _lblConvData_6, _lblConvData_7, _lblConvData_8, _lblConvData_9 });

            lblShowRaw = (new Label[] { _lblShowRaw_0, _lblShowRaw_1,
                                        _lblShowRaw_2, _lblShowRaw_3, _lblShowRaw_4, _lblShowRaw_5,
                                        _lblShowRaw_6, _lblShowRaw_7, _lblShowRaw_8, _lblShowRaw_9 });
        }
Example #24
0
        private void tmrReadInputs_Tick(object eventSender, System.EventArgs eventArgs)         /* Handles tmrReadInputs.Tick */
        {
            tmrReadInputs.Stop();

            // so invalid bit numbers can be handled locally.
            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.StopAll);

            int BitNum;

            MccDaq.DigitalLogicState BitValue;
            for (int i = 0; i <= 7; ++i)
            {
                //  read the bits of AuxPort digital input and display

                //   Parameters:
                //     PortType    :the type of port
                //     BitNum     :the number of the bit to read from the port
                //     BitValue   :the value read from the port
                BitNum = i;
                ULStat = DaqBoard.DBitIn(PortType, BitNum, out BitValue);
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblShowBitVal[i].Text = Convert.ToInt32(BitValue).ToString("0");
                }
                else if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadBitNumber)
                {
                    lblShowBitVal[i].Text = "X";                     // Trap invalid bit numbers
                }
                else
                {
                    throw(new System.Exception());
                }
            }

            tmrReadInputs.Start();
        }
Example #25
0
        private void PrintExpInfo(MccDaq.MccBoard pBoard)
        {
            //  Get the number of Exps attached to pBoard
            int numEXPs = 0;

            MccDaq.ErrorInfo ULStat = pBoard.BoardConfig.GetNumExps(out numEXPs);

            int BoardType = 0;
            int ADChan1   = 0;
            int ADChan2   = 0;

            for (int expNum = 0; expNum < numEXPs; ++expNum)
            {
                pBoard.ExpansionConfig.GetBoardType(expNum, out BoardType);
                pBoard.ExpansionConfig.GetMuxAdChan1(expNum, out ADChan1);

                if (BoardType == 770)
                {
                    // it's a CIO-EXP32
                    pBoard.ExpansionConfig.GetMuxAdChan2(expNum, out ADChan2);
                    Info += "     A/D channels " + ADChan1.ToString("0") +
                            " and " + ADChan2.ToString("0") + " connected to EXP(devID="
                            + BoardType.ToString("0") + ")." + LF;
                }
                else
                {
                    Info += "     A/D channel " + ADChan1.ToString("0") +
                            " connected to EXP(devID=" + BoardType.ToString("0") + ")." + LF;
                }
            }

            if (Info.Length != 0)
            {
                Info += LF;
            }
        }
Example #26
0
 private void frm9513Freq_Load(object sender, EventArgs e)
 {
     InitUL();
     NumCtrs = CtrProps.FindCountersOfType(DaqBoard, CounterType, out CounterNum);
     if (NumCtrs == 0)
     {
         lblInstruct.Text = "Board " + DaqBoard.BoardNum.ToString() +
                            " has no 9513 counters.";
         cmdMeasureFreq.Enabled = false;
     }
     else
     {
         //  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
         //     TimeOfDay  :time of day mode control
         short FOutDivider                      = 1;                          //  sets up OSC OUT for 10kHz signal which can
         MccDaq.CounterSource Source            = MccDaq.CounterSource.Freq3; //  be used as frequency 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);
         this.lblDemoFunction.Text =
             "Demonstration of Frequency Measurement using 9513 Counter"
             + " using board " + DaqBoard.BoardNum.ToString() + ".";
         this.lblInstruct.Text = "There must be a TTL pulse at counter " +
                                 "1 input on board " + DaqBoard.BoardNum.ToString() +
                                 " with a frequency between 100Hz and  600kHz. Also, " +
                                 "connect the output of counter 4 to the gate of counter 5.";
     }
 }
Example #27
0
 private void InitUL()
 {
     ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);
 }
Example #28
0
        private void cmdStart_Click(object eventSender, System.EventArgs eventArgs)         /* Handles cmdStart.Click */
        {
            cmdStart.Enabled = false;

            //  Select the trigger source using Mccdaq.MccBoard.SetTrigger()
            //  Parameters:
            //    TrigType       :the type of triggering based on external trigger source
            //    LowThreshold   :Low threshold when the trigger input is analog
            //    HighThreshold  :High threshold when the trigger input is analog
            float highVal = 1.0F;

            MccDaq.Range Range         = MccDaq.Range.Bip10Volts;     // analog trigger range
            ushort       HighThreshold = 0;

            MccDaq.ErrorInfo ULStat = DaqBoard.FromEngUnits(Range, highVal, out HighThreshold);

            float  lowVal       = 0.1F;
            ushort LowThreshold = 0;

            ULStat = DaqBoard.FromEngUnits(Range, lowVal, out LowThreshold);

            MccDaq.TriggerType TrigType = MccDaq.TriggerType.TrigAbove;
            ULStat = DaqBoard.SetTrigger(TrigType, LowThreshold, HighThreshold);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                //  Collect the values with MccDaq.MccBoard.AInScan()
                //  Parameters:
                //    LowChan    :the first channel of the scan
                //    HighChan   :the last channel of the scan
                //    Count      :the total number of A/D samples to collect
                //    Rate       :sample rate
                //    Range      :the range for the board
                //    MemHandle  :Handle for Windows buffer to store data in
                //    Options    :data collection options
                int LowChan = 0;                        //  first channel to acquire
                HighChan = int.Parse(txtHighChan.Text); //  last channel to acquire
                if (HighChan > 7)
                {
                    HighChan = 7;
                }
                txtHighChan.Text = HighChan.ToString();

                int Count = NumPoints;                                      //  total number of data points to collect
                int Rate  = 390;                                            //  per channel sampling rate ((samples per second) per channel)
                Range = MccDaq.Range.Bip5Volts;                             // set the range
                MccDaq.ScanOptions Options = MccDaq.ScanOptions.ConvertData //  return data as 12-bit values
                                             | MccDaq.ScanOptions.ExtTrigger;
                ULStat = DaqBoard.AInScan(LowChan, HighChan, Count, ref Rate, Range, MemHandle, Options);

                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange)
                {
                    MessageBox.Show("Change the Range argument to one supported by this board.", "Unsupported Range", 0);
                }


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


                for (int i = 0; i <= HighChan; ++i)
                {
                    lblADData[i].Text = ADData[i].ToString("0");
                }

                for (int j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }
            }
            cmdStart.Enabled = true;
        }
Example #29
0
 // *----------------------------------------------------------------*
 // *     Functions to set output value                              *
 // *----------------------------------------------------------------*
 /// <summary>
 /// Send the hot states to the card.
 /// </summary>
 public void setHotStates()
 {
     for (int RoomId = 1; RoomId <= 3; RoomId++)
     {
         if (GlobalVariables.MyHouse.Rooms[RoomId].hot_is_active)
             ULStat = DaqBoard.DBitOut(MccDaq.DigitalPortType.FirstPortA, RoomId, MccDaq.DigitalLogicState.High);
         else
             ULStat = DaqBoard.DBitOut(MccDaq.DigitalPortType.FirstPortA, RoomId, MccDaq.DigitalLogicState.Low);
     }
 }
Example #30
0
 /// <summary>
 /// Send the light state to the card
 /// </summary>
 public void setLightState()
 {
     if(GlobalVariables.MyHouse.Rooms[0].light_is_active)
         ULStat = DaqBoard.DBitOut(MccDaq.DigitalPortType.FirstPortA, 0, MccDaq.DigitalLogicState.High);
     else
         ULStat = DaqBoard.DBitOut(MccDaq.DigitalPortType.FirstPortA, 0, MccDaq.DigitalLogicState.Low);
 }
Example #31
0
        const MccDaq.DigitalPortDirection Direction = MccDaq.DigitalPortDirection.DigitalOut;         //  program first digital port for output mode


        public frmSetBitOut()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            chkSetBit = (new CheckBox[] { _chkSetBit_0, _chkSetBit_1, _chkSetBit_2, _chkSetBit_3,
                                          _chkSetBit_4, _chkSetBit_5, _chkSetBit_6, _chkSetBit_7 });

            //  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);


            //Get the first port on the device - some devices (such as the
            //USB-ERB08 and USB-SSR08) don't have FirstPortA, but do have
            //FirstPortCL.

            //Parameters:
            //      DevNum      : 0-based digital device index
            //      FirstPort   : return value for type of device

            int DevNum    = 0;
            int FirstPort = 0;

            ULStat = DaqBoard.DioConfig.GetDevType(0, out FirstPort);

            switch (FirstPort)
            {
            case (int)MccDaq.DigitalPortType.FirstPortA:
                FirstBit = 0;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortB:
                FirstBit = 8;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortCL:
                FirstBit = 16;
                break;

            case (int)MccDaq.DigitalPortType.FirstPortCH:
                FirstBit = 20;
                break;

            default:
                FirstBit = 0;
                break;
            }

            //  configure the first port for digital input
            //   Parameters:
            //     PortNum    :the input port
            //     Direction  :sets the port for input or output

            PortNum = (MccDaq.DigitalPortType)FirstPort;
            ULStat  = DaqBoard.DConfigPort(PortNum, Direction);

            // if the first port is FIRSTPORTCL, configure FIRSTPORTCH, too
            if (PortNum == MccDaq.DigitalPortType.FirstPortCL)
            {
                ULStat = DaqBoard.DConfigPort(PortNum + 1, Direction);
            }
        }
Example #32
0
        private void cmdStartAcq_Click(object eventSender, System.EventArgs eventArgs)
        {
            cmdStartAcq.Enabled    = false;
            cmdStartAcq.Visible    = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;

            //  Parameters:
            //    LowChan    :first A/D channel of the scan
            //    HighChan   :last A/D channel of the scan
            //    Count      :the total number of A/D samples to collect
            //    Rate       :per channel sampling rate ((samples per second) per channel)
            //    Range      :the gain for the board
            //    FileName   :the filename for the collected data values
            //    Options    :data collection options
            int    Count    = NumPoints;
            string FileName = txtFileName.Text; //  a full path may be required here
            int    Rate     = 1000;
            int    LowChan  = 0;
            int    HighChan = 1;

            MccDaq.ScanOptions Options = MccDaq.ScanOptions.Default;

            string DataCount = NumPoints.ToString("0");

            lblAcqStat.Text     = "Collecting " + DataCount + " data points";
            lblShowRate.Text    = Rate.ToString("0");
            lblShowLoChan.Text  = LowChan.ToString("0");
            lblShowHiChan.Text  = HighChan.ToString("0");
            lblShowOptions.Text = Enum.Format(Options.GetType(), Options, "d");
            lblShowGain.Text    = Range.ToString();
            lblShowFile.Text    = FileName;
            lblShowCount.Text   = Count.ToString("0");
            lblShowPreTrig.Text = "Not Applicable";
            Application.DoEvents();

            //  Collect the values with Collect the values by calling MccDaq.MccBoard.FileAInScan()

            MccDaq.ErrorInfo ULStat = DaqBoard.FileAInScan
                                          (LowChan, HighChan, Count, ref Rate, Range, FileName, Options);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadFileName)
            {
                MessageBox.Show(
                    "Enter the name of the file to create in text box.",
                    "Bad File Name", 0);
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdStartAcq.Enabled    = true;
                cmdStartAcq.Visible    = true;
                txtFileName.Focus();
                return;
            }


            //  show how many data points were collected
            short FileLowChan;
            short FileHighChan;
            int   TotalCount;
            int   PretrigCount;

            ULStat = MccDaq.MccService.FileGetInfo
                         (FileName, out FileLowChan, out FileHighChan,
                         out PretrigCount, out TotalCount, out Rate, out Range);

            lblReadRate.Text    = Rate.ToString("0");
            lblReadLoChan.Text  = FileLowChan.ToString("0");
            lblReadHiChan.Text  = FileHighChan.ToString("0");
            lblReadOptions.Text = Enum.Format(Options.GetType(), Options, "d");
            lblReadGain.Text    = Range.ToString();
            lblReadFile.Text    = FileName;

            lblReadTotal.Text   = TotalCount.ToString("0");
            lblReadPreTrig.Text = PretrigCount.ToString("0");
        }
Example #33
0
        private bool InternalDAConfig()
        {
            if (DAMemHandle != IntPtr.Zero)
            {
                MccDaq.MccService.WinBufFreeEx(DAMemHandle);
            }

            int FirstPoint = 0;
            DAMemHandle = MccDaq.MccService.ScaledWinBufAllocEx(Count); // set aside memory to hold data
            if (DAMemHandle == IntPtr.Zero)
            {
                return false;
            }

            BuildArray();

            ULStat = MccDaq.MccService.ScaledWinArrayToBuf(DAData, DAMemHandle, FirstPoint, Count);
            return ULStat.Value == ErrorInfo.ErrorCode.NoErrors;
        }
Example #34
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);
        }
Example #35
0
        private void ConfigureOvenBoardDioChannelsForOutput()
        {
            MccDaq.ErrorInfo RetVal = new MccDaq.ErrorInfo();

            if (oven_board == null) return;

            for (int i = 0; i < 7; i++)
            {
                RetVal = oven_board.DConfigBit(DigitalPortType.AuxPort, i,
                    DigitalPortDirection.DigitalOut);
                IsError(this, RetVal, true);
            }
        }
Example #36
0
        public bool StartAll()
        {
            if (!IsInit)
                return false;

            int CurIndex;
            int CurCount;
            short Status;

            Rate = NumPoints;

            MccDaq.ScanOptions options = MccDaq.ScanOptions.Background | MccDaq.ScanOptions.ScaleData;

            if (IsExtTrig)
            {
                options |= ScanOptions.ExtTrigger;
            }

            if (!IsFinite)
            {
                options |= MccDaq.ScanOptions.Continuous;
            }

            int rate = IsFinite ? FiniteRate : Rate;
            int count = IsFinite ? FiniteCount : Count;

            ULStat = DaqBoard.AOutScan(0, NumChannels - 1, count, ref rate, VoltageGain, DAMemHandle, options);

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AoFunction);

            return (Status == MccDaq.MccBoard.Running);
        }
Example #37
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");
        }
Example #38
0
        // *----------------------------------------------------------------*
        // *     Functions to take values                                   *
        // *----------------------------------------------------------------*
        /// <summary>
        /// read the temperature and send it to the model
        /// </summary>
        public void ReadTemp()
        {
            float[] EngUnits;   // [] car array
            System.UInt16 DataValue;

            //  Collect the data by calling AIn memeber function of MccBoard object
            //   Parameters:
            //     Chan       :the input channel number
            //     Range      :the Range for the board.
            //     DataValue  :the name for the value collected
            Range = Range.Bip10Volts; // selectionne un range de 10 V

            // on définit la taille de engunit
            EngUnits = new float[4];

            // taking the values from the card

            for (int i = 0; i <= 3; i++)
            {
                ULStat = DaqBoard.AIn(i, Range, out DataValue);
                // on vérifie si le range est bon
                if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange)
                {
                    MessageBox.Show("Range not upported by the card.",
                        "Unsupported Range", MessageBoxButtons.OK);
                    Application.Exit();
                }

                ULStat = DaqBoard.ToEngUnits(Range, DataValue, out EngUnits[i]);// converting to voltage
                float Value = (EngUnits[i] * 100F / 11F);
                Functions.SaveTemperature(i, Value);
            }
        }
Example #39
0
 public void StopAll()
 {
     if (DaqBoard != null)
     {
         ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AoFunction);
     }
 }
Example #40
0
        /// <summary>
        /// Read all the states and send it to the model
        /// </summary>
        public void ReadStates()
        {
            short DigitalIn;
            ULStat = DaqBoard.DIn(MccDaq.DigitalPortType.FirstPortB, out DigitalIn); // read from the card

            Boolean[] Raw_states = NumberToBinaryArray(DigitalIn);
            // now we have to push this to the model, We have to pay attention because the number is inverted !!!!
            // we can't make a for because this is difficult to attributes it to a array

            GlobalVariables.MyHouse.Walls[0].Openings[0].isOpen = Raw_states[7];
            GlobalVariables.MyHouse.Walls[0].Openings[1].isOpen = Raw_states[6];
            GlobalVariables.MyHouse.Walls[0].Openings[2].isOpen = Raw_states[5];
            GlobalVariables.MyHouse.Walls[1].Openings[0].isOpen = Raw_states[4];
            GlobalVariables.MyHouse.Walls[2].Openings[0].isOpen = Raw_states[3];
            GlobalVariables.MyHouse.Walls[3].Openings[0].isOpen = Raw_states[2];
            GlobalVariables.MyHouse.Walls[4].Openings[0].isOpen = Raw_states[1];
        }
Example #41
0
        /// <summary>
        /// Function that check the luminosity
        /// </summary>
        /// <returns></returns>
        public Boolean IsDay()
        {
            float Voltage;   // [] car array
            System.UInt16 DataValue;

            //  Collect the data by calling AIn memeber function of MccBoard object
            //   Parameters:
            //     Chan       :the input channel number
            //     Range      :the Range for the board.
            //     DataValue  :the name for the value collected
            Range = Range.Bip10Volts; // selectionne un range de 10 V

            ULStat = DaqBoard.AIn(4, Range.Bip10Volts, out DataValue);

            // on vérifie si le range est bon
            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadRange)
            {
                MessageBox.Show("Range not upported by the card.",
                    "Unsupported Range", MessageBoxButtons.OK);
                Application.Exit();
            }

            ULStat = DaqBoard.ToEngUnits(Range, DataValue, out Voltage);// converting to voltage
            Program.MainForm.LightConfProgress.Value = Convert.ToInt16(Voltage * 100/5);

            if (Voltage >= 0.5 + 0.2 * Program.MainForm.ScrollSensibility.Value/5)
                return false;
            else
                return true;
        }
Example #42
0
        private bool InternalFiniteDAConfig()
        {
            if (DAMemHandle != IntPtr.Zero)
            {
                MccDaq.MccService.WinBufFreeEx(DAMemHandle);
            }

            int samples, freq;
            GetMaxFreqSamples(out samples, out freq);

            FiniteRate = freq * 2;
            FiniteNumPoint = samples;

            int FirstPoint = 0;
            DAMemHandle = MccDaq.MccService.ScaledWinBufAllocEx(FiniteCount); // set aside memory to hold data
            if (DAMemHandle == IntPtr.Zero)
            {
                return false;
            }

            BuildFiniteArray();

            ULStat = MccDaq.MccService.ScaledWinArrayToBuf(DAData, DAMemHandle, FirstPoint, FiniteCount);
            return ULStat.Value == ErrorInfo.ErrorCode.NoErrors;
        }
Example #43
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;
            }
        }