Two issues : K8055 / Vm110 problems with two cards connected

I have recently purchased two vm110 interface boards. Currently i am writing the software for it to control several devices.

I am using K8055d.dll version 2.0.0.1

The two cards are controlled from one thread within the software. I have programmed a continues loop which scans first device 0 and then device 1. Board switching is performed with the SetCurrentDevice procedure.

I have two issues with the cards at the moment which leads me to conclude that the problem might be within the K8055D.dll

Issue 1:
Situation:
Two boards connected. I have programmed within the loop that when button 5
is pressed on card 0 output 5 is set to TRUE. When button 4 is pressed output 5 is set to FALSE.
The code does seperate handling for card 0 and seperate handling for card 1 (but all in one loop).
I programmed the same functionality (press 5 --> output 5 TRUE, press 4 --> output 5 FALSE) for board 1 (seperate piece of code, like if currentcard = 1 then perform the following actions, and if current card = 0 then perform other actions)

The test i have conduced :
I have started the software to continuesly scan the cards.
The following happens.
Press button 5 on card 0 = output 5 on card 0 is true (led is on)
Press button 5 on card 1 = output 5 on card 1 stays false (led stays off)
Press button 4 on card 1 = nothing happens (led is already off ofcourse)
Press button 5 on card 1 = output 5 on card 1 is true (led is on)

I can see i have pushed the buttons ( the software i have written shows it to me)
I tested the button behaviour also with software commands (not pressing the buttons, but just giving the SetDigitalChannel command
Behaviour seems to be the same

Issue 2:
Within the same loop i want to a set the analog outputs also (OutputAnalogChannel(long,long)).
When i do this the next time i issue the command SetDigitalChannel(5) both cards set output 5 to true!
This means that after i have set one of the analog ports i loose the ability to control a board individually.

I am using powerbuilder 10, and one card functions without any problems.
If anyone needs to see the sourcecode, i will post it, but for a first post i thinks it’s a bit much

Does anyone have any idea’s? :lol:

Difficult to say what might be the cause to the problem.
Please post your code here.

As requested (the paste looses the tabs, sorry for that):

/***************************************************************************
of_set_check_box: 	
Card 0
Channel 1 to 8 output	:	1 to 8 	Set the corresponding output check box in the main window to on
Channel 1 to 8 output	:	11 to 18 	Unset the corresponding output check box in the main window to on
channel 1 to 5 input 	:	21 to 25	Set the corresponding input check box in the main window to on
channel 1 to 5 input 	:	31 to 35	Unset the corresponding input check box in the main window to on

Card 1
Channel 1 to 8 output	:	101 to 108 	Set the corresponding output check box in the main window to on
Channel 1 to 8 output	:	111 to 118 	Unset the corresponding output check box in the main window to on
channel 1 to 5 input 	:	121 to 125	Set the corresponding input check box in the main window to on
channel 1 to 5 input 	:	131 to 135	Unset the corresponding input check box in the main window to on
***************************************************************************/
boolean lb_channel_0, lb_channel_1
boolean lb_prev_out[16]
integer li_channel_counter = 1 ,  li_temp
long ll_digital_input, ll_digital_output
long ll_Return_Value
integer li_prev_milli_time, li_cur_milli_time, li_milli_sec_diff
long ll_CurrentDevice = 0

lo_nvo_intfobj.ib_stop = FALSE
li_prev_milli_time = 0
li_cur_milli_time = 0

ll_Return_Value = OpenDevice(1)
ClearAllDigital()

ll_Return_Value = OpenDevice(0)
ClearAllDigital()

lo_nvo_intfobj.of_SpamMessage("Opened devices")

DO until lo_nvo_intfobj.ib_stop = TRUE
    SetCurrentDevice(ll_CurrentDevice)
    //We get the system time from kernel32 to show the scan interval in the main window
    GetSystemTime(s_systime)	
	li_cur_milli_time =  s_systime.millisecond
	IF li_prev_milli_time < li_cur_milli_time THEN
		li_milli_sec_diff = li_cur_milli_time - li_prev_milli_time
	ELSE
		li_milli_sec_diff = 1000 - li_prev_milli_time + li_cur_milli_time
	END IF
	li_prev_milli_time = li_cur_milli_time
	lo_nvo_intfobj.of_set_interval_message(li_milli_sec_diff)
	
	//First we check whether a input button is pressed
	IF ll_CurrentDevice = 0 THEN
		FOR ll_digital_input = 1 TO 5
			lb_channel_0 = ReadDigitalChannel(ll_digital_input)
			IF  lb_channel_0 = TRUE THEN
				lo_nvo_intfobj.of_SpamMessage("Button " + string(ll_digital_input) + " pressed on card 0")
				IF ll_digital_input = 5 THEN
					SetDigitalChannel(5)
					lo_nvo_intfobj.of_set_check_box(5)
				END IF
				IF ll_digital_input = 4 THEN
					lo_nvo_intfobj.of_SpamMessage("Button " + string(ll_digital_input) + " pressed on card 0")
					ClearDigitalChannel(5)
				lo_nvo_intfobj.of_set_check_box(15)
				END IF
				lo_nvo_intfobj.of_set_check_box(ll_digital_input + 20)
			ELSE
				lo_nvo_intfobj.of_set_check_box(ll_digital_input + 30)
			END IF		
		NEXT
	END IF
	
	IF ll_CurrentDevice = 1 THEN
		FOR ll_digital_input = 1 TO 5
			lb_channel_1 = ReadDigitalChannel(ll_digital_input)
			IF  lb_channel_1 = TRUE THEN
				lo_nvo_intfobj.of_SpamMessage("Button " + string(ll_digital_input) + " pressed on card 1")
				IF ll_digital_input = 5 THEN
					SetDigitalChannel(5)
					lo_nvo_intfobj.of_set_check_box(105)
				END IF
				IF ll_digital_input = 4 THEN
					lo_nvo_intfobj.of_SpamMessage("Button " + string(ll_digital_input) + " pressed on card 1")
					ClearDigitalChannel(5)
					lo_nvo_intfobj.of_set_check_box(115)
				END IF
				lo_nvo_intfobj.of_set_check_box(ll_digital_input + 120)
			ELSE
				lo_nvo_intfobj.of_set_check_box(ll_digital_input + 130)
			END IF		
		NEXT
	END IF
	
	
	//Then we check whether we received a message to set a digital output
	// This goes on from 1 to 16 (Two Cards)
	IF ll_CurrentDevice = 1 and li_channel_counter > 8 THEN
			FOR li_channel_counter = 9 to 16 
				IF lb_prev_out[li_channel_counter] <> lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter] THEN
					lb_prev_out[li_channel_counter] = lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter]
					lo_nvo_intfobj.of_SpamMessage("Output Channel Value = " + string(lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter]) + " for card 1")							
					ll_digital_output = li_channel_counter - 8
					IF lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter] = TRUE THEN
						lo_nvo_intfobj.of_SpamMessage("Output " + string(ll_digital_output) + " for card 1 set")										SetDigitalChannel(ll_digital_output)
						li_temp = Integer(ll_digital_output) + 100
						lo_nvo_intfobj.of_SpamMessage("Message = " + string(li_temp) + " for card 1")					
						lo_nvo_intfobj.of_set_check_box( li_temp )
					ELSE
						lo_nvo_intfobj.of_SpamMessage("Output " + string(ll_digital_output) + " for card 1 unset")
						//First we do a set, it seems like the card does not like a set when we send an set message to the other card
						// Maybe he is starving for attention
						SetDigitalChannel(ll_digital_output)
						ClearDigitalChannel(ll_digital_output)
						li_temp = Integer(ll_digital_output) + 110 
						lo_nvo_intfobj.of_SpamMessage("Message = " + string(li_temp) + " for card 1")			
						lo_nvo_intfobj.of_set_check_box( li_temp )
					END IF
				END IF
			NEXT
	ELSE
			FOR li_channel_counter = 1 to 8 
				IF lb_prev_out[li_channel_counter] <> lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter] THEN
					lb_prev_out[li_channel_counter] = lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter]
					lo_nvo_intfobj.of_SpamMessage("Output Channel Value = " + string(lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter]) + " for card 0")
					ll_digital_output = li_channel_counter
					IF lo_nvo_intfobj.ib_outputchannelvalue[li_channel_counter] = TRUE THEN
						lo_nvo_intfobj.of_SpamMessage("Output " + string(ll_digital_output) + " for card 0 set")										SetDigitalChannel(ll_digital_output)
						li_temp = Integer(ll_digital_output)
						lo_nvo_intfobj.of_SpamMessage("Message = " + string(li_temp) + " for card 0")			
						lo_nvo_intfobj.of_set_check_box( li_temp )
					ELSE
						lo_nvo_intfobj.of_SpamMessage("Output " + string(ll_digital_output) + " for card 0 unset")										ClearDigitalChannel(ll_digital_output)
						li_temp = Integer(ll_digital_output) + 10 
						lo_nvo_intfobj.of_SpamMessage("Message = " + string(li_temp) + " for card 0")			
						lo_nvo_intfobj.of_set_check_box( li_temp )
					END IF
				END IF
			NEXT
	END IF
	

	
	// Then we set the analog channel to the value requested
	// Not implemented because there is a problem with this.
	// When the analog channel is set then the next time we set a digital channel
	// both cards repond to it. And thats not what we want!!
	/*
	IF ll_CurrentDevice = 0 THEN
		OutputAnalogChannel(1, lo_nvo_intfobj.ii_analog_1)
		OutputAnalogChannel(2, lo_nvo_intfobj.ii_analog_2)
	END IF
	IF ll_CurrentDevice = 1 THEN
		OutputAnalogChannel(1, lo_nvo_intfobj.ii_analog_3)
		OutputAnalogChannel(2, lo_nvo_intfobj.ii_analog_4)
	END IF
	*/
	//Now we set the other card active and restart the loop again
	IF ll_CurrentDevice = 0 THEN
		ll_CurrentDevice = 1
	ELSE
		ll_CurrentDevice = 0
	END IF
	//Then we check whether we need to stop
	IF lo_nvo_intfobj.ib_stop = TRUE THEN 
		lo_nvo_intfobj.of_SpamMessage("Stopped scanning the device")
		exit
	END IF
LOOP 


CloseDevice()

//END IF

	

Sorry about loosing the tabs. Indeed should be more readable with the tabs…
I’ll check your code.

Please use the ‘code’ button. It will make sure that the original formatting is kept…
If the piece of code is rather large, please post as a link to a file.

I have changed the post, so there are tabs.

Hereby link to updated code for you to evaluate:

http://calliope.velleman.be/553654befb662a1ff8872f1c50db48eb/Two_cards_0_1.zip

A ß-version of the K8055 Version 3.0.0.0 is now available at our download section at our website.

Please test this DLL and let us know your comment.

I have done testing with the DLL and all of the above mentioned issues seem to be solved.

Thanks for the very quick respons. Thumsbs up!