| 
		
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		http://www.vellemanusa.com/support/down ... 055&type=9
Any way to get this to work in QM? I can't get the DLL to register...most likely .NET and not COM.
 
Is there anyway to convert? Or am I just stuck. I sure would prefer to not be stuck.
 
Thanks, 
Jim
	 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		It is simple dll, not COM or Net. 
Read K8055_DLL_manual.pdf and declare the functions in QM. Function declarations there are in C++ language.
 
Macro Macro1584 dll kb8055d,#OpenDevice CardAddress
 ,CloseDevice
 ,...
 
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		Ok. I was trying to register it with QM and it failed. I'll try it out later and see if I can get it to work.
 Thanks!
 Jim
 
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		I don't know how to set up the dll and execute commands really with QM. 
Ok, so I've gotten the the kit to execute one command using (I haven't set up all the functions of the dll because you cannot copy and paste from the pdf, so I'd either have to rekey or convert the pdf):
 outdll K8055D
 ,#OpenDevice CardAddress=0
 ,#OutputAnalogChannel
 ,#WriteAllDigital
 ,#CloseDevice
 ,#ClearAllDigital
 OpenDevice(0)
 WriteAllDigital(9)
If I try to run again I get: 
Exception 0xEEDFADE.  In KERNELBASE.dll at 0x75E2B760 (0x75E20000+0xB760).
 
When I restart QM I get this error:
   
Like I said, I know I am doing this all wrong. I'm actually pretty excited to see QM execute at least one command!!
 
Thanks, 
Jim
	 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		Why =0? 
Macro Macro1569 outdll K8055D
 ,#OpenDevice CardAddress
 ,CloseDevice
 ,OutputAnalogChannel Channel Data
 ,WriteAllDigital Data
 ,ClearAllDigital
 int cardAddress=OpenDevice(0)
 if(cardAddress=-1) end "error"
 WriteAllDigital(9)
 5
 CloseDevice
 
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		You can have more than one device that are assigned an address by jumpers on the board. 
I have both jumpers on so the device id is 0.
 
Still I have the exact same issues.
 
I can run the function once and then the same things happen.
 
It will run multiple commands:
 outdll K8055D
 ,#OpenDevice CardAddress
 ,CloseDevice
 ,OutputAnalogChannel Channel Data
 ,WriteAllDigital Data
 ,ClearAllDigital
 int cardAddress=OpenDevice(0)
 if(cardAddress=-1) end "error"
 WriteAllDigital(9)
 1
 WriteAllDigital(7)
 1
 WriteAllDigital(122)
 1
 WriteAllDigital(144)
 5
 CloseDevice
but if I try to run the function again, same errors as above.
 
-jim
	 
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		I guess what I am asking, is how do I open the device in one function and then send commands in other functions?
	 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		Probably cannot be opened/closed two times in process. For easier testing, run in separate process. 
or
 
Macro Macro1569 outdll K8055D
 ,#OpenDevice CardAddress
 ,CloseDevice
 ,OutputAnalogChannel Channel Data
 ,WriteAllDigital Data
 ,ClearAllDigital
 
 int+ g_kit
 if(!g_kit)
 ,g_kit=OpenDevice(0)+1
 ,if(!g_kit) end "error"
 ,;or put this code in a function that runs at startup
 
 WriteAllDigital(9)
 
 ;CloseDevice ;;call it when QM exits, for example in a function with trigger "QM events -> file unloading", or from a destructor of a global variable.
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		I would use this function to open and close. Not tested. 
Function KitInit ;/function# [close]
 
 ;Opens or closes kit.
 ;Error if fails to open.
 ;On Open returns kit card address.
 ;Can be called many times. If already open, will not try to open again. Error if already closed.
 
 ;Call this function before using kit functions:
 ;<code>KitInit</code>
 
 ;Call this function when QM exits, for example in a function with trigger "QM events -> file unloading", or from a destructor of a global variable:
 ;<code>KitInit 1</code>
 
 
 dll K8055D
 ,#OpenDevice CardAddress
 ,CloseDevice
 ,OutputAnalogChannel Channel Data
 ,WriteAllDigital Data
 ,ClearAllDigital
 
 int+ __g_kit ;;0 not opened, -1 closed, >0 open
 
 if(__g_kit=-1) end "don't call this function after closing"
 
 if close
 ,if __g_kit
 ,,__g_kit=-1
 ,,CloseDevice
 ,ret
 
 if !__g_kit
 ,lock
 ,if !__g_kit
 ,,__g_kit=OpenDevice(0)+1
 ,,if(!__g_kit) end "failed to open kit"
 
 ret __g_kit-1
 
	
	
	
		
	Posts: 1,000Threads: 253
 Joined: Feb 2008
 
	
	
		So if I use a dialog to initialize the KitInit, I can then executed commands from separate functions as long as the dialog is open. 
If I close the dialog and reopen it, none of the commands works until I restart QM where I get the same runtime error.  Once QM restarts, I can run the dialog and execute commands again.
 
Function InitKitDlg \Dialog_Editorfunction# hDlg message wParam lParam
 if(hDlg) goto messages
 
 ;BEGIN DIALOG
 ;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
 ;END DIALOG
 ;DIALOG EDITOR: "" 0x2030208 "" "" ""
 if(!ShowDialog("InitKitDlg" &InitKitDlg)) ret
 ret
 ;messages
 sel message
 ,case WM_INITDIALOG
 ,KitInit
 ,case WM_DESTROY
 ,case WM_COMMAND goto messages2
 ret
 ;messages2
 sel wParam
 ,case IDOK
 ,case IDCANCEL
 ret 1
 
	
	
	
		
	Posts: 12,239Threads: 144
 Joined: Dec 2002
 
	
	
		Then probably thread  that called OpenDevice or KitInit must be running all the time.
 dialog:
 mac "kit_thread"
 
 Function kit_thread:
 KitInit
 atend KitInit 1
 wait -1
 
 For kit_thread check "Allow only single instance".
 
 Or, let the dialog run all the time. Instead of closing - hide. Next time, if dialog exists, show it.
 
 Or try this:
 DisableThreadLibraryCalls GetModuleHandle("K8055D")
 Then the dll will not know that the thread ended.
 |