Velleman VM140 Python Question


I was wondering if someone could help me here with the problem i have running 2 VM140 boards in Python.

I am trying to run two Python scripts each one getting data from one VM 140 board. When i start the first script
it opens the card and i get data, but when i start the second script, it is not able to open the second card. When
i stop the first script the second script is able to open the card and works ok.

I have set the jumper id’s on both cards. One to id0 and the other to id1.

Both card are working in the demo.exe program that is supplied with boards.

I am kinda confused how i should open the cards in the scripts. Should i open both cards in one script, or
is it possible to open the seperate cards in each script. ??

Please can someone shine some light on this ??

Thanks a lot !!!


I guess everything depends on what’s inside those scripts

Well maybe when i change the question it makes more sense.

I have python script x logging data to a file from a vm140 board with id set to 0.

I want python script y doing the same on a vm140 board with an id set to 1 and so on up to
8 boards.

But when script x is running i am not able to open the vm140 board in script y.

When i execute the opencard command twice in script x, both boards are openened but i do
not get any data from the board in script y.

Hope this explains things better.

Thank you

What I was trying to tell is that to debug a script, we kind of need to see the script, not just a description of what it does :slight_smile:

Opening the same device in two separate applications at the same time, is not possible. Opening device A in application A, and opening device B in application B, is possible.


I want to do the second thing you mentioned: Opening device a in application a, and opening device b in application b.

Here is part of the python code that runs without problems on card 0. How do i use this code (applied to card 1) to open the second card and
read that card.

Thank you for your time !

from ctypes import *                                                                                                
from time import *                                                                                                  

global CardAddress

CardAddress = 0

def startupcard ():                                                                                                 
    import time
    print ""                                                                                    
    print "Initial Startup ......"
    print ""
    time.sleep( 1 )
    time.sleep( 1 )

def connectioncheck ():                                                                                             
    import time
    if windll.k8061.Connected(CardAddress):                                                      
        print "Connection Card is OK !"
        print ""
        print "Connection Card is NOT OK !"
        print ""
        print "Retrying ..."
        print ""
        time.sleep( 5 )
    time.sleep( 1 )

def powergood ():                                                                                                  
    import time
    if windll.k8061.PowerGood(CardAddress):                                                      
        print "Power Supply is OK !"
        print ""
        print "Power Supply is NOT OK !"
        print ""
        print "Retrying ..."
        print ""
        time.sleep( 5 )
    time.sleep( 1 )                                                                  
def getvalues ():                                                                                            
    windll.k8061.OutputAnalogChannel(CardAddress,1,129) #Setting analog out to supply 5V analog in.                                         
    global anin1, anin2, anin3, vanin1, vanin2, vanin3
    anin1 = float(windll.k8061.ReadAnalogChannel(CardAddress,1))                                 
    anin2 = float(windll.k8061.ReadAnalogChannel(CardAddress,2))                                
    anin3 = float(windll.k8061.ReadAnalogChannel(CardAddress,3))                                 

def printvariables ():                                                                                              
    import time                                                                              
    from datetime import date                                                                
    global date
    date =
    print ""
    print "Analog input channel 1 =", anin1,"dec" "       Timestamp : %s" % time.ctime()     
    print "Analog input channel 2 = ", anin2,"dec" "       Timestamp : %s" % time.ctime()    
    print "Analog input channel 3 =", anin3,"dec" "       Timestamp : %s" % time.ctime()     
    print ""



OpenDevice does not accept any parameters, so it probably opens all available cards, which would indeed block it from any other script.

I’m afraid you’ll have to mix both scripts…

Well i tried some things but that is not the case.

When i do a “windll.k8061.OpenDevice()” and
after that i do "windll.k8061.Connected(0) it will return a 1.

When i check card 1 with “windll.k8061.Connected(1)” it returns a 0.
So this one is not opened yet.

When i again do “windll.k8061.OpenDevice()” both cards give a 1
when i check with the connected() command.

I am also able to close the cards one by one using the closedevice() command.

Is there not some way to split up the dll reading completely. I am using the script to do longtime logging, and cards have to beconnected one after another and stopping the script for adding another card is no option.

Thanks for your time.

You can use the return value of the OpenDevice as the card address.
Use this value in the next function calls to access this card.
When more than one K8061 card is connected to the PC, repeat the OpenDevice function call until all the cards are opened.

Here a snippet from the manual:

More data and examples available here: …


Well of course i have read the dll manual you’re referring to.

From your answers i am making up that Velleman also does not exactly know the answer
as i dont get a direct answer.

I have tried al things last night and my conclusion is that once you have opened one card
in script x it is impossible to open the other card in script y. Executing the opendevice command
results in a -1 value that means al cards are openened.

I will rewrite the program for another another card as the VM140 is useless this way.

Thanks for your time.