Hi,
I use VM140 with Excel 2007 and VBA Makros for heating control, home automation.
Works fine, but after a couple of days, the read analog values are just nonsense.
Under XP, I created a workaround: close the Excel application, reload it. This happened every couple of days.
Now, with Win7, even after this workaround, the read values are still nonsense.
Any Idea?
Here some parts of my code:
Option Explicit
Private Declare Function OpenDevice Lib "k8061.dll" () As Long
Private Declare Sub CloseDevices Lib "k8061.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long) As Long
Private Declare Function PowerGood Lib "k8061.dll" (ByVal CardAddress As Long) As Boolean
Private Declare Function Connected Lib "k8061.dll" (ByVal CardAddress As Long) As Boolean
Private Declare Sub ClearDigitalChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Private Declare Sub SetDigitalChannel Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Channel As Long)
Function ReadAdChannel(i As Integer) As Integer
Dim locvar As Long
Dim locvarErg As Long
Dim b As Boolean
locvar = i + 1
locvarErg = ReadAnalogChannel(hwAdr, locvar)
If locvarErg > 1023 Then
'Problem occured!
b = Connected(hwAdr)
b = PowerGood(hwAdr)
Range("AD_Status").Value = Range("AD_Status").Value + 1
'Test
CloseDevices
Application.Run ("Personal.xlsb!Workaround_Heizung")
...
Any help is appreciated…