TABLE OF CONTENTS
- The board
- Requirements
- Connecting to the board
- Initializing the board
- Reading the pin value and setting a Dise trigger
The board
The VM167 is connected using USB and has multiple inputs/outputs you can connect buttons or other hardware.
Read more here: https://www.velleman.eu/products/view/?id=384006
Requirements
- I experienced the software could not be run on x64. I resolved that by removing 64-bit python and replacing it with 32-bit. If you find a way to run it on 64-bit - please inform us on how to achieve that.
- To run the DLL on the players they also need to install the VM167 SDK. If you find a way which is easier - please inform us on how to achieve that.
Connecting to the board
You can find the SDK and communication routines (API) here (as of 2022-07-29): https://www.velleman.eu/support/downloads/?code=WMI167
When installting the software you can find a useful demo application and code examples in various languages under 'C:\Program Files (x86)\Velleman\VM167 SDK'.
Initializing the board
import ctypes VM167 = ctypes.WinDLL(PATH_TO_VM167_DLL) cards = VM167.OpenDevices() while(cards < 1): if(cards == 0): DISEScript.Log("error", "Card open error. Retrying.") if(cards == -1): DISEScript.Log("error", "Card not found. Is the card installed correctly?") DISEScript.Sleep(1000) cards = VM167.OpenDevices() connected = VM167.Connected() if(connected == 0): DISEScript.Log("error", "No cards connected.") if(connected == 1): DISEScript.Log("info", "Card at the Card Address 0 found.") if(connected == 2): DISEScript.Log("info", "Card at the Card Address 1 found.") if(connected == 3): DISEScript.Log("info", "Cards at the Card Address 0 and 1 found. Using default Card Address") #We need to set which pins should be inputs and which should be outputs. Read the docs for more info. VM167.InOutMode(CARD_ADDRESS, 0, 1) #This sets a digital output channel (a pin). Read the docs for more info. VM167.SetDigitalChannel(CARD_ADDRESS, DIGITAL_PIN_OUTPUT)
Reading the pin value and setting a Dise trigger
currentValue = True if VM167.ReadDigitalChannel(CARD_ADDRESS, DIGITAL_PIN_INPUT) == 1 else False DISEScript.SetTrigger(TRIGGER_NAME, currentValue)