#pragma rtGlobals=1 // Use modern global access method. #pragma rtGlobals=1 // Use modern global access method. //////////////////////////////////////////////////////////////////////////////////////////////////// //Procedures for controlling a Lumencor light engine (http://lumencor.com) //08/10/2012 Josef G. Trapani (jtrapani@amherst.edu) //08/07/14 JGT, version 2.0: added all colors and incremental changes to intesity //Disable the temp sensor check since using the Lumencor RCA (remote control accessory) causes this feature to hang. //Note: Procedure requires the VDT2.xop extension to be installed //Note: User must install the FTDI USB Serial driver for the USB to Serial (RS232) cable for the Lumencor: http://www.ftdichip.com/Drivers/VCP.htm //////////////////////////////////////////////////////////////////////////////////////////////////// Menu " <}}}>< " "Lumencor Light",Start_Lumencor_Panel("start") End //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // Panel for Lumencor Function Start_Lumencor_Panel(ctrlName) String ctrlName String savedDataFolder = GetDataFolder(1) // Save If (cmpstr(ctrlName,"closePanel")==0) NVAR /z event = root:Lumencor:Lumencor_On If(event==1) Lumencor_start ("button3") Endif DoWindow Lumencor_Panel If (V_flag==1) KillWindow Lumencor_Panel SetDataFolder root:Lumencor KillWaves /Z /A KillDataFolder /Z root:Lumencor Endif Else NewDataFolder /O/S root:Lumencor Variable /G Lumencor_intensity = 40 // DAC intensity 0xFF is full off and 0x00 is full on Variable /G Lumencor_On = 0 // 0 is Off and 1 is On Variable /G Lumencor_Temp // Lumencor Temp sensor String /G Lumencor_serialName // Lumencor serial device name Endif SetDataFolder savedDataFolder // and restore Variable returnNum = initLumencor(ctrlName) If (returnNum==-1) DoAlert 0, "No Serial Devices Found! ---> Check menu /MISC/VDT2/ (on PC set COM in procedure file)" Lumencor_Panel("off") Elseif (returnNum==0) Print "Lumencor Light panel closed. Light is off." Elseif (returnNum==1) Lumencor_Panel("on") Endif End //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Initialize Lumencor Serial Devices Function initLumencor(ctrlName) String ctrlName String cmd String tempSerialList String tempSerialName String platform= UpperStr(igorinfo(2)) Variable i SVAR /z SerialName = root:Lumencor:Lumencor_serialName If ((cmpstr(ctrlName,"start")==0)&&(SVAR_Exists(SerialName)==1)) VDTGetPortList2 tempSerialList = S_VDT If (cmpstr(platform,"WINDOWS")==0) //Determine Serial Device Names tempSerialName = StringFromList(1, tempSerialList,";") If (cmpstr(tempSerialName, "COM4")!=0) //********* Set this COM to the # that corresponds to your Lumencor****** return -1 Else SerialName = StringFromList(1, tempSerialList,";") Endif Elseif (cmpstr(platform,"MACINTOSH")==0) //Determine Serial Device Names For (i=0;i " \002" = 02Hex and \255 = FF hex // VDTWrite2 "W\003\171P" + "\r\n" //57 03 AB 50 ==> "\003" = 03Hex and \171 = AB hex // VDTWrite2 "O P" + "\r\n" //4F FF 50 - diasbles all channels // //Print "Lumencor serial port initialized" End //////////////////////////////////////////////////////////////////////////////////////// // Lumencor Controller Panel Static Function Lumencor_Panel(ctrlName) String ctrlName Variable Xcoord=200 Variable Ycoord=60 String info = IgorInfo(0) String screen1RectStr = StringByKey("SCREEN1", info) //e.g., "DEPTH=23,RECT=0,0,1280,1024" Variable depth, left, top, right, bottom sscanf screen1RectStr, "DEPTH=%d,RECT=%d,%d,%d,%d", depth, left,top, right, bottom top+=40 //adjust for title bar String platform= UpperStr(igorinfo(2)) If (cmpstr(platform,"WINDOWS")==0) NewPanel /N=Lumencor_Panel /W=(right-300,top,right,300) /FLT=0 /K=2 as "Light Driver v2.0" Else NewPanel /N=Lumencor_Panel /W=(right-380,top,right-80,300) /FLT=0 /K=2 as "Light Driver v2.0" Endif SetActiveSubwindow _endfloat_ ModifyPanel /W=Lumencor_Panel cbRGB=(62535,62535,62535), frameStyle=3, frameInset=5, noEdit=1, fixedSize=1 SetDrawLayer /W=Lumencor_Panel UserBack SetDrawEnv /W=Lumencor_Panel fillfgc= (45535,46535,46214) DrawRect /W=Lumencor_Panel 10,10,290,50 SetDrawEnv /W=Lumencor_Panel linefgc= (21845,21845,21845) DrawText /W=Lumencor_Panel 20,40,"Lumencor Light Driver" CheckBox colorCheck1 pos={Xcoord-180,Ycoord+50}, title="white",mode=0, value=1,disable=2, win=Lumencor_Panel CheckBox colorCheck2 pos={Xcoord-180,Ycoord+70}, title="violet DAPI",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck3 pos={Xcoord-180,Ycoord+90}, title="blue CFP",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck4 pos={Xcoord-180,Ycoord+110}, title="cyan GFP",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck5 pos={Xcoord-100,Ycoord+50}, title="teal YFP",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck6 pos={Xcoord-100,Ycoord+70}, title="green CY3",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck7 pos={Xcoord-100,Ycoord+90}, title="yellow mCherry",mode=0, value=0,disable=2, win=Lumencor_Panel CheckBox colorCheck8 pos={Xcoord-100,Ycoord+110}, title="red Cy5",mode=0, value=0,disable=2, win=Lumencor_Panel Checkbox checkBig,pos={Xcoord-180,Ycoord},size={40,10},value=0,disable=2,proc=BigLumencorPanel,title="Big \rButton", win=Lumencor_Panel Button closePanel,pos={210,20},size={60,20},proc=Start_Lumencor_Panel,title="Close", win=Lumencor_Panel Button button3,pos={Xcoord-100,Ycoord},size={100,40},disable=2,proc=Lumencor_Start,title="Light is Off", win=Lumencor_Panel Button button3,fSize=16,fStyle=16,fColor=(255,255,255), win=Lumencor_Panel NVAR /Z gIntensity= root:Lumencor:Lumencor_intensity Slider setvar1,pos={Xcoord+20,Ycoord},size={100,100}, title="% Intensity",value=gIntensity, win=Lumencor_Panel Slider setvar1, live=0, fSize=12,limits={0,100,10}, disable=2, win=Lumencor_Panel SetVariable setvar3,pos={Xcoord+20,Ycoord+130},size={60,1},limits={0,100,1}, disable=2,title=" ",value=gIntensity, win=Lumencor_Panel If (cmpstr(ctrlName,"on")==0) Button button3,disable=0 CheckBox colorCheck1,disable=2,proc=Lumencorcheck CheckBox colorCheck2,disable=0,proc=Lumencorcheck CheckBox colorCheck3,disable=0,proc=Lumencorcheck CheckBox colorCheck4,disable=0,proc=Lumencorcheck CheckBox colorCheck5,disable=0,proc=Lumencorcheck CheckBox colorCheck6,disable=0,proc=Lumencorcheck CheckBox colorCheck7,disable=0,proc=Lumencorcheck CheckBox colorCheck8,disable=0,proc=Lumencorcheck CheckBox checkBig,disable=0,proc=BigLumencorPanel Slider setvar1,disable=0, proc=updateIntensitySlider SetVariable setvar3, disable=0, proc=updateIntensityBox //Not working, gives a parentheses error? NVAR gTemp = root:Lumencor:Lumencor_Temp SetVariable setvar2,pos={Xcoord-180,Ycoord+150},size={160,1},limits={1,1000,0},title="Sensor Temp:",fSize=12, proc=readLumencortemp, win=Lumencor_Panel SetVariable setvar2, disable=2, value=gTemp, win=Lumencor_Panel Endif End Function //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Lumencor checkbox for color selection Function Lumencorcheck (ctrlName,checked) : CheckBoxControl String ctrlName Variable checked NVAR /z event = root:Lumencor:Lumencor_On If (checked==1) // 1 if selelcted, 0 if not CheckBox colorCheck1, disable=2*(cmpStr(ctrlName,"colorCheck1")==0), value=(cmpStr(ctrlName,"colorCheck1")==0), win=Lumencor_Panel CheckBox colorCheck2, disable=2*(cmpStr(ctrlName,"colorCheck2")==0), value=(cmpStr(ctrlName,"colorCheck2")==0), win=Lumencor_Panel CheckBox colorCheck3, disable=2*(cmpStr(ctrlName,"colorCheck3")==0), value=(cmpStr(ctrlName,"colorCheck3")==0), win=Lumencor_Panel CheckBox colorCheck4, disable=2*(cmpStr(ctrlName,"colorCheck4")==0), value=(cmpStr(ctrlName,"colorCheck4")==0), win=Lumencor_Panel CheckBox colorCheck5, disable=2*(cmpStr(ctrlName,"colorCheck5")==0), value=(cmpStr(ctrlName,"colorCheck5")==0), win=Lumencor_Panel CheckBox colorCheck6, disable=2*(cmpStr(ctrlName,"colorCheck6")==0), value=(cmpStr(ctrlName,"colorCheck6")==0), win=Lumencor_Panel CheckBox colorCheck7, disable=2*(cmpStr(ctrlName,"colorCheck7")==0), value=(cmpStr(ctrlName,"colorCheck7")==0), win=Lumencor_Panel CheckBox colorCheck8, disable=2*(cmpStr(ctrlName,"colorCheck8")==0), value=(cmpStr(ctrlName,"colorCheck8")==0), win=Lumencor_Panel If (event==1) //If light is ON Lumencor_start (ctrlName) Endif Endif End Function //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Big Button popup window Function BigLumencorPanel (ctrlName,checked) : CheckBoxControl String ctrlName Variable checked If (checked==1) // 1 if selelcted, 0 if not String info = IgorInfo(0) String screen1RectStr = StringByKey("SCREEN1", info) //e.g., "DEPTH=23,RECT=0,0,1280,1024" Variable depth, left, top, right, bottom sscanf screen1RectStr, "DEPTH=%d,RECT=%d,%d,%d,%d", depth, left,top, right, bottom String platform= UpperStr(igorinfo(2)) If (cmpstr(platform,"WINDOWS")==0) NewPanel /N=BigLumencor_Panel /W=(right-250,top,right,150) /FLT=2 Else NewPanel /N=BigLumencor_Panel /W=(right-300,top,right-50,150) /FLT=2 Endif ModifyPanel cbRGB=(30583,30583,30583) DoWindow /HIDE=1 /W=Lumencor_Panel Lumencor_Panel SetDrawLayer UserBack DrawRRect 16,15,240,135 Button button0,pos={30,25},size={200,100},proc=Lumencor_Start,title="On/Off",fSize=58 Checkbox checkBig,pos={0,0},size={40,10},value=1,disable=0,proc=BigLumencorPanel,title="Close" Else DoWindow /F /HIDE=0 /W=Lumencor_Panel Lumencor_Panel Checkbox checkBig,value=0, win=Lumencor_Panel Killwindow BigLumencor_Panel Endif End Function //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Light On/Off Lumencor Function Lumencor_start (ctrlName) : ButtonControl String ctrlName //Lumencor color selection NVAR /z event = root:Lumencor:Lumencor_On NVAR /z gIntensity = root:Lumencor:Lumencor_intensity String cmd String Byte2 If ( (event==0) && ( (cmpStr (ctrlName,"button3")==0)||(cmpStr (ctrlName,"button0")==0) ) ) Button button3, win=Lumencor_Panel, title="Light is On", fColor=(65535,65535,65535) Button /Z button0, win=BigLumencorPanel, title="Light is On", fColor=(65535,20000,20000) controlInfo /W=Lumencor_Panel colorCheck1 If (V_Value==1) Byte2 = "0x00" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck2 If (V_Value==1) Byte2 = "0x77" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck3 If (V_Value==1) Byte2 = "0x5F" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck4 If (V_Value==1) Byte2 = "0x7B" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck5 If (V_Value==1) Byte2 = "0x3F" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck6 If (V_Value==1) Byte2 = "0x7D" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck7 If (V_Value==1) Byte2 = "0x6D" event=1 Endif controlInfo /W=Lumencor_Panel colorCheck8 If (V_Value==1) Byte2 = "0x7E" event=1 Endif ElseIf ( (event==1) && ( (cmpStr (ctrlName,"button3")==0)||(cmpStr (ctrlName,"button0")==0) ) ) Button button3, win=Lumencor_Panel, title="Light is Off",fColor=(255,255,255) Button /Z button0, win=BigLumencorPanel, title="Light is Off",fColor=(255,255,255) Byte2 = "0xFF" event=0 ElseIf (event==1) If (cmpStr (ctrlName,"colorCheck1")==0) //white Byte2 = "0x00" ElseIf (cmpStr (ctrlName,"colorCheck2")==0) //violet Byte2 = "0x77" ElseIf (cmpStr (ctrlName,"colorCheck3")==0) //blue Byte2 = "0x5F" ElseIf (cmpStr (ctrlName,"colorCheck4")==0) //cyan Byte2 = "0x7B" ElseIf (cmpStr (ctrlName,"colorCheck5")==0) //teal Byte2 = "0x3F" ElseIf (cmpStr (ctrlName,"colorCheck6")==0) //green Byte2 = "0x7D" ElseIf (cmpStr (ctrlName,"colorCheck7")==0) //yellow Byte2 = "0x6D" ElseIf (cmpStr (ctrlName,"colorCheck8")==0) //red Byte2 = "0x7E" Endif Endif Sprintf cmd, "VDTWriteBinary2 /TYPE=(0x48) 0x4F, %s, 0x50",Byte2 // For color enabled Execute cmd //readLumencortemp(ctrlName) //Currently disabled ControlUpdate /A /W=Lumencor_Panel End //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Update Lumencor Intensity Slider Function updateIntensitySlider (name, value, event) : SliderControl String name // name of this slider control Variable value // value of slider Variable event // bit field: bit 0: value set; 1: mouse down, 2: mouse up, 3: mouse moved Variable DECintensity String HEXintensity String cmd String low String highNib String lowNib String Byte1 String Byte2 NVAR gIntensity = root:Lumencor:Lumencor_intensity // Lumencor Intensity gIntensity = value DECintensity = round((100-gIntensity)*255/100) //0 equals full intensity; 255 equals off sprintf HEXintensity, "%4X", DECintensity //Byte 2 low nibble is the high nibble for the DAC byte //Byte 1 high nibble is the low nibble for the DAC byte //See handwritten notes for more info low = HEXintensity[2,3] //for values up to 256, only the low nibble matters; high=HEXintensity[0,1] lowNib = low[1] highNib = low[0] Byte1 = "0x"+lowNib+"0" Byte2 = "0xF"+highNib Sprintf cmd, "VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, %s, %s, 0x50",Byte2,Byte1 // For Violet, Cyan, Green, Red Execute cmd Sprintf cmd, "VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, %s, %s, 0x50",Byte2,Byte1 // For Blue and Teal Execute cmd ControlUpdate /A /W=Lumencor_Panel // // If (gIntensity==100) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xF0, 0x00, 0x50 // Full on Violet, Cyan, Green, Red // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xF0, 0x00, 0x50 // Full on Blue and Teal // // Elseif (gIntensity==80) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xF1, 0xF0, 0x50 // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xF1, 0xF0, 0x50 // // Elseif (gIntensity==60) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xF3, 0xF0, 0x50 // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xF3, 0xF0, 0x50 // // Elseif (gIntensity==40) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xF7, 0xF0, 0x50 // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xF7, 0xF0, 0x50 // // Elseif (gIntensity==20) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xFB, 0xF0, 0x50 // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xFB, 0xF0, 0x50 // // Elseif (gIntensity==0) // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, 0xFF, 0xF0, 0x50 // Full off Violet, Cyan, Green, Red // VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, 0xFF, 0xF0, 0x50 // Full off Blue and Teal // Endif End //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Update Lumencor Intensity Text Box Function updateIntensityBox (ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName Variable DECintensity String HEXintensity String cmd String low String highNib String lowNib String Byte1 String Byte2 NVAR gIntensity = root:Lumencor:Lumencor_intensity // Lumencor Intensity gIntensity = VarNum DECintensity = round((100-gIntensity)*255/100) //0 equals full intensity; 255 equals off sprintf HEXintensity, "%4X", DECintensity low = HEXintensity[2,3] //for values up to 256, only the low nibble matters; high=HEXintensity[0,1] lowNib = low[1] highNib = low[0] Byte1 = "0x"+lowNib+"0" Byte2 = "0xF"+highNib Sprintf cmd, "VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x18, 0x03, 0x0F, %s, %s, 0x50",Byte2,Byte1 // For Violet, Cyan, Green, Red Execute cmd Sprintf cmd, "VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x1A, 0x03, 0x0F, %s, %s, 0x50",Byte2,Byte1 // For Blue and Teal Execute cmd ControlUpdate /A /W=Lumencor_Panel End //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //Read IIC Temp Sensor Strings Function readLumencortemp(ctrlName) String ctrlName Variable tempTemp NVAR gTemp = root:Lumencor:Lumencor_Temp VDTWriteBinary2 /TYPE=(0x48) 0x53, 0x91, 0x02, 0x50 // Command String to the IIC Temp Sensor VDTReadBinary2 /TYPE=(0x50) tempTemp // Read as unsigned 16-bit. Data is in most-significant 11 bits. tempTemp = trunc(tempTemp / 32) // Shift right dropping 5 low-order bits. tempTemp *= 0.125 // Scale to degrees C. gTemp = tempTemp End //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////