|
Add a reference to MccDaq
Go to your Solution Explorer window
Expand the References folder (if it is not already expanded)
Right mouse click on References folder, and select “Add Reference…”
The Add Reference dialog box appears
Scroll down to MccDaq, click on it, click on the Select button at the right
Then click on the ‘OK’ button at the bottom of the dialog box
Add a new instance of a board object
Go to your Solution Explorer window
click on Form1.vb then press F7 to activate the code window
Locate the line “Inherits System.Windows.Forms.Form”
Just after that add “Private DaqBoard As MccDaq.MccBoard” below it
Add the Initialization to Windows Form Designer
Find the grayed out region of code labeled “Windows Form Designer generated code”
Click on the + sign to the left to expand it
Locate the following comment “'Add any initialization after the InitializeComponent() call”
Just after that add the following “InitUL()”
Add Universal Library Initialization code
Minimize the “Windows Form Designer generated code” region by clicking on the – sign next to #Region
Place your cursor just below the end of that region
Then paste in the following code:
#Region "Universal Library Initialization - Expand to change error handling, etc."
Private Sub InitUL()
Dim ULStat As MccDaq.ErrorInfo
' 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 any error is encountered, the program will stop
ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll)
If ULStat.Value <> MccDaq.ErrorInfo.ErrorCode.NoErrors Then
Stop
End If
End Sub
Add the Form1_Load code
Locate the line of code that starts with “Private Sub Form1_Load(ByVal sender…”
Paste in the following code in that procedure:
Dim ULStat As MccDaq.ErrorInfo
Dim BoardNum As Integer
BoardNum = 0
DaqBoard = New MccDaq.MccBoard(BoardNum)
That’s it. From here you can add code and procedures to things such as:
| Analog input: | DaqBoard.AIn |
| Analog InScan: | DaqBoard.AInScan |
| Digital In: | DaqBoard.DIn |
| Digital Out: | DaqBoard.DOut |
| Digital Bit In : | DaqBoard.DBitIn |
| Digital Bit Out: | DaqBoard.DBitOut |
| Analog Out: | DaqBoard.AOut |
| Analog Out Scan: | DaqBoardAOutScan |
Please see the Universal Library function reference guide for more information. |