VM140 / K8061 running with Excel. Crazy A/D results

I´m doing heating control with the VM140 based on a Excel sheet. Access with VBA macro works fine for a while, but after some hours (or a day), suddenly I get crazy values for the analog inputs (like 58804). Digital outputs still work fine. DLL tells still connected and PowerGood.
After complete stop and unload / reload Excel, program is running again.
My macro does set dig. outputs every couple of seconds; analog inputs are read avery 15 minutes. Once the problem happens, all following attempts to read analog values will result in such crazy values.

Any idea?

By the way, the DLL interface is defined with long variables. Is this really OK? (Not necessary for values 0…1023)

Regards

Hi,
I have the same problem, did you fix the problem???
I’m using the board as a domotic controller.

Unfortunately, I didn´t get any feedback about this issue from Velleman.

So I made a workaround: if the problem occurs, my Excel application is stopped and closed…but reloaded and restarted by a second Excel application.
Well: not nice, but it works.
I have installed a counter - up to now, this happened about 400 times within the last 10 months.

If you have a more elegant idea: let me know.

Best regards
Günther

My workaround is not so good like yours because in my case it’s not sufficient to reload the application.
I need to switch off and on the board. I made this with one Digital output.
the board switch a digital output that is connected in series (with a relè) to the power supply, the board switch off, and automatically the output change to previous state so the board restart… very bad…
I would like to use this board for anti-intrusion system too, but with this bugs is not recommended.

Hey, velleman support team, is there any fix for our boards? I read other users with the same bug!

In my system it happens up to 30 times per day! and when it happens, one or more AD is at 512! It happens with the demo sw too! in all languages (VB, .net, Delphi…).
I’m doing some tests, seems related not directly to the AD input but to Digital Inputs… when I have “movement” on the DI, it happens often!
Please, velleman team, check for this bug and give us a fix!
I would like to buy other 2 boards to complete my domotic system but not in this condition.

please post yours codes ! (vba, vb.net)
we can’t help you whitout code . (sorry i’m french ^^)
but i use this cards (k8055 & k8061) for office use for a long time so i can help you .
@++

Hello @dn

here are some snips of my code (Excel 2007, VBA).

