Python control module for Vialux DMDs based on ALP4.X API.
Switch branches/tags
Clone or download
Latest commit 67914a8 Sep 14, 2018
Failed to load latest commit information.
src Update Jan 26, 2018
LICENSE Create LICENSE Oct 9, 2016 Update Sep 14, 2018 Update Jan 25, 2018


ALP4lib is a Python module to control Vialux DMDs based on ALP4.X API. This is not an independant open source module, it uses the .ddl files provided by Vialux. This software is still experimental, use it at your own risk.

What is it?

This module wraps the basic function of the Vialux dlls to control a digitial micro-mirror device with a Vialux board. Vialux provides dlls and also modules for Matlab and Labview but not for Python. This code is tested with a device using the 4.3 version of the ALP API, other versions may have issues. LED control related functions are not implemented. Please read the ALP API description provided with the Vialux ALP installation.


  • Windows 32 or 64,
  • Vialux drivers and the ALP4.X dll files available for download on Vialux website.

Warning: Still display issues with Python 3.X, a fix is on its way.

Citing the code

If the code was helpful to your work, please consider citing it:



Manual installation

Just copy the file in the working directory.

Automatic installation

To automatically download and copy the module in the python directory (so it can be available from anywhere), run the command:

pip install ALP4lib


easy_install ALP4lib

Copy the .dll

The win32 ALPX.dll files should be directly in the working directory and the win64 dll with the same name in a /x64 subfolder. Alternatively, a different dll directory can be set at the initialization of the DMD handler object. The dlls have the following names respectively for the 4.1, 4.2 and 4.3 versions of the ALP API: 'alp41.dll', 'alp42.dll' and 'alp4395.dll'.

A simple example

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.3 API')
# 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