Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

USB Experiment Interface Board PBWIN8

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • USB Experiment Interface Board PBWIN8

    ...reference to discussion at http://www.powerbasic.com/support/pb...ad.php?t=36267

    Code:
    '------------------------------------------------------------------------------
    ' DEMO;
    ' User interface supplied with Velleman Kit K8055 USB Experiment Interface Board
    '
    ' Kit w/DLL located at;
    ' http://www.vellemanusa.com/us/enu/pr...iew/?id=500349
    '
    ' VB to PBWIN8 v8.04 translated by: Jules Marchildon
    ' Date created: Feb 3nd, 2008
    '
    '------------------------------------------------------------------------------
    #COMPILE EXE
    #DIM ALL
    
    '---Includes...
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    #INCLUDE "PBForms.INC"
    #INCLUDE "K8055D.INC"        'Velleman K8055D.DLL header
    
    '---Constants...
    %IDD_Form1           =  101  'main form
    
    %IDC_Check1_1        = 1000  'card address SK5
    %IDC_Check1_0        = 1001  'card address SK6
    %IDC_Connect         = 1002  'connect button
    %IDC_Label1          = 1003  'connect status
    
    %IDC_Text1           = 1100  'counter 1 textbox, value
    %IDC_Reset1          = 1101  'counter 1 reset button
    %IDC_Option1_0       = 1102  'counter 1 debounce time 0ms
    %IDC_Option1_1       = 1103  'counter 1 debounce time 2ms
    %IDC_Option1_2       = 1104  'counter 1 debounce time 10ms
    %IDC_Option1_3       = 1105  'counter 1 debounce time 1000ms
    
    %IDC_Text2           = 1200  'counter 2 textbox, value
    %IDC_Reset2          = 1201  'counter 2 reset button
    %IDC_Option2_0       = 1202  'counter 2 debounce time 0ms
    %IDC_Option2_1       = 1203  'counter 2 debounce time 2ms
    %IDC_Option2_2       = 1204  'counter 2 debounce time 10ms
    %IDC_Option2_3       = 1205  'counter 2 debounce time 1000ms
    
    %IDC_SetAllDig       = 1300  'set all digital button
    %IDC_ClearAllDig     = 1301  'clear all digital button
    %IDC_SetAllAnalog1   = 1302  'set all analog button
    %IDC_ClearAllAnalog1 = 1303  'clear all analog button
    %IDC_Check4          = 1304  'output text checkbox
    
    %IDC_Check3_0        = 1402  'set digital output checkbox,LD1 LED
    %IDC_Check3_1        = 1403  'set digital output checkbox,LD2 LED
    %IDC_Check3_2        = 1404  'set digital output checkbox,LD3 LED
    %IDC_Check3_3        = 1405  'set digital output checkbox,LD4 LED
    %IDC_Check3_4        = 1406  'set digital output checkbox,LD5 LED
    %IDC_Check3_5        = 1407  'set digital output checkbox,LD6 LED
    %IDC_Check3_6        = 1408  'set digital output checkbox,LD7 LED
    %IDC_Check3_7        = 1409  'set digital output checkbox,LD8 LED
    
    %IDC_Check2_0        = 1500  'status digital input checkbox,Inp1 sw
    %IDC_Check2_1        = 1501  'status digital input checkbox,Inp2 sw
    %IDC_Check2_2        = 1502  'status digital input checkbox,Inp3 sw
    %IDC_Check2_3        = 1503  'status digital input checkbox,Inp4 sw
    %IDC_Check2_4        = 1504  'status digital input checkbox,Inp5 sw
    
    %IDC_VTrackbar1      = 1601  'DA1 trackbar PWM1-LD9  LED brightness
    %IDC_Label3          = 1602  'DA1 status value
    %IDC_VTrackbar2      = 1603  'DA2 trackbar PWM2-LD10 LED brightness
    %IDC_Label4          = 1604  'DA2 status value
    
    %IDC_Vprogress1      = 1605  'AD1 progress bar   ATT1 adj trimpot
    %IDC_Label7          = 1606  'AD1 status value
    %IDC_Vprogress2      = 1607  'AD1 progress bar   ATT2 adj trimpot
    %IDC_Label9          = 1608  'AD1 status value
    
    %IDC_Timer1          = 1700  'timer 1
    %IDC_Timer2          = 1701  'timer 2
    
    %IDC_Frame1          = 1800  'Card Address
    %IDC_Frame2          = 1801  'DA1
    %IDC_Frame3          = 1802  'DA2
    %IDC_Frame4          = 1803  'AD1
    %IDC_Frame5          = 1804  'AD3
    %IDC_Frame6          = 1805  'Inputs
    %IDC_Frame7          = 1806  'Outputs
    %IDC_Frame8          = 1807  'Counter1
    %IDC_Frame9          = 1808  'Counter2
    
    %IDC_Label10         = 1900  'Debounce Time
    %IDC_Label11         = 1901  'Debounce Time
    
    %ADC_MIN             = 0     'corresponds to a minimum input of 0V (8Bit ADC)
    %ADC_MAX             = 255   'corresponds to a maximum input of +5V (8bit ADC)
    %DAC_MIN             = 0     'corresponds to a minimum output of 0V (8Bit DAC)
    %DAC_MAX             = 255   'corresponds to a maximum output of +5V (8Bit DAC)
    
    '---Delcares...
    DECLARE CALLBACK FUNCTION ShowForm1Proc()
    DECLARE FUNCTION ShowForm1(BYVAL hParent AS DWORD) AS LONG
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION GetCardAddress(BYVAL hDlg AS DWORD,BYVAL idCheckSK5 AS LONG,BYVAL idCheckSK6 AS LONG) AS LONG
    
        LOCAL SK5 AS LONG, SK6 AS LONG
    
        '  --------------------------
        ' | SK5 | SK6 | CARD ADDRESS |
        '  ------------- ------------
        ' | ON  | ON  |      0       |
        ' | OFF | ON  |      1       |
        ' | ON  | OFF |      2       |
        ' | OFF | OFF |      3       |
        '  --------------------------
    
        CONTROL GET CHECK hDlg, idCheckSK5 TO SK5
        CONTROL GET CHECK hDlg, idCheckSK6 TO SK6
    
        IF     SK5 = 1 AND SK6 = 1 THEN
            FUNCTION = 0  'card address 0
        ELSEIF SK5 = 0 AND SK6 = 1 THEN
            FUNCTION = 1  'card address 1
        ELSEIF SK5 = 0 AND SK6 = 1 THEN
            FUNCTION = 2  'card address 2
        ELSEIF SK5 = 0 AND SK6 = 1 THEN
            FUNCTION = 3  'card address 3
        ELSE
            FUNCTION = -1 'error
        END IF
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION ConnectToUSBK8055D(BYVAL hDlg AS DWORD) AS LONG
    
        LOCAL cardAddress AS LONG
        LOCAL lrt AS LONG
        LOCAL cstatus AS STRING
    
        cardAddress = GetCardAddress(hDlg,%IDC_Check1_0,%IDC_Check1_1)
    
        lrt = OpenDevice(CardAddress)
    
        IF lrt = -1 THEN
            cstatus$ = "Card " & STR$(cardAddress) & "  not found !"
        ELSE
            cstatus$ = "Card " & STR$(lrt) & "  Connected !"
        END IF
    
        CONTROL SET TEXT hDlg,%IDC_Label1 , cstatus$
    
        FUNCTION = lrt
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB UpdateDigitalOutputStatus(BYVAL hDlg AS DWORD, BYVAL bport AS LONG )
    
          'valid bport param, &HFF, &B00001111, 0-255
    
          LOCAL idx AS LONG
          LOCAL vbit AS LONG
    
          FOR idx = 0 TO 7
            vbit = BIT(bport, idx)
            CONTROL SET CHECK hDlg ,%IDC_Check3_0 + idx, vbit
          NEXT idx
    
    END SUB
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB UpdateAnalogInputStatus(BYVAL hDlg AS DWORD)
    
        LOCAL adc1 AS LONG, adc2 AS LONG
    
        '-fetch the analog channel values, valid range is 0-255
        CALL ReadAllAnalog(BYVAL VARPTR(adc1), BYVAL VARPTR(adc2))
    
        CONTROL SEND hDlg, %IDC_Vprogress1, %PBM_SETPOS, adc1, 0 'AD1
        CONTROL SEND hDlg, %IDC_Vprogress2, %PBM_SETPOS, adc2, 0 'AD2
    
        '-update the values, show as resolution between 0-255 bit
        CONTROL SET TEXT hDlg,%IDC_Label7, STR$(adc1) 'bottom of AD1 frame
        CONTROL SET TEXT hDlg,%IDC_Label9, STR$(adc2) 'bottom of AD2 frame
    
    END SUB
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB UpdateAnalogOutputStatus(BYVAL hDlg AS DWORD, BYVAL dac1 AS BYTE, BYVAL dac2 AS BYTE)
    
        '-NOTE:
        ' The trackbar is in vertical position, 0 at the top, 255 at the bottom
        ' we flip position 0 at the bottom and 255 at the top
        
        '-send value to both channels on card, flipping the value
        CALL OutputAnalogChannel(1, 255-dac1)
        CALL OutputAnalogChannel(2, 255-dac2)
    
        '-update the position of the  trackbars
        ' not necessary like scrollbars, but caller can set it manually with this call.
        CONTROL SEND hDlg,%IDC_VTrackbar1,%TBM_SETPOS,%TRUE, dac1  'DA1
        CONTROL SEND hDlg,%IDC_VTrackbar2,%TBM_SETPOS,%TRUE, dac2  'DA2
    
        '--we flip the value for display visually 0 at the bottom, 255 at the top
        CONTROL SET TEXT hDlg,%IDC_Label3, STR$(255-dac1)
        CONTROL SET TEXT hDlg,%IDC_Label4, STR$(255-dac2)
    
    END SUB
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB UpdateReadDigitalInputs(BYVAL hDlg AS DWORD)
    
        LOCAL ip AS LONG, idx AS LONG
    
        DIM bflag(0:4) AS LONG
    
        ip = ReadAllDigital()
    
        bflag(0) = (ip AND 1)
        bflag(1) = (ip AND 2)  / 2
        bflag(2) = (ip AND 4)  / 4
        bflag(3) = (ip AND 8)  / 8
        bflag(4) = (ip AND 16) / 16
    
        FOR idx = 0 TO 4
            CONTROL SET CHECK hDlg, %IDC_Check2_0 +idx, bflag(idx)
        NEXT idx
    
    END SUB
    
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB GetDigitalCheckboxState(BYVAL hDlg AS DWORD)
    
        LOCAL idx AS LONG
        LOCAL bflag AS LONG
        LOCAL writebyte AS BYTE
    
        '-get all the checkbox states
        FOR idx = 0 TO 7
            CONTROL GET CHECK hDlg,%IDC_Check3_0 +idx TO bflag
            IF bflag = 1 THEN
                BIT SET writebyte,idx
            END IF
        NEXT idx
    
        '-send them to the card...
        CALL WriteAllDigital(writebyte)
    
    END SUB
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    SUB GetDebounceTimeOptionStatus(BYVAL hDlg AS DWORD, BYVAL id AS LONG)
    
        LOCAL nCounter AS LONG, nTime AS LONG
    
        '-identify option button checked and counter to set
        SELECT CASE id
            CASE %IDC_Option1_0 : nCounter = 1 : nTime = 0
            CASE %IDC_Option1_1 : nCounter = 1 : nTime = 2
            CASE %IDC_Option1_2 : nCounter = 1 : nTime = 10
            CASE %IDC_Option1_3 : nCounter = 1 : nTime = 1000
            CASE %IDC_Option2_0 : nCounter = 2 : nTime = 0
            CASE %IDC_Option2_1 : nCounter = 2 : nTime = 2
            CASE %IDC_Option2_2 : nCounter = 2 : nTime = 10
            CASE %IDC_Option2_3 : nCounter = 2 : nTime = 1000
        END SELECT
    
        CALL SetCounterDebounceTime(nCounter, nTime)
    
    END SUB
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        STATIC hLib AS DWORD
        hLib = LoadLibrary("K8055D.DLL")
        IF hLib = %NULL  THEN
            MSGBOX "Error loading K8055D.DLL"
        END IF
        PBFormsInitComCtls( %ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES ) 'Macro
        CALL ShowForm1(%HWND_DESKTOP)
        CALL FreeLibrary(hLib)
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowForm1Proc()
    
        LOCAL  lrt         AS LONG
        LOCAL  cstatus     AS STRING
        STATIC cardAddress AS LONG
        STATIC hTimer1     AS LONG,  hTimer2 AS LONG
        LOCAL  tPos1       AS LONG,  tPos2   AS LONG
        STATIC bLEDstatus  AS BYTE
        STATIC LEDcount    AS LONG
    
        '---
        SELECT CASE AS LONG CBMSG
    
            '---
            CASE %WM_INITDIALOG
    
                '-set default Card Address to 0
                CONTROL SET CHECK CBHNDL, %IDC_Check1_0, 1 'SK5
                CONTROL SET CHECK CBHNDL, %IDC_Check1_1, 1 'SK6
    
                '-initialize trackbars for DAC output display
                CONTROL SEND CBHNDL,%IDC_VTrackbar1,%TBM_SETRANGE,%TRUE,MAKDWD(%DAC_MIN,%DAC_MAX)
                CONTROL SEND CBHNDL,%IDC_VTrackbar1,%TBM_SETTICFREQ,8,0
                CONTROL SEND CBHNDL,%IDC_VTrackbar1,%TBM_SETPAGESIZE,0,16
                CONTROL SEND CBHNDL,%IDC_VTrackbar2,%TBM_SETRANGE,%TRUE,MAKDWD(%DAC_MIN,%DAC_MAX)
                CONTROL SEND CBHNDL,%IDC_VTrackbar2,%TBM_SETTICFREQ,8,0
                CONTROL SEND CBHNDL,%IDC_VTrackbar2,%TBM_SETPAGESIZE,0,16
                
                '-NOTE: we flip this around for visual effect only, 255=top, 0=bottom
                CALL UpdateAnalogOutputStatus(CBHNDL,255,255)   'set thumb pos to min
    
                '-initialize progress bars for ADC input display
                CONTROL SEND CBHNDL,%IDC_Vprogress1,%PBM_SETRANGE,0,MAKDWD(%ADC_MIN,%ADC_MAX)
                CONTROL SEND CBHNDL,%IDC_Vprogress1,%PBM_SETPOS, 0, 0
                CONTROL SEND CBHNDL,%IDC_Vprogress2,%PBM_SETRANGE,0,MAKDWD(%ADC_MIN,%ADC_MAX)
                CONTROL SEND CBHNDL,%IDC_Vprogress2,%PBM_SETPOS, 0, 0
    
                '-set Card Debounce time to default 2ms, make sure card is updated.
                CONTROL SET CHECK CBHNDL, %IDC_Option1_1, 1
                CONTROL SET CHECK CBHNDL, %IDC_Option2_1, 1
                CALL GetDebounceTimeOptionStatus(CBHNDL,%IDC_Option1_1)
                CALL GetDebounceTimeOptionStatus(CBHNDL,%IDC_Option2_1)
    
    
            '---
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
    
            '---
            CASE %WM_TIMER
                SELECT CASE AS LONG CBWPARAM
                    '---
                    CASE %IDC_Timer1  'poll all inputs and counters.
                        CALL UpdateAnalogInputStatus(CBHNDL)
                        CALL UpdateReadDigitalInputs(CBHNDL)
                        CONTROL SET TEXT CBHNDL,%IDC_Text1,STR$(ReadCounter(1))
                        CONTROL SET TEXT CBHNDL,%IDC_Text2,STR$(ReadCounter(2))
                    '---
                    CASE %IDC_Timer2  'output LED rotate test
                        CALL ClearDigitalChannel(LEDcount + 1)
                        INCR LEDcount
                        IF LEDcount = 8 THEN LEDcount = 0 : bLEDstatus = &B10000000
                        CALL SetDigitalChannel(LEDcount + 1)
                        ROTATE LEFT bLedStatus,1
                        CALL UpdateDigitalOutputStatus(CBHNDL,bLEDstatus)
                END SELECT
    
    
            '---
            CASE %WM_COMMAND
    
                SELECT CASE AS LONG CBCTL
    
                    '---Card Address
                    CASE %IDC_Check1_0 'SK5
                    CASE %IDC_Check1_1 'SK6
    
                    '---
                    CASE %IDC_Connect          '<-Connect to Card button
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            lrt = ConnectToUSBK8055D(CBHNDL)
                            IF lrt = 0 OR lrt = 1 OR lrt = 2 OR lrt = 3 THEN
                                IF ISTRUE(hTimer1) THEN CALL KillTimer(CBHNDL, hTimer1)
                                hTimer1 = SetTimer(CBHNDL,%IDC_Timer1,100, BYVAL %NULL)
                            ELSE
                                MSGBOX "Unable To Connect To Device!", %MB_TASKMODAL
                            END IF
                        END IF
                    CASE %IDC_SetAllDig        '<-Set All Digital button
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                           CALL SetAllDigital()
                           CALL UpdateDigitalOutputStatus(CBHNDL,&B11111111)
                        END IF
                    CASE %IDC_ClearAllDig      '<-Clear All Digital button
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CALL ClearAllDigital()
                            CALL UpdateDigitalOutputStatus(CBHNDL,&B00000000)
                        END IF
                    CASE %IDC_SetAllAnalog1    '<-Set All Analog button
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CALL SetAllAnalog()   'All DA channels 1&2 are set to +5V
                            '--Note: we flip this for visaul effect, 0=bottom, 255=top
                            CALL UpdateAnalogOutputStatus(CBHNDL,0,0)
                        END IF
                    CASE %IDC_ClearAllAnalog1  '<-Clear All Analog button
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CALL ClearAllAnalog() 'All DA channels 1&2 are set to 0V
                            '--Note: we flip this for visaul effect, 0=bottom, 255=top
                            CALL UpdateAnalogOutputStatus(CBHNDL,255,255)
                        END IF
                    CASE %IDC_Reset1           '<-Reset button, counter 1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CALL ResetCounter(1)
                        END IF
                    CASE %IDC_Reset2           '<-Reset button, counter 2
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CALL ResetCounter(2)
                        END IF
    
                    '---Output Test, Rotate LEDS...
                    CASE %IDC_Check4
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            CONTROL GET CHECK CBHNDL, %IDC_Check4 TO lrt
                            IF lrt = 1 THEN
                                bLEDstatus = &B00000000
                                hTimer2 = SetTimer(CBHNDL,%IDC_Timer2,50, BYVAL %NULL)
                            ELSE
                                CALL KillTimer(CBHNDL, hTimer2)
                                'CALL ClearAllDigital()
                                'CALL UpdateDigitalOutputStatus(CBHNDL,&B00000000)
                            END IF
                        END IF
    
                    '---Digital Outputs checkbox group
                    CASE %IDC_Check3_0, _
                         %IDC_Check3_1, _
                         %IDC_Check3_2, _
                         %IDC_Check3_3, _
                         %IDC_Check3_4, _
                         %IDC_Check3_5, _
                         %IDC_Check3_6, _
                         %IDC_Check3_7
                            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                CALL GetDigitalCheckboxState(CBHNDL)
                            END IF
    
                    '---Counter 1 option group
                    CASE %IDC_Option1_0, _
                         %IDC_Option1_1, _
                         %IDC_Option1_2, _
                         %IDC_Option1_3
                            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                CALL GetDebounceTimeOptionStatus(CBHNDL,CBCTL)
                            END IF
                    '---Counter 2 option group
                    CASE %IDC_Option2_0, _
                         %IDC_Option2_1, _
                         %IDC_Option2_2, _
                         %IDC_Option2_3
                            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                CALL GetDebounceTimeOptionStatus(CBHNDL,CBCTL)
                            END IF
                END SELECT
    
            '---
            CASE %WM_VSCROLL '-handle both trackbars...
                SELECT CASE LOWRD(CBWPARAM)
                    CASE %TB_THUMBTRACK, _   '-Mouse
                         %TB_LINEDOWN,   _   '-Keyboard
                         %TB_LINEUP,     _   '-Keyboard
                         %TB_PAGEDOWN,   _   '-Keyboard
                         %TB_PAGEUP,     _   '-Keyboard
                         %TB_TOP,        _   '-Keyboard
                         %TB_BOTTOM          '-Keyboard
                        CONTROL SEND CBHNDL,%IDC_VTrackbar1,%TBM_GETPOS,0,0 TO tPos1
                        CONTROL SEND CBHNDL,%IDC_VTrackbar2,%TBM_GETPOS,0,0 TO tPos2
                        tPos1 = LOWRD(tPos1) : tPos2 = LOWRD(tPos2)
                        CALL UpdateAnalogOutputStatus(CBHNDL,tPos1,tPos2)
                END SELECT
    
            '---
            CASE %WM_DESTROY
                CALL CloseDevice() '<-unload the USB K8055D device drivers
                IF ISTRUE(hTimer1) THEN CALL KillTimer(CBHNDL, hTimer1)
                IF ISTRUE(hTimer2) THEN CALL KillTimer(CBHNDL, hTimer2)
    
            '---
            CASE %WM_CLOSE
    
    
        END SELECT
    END FUNCTION
    
    '------------------------------------------------------------------------------
    '
    '------------------------------------------------------------------------------
    FUNCTION ShowForm1(BYVAL hParent AS DWORD) AS LONG
    
        LOCAL lRslt  AS LONG
        LOCAL hDlg   AS DWORD
        LOCAL hFont1 AS DWORD
    
        DIALOG NEW hParent, "K8055 USB Experiment Interface Demo", 131, 82, 406, 211, %WS_POPUP OR _
            %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_BORDER OR %WS_DLGFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE _
            OR %DS_SETFONT OR %WS_SYSMENU OR %WS_THICKFRAME, %WS_EX_LEFT OR %WS_EX_LTRREADING _
            OR %WS_EX_RIGHTSCROLLBAR OR %WS_EX_CONTROLPARENT OR %WS_EX_APPWINDOW, TO hDlg
    
        CONTROL ADD FRAME,   hDlg, %IDC_Frame1,   "Card Address", 5, 2, 73, 31
        CONTROL ADD CHECKBOX,hDlg, %IDC_Check1_0, "SK5", 13, 15, 28, 10
        CONTROL ADD CHECKBOX,hDlg, %IDC_Check1_1, "SK6", 45, 15, 28, 10
    
        CONTROL ADD BUTTON,hDlg, %IDC_Connect, "Connect", 5, 39, 73, 18
        CONTROL ADD LABEL, hDlg, %IDC_Label1,  "- - -", 8, 62, 80, 8
    
        CONTROL ADD BUTTON, hDlg, %IDC_SetAllAnalog1,   "Set All Analog",   5, 148, 73, 13
        CONTROL ADD BUTTON, hDlg, %IDC_ClearAllAnalog1, "Clear All Analog", 5, 162, 73, 13
    
        CONTROL ADD CHECKBOX,hDlg, %IDC_Check4,   "Output Test", 5, 185, 73, 15
    
        CONTROL ADD FRAME, hDlg, %IDC_Frame2,   "DA1", 91, 2, 31, 198
        CONTROL ADD LABEL, hDlg, %IDC_Label3,   " 0",96,188,20,8,%WS_CHILD _
                    OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
    
        CONTROL ADD "msctls_trackbar32", hDlg, %IDC_VTrackbar1,"",94,15,25,170,%WS_CHILD _
                    OR %WS_VISIBLE OR %WS_TABSTOP OR %TBS_VERT OR %TBS_LEFT OR %TBS_AUTOTICKS
    
        CONTROL ADD FRAME, hDlg, %IDC_Frame3,   "DA2", 126, 2, 31, 198
        CONTROL ADD LABEL, hDlg, %IDC_Label4,   " 0", 132, 188, 20,8,%WS_CHILD _
                    OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
        CONTROL ADD "msctls_trackbar32", hDlg, %IDC_VTrackbar2,"",129,15,25,170,%WS_CHILD _
                    OR %WS_VISIBLE OR %WS_TABSTOP OR %TBS_VERT OR %TBS_LEFT OR %TBS_AUTOTICKS
    
        CONTROL ADD FRAME, hDlg, %IDC_Frame4,   "AD1", 165, 2, 28, 198
        CONTROL ADD LABEL, hDlg, %IDC_Label7,   "00", 168, 188, 20, 8,%WS_CHILD _
                    OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
    
        CONTROL ADD "msctls_progress32", hDlg, %IDC_Vprogress1,"",173,15,12,170, %WS_CHILD _
                     OR %WS_VISIBLE OR %PBS_SMOOTH OR %PBS_VERTICAL
    
        CONTROL ADD FRAME, hDlg, %IDC_Frame5,   "AD2", 197, 2, 28, 198
        CONTROL ADD LABEL, hDlg, %IDC_Label9,   "00", 200, 188, 20, 8,%WS_CHILD _
                    OR %WS_VISIBLE OR %SS_CENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING
    
        CONTROL ADD "msctls_progress32", hDlg, %IDC_Vprogress2,"",205,15,12,170, %WS_CHILD _
                    OR %WS_VISIBLE OR %PBS_SMOOTH OR %PBS_VERTICAL
    
        CONTROL ADD BUTTON,  hDlg, %IDC_SetAllDig,   "Set All Digital", 5,113,73, 13
        CONTROL ADD BUTTON,  hDlg, %IDC_ClearAllDig, "Clear All Digital",5,128, 73, 13
    
        CONTROL ADD FRAME,    hDlg, %IDC_Frame6,   "Inputs", 240, 2, 105, 31
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check2_0, "1", 245, 15, 22, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check2_1, "2", 264, 15, 22, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check2_2, "3", 283, 15, 22, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check2_3, "4", 301, 15, 22, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check2_4, "5", 323, 15, 19, 10
    
    
        CONTROL ADD FRAME,    hDlg, %IDC_Frame7,   "Outputs", 240, 39, 158, 31
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_0, "1", 245, 52, 17, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_1, "2", 264, 52, 17, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_2, "3", 283, 52, 16, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_3, "4", 301, 52, 17, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_4, "5", 320, 52, 17, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_5, "6", 339, 52, 16, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_6, "7", 357, 52, 17, 10
        CONTROL ADD CHECKBOX, hDlg, %IDC_Check3_7, "8", 376, 52, 17, 10
    
    
        CONTROL ADD FRAME,  hDlg, %IDC_Frame8,    "Counter1",     240, 94, 73, 106
        CONTROL ADD TEXTBOX,hDlg, %IDC_Text1,     "0",            248, 106, 57, 12
        CONTROL ADD BUTTON, hDlg, %IDC_Reset1,    "Reset",        248, 121, 54, 13
        CONTROL ADD LABEL,  hDlg, %IDC_Label10,   "Debounce Time",248, 138, 54,8
        CONTROL ADD OPTION, hDlg, %IDC_Option1_0, "0ms",          248, 148, 30, 8, _
                    %WS_CHILD OR %WS_VISIBLE OR %WS_GROUP OR %WS_TABSTOP OR %BS_TEXT OR _
                    %BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER
        CONTROL ADD OPTION, hDlg, %IDC_Option1_1, "2ms",          248, 160, 30, 8
        CONTROL ADD OPTION, hDlg, %IDC_Option1_2, "10ms",         248, 172, 35, 8
        CONTROL ADD OPTION, hDlg, %IDC_Option1_3, "1000ms",       248, 185, 38, 8
    
        CONTROL ADD FRAME,  hDlg, %IDC_Frame9,    "Counter2",     325, 94, 73,  106
        CONTROL ADD TEXTBOX,hDlg, %IDC_Text2,     "0",            333, 106, 57, 12
        CONTROL ADD BUTTON, hDlg, %IDC_Reset2,    "Reset",        333, 121, 57, 13
        CONTROL ADD LABEL,  hDlg, %IDC_Label11,   "Debounce Time",333, 138, 54, 8
        CONTROL ADD OPTION, hDlg, %IDC_Option2_0, "0ms",          333, 148, 30, 8, _
                    %WS_CHILD OR %WS_VISIBLE OR %WS_GROUP OR %WS_TABSTOP OR %BS_TEXT OR _
                    %BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER
        CONTROL ADD OPTION, hDlg, %IDC_Option2_1, "2ms",          333, 160, 30, 8
        CONTROL ADD OPTION, hDlg, %IDC_Option2_2, "10ms",         333, 172, 36, 8
        CONTROL ADD OPTION, hDlg, %IDC_Option2_3, "1000ms",       333, 185, 38, 8
    
        hFont1 = PBFormsMakeFont("MS Sans Serif",8,700,%FALSE,%FALSE,%FALSE,%ANSI_CHARSET)
    
        CONTROL SEND hDlg, %IDC_Connect,%WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Label3, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Label4, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Label7, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Label9, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Text2,  %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_Text1,  %WM_SETFONT, hFont1, 0
    
        DIALOG SHOW MODAL hDlg, CALL ShowForm1Proc TO lRslt
    
        CALL DeleteObject(hFont1)
    
        FUNCTION = lRslt
    END FUNCTION
    Code:
    '------------------------------------------------------------------------------
    ' K8055 VELLEMAN-kit USB EXPERIMENT INTERFACE BOARD
    ' HEADER INLCUDE FILE FOR K8055D.DLL  LIBRARY
    ' FILE NAME: K8055D.INC
    ' TRANSLATION BY JULES MARCHILDON TO POWERBASIC FOR WINDOWS  PBWIN8 v8.04
    '------------------------------------------------------------------------------
    DECLARE FUNCTION OpenDevice LIB "K8055D.DLL" ALIAS "OpenDevice" (BYVAL CardAddress AS LONG) AS LONG
    DECLARE SUB CloseDevice LIB "K8055D.DLL" ALIAS "CloseDevice" ()
    DECLARE FUNCTION ReadAnalogChannel LIB "K8055D.DLL" ALIAS "ReadAnalogChannel"(BYVAL Channel AS LONG) AS LONG
    DECLARE SUB SetAnalogChannel LIB "K8055D.DLL" ALIAS "SetAnalogChannel" (BYVAL Channel AS LONG )
    DECLARE SUB OutputAnalogChannel LIB "K8055D.DLL" ALIAS "OutputAnalogChannel" (BYVAL Channel AS LONG, BYVAL oData AS LONG)
    DECLARE SUB ClearAnalogChannel LIB "K8055D.DLL" ALIAS "ClearAnalogChannel" (BYVAL Channel AS LONG)
    DECLARE SUB ReadAllAnalog LIB "K8055D.DLL" ALIAS "ReadAllAnalog" (BYVAL Data1 AS LONG, BYVAL Data2 AS LONG)
    DECLARE SUB SetAllAnalog LIB "K8055D.DLL" ALIAS "SetAllAnalog" ()
    DECLARE SUB OutputAllAnalog LIB "K8055D.DLL" ALIAS "OutputAllAnalog" (BYVAL Data1 AS LONG, BYVAL Data2 AS LONG)
    DECLARE SUB ClearAllAnalog LIB "K8055D.DLL" ALIAS "ClearAllAnalog" ()
    DECLARE SUB WriteAllDigital LIB "K8055D.DLL" ALIAS "WriteAllDigital" (BYVAL aData AS LONG)
    DECLARE SUB ClearAllDigital LIB "K8055D.DLL" ALIAS "ClearAllDigital" ()
    DECLARE SUB SetDigitalChannel LIB "K8055D.DLL" ALIAS "SetDigitalChannel" (BYVAL Channel AS LONG)
    DECLARE FUNCTION ReadDigitalChannel LIB "K8055D.DLL" ALIAS "ReadDigitalChannel" (BYVAL Channel AS LONG) AS LONG
    DECLARE SUB SetAllDigital LIB "K8055D.DLL" ALIAS "SetAllDigital" ()
    DECLARE FUNCTION ReadAllDigital LIB "K8055D.DLL" ALIAS "ReadAllDigital" () AS LONG
    DECLARE SUB ClearDigitalChannel LIB "K8055D.DLL" ALIAS "ClearDigitalChannel" (BYVAL Channel AS LONG)
    DECLARE SUB SetCounterDebounceTime LIB "K8055D.DLL" ALIAS "SetCounterDebounceTime" (BYVAL CounterNr AS LONG, BYVAL DebounceTime AS LONG)
    DECLARE SUB ResetCounter LIB "K8055D.DLL" ALIAS "ResetCounter" (BYVAL CounterNr AS LONG)
    DECLARE FUNCTION ReadCounter LIB "K8055D.DLL" ALIAS "ReadCounter" (BYVAL CounterNr AS LONG) AS LONG
    Best regards
    Jules
    www.rpmarchildon.com
Working...
X