[color=#0000BF]Code part on Close:[/color]

CloseDevices

[color=#0000FF]Code part on Open:[/color]

CloseDevices

'Open channel to HW
hwAdr = OpenDevice()
If hwAdr < 0 Then
    MsgBox ("Kanal zur USB I/O-Karte konnte nicht geöffnet werden!")
    End
End If

[color=#0000FF]Called every 5 secs:[/color]

Sub RefreshRelais()
Dim i As Integer
Dim b As Boolean

'refresh relais outputs
Range("RelOutFirstBit").Select
For i = 0 To 31
    If ActiveCell.Value <> 0 Then
        b = False
    Else
        b = True
    End If
    sendBit (b)
    ActiveCell.Offset(0, -1).Select
Next i

'Now takeover all 32 bits in Ginnes Hardware (Shift register behind Velleman HW)
nixnutz = ClearDigitalChannel(hwAdr, 3)
nixnutz = SetDigitalChannel(hwAdr, 3)

'Wait a bit to get stable analog data
Application.Wait (Now + TimeValue("0:00:01"))

End Sub

[color=#008000]Rem: …to bring digital data into a shift register behind the Velleman HW[/color]
Sub sendBit(setting As Boolean)
Dim b As Boolean

If setting = True Then
    nixnutz = ClearDigitalChannel(hwAdr, 1)
Else
    nixnutz = SetDigitalChannel(hwAdr, 1)
End If

'generate the clockpulse
nixnutz = ClearDigitalChannel(hwAdr, 2)
nixnutz = SetDigitalChannel(hwAdr, 2)

End Sub

[color=#0000FF]This is called every 15 minutes:
3 Levels each 7 roos. I always read 10 times, kick away the lowest and the highest value (followed by an averaging of the other 8 measurements)[/color]

Sub ReadAdChannels_averaging()

Dim i As Integer
Dim k As Integer
Dim l As Integer
Dim n As Integer 'pointer to minimum
Dim x As Integer 'pointer to maximum
Dim minVal As Integer 'to store curr. minimum
Dim maxVal As Integer 'to store curr. maximum

For i = 0 To 2
    'Do for every level
    SelectLevel (i)
    Range("SingleRawBase").Select
    ActiveCell.Offset(0, i * 7).Select
    For k = 0 To 6
        'Do for every room
        minVal = 2000   'reset
        maxVal = 0      'reset
        For l = 0 To 9
            ActiveCell.Offset(l, 0).Value = ReadAdChannel(k)
            If ActiveCell.Offset(l, 0).Value < minVal Then
                minVal = ActiveCell.Offset(l, 0).Value
                n = l       ' set pointer
            End If
            If ActiveCell.Offset(l, 0).Value > maxVal Then
                maxVal = ActiveCell.Offset(l, 0).Value
                x = l       ' set pointer
            End If
        Next l
        
        'now do averaging for this channel
        ActiveCell.Offset(n, 0).Value = 0   'don´t use the minimum value
        ActiveCell.Offset(x, 0).Value = 0   'don´t use the maximum value
        'Special case: 10 times the same value
        If n = x Then
            ActiveCell.Offset(1, 0).Value = 0   'clear any second value!
        End If
        
        ActiveCell.Offset(0, 1).Select
    Next k
Next i
UnSelectLevel

End Sub

[color=#0000FF]Commonly used:[/color]

Function ReadAdChannel(i As Integer) As Integer
Dim locvar As Long
Dim locvarErg As Long

locvar = i + 1
locvarErg = ReadAnalogChannel(hwAdr, locvar)
If locvarErg > 1023 Then
    locvarErg = locvarErg - 1   'just for Breakpoint in case of THIS PROBLEM HAPPENS
End If

ReadAdChannel = locvarErg

End Function

hello, here somes questions and help

'refresh relais outputs Range("RelOutFirstBit").Select For i = 0 To 31 If ActiveCell.Value <> 0 Then b = False Else b = True End If sendBit (b) ActiveCell.Offset(0, -1).Select Next i
a quoi sert la boucle ? pourquoi ne pas utiliser l’évenement cell_change ?
I don’t understand the loop i ? why don’t use the event cell_change ?

[code]'Now takeover all 32 bits in Ginnes Hardware (Shift register behind Velleman HW)
nixnutz = ClearDigitalChannel(hwAdr, 3)
nixnutz = SetDigitalChannel(hwAdr, 3)

'generate the clockpulse
nixnutz = ClearDigitalChannel(hwAdr, 2)
nixnutz = SetDigitalChannel(hwAdr, 2)
End Sub[/code]

a quoi cela sert ??? mettre à 0 puis à 1 ?
equal to put out 3 and 2 always at true ?

For l = 0 To 9 ActiveCell.Offset(l, 0).Value = ReadAdChannel(k) If ActiveCell.Offset(l, 0).Value < minVal Then minVal = ActiveCell.Offset(l, 0).Value n = l ' set pointer End If

il serait bien mieux de lire toutes les voies dans un tableau et ensuite de les attribuer aux cellules
most better to read all analog way in a double() and read after each double(i) whit :

for i = 0 to double().lenght-1 cell(..,i).value = double(i) next

If locvarErg > 1023 Then locvarErg = locvarErg - 1 'just for Breakpoint in case of THIS PROBLEM HAPPENS ' // devient / remplace whit If locvarErg >= 1023 Then locvarErg = 1023 ' THIS PROBLEM DO NOT HAPPENS ;)
i post soon a version in vb.net for read all analog ways, regards

For use timer whit excel you can use this :

'déclaration de la gestion des tempos via le kernel32 ^^ Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' // OR 'déclaration du timer pour excel Public Declare Function SetTimer Lib "user32" ( _ ByVal HWnd As Long, ByVal nIDEvent As Long, _ ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Public Declare Function KillTimer Lib "user32" ( _ ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

[quote]By the way, the DLL interface is defined with long variables. Is this really OK? (Not necessary for values 0…1023)
[/quote]
it’s false look here :
Public Declare Sub VM140_ReadAllAnalog Lib “k8061.dll” Alias “ReadAllAnalog” (ByVal intCardNumber As Integer, ByRef Buffer As Integer)

I have a K8061 at home , if i have some time for, i test to wryte a datalogger whit excel and i test it during tree days, and i post my result, regards

Hi @dn,

regarding the digital out statements:
There is a loooong shift register behind the K8061, driven by the first 3 digital outputs.
Output 1 drives the data, Output 2 the clock and output 3 the strobe line. It works.

I found that digital outputs are still working even in the situation with the “crazy” analog input values.
So I think the problem is just on the analog input side.

I´m interested on your proposals for the analog input.

Regards,

Good evening, I’m sorry but my English is very poor to understand your problem. I 'm French and I do not learn English also through forums such as this one. I’m afraid to do not understand your request.
i m sorry but i can’t help you in english.
very sorry, regards.

Hi Guys,
I discover the problem on my board.
The problem on analog inputs cames from Digitals.
In particular, the I2! Moving this signal to I7 the problem is Fixed.
Before this change, i tried to filter all inputs, Digitals and analogs… but without success.
It’s strange… but now my board works good by weeks.

Hi figottopaciarotto,

didn´t understand you - what´s exactly your measurement?
For me, the digital IN are not used at all, but I need all analog INs.

rgs,
Günther

M’interresse your problem, you can be clearer or better in French?
@++ @dn