How do you transfer a number on the excel spread sheet onto a digital output to the 8055 board thanks and regards
In other words, I want to use the Excel Sheet for doing logic functions from the 8055 inputs and then transfer the outcome to the 8055 output channels.
Here is a simple example.
The VBA code reads the digital input data of the K8055 to cell A1.
On the Excel sheet there is added 1 to the value of A1 and the result is put to cell A2.
The value of A2 is then sent to the digital output of the K8055.
Here is the VBA code:
[code]Option Explicit
Private Declare Function OpenDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Sub CloseDevice Lib “k8055d.dll” ()
Private Declare Function ReadAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long) As Long
Private Declare Function ReadAllDigital Lib “k8055d.dll” () As Long
Private Declare Sub WriteAllDigital Lib “k8055d.dll” (ByVal data As Long)
Private Declare Function SetTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Sub Button1_Click()
Dim h As Long
h = OpenDevice(0)
If h = 0 Then
ActiveSheet.Cells(1, 4) = “Card 0 Connected”
TimerSeconds = 0.1 ’ the timer interval is now .1 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
Else
ActiveSheet.Cells(1, 4) = “Card 0 Not Found”
End If
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
ActiveSheet.Cells(1, 1) = ReadAllDigital
WriteAllDigital ActiveSheet.Cells(2, 1)
End Sub
Sub Button3_Click()
KillTimer 0&, TimerID
CloseDevice
ActiveSheet.Cells(1, 4) = “Card 0 Closed”
End Sub[/code]