wavefrontshaping / ALP4lib

Python control module for Vialux DMDs based on ALP4.X API.
MIT License
54 stars 37 forks source link

Problem with DMD.Initialize( ) when initializing for the second time #12

Open guilhermebene opened 3 years ago

guilhermebene commented 3 years ago

Problem

I am having this problem whenever I try to initialize the DMD after a first run without disconnecting the cables from my computer. I am using Anaconda and Spyder. I tried downgrading to Python 3.7 since it was suggested in #8 that Initialization problems could appear at Python versions more recent than 3.7.


Error

Loading library: ./x64/alpV42.dll
Traceback (most recent call last):

  File "<ipython-input-4-5f96d1110e72>", line 1, in <module>
    runfile('C:/PySpec/DMD.py', wdir='C:/PySpec')

  File "C:\Users\creatis\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

  File "C:\Users\creatis\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/PySpec/DMD.py", line 9, in <module>
    DMD.Initialize(DeviceNum=None)

  File "C:\PySpec\ALP4.py", line 411, in Initialize
    self._checkError(self._ALPLib.AlpDevAlloc(DeviceNum, ALP_DEFAULT, ct.byref(self.ALP_ID)), 'Cannot open DMD.')

  File "C:\PySpec\ALP4.py", line 391, in _checkError
    raise ALPError(returnValue)

ALPError: The specified ALP device has not been found or is not ready.

My code

import numpy as np
from ALP4 import *
import time

# Load the Vialux .dll
DMD = ALP4(version = '4.2',libDir='./')

# Initialize the device considering only one DMD is connected
DMD.Initialize(DeviceNum=None)
DMD_device_number = DMD.DevInquire(ALP_DEVICE_NUMBER)

DMD.Halt()
DMD.Free()