Using 2 K8055N together (cascading)
Can anyone help me?
I have 2 K8055N cards
For the first card, address is 0
Device = 0
For the 2nd card, address is 1
Device = 1
I use two forms (Form1 and Form2) programing In VB6
The first form is derived from the example program which I downloaded and modified.
I then created a 2nd form each form containing the declarations and card address’s etc. And check boxes relating to the card inputs.
When I run the program, select the addresses and device for each form/card the result is:-
On clicking the test button (for input 1) on the first card results in both check boxes on both forms being “checked”.
I was expecting to see the check box on form 1 (card 1) to change only. And if I was to
Click the test button (for input 1) on the 2nd card to see it checked on form2 only.
You have to use the function SetCurrentDevice to select the card you like to control (read / write).
So in Form1 use SetCurrentDevice(0).
After doing this you can read and write card address 0.
In Form2 use SetCurrentDevice(1).
After doing this you can read and write card address 1.
Card 1 is connected to PC, with card address pins on PCB selected as 0
Card 2 is connected to PC, with card address pins on PCB selected as 1
Run Program using VB
Form1
Form1 is the start form and opens automatically
In Form 1 I click the connect button which confirms the card address as 0
I click the button search devices and click to select device 0
Form2
On Form1 I click a button to show form 2
In Form 2 I click the connect button which confirms the card address as 1
I click the button search devices and click to select device 1
If I now click on card 2 one of the test input buttons, the results show check boxes IN BOTH FORMS being checked.
I would expect to see only the input check box being checked in form 2
You can try following solution:
In Form1 add to the subroutine “Private Sub Timer1_Timer()” the following line:
SetCurrentDevice (0)
In Form2 add:
SetCurrentDevice (1)
Now Form1 should display card 0 and Form2 card should display card 1 input status.
I made a simple test to read two cards inputs to check boxes simultaneously.
This works only if both of the cards 0 and 1 are “open”.
[code] Dim i As Long
SetCurrentDevice (0)
i = ReadAllDigital
Check2(0).Value = (i And 1)
Check2(1).Value = (i And 2) \ 2
Check2(2).Value = (i And 4) \ 4
Check2(3).Value = (i And 8) \ 8
Check2(4).Value = (i And 16) \ 16
SetCurrentDevice (1)
i = ReadAllDigital
Check2(5).Value = (i And 1)
Check2(6).Value = (i And 2) \ 2
Check2(7).Value = (i And 4) \ 4
Check2(8).Value = (i And 8) \ 8
Check2(9).Value = (i And 16) \ 16[/code]