Wavefront shaping techniques in complex media

[tutorial] 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 to use in a simple manner the basic functions while providing the advanced features of the ALP API.

DOI

 

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 ask 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
DMD.Initialize()
# 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
DMD.Run()
time.sleep(10)
# Stop the sequence display
DMD.Halt()
# Free the sequence from the onboard memory
DMD.FreeSeq()
# De-allocate the device
DMD.Free()

 

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

DOI

Submit to FacebookSubmit to Google BookmarksSubmit to TwitterSubmit to LinkedIn

Additional information