Control a Vialux DMD with Python

Vialux provides Texas Instrument DMD (Digital MicroMirror Devices) chips with an electronic board to send and display image sequences at high speed (up to 30kHz). While they provide a C++ dll, Labview, and Matlab codes, I did not find any tool for Python. I share here a simple module that wraps the C++ functions for Python. It allows using in a simple manner the basic functions while providing the advanced features of the ALP API.


The Python module is available on the ALP4lib Github repository. Please read the short introduction on the repository and the Vialux ALP API description document for a complete overview of the features. It uses the same syntax as the ALP API but functions can be called with fewer arguments to simplify the code when advanced features are not needed.

Here is a basic example of the use of the ALP4lib module. It displays a sequence of two images with all pixel black then white at a 50 Hz rate continuously until the user asks the DMD to stop.

import numpy as np
from ALP4 import *
import time
# Load the Vialux .dll
DMD = ALP4(version = '4.3', libDir = 'C:/Program Files/ALP-4.3/ALP-4.3API')
# Initialize the device
# Binary amplitude image (0 or 1)
bitDepth = 1
imgBlack = np.zeros([DMD.nSizeY,DMD.nSizeX])
imgWhite = np.ones([DMD.nSizeY,DMD.nSizeX])*(2**8-1)
imgSeq = np.concatenate([imgBlack.ravel(),imgWhite.ravel()])
# Allocate the onboard memory for the image sequence
DMD.SeqAlloc(nbImg = 2, bitDepth = bitDepth)
# Send the image sequence as a 1D list/array/numpy array
DMD.SeqPut(imgData = imgSeq)
# Set image rate to 50 Hz
DMD.SetTiming(illuminationTime = 20000)
# Run the sequence in an infinite loop
# Stop the sequence display
# Free the sequence from the onboard memory
# De-allocate the device


If this program was useful to your work, please consider citing it using its DOI:


Created by sebastien.popoff on 17/10/2016