K8055 read analog inputs from 2 cards

Hi can anyone help?
I’m trying to read the analog inputs from 2 separate 8055 cards but the SETCURRENTDEVICE() doesn’t seem to work correctly. It only reads card 0 and applies card 0 analog input values to card 1 values as well.
I originally had the same problem with the analog outputs but after reading the FAQs I downloaded version 3 of 8055dll and that fixed the analog out problem.
this is the code I am using VB6 with a form

        pitch.Caption = pch
        PitchScaled = (pch * 4.25) + 127
        If pch > 30 Then PitchScaled = 255
        If pch < -30 Then PitchScaled = 0
         a = OpenDevice(0)
        If a = 0 Then SetCurrentDevice (0)
        Connect_to_0.Caption = "Card 0 Connected"
        OutputAnalogChannel 1, PitchScaled
        Alog_0_1_out_value.Caption = PitchScaled
        ReadAllAnalog Data1, Data2
        Alog_0_1_in_value.Caption = Data1
        Alog_0_2_in_value.Caption = Data2

      
    roll.Caption = rol
    RollScaled = (rol * 4.25) + 127
        If rol > 30 Then RollScaled = 255
        If rol < -30 Then RollScaled = 0
         b = OpenDevice(1)
        If b = 1 Then SetCurrentDevice (1)
        Connect_to_1.Caption = "Card 1 Connected"
        OutputAnalogChannel 2, RollScaled
        Alog_1_1_OUT_value.Caption = RollScaled
        ReadAllAnalog a3, a4
        A1_IN_value.Caption = a3
        A2_IN_value.Caption = a4

a1 and a2 are card 0 analog inputs
a3 and a4 are card 1 analog inputs
a3 value gets a1 value and a4 value gets a2 value
analog outs work OK

If you change the If statement like this, you’ll see that the card may be not connected:

If a = 0 Then SetCurrentDevice (0) Connect_to_0.Caption = "Card 0 Connected" Else Connect_to_0.Caption = "Card 0 NOT Connected" End If

I think the problem is that you are calling the OpenDevice several times without CloseDevice.
You need just one time call OpenDevice(0) and OpenDevice(1).
After doing this just use SetCurrentDevice (0) and SetCurrentDevice (1) as many times as you like to switch the control between the cards.
Here some simple examples:
First open both cards:

Private Sub Command7_Click() Dim a As Long a = OpenDevice(0) If a = 0 Then Label6.Caption = "Card 0 Connected" Else Label6.Caption = "Card 0 NOT Connected" End If a = OpenDevice(1) If a = 1 Then Label8.Caption = "Card 1 Connected" Else Label8.Caption = "Card 1 NOT Connected" End If End Sub

Then read the data etc.

Private Sub Command5_Click() Dim Data1 As Long Dim Data2 As Long SetCurrentDevice (0) ReadAllAnalog Data1, Data2 VScroll3.Value = Data1 SetCurrentDevice (1) ReadAllAnalog Data1, Data2 VScroll4.Value = Data1 End Sub

Yes you’re right. Now I only open each device once and it all works perfectly. Many thanks for your prompt assistance. These cards are so useful and so cheap!. I’m using them as an interface to FSX.They’ll eventually control DC motors via some H bridges, when I am happy with my software. Many thanks

Thx, this was also the solution for my problem.

But what I don’t understand, that I can’t find this function in your document called “MAN_NL_K8055_DLL.PDF” or others (I checked the UK version). While in the introduction you say that all functions an procedures are written in that piece of paper.
I notice that are other fuctions and/or procedures availible and not documented.

It would be nice if the document could be updated, it would make your product even more nice :laughing:

Please download the latest software package for the K8055.
Here is the link to download page:
velleman.eu/distributor/supp … code=K8055
Download the: “Complete SDK Pack (Rev 4.0)”.

The DLL functions are documented in the: K8055_DLL_manual.pdf included to the package

The package includes new K8055D.DLL and sample projects written in various programming languages. Pleas read the “README.TXT” and the “K8055 & VM110 Getting Started.pdf”.