-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
155 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from pyAndorSDK2 import atmcd | ||
import win32event | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import time | ||
''' To be run in Spyder. Run andor_driver first then run this in the same terminal ''' | ||
|
||
|
||
|
||
cam = atmcd()# atmcd("") was working. Switch back if a problem! Without the "" also appears to be working #load the atmcd library | ||
# reset() | ||
|
||
(ret) = cam.Initialize("/usr/local/etc/andor") #initialise camera # C:\Program Files\Andor SDK | ||
(ret, iSerialNumber) = cam.GetCameraSerialNumber() | ||
(ret) = cam.CoolerON() | ||
(ret) = cam.SetCoolerMode(1) | ||
(ret) = cam.SetTemperature(-60) | ||
(ret) = cam.SetADChannel(0) # Added 4/6/22 | ||
(ret) = cam.SetHSSpeed(0,0) # 0 corresponds to 17MHz on AD channel 0 (the only channel for our camera) in EM Gain mode | ||
# print("HSSpeed",cam.GetHSSpeed(0, 0, 0)) | ||
(ret) = cam.SetVSSpeed(4) # 4 corresponds to 3.3us. 0 is .3 | ||
# print("VSSpeed",cam.GetVSSpeed(4)) | ||
(ret) = cam.SetVSAmplitude(0) # 0 corresponds to 'Normal' 3 required for good image at 0.3 usec VSSpeed | ||
# print("Number VSAmplitudes is",cam.GetNumberVSAmplitudes()) | ||
(ret) = cam.SetPreAmpGain(2) # 2 corresponds to a gain of 3.0 | ||
# print("PreAmpGain", cam.GetPreAmpGain(2)) | ||
|
||
(ret) = cam.SetBaselineClamp(1) | ||
(ret) = cam.SetOutputAmplifier(0) # 0 is EMCCD. David added this | ||
(ret) = cam.SetEMGainMode(3) # Max is 300? David added this | ||
(ret) = cam.SetEMCCDGain(100) # Max is 300? David added this ########################################################### | ||
(ret) = cam.SetCountConvertMode(1) # 1 is electron, 2 is photon | ||
(ret) = cam.SetFrameTransferMode(0) | ||
# (ret) = cam.SetCountConvertWavelength(float(852)) | ||
(ret) = cam.SetShutter(0,1,50,50) # (0,1,50,50) opens shutter. (0,2,50,50) closes shutter. | ||
# (ret) = cam.SetAcquisitionMode(1) | ||
############################################################## | ||
(ret) = cam.SetFastExtTrigger(1) #when FastExtTrigger is active, set to 1, camera will NOT wait until a Keep Clean cycle is complete before taking an image | ||
(ret) = cam.SetAcquisitionMode(3) #3 is Kinetics | ||
(ret) = cam.SetNumberKinetics(2) #number of images taken in an acquisition | ||
(ret) = cam.EnableKeepCleans(1) | ||
(ret) = cam.SetNumberAccumulations(1) #Default value is 1. Excplicitly stating this is probably unnecessary. | ||
# (ret) = cam.SaveEEPROMToFile(r'C:\Users\hoodl\Desktop\EEPROM.txt') # This breaks the camera initialization. | ||
#(ret) = SetIsolatedCropMode(1, 30, 30, 1, 1) | ||
############################################################## | ||
(ret) = cam.SetReadMode(4) | ||
(ret) = cam.SetTriggerMode(1) # 0 is internal, 1 is external, 6 is external start? | ||
(ret, xpixels, ypixels) = cam.GetDetector() | ||
imageSize = xpixels*ypixels | ||
(ret) = cam.SetImage(1, 1, 1, xpixels, 1, ypixels) | ||
(ret) = cam.SetExposureTime(0.010) # Set exposure time here! WAS 0.010 ms! | ||
(ret, fminExposure, fAccumulate, fKinetic) = cam.GetAcquisitionTimings() | ||
(ret) = cam.PrepareAcquisition() | ||
|
||
if atmcd.DRV_SUCCESS==ret: | ||
print("Andor Initializiation was successful...") | ||
else: | ||
print("Andor Initializiation failed...Try restarting Artiq and/or powercycling camera") | ||
|
||
#%% | ||
|
||
event = win32event.CreateEvent(None, 0, 0, None) | ||
cam.SetDriverEvent(event) | ||
ret = cam.StartAcquisition() # It needs time.sleep(0.07) between StartAcq and WaitForSingleObject | ||
#%% | ||
|
||
time.sleep(0.07) # Needed | ||
print(cam.GetNumberAvailableImages()[2]) | ||
# retrieve_trigger | ||
# for i in range(2): | ||
ret = win32event.WaitForSingleObject(event, 1) # 1 second extra delay was removed as of 7/29 | ||
# print(ret) | ||
|
||
# time.sleep(0.5) | ||
|
||
(ret, image,_,_) = cam.GetImages(1,1,imageSize) | ||
img0 = np.reshape(image, (512,512)) #Converts c_long 262k array to 512x512 image numpy array | ||
(ret, image,_,_) = cam.GetImages(2,2,imageSize) | ||
img1 = np.reshape(image, (512,512)) #Converts c_long 262k array to 512x512 image numpy array | ||
|
||
# plt.imshow(img0) | ||
|
||
print('img0/img1',np.mean(img0),np.mean(img1)) | ||
|
||
cam.CancelWait() | ||
cam.AbortAcquisition() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters