K8055 - CardAddress

In your briefs you mention that you can use “upto 4 cards”, and using a jumper to set from 0-3 makes this possible.

Now when you use the OpenDevice function from the DLL you can specify which one to open. But, CloseDevice just closes it.

What would happen if I wanted to open multiple cards at once?
None of your Declarations have any way to specify the CardAddress to use… so I take it that its not possible to open more than one card at once?

I will look into the Delphi source code myself of the DLL to see if it can be possible to implement this.
(I am also working on putting the “Timer” into the DLL itself so it will do a callback when an event/input changes. This should save the “user” having to keep checking for it in the project)

You can open all the 4 cards. Do not close any of those.
Use SetCurrentDevice function to select the card you want to control.
Please see also the following threads:
forum.velleman.be/viewtopic.php? … 995019b7e6
forum.velleman.be/viewtopic.php? … 998ce29f7b
forum.velleman.be/viewtopic.php? … 07697171b8

Ah ok thanks, I totally missed that one, I left it at the bottom of my new code until I sorted out the other stuff.
The CloseDevice will close the “CurrentDevice” or all of them?

Would there be any performance hit if I always set the device before making a change. So if I make my own “helper” function…

(Psudeo code)

Sub SetDOut(Channel, CardAddress)
    Call SetCurrentDevice CardAddress
    Call SetDOut Channel, True

End Sub

This would be setting the device everytime I want to make a change rather than when changing between cards.

Basically I want to change this…


Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)

to this

Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long, ByVal CardAddress As Byte)

this means I can call

WriteAllDigital n, 0     ' Card 0

instead of

SetCurrentDevice 0
WriteAllDigital n

Also, why are you using Long for a value of 0-255? Byte will cover this.

Your “helper” function is a good idea. I think you can’t modify the DLL but you can call this “helper” function within your own code.

CloseDevice closes all the devices.

You are right a little space is wasted by using “As Long” instead of “As Byte”.
“As Long” is used because it is a sort of “standard” in 32 bit systems.

When running this code in VB2005, 2008 or .NET etc. it must be changed to “As Integer”.