k8055D.dll source code or 64-bit release of the .dll?

Hi, I’m looking for a 64-bit release of the k8055D.dll or the source code for the .dll itself so I can compile a 64-bit version.

The company I work for is currently using the k8055 to control various hardware components, but our native software is 64-bit only. We are developing software in both MATLAB and C++, and a quick search of the various internet forums shows there is quite a large amount if interest in a 64-bit version, especially in the MATLAB community where it is not possible to call 32-bit .dll’s within the 64-bit release. This would be extremely beneficial for us as we currently do all our prototyping within MATLAB.

If it is not possible to compile a 64-bit version for the k8055, would it be possible to obtain the source code for the .dll, and preferably its dependencies as well so our software team can attempt to create a 64-bit version? I would be happy to share the results for publishing on-line.

I’m sorry if this is a repeat question!

Thanks

The original DLL from Velleman was written in Delphi (Pascal). The source code is available. See link in this post: viewtopic.php?f=3&t=7405#p27681

I do have C code that is functionally equivalent as part of the K8055 Open Source project. Although the overall code does a lot more, it has a backward compatible mode and can talk to original K8055 boards. I compile it as 32 bit DLL with MinGW. I have not yet tried to compile it with a 64 bit compiler. That source code is available in the “client” directory of this github repository: github.com/wieck/k8055-pic18f (files k8055d.c, k8055d.h, k8055legacy.c, k8055legacy.h and k8055_hidprotocol.h contain what you’re looking for).

If you want pure original K8055 support only, you would obviously have to rip out all the K8055M parts, that deal with the new HID protocol of the PIC18F firmware. At least it should give you a good example of how to implement such a DLL. Let me know if there is anything unclear in the code.

Regards

If anyone is interested, I have a 64bit version of k8055D.dll compiled with FPC.
The Delphi Demo is also converted to Lazarus and works as a 64bit Version under Win7/64.

Regards
Theo

Hi,

I’m actually interested by a 64-bit version of K8055D.dll, if it allows to use this board with matlab 64bits.
Could you post a link to this file ? I didn’t find out how to contact you direcly, sorry about that.

More generally, is it possible that a new revision of the “complete sdk pack” comes out ? (I now use the rev4.0 but with matlab32bits)

Thanks in advance

Dear MostlyHarmless,

I tried to look at the source code in your link, found the files you are talking about, nevertheless I’m unable to make a dll from that.
I installed Dev-c++ so I think I use MinGW to compile. With the help of a tutorial I also made my first dll containing only one ‘hello world’ function.
But now I’m stuck because :

  • I don’t know how to include the .c files to my dev-c++ project to create the dll,
  • and any function in the K8055D files call functions from the K8055M files. So should I replace them ? And how ?

Sorry for these beginner questions.
My aim is only to have a K8055D.dll in 64-bits to work with Matlab, so if you have any idea it would help me a lot !

Thanks, regards,
Ghislain

[quote=“Ghislain_B”]Dear MostlyHarmless,

I tried to look at the source code in your link, found the files you are talking about, nevertheless I’m unable to make a dll from that.
I installed Dev-c++ so I think I use MinGW to compile. With the help of a tutorial I also made my first dll containing only one ‘hello world’ function.
But now I’m stuck because :

  • I don’t know how to include the .c files to my dev-c++ project to create the dll,
  • and any function in the K8055D files call functions from the K8055M files. So should I replace them ? And how ?

Sorry for these beginner questions.
My aim is only to have a K8055D.dll in 64-bits to work with Matlab, so if you have any idea it would help me a lot !

Thanks, regards,
Ghislain[/quote]

I’ve never used Dev-c++, so I don’t know how to build projects in there. There also does not seem to be a Dev-c++ version that contains the MinGW-w64 compiler. You need that one to build a 64 bit DLL. Otherwise even when you are running on a 64 bit Windows, you will still create a 32 bit DLL.

I will try to get MinGW-w64 running on one of my systems and see if the K8055D code I have compiles into a 64 bit DLL.

Regards,
Jan

Thanks a lot for your help, for sure you make me save a lot of time.
In the case you can’t compile in 64-bits, at least you made me realize I couldn’t do it myself ! :-p
But if you manage to compile the dll, be sure I’ll be your first tester !
Regards,
Ghislain

Ghislain,

I have a first build of my current k8055d.dll with mingw-w64. It is identified as PE32+ .Net Assembly file. I don’t have any 64 bit application to test it though, so I have no idea if this works or not. It’s only 170K in size, 56K zipped. If you send me an email to janwieck@yahoo.com I will reply with it attached. We can publish the final binaries once we know that it all works.

Regards,
Jan

You can download a 64bit Version of the DLL here.
theo.ch/lazarus/K8055fpc64.zip
64bit Demo included.
Compiled with Free Pascal freepascal.org/

[quote=“theo22”]You can download a 64bit Version of the DLL here.
theo.ch/lazarus/K8055fpc64.zip
64bit Demo included.
Compiled with Free Pascal freepascal.org/[/quote]

Thanks for sharing. That is useful.

Interestingly, the DLL I built does work (renamed to K8055FPC64.DLL) when used with a K8055 board. It does not work (freezes the demo app) when used with a modified PIC18F board. I suspect the 64 bit version of the pthread library at this point. The legacy K8055 support code doesn’t use pthreads but more or less emulates the original DLL, so that’s a smoking gun for me.

Regards,
Jan

Thanks

Does my DLL work with your “modified PIC18F board”?

[quote=“theo22”]Thanks

Does my DLL work with your “modified PIC18F board”?[/quote]

No, but that is to be expected.

The open source PIC18F firmware has more features, like 10 bit A/D and PWM resolution, 5 counters and driving hobby servos through the digital ports. It is work in progress with more features to come. Those features required me to change the format of the HID messages, so the protocol isn’t compatible. To distinguish the cards, the PIC18F board uses a different product ID code than the original K8055. So your and the original K8055D.DLL don’t even see the card.

My DLL code can talk both protocols and supports two API’s. When using the old Velleman API, both card types act more or less the same and the new features aren’t available. It all works under Win32. Apparently there is something wrong with the libpthread.a included in mingw-w64. I’m still wading through sourceforge discussions to figure out how to fix that.

Regards,
Jan

Bugs found and fixed. My DLL now works with both card types, the original K8055 and the PIC18F modified one.

The problem was actually in my code with a double pthread_mutex_lock() in an error case. That error was triggered by a different alignment of struct members in the HID command message due to 32 vs. 64 bit compiler.

As soon as I get some positive feedback I will wrap a new snapshot for download.

Thanks again,
Jan

Thank you, theo22, for doing this 64-bit DLL K8055fpc64.dll.
I tested it in Visual Studio - everything works fine!
In Visual Studio you can now set the target platform to all CPU types or to x64.
With the original K8055D.DLL you have to use target platform x86 only.

Dear all,

After a few changes I could make the K8055 board work with Matlab 64-bits !!! (it works with Theo’s and MostlyHarmless’ DLLs)

I’m not sure I did it the correct way, but at least it works. Please tell me if the is something better to do.
Here are the changes I made :

  • In the “setup.m” file in the support package provided by matlab, comment any code that tests if it is a 32-bit matlab.
  • When running the setup, use the 64bits DLL (rename it to K8055D.dll) instead of the official one that the “readme.pdf” tells you to dowload.
  • To be able to load the library, I made a .m file named “mHeader”. For this, first seek the K8055.h file in the package and copy it to the folder containing the 64bits version of your DLL. Then in matlab go to this folder and :
    [notfound, warnings] = loadlibrary(‘K8055D.dll’, ‘K8055D.h’, ‘mfilename’, ‘mHeader’)
    (This creates other files in the same folder that seem to be important also)
  • Still in the support package, Matlab uses “ExperimentBoard.m” to connect to the board, so edit this file and comment any code that tests if it is a 32-bit matlab, again. Also change the calls to ‘loadlibrary’ so that it uses mHeader.m instead of K8055D.h :
    loadlibrary(‘K8055D.dll’,@mHeader)
    And of course adapt the if conditions that lead to this call.

Hope it helps !

Edit : It was unnecessary to remove the “__stdcall” in the mHeader file.

Ghislain,

apparently the difference between mingw-32 and mingw-w64 is that the latter doesn’t define the STDCALL macro by default. I just sent you another version of the DLL that I compiled with STDCALL defined as __stdcall instead of an empty macro. That may do the trick.

Regards,
Jan

(problems solved, see previous post)

If that may help other people, the dll from MostlyHarmless works with Theo’s demo .exe so both dlls actually work.
However, under Matlab I only managed to use Theo’s dll. I looked in the program ‘ExperimentBoard.m’ provided in Matlab support package and it seems that a problem occurs at the step ‘SetCurrentDevice’ (result -1) only in MostlyHarmless’ dll case. If I remove this step, surprisingly it still works with Theo’s dll and not with MostlyHarmless’ (no error anymore but functions have no effect to the board).

It might be important, but I’m not aware of the different versions of the board, so here is what I can read on it :
P8055-1 Velleman 2003
K8055 USB experiment board

I don’t know how to know if it is “K8055D” or “K8055M” for instance.

K8055M is what I call a K8055 that has been modified (M) to use a PIC18F2550 at 30 MHz with the enhanced open source firmware. You most likely have an unmodified original K8055 with the PIC16C745 at 6 MHz.

I think I found the error. SetCurrentDevice() was broken in my code. I have sent you a fixed version of the DLL.

Thanks for testing.

Since everything now works, I posted a “how to” in matlab forum (see here).
I needed to include a link to a 64-bit DLL, so I copied Theo’s.
Does the license of your code allow to distribute it freely, like MostlyHarmless’ ? I guess yes, it’s probably not limited to this site.
Also, will the link remain valid ? If not, is there a better choice ?

[quote=“Ghislain_B”]
Does the license of your code allow to distribute it freely, like MostlyHarmless’ ? I guess yes, it’s probably not limited to this site.
Also, will the link remain valid ? If not, is there a better choice ?[/quote]

I don’t care about the license.
I’m not going to delete the link soon, but a copy of the files somewhere at velleman.eu would be nice.