Testing the Pulse width modulation outputof the Velleman K8061 USB interface board
|
|
I wrote a little program which allows you to change the pulse width from the keyboard.As the supply is taken from the DAC, the amplitude can also be changed in a rather neat way. Admittedly all this is no more than a little demonstration, but it is great fun to set up. The arrangement is shown on the left.On my K8061, the output frequency is a very steady 15.627kHz and doesn't change with decreasing amplitude.As usual I supply a zip archive with the program file and the executable |
10 REM Testing the 8061 20 REM Version 1.0 30 REM Just testing 35 REM Jochen Lueg 40 REM Limavady February 2011 50 COLOUR 128 60 CLS 70 COLOUR 15 80 90 PROCK8061_init 100 SYS K8061_CloseDevices% 110 SYS K8061_OpenDevice% TO Card% 120 PRINT " Card address: ";Card% 130 SYS K8061_Connected%,Card% TO Con% 140 PRINT " Connected: ";Con% 150 160 SYS K8061_PowerGood%,Card% TO Power% 170 PRINT " Power: ";Power% 180 PRINT 190 PROCpwm 200 210 SYS K8061_CloseDevices% 220 END 230 240 250 DEFPROCpwm 260 LOCAL Width%,K$,An% 270 An%=255:Width%=512:K$="" 280 PRINT " Remember to connect a 10k resistor between DAC1 AND PWM1" 290 PRINT 300 PRINT 310 PRINT " < . . . . . . . . Decrease pulse width" 320 PRINT " > . . . . . . . . Increase pulse width" 330 PRINT " Z . . . . . . . . Decrease amplitude" 340 PRINT " X . . . . . . . . Increase amplitude" 350 PRINT 360 PRINT " S . . . . . . . . Stop program" 370 380 390 REPEAT 400 K$=INKEY$(0) 410 IF K$="," OR K$="<" Width%+=4:IF Width%<0 Width%=0 420 IF K$="." OR K$=">" Width%-=4:IF Width%>1023 Width%=1023 430 IF K$="z" OR K$="Z" An%-=1:IF An%<0 An%=0 440 IF K$="x" OR K$="X" An%+=1:IF An%>255 An%=255 450 PRINTTAB(2,15)"Amplitude: ";An%;" " 460 PRINTTAB(2,16)"Pulse width: ";Width% 470 SYS K8061_OutputPWM%,Card%,Width% 480 SYS K8061_OutputAnalogChannel%,Card%,1,An% 490 UNTIL K$="s" OR K$="S" 500 510 ENDPROC |
530 540 550 DEFPROCK8061_init 560 REM Complete list of routines 570 SYS"LoadLibrary","K8061.dll" TO K8061_Board% 580 SYS"GetProcAddress",K8061_Board%,"OpenDevice" TO K8061_OpenDevice% 590 SYS"GetProcAddress",K8061_Board%,"CloseDevices" TO K8061_CloseDevices% 600 SYS"GetProcAddress",K8061_Board%,"CloseDevice" TO K8061_CloseDevice% 610 SYS"GetProcAddress",K8061_Board%,"ReadAnalogChannel" TO K8061_ReadAnalogChannel% 620 SYS"GetProcAddress",K8061_Board%,"ReadAllAnaloge" TO K8061_ReadAllAnalog% 630 SYS"GetProcAddress",K8061_Board%,"OutputAnalogChannel" TO K8061_OutputAnalogChannel% 640 SYS"GetProcAddress",K8061_Board%,"OutputAllAnaloge" TO K8061_OutputAllAnalog% 650 SYS"GetProcAddress",K8061_Board%,"ClearAnalogChannel" TO K8061_ClearAnalogChannel% 660 SYS"GetProcAddress",K8061_Board%,"ClearAllAnalog" TO K8061_ClearAllAnalog% 670 SYS"GetProcAddress",K8061_Board%,"SetAnalogChannel" TO K8061_SetAnalogChannel% 680 SYS"GetProcAddress",K8061_Board%,"SetAllAnalog" TO K8061_SetAllAnalog% 690 SYS"GetProcAddress",K8061_Board%,"OutputAllDigital" TO K8061_OutputAllDigital% 700 SYS"GetProcAddress",K8061_Board%,"ClearDigitalChannel" TO K8061_ClearDigitalChannel% 710 SYS"GetProcAddress",K8061_Board%,"ClearAllDigital" TO K8061_ClearAllDigital% 720 SYS"GetProcAddress",K8061_Board%,"SetDigitalChannel" TO K8061_SetDigitalChannel% 730 SYS"GetProcAddress",K8061_Board%,"SetAllDigital" TO K8061_SetAllDigital% 740 SYS"GetProcAddress",K8061_Board%,"ReadDigitalChannel" TO K8061_ReadDigitalChannel% 750 SYS"GetProcAddress",K8061_Board%,"ReadAllDigital" TO K8061_ReadAllDigital% 760 SYS"GetProcAddress",K8061_Board%,"OutputPWM" TO K8061_OutputPWM% 770 SYS"GetProcAddress",K8061_Board%,"PowerGood" TO K8061_PowerGood% 780 SYS"GetProcAddress",K8061_Board%,"Connected" TO K8061_Connected% 790 SYS"GetProcAddress",K8061_Board%,"ReadVersion" TO K8061_ReadVersion% 800 SYS"GetProcAddress",K8061_Board%,"ReadBackDigitalOut" TO K8061_ReadBackDigitalOut% 810 SYS"GetProcAddress",K8061_Board%,"ReadBackAnalogOut" TO K8061_ReadBackAnalogOut% 820 SYS"GetProcAddress",K8061_Board%,"ReadBackPWMOut" TO K8061_ReadBackPWMOut% 830 ENDPROC 840 850 |
Return to the interfacing index
|