The simplest way for programming is executing sample programs and confirming the action.
After the action is confirmed, refer to the codes of sample programs, study the used functions.
The usage of functions is described in [Reference For Each Driver]-[Function Reference].
In function reference, there are examples for Visual Basic.NET, Visual C# and Visual C++.
Here the process of basic programming is described. (Brief with example in Visual Basic.NET, it is same in other language.)
In API function library, initialization is done for using device and termination is done after using.
To use plural devices, after the initialization, the ID is returned that designates the device to use.
It is must be specified in condition setting functions and input/output functions.
Example of using digital I/O board in Visual Basic.NET
' Retrieves Id. It is necessary to perform other functions, so declare as global variable.
Dim Id As Short '
Store Id(global variable)
Dim Ret As Integer ' Return
value
Dim InpBuf As Byte ' Input data
' Initialization
Ret =DioInit("DIO080000",Id) ' Store ID
of device DIO080000 to Id
' Get input value for
bit 0 (store value to InpBuf)
Ret = DioInpBit(Id, 0, InpBuf) ' Specify Id retrieved
in initialization
' Termination
Ret =DioExit(Id)
Use plural devices
When using plural devices, do the initialization for each device. So, it is necessary to declare 2 Ids.
Dim Id1 As Short '
Id1(global variable)
Dim Id2 As Short ' Id2(global variable)
Dim Ret As Integer ' Return value
Dim InpBuf As Byte ' Input data
' Initialization
Ret =DioInit("DIO080001", Id1) ' Initialize
device whose device name is DIO080001
Ret =DioInit("DIO080002", Id2) ' Initialize
device whose device name is DIO080002
' Get input value for
bit 0 (store value to InpBuf)
Ret = DioInpBit(Id1, 0, InpBuf) ' Input bit 0 of
"DIO080001"
Ret = DioInpBit(Id2, 0, InpBuf) ' Input bit 0 of
"DIO080002"
' Termination
Ret =DioExit(Id1)
Ret =DioExit(Id2)