|   | |||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
  |
Using LabView With Our Products This page contains some information that may prove helpful for users who want to use the stepper motor controllers with Labview. To use the controller with Labview you will need to issue commands in Labview by calling functions in the DLL software we provide. A few emails from our customers about LabView: Jeremy, Thanks for your reply. I also contacted National Instruments, the makers of Labview, about my problem. They have a Labview program that will read the exported function names in a DLL. It turns out that the function names need a few extra characters in order for them to be recognized by Labview, such as: _fnTurn_motor1@4. I also tried Borland's IMPDEF utitlity, which also extracts functions from a DLL. It lists the function names, then an "=", and then anothername. It is this second name which must be specified in Labview. I have included the definition file for your future reference. Thanks, Ben Daniel, I sorted it out - things are working just fine now! In case someone else asks the same question I did: You ned LabView version 5 or later to do these things... Find a vi called "Get DLL Exports.vi" from ni.com. Run this on the windows .dll file for the stepper motor control program. It will then give you the names and settings used in the "Call Library Function" sub-vi. I used the A-200. The tricky thing about naming schemes, aside from extra characters that LabView assigns, is that functions motor1 apply to motor 1 on the board, but motor3 calls affect motor 2. Could get confusing. Once I sorted out the naming scheme problem, it was easy. For example: To turn motor 2 it looks like you should call fnTurn_motor2 from the .dll list on the website. With the 2 -> 3 problem, and LabView adding garbage the function call is actually _fnTurn_motor3@4. "Get DLL Exports.vi" will help you sort this out. Thanks for trying to help me out, and I hope this might save someone else some time. Alex Hey! Just letting you know I finally got it working. The Borland compiler (or linker) couldn't find the functions in the DLL, probably simply because they were made in Visual C++. In any case, I gave up trying to use the actual function names, since the compiler obviously didn't know where they were. After I generated my own *.lib file, I looked inside it (using tdump.exe, the borland equivalent of dumpbin.exe). While I was busy trying everything imaginable, one of the things I tried was to dynamically load the dll, and find the addresses of the functions by using their INTERNAL names (ie _fnTurn_motor1@4). For some strange reason it worked! I tried using the ordinal number, but that didn't work either. I don't know if or how the borland compiler can use the ordinal numbers... Anyway, in case anyone ever has the same problem, the code I used looks like this: //--------------------------------------------- //In header file - actually, in private section of a class //--------------------------------------------- (...) HINSTANCE hinst; void far _stdcall (*fnTurn_motor2)(int m2_steps); void far _stdcall (*fnTurn_motor1)(int m1_steps); void far _stdcall (*set_motor1_direction)(int motor1_direction); void far _stdcall (*set_motor2_direction)(int motor2_direction); int far _stdcall (*get_delay_time)(void); void far _stdcall (*set_delay_time)(int delay); void far _stdcall (*set_controller1)(int address); (...) //--------------------------------------------- //--------------------------------------------- //In constructor for class //--------------------------------------------- (...) //Load DLL hinst = LoadLibrary("STEPPERMOTOR.DLL"); //Get function addresses (FARPROC)fnTurn_motor1 = GetProcAddress(hinst,"_fnTurn_motor1@4"); (FARPROC)fnTurn_motor2 = GetProcAddress(hinst,"_fnTurn_motor2@4"); (FARPROC)set_motor1_direction = GetProcAddress(hinst,"_set_motor1_direction@4"); (FARPROC)set_motor2_direction = GetProcAddress(hinst,"_set_motor2_direction@4"); (FARPROC)get_delay_time = GetProcAddress(hinst,"_get_delay_time@0"); (FARPROC)set_delay_time = GetProcAddress(hinst,"_set_delay_time@4"); (FARPROC)set_controller1 = GetProcAddress(hinst,"_set_controller1@4"); (...) //--------------------------------------------- Thank you very much for all your help! I'll let you know if I have any more trouble... (Hopefully, things should be ok from now on...) Kind regards, Kevin If you're still having trouble with LabView, send us an email at info@steppercontrol.com or fill out our contact form.   |
  |
![]() |
|
|   | |||||
|
Copyright © 2004, Mill-Shaf Technologies, Inc. All Rights Reserved |
|||||