64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi All,
I'm attempting to use the wonderful Kflop from MATLAB, a popular numeric computing platform. My initial plan is to use the KMotion_dotNet dll since MATLAB has a .NET interface.
Unfortunately MATLAB stopped supporting releasing 32 bit versions many years ago and now only provides versions for 64 bit Windows. This means it is impossible to load 32 bit libraries into MATLAB applications.
I wonder if there is a 64 bit version of the libraries, or KMotion, or if anyone knows of a workaround?
Possible solutions which come to mind:
- Compile 64 bit version of the KMotionDLL or KMotion_dotNet.dll (though I guess this will require building of some associated libraries and may snowball into a big task)
- Run old version of MATLAB with 32 bit release. Unfortunately not an option since there are other backwards compatibility issues with our applications.
- Build some sort of intermediary/wrapper application. For example, I can imagine a 32 bit process running in a WOW64 compatibility layer will be able to load the 32bit library. MATLAB could communicate with this process via pipes or sockets.
But before I go further, I suspect this may have been an issue for someone previously or has an idea for a more elegant solution?
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi gperkins,
A few years ago a 64 bit version was made (from KMotion Version 4.33q) and seems to work properly. Unfortunately it hasn't been updated since but depending on what you are trying to do it might work fine.
Here is a link.
Otherwise the 32 bit and 64 bit versions of 4.33q might be compared and the changes merged into a current Version.
HTH
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi Tom,
That is extremely helpful thanks! I've just dowloaded it and see that KMotion excecutable doesn't run (missing GCodeInterpreter.dll). Looks like some of the libraries are not built.
Do I need to compile them using the BuildAllLibs VS solution, or is this intentionally a barebones 64 bit build of the KMotion_dotNet library? Which is fine for me - as long as it can work that way!
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Yes use BuildAllLibs.sln to create the binaries. You will probably want the Release code. Use VS 2015 to have less issues
1 Attachment(s)
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Thanks Tom. Since my last post I've continued chipping away at this. I see Kmotion, KMotionCNC applications in this release are 32 bit. That's fine, I only need the libraries.
The 64 bit libraries built successfully from VS2015. Just needed a tweak to the build config to target 64 bit & build for Release.
I also had to copy 64 bit FTDI drivers into the KMotion release directory (ftd2xx.lib ftd2xx64.dll)
I tried running a couple of the example applications (also recompiled 64 bit) and got as far as a message about wrong FW on the Kflop board, so I used a working (32 bit) installation of KMotion 433q to flash the correct firmware.
Now, running SimpleCoeffLoad.exe I get a KMotionDLL Error Extracting version information from DSPKFLOP.out. So looks like I still have something to track down
I might also try using the Kmotion_dotNET library instead instead of KMotionDLL..
I'll update with any further progress. Meanwhile, any hints will be gratefully received.
https://www.cnczone.com/forums/attac...d=488938&stc=1
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
I think I found the bug. This structure in COFF.h had 2 pointers _n_nptr[2] that were read in as binary structures from the COFF file. Switching to x64 changes the pointers from 32 to 64 bits which throws off the alignment in the COFF file. Changing back to 32 bit fields as shown below seems to solve the issue. Those fields aren't used in our app anyway,
Code:
struct syment
{
union
{
char _n_name[SYMNMLEN]; /* old COFF version */
struct
{
long _n_zeroes; /* new == 0 */
long _n_offset; /* offset into string table */
} _n_n;
// char *_n_nptr[2]; /* allows for overlaying */
int _n_nptr[2]; /* 2 32 bit fields - tktk - allows for overlaying */
} _n;
long n_value; /* value of symbol */
short n_scnum; /* section number */
unsigned short n_type; /* type and derived type */
char n_sclass; /* storage class */
char n_numaux; /* number of aux. entries */
};
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
That did the trick thanks, the example works. It also seems to be working fine with MATLAB now - I've made a quick video showing it running.
https://www.youtube.com/watch?v=xMWeBA-eBL0
I'm not sure if it's expected with the dot_Net library, but if KMotion/KMotionServer aren't running, I get an error "Unable to execute:\r\rKMotionServer.exe\r\rTry re-installing software or copy this file to the same location as KMotion.exe". So I just make sure it's running first.
Thanks very much for your help, Tom.
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Great. Does the example launch KMotionServer.exe correctly if it isn't already running?
You might add the location of KMotionServer to the Windows PATH environmental variable.
Anyway you seem to have handled it well.
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Adding the location of KMotionServer to the Windows PATH environmental variable sorts that out, thanks!
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi, I'm having the same need for 64-bit libraries of KMotion - it looks like you have made some very good progress in getting it working!
Would you be willing to share the compiled libraries/KMotion? It would be a massive help.
Many thanks
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
here's a possible solution:
Considering MATLAB's lack of 32-bit support and the need for Kflop integration, you could explore the option of creating an intermediary/wrapper application. This approach involves setting up a 32-bit process to run within a WOW64 compatibility layer, enabling it to load the 32-bit library. MATLAB could then communicate with this intermediary application using pipes or sockets. While it may involve additional development, this method might provide the compatibility you're looking for between MATLAB and the KMotion libraries.for my location and 32- bit support
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Quote:
Originally Posted by
TomKerekes
Yes use BuildAllLibs.sln to create the binaries. You will probably want the Release code. Use VS 2015 to have less issues
Hello Tom. I found "KMotion5.2.1x64" in the dynomotion downloads. its libraries seem x64 builded. I plan to install KMotion5.2.1, flash kflop and reboot, then replace all files with KMotion5.2.1x64. Do you have any tips for this version?
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi,
You should just be able to unzip KMotion5.2.1x64 and use it like any other installation and it has the x64 libraries pre-built in the \KMotion\Release64 folder.
KMotion.exe is only a 32 bit app in \KMotion\Release
We hope to have a normal installation soon.
See also the wiki here.
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Sure, here you go. I'm using the KMotion_dotNet.dll in the release directory.
https://www.dropbox.com/scl/fi/pppan...o50nz9fu1&dl=0
However, I see the post blow about a newer version KMotion5.2.1x64. This is probably a better bet for you
I hope this helps.
Quote:
Originally Posted by
scintam
Hi, I'm having the same need for 64-bit libraries of KMotion - it looks like you have made some very good progress in getting it working!
Would you be willing to share the compiled libraries/KMotion? It would be a massive help.
Many thanks
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Note the 32/64-bit code has been released. See the 5.3.0 announcement here.
Re: 64 bit version of KMotion libraries for MATLAB and other 64 bit platforms
Hi George,
Thanks for the time for posting back.
Yes all future Versions will include both 32 and 64-bit Versions.