A dual 7-segment display

After spilling a box of electronic components and amusing myself by sorting the dusty debris, I came across a rather ancient dual 7-segment display and decided to see what a Velleman board could do to it. The result of this innocent amusement can be seen below.

MSF clock

Circuit description

The seven segments plus the decimal point leds are doubled up and connected to the eight output lines of the Velleman board.  As the Velleman board has only eight output ports, I used the two digital to analogue converter outputs for multiplexing, hoping that they would be fast enough to make a usable display. In this assumption I was wrong.

Here is the circuit diagram of the project.

The circuit diagram

The doubled up cathodes of the diodes are connected to the output ports. The anodes of the two digits are driven by two BCY51 transistors. The type of transistor is not important, I simply used what I had in the box. The bases of the transistors are connected to the DAC outputs. By setting one or the other of the DACs to 5V, it is possible to select either one of the digits.

The Program

This is kept straight forward in keeping with the philosophy of this site. Four choices are offered. The first two simply use one or the other of the digits to count from 0 to 9. This is done by sending 255 to one of the DACs and the count sequence to the output ports. To change digits, the first DAC is turned off and 255 is sent to the second DAC. This nicely demonstrates the multiplexing technique  in slow motion. The relevant procedure starts at line 440 in the listing below.

The third choice offers a 'walking' segment which uses both digits. Innocent fun and of no use whatsoever, but it looks very impressive. The relevant procedure is at line 620.

The fourth choice offered is a count from 0 to 99 - using both digits in multiplexing mode, i.e. switching so fast between the two that the persistence of our vision fools the brain into thinking that both displays are on at the same time. The relevant procedure starts at line 920.

This unfortunately did not work very well. The oscilloscope revealed why.

Timing display

Above is the output of one of the DACs driven as fast as BBC BASIC and the response time of the Velleman K-8055 board allow. As can be seen, there is a rather long rise and fall time. As a result, the display is very dim because most of the time there is not enough voltage to produce a bright output. I had to  insert the time delay into the code at lines 1030 and 1070 . This made the display much brighter, but it also produced a very noticeable flicker. Ah well, you can't win them all and at least it demonstrates the multiplexing principle in a very graphic way.


Below is the usual link to the archive with the BBC BASIC file and an executable file of the  below. 


K8055_7_seg-x2_1_4.zip

Here is a YouTube video of the project


I have also converted this program for the K8061 interface board. This board is faster than the K8055 and the multiplexing works much better.

K8061_7-seg.zip




  10 REM K8055_7-seg
  20 REM Multiplex two 7-segment displays
  30 REM Jochen Lueg
  40 REM http://roevalley.com
  50 REM Limavady, February 2012
  60 REM Version 1.2
  70
  80
  90
ON ERROR PROCerror
 100 PROCK8055_init
 110 PROCinit
 120 SYS K8055_CloseDevice%,Board%
 130 SYS K8055_OpenDevice%,Board%
 140 PROCscreen(480,250)
 150 OFF
 160 PRINT
 170 PRINT "   Select from the following:"
 180 PRINT
 190 PRINT "   1 . . . . . . . . Display 1 counts from 0 to 9"
 200 PRINT "   2 . . . . . . . . Display 2 counts from 0 to 9"
 210 PRINT "   3 . . . . . . . . Walking segment"
 220 PRINT "   4 . . . . . . . . Count from 0 to 99 on both displays"
 230 PRINT
 240 PRINT "   R . . . . . . . . Return to this menu"
 250 PRINT "   Q . . . . . . . . Leave this program"
 260 PRINT
 270 REPEAT
 280   REPEAT
 290     Key$=INKEY$(0)
 300   UNTIL Key$="1" OR Key$="2" OR Key$="3" OR Key$="4" OR Key$="Q" OR Key$="q"
 310   IF Key$="1" PROCcount_display(2)
 320   IF Key$="2" PROCcount_display(1)
 330   IF Key$="3" PROCwalking_segment
 340   IF Key$="4" PROCmultiplex
 350 UNTIL Key$="Q" OR Key$="q"
 360
 370
SYS K8055_ClearAllDigital%,1
 380 SYS K8055_ClearAllAnalog%,1
 390 SYS K8055_CloseDevice%,1
 400 SYS "FreeLibrary",K8055_Board%
 410 REPEAT UNTIL INKEY(0)=-1
 420 *QUIT
 430 END
 440
 450
 460
DEFPROCscreen(ScreenWidth%,ScreenHeight%)
 470 SYS "SetWindowPos",@hwnd%,0,0,0,ScreenWidth%,ScreenHeight%,6
 480 VDU 26
 490 COLOUR 128
 500 CLS
 510 COLOUR 15
 520 ENDPROC
 530
 540
 550
DEFPROCcount_display(d%)
 560 SYS K8055_ClearAllDigital%,1
 570 SYS K8055_ClearAllAnalog%,1
 580 SYS K8055_OutputAnalogChannel%,d%,255
 590 REPEAT
 600   FOR J%=0 TO 9
 610     SYS K8055_WriteAllDigital%,N%(J%)
 620     TIME=0
 630     REPEAT
 640       Key$=INKEY$(0)
 650     UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"  OR TIME >50
 660   NEXT
 670 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
 680 SYS K8055_ClearAllAnalog%,1
 690 SYS K8055_ClearAllDigital%,1
 700 ENDPROC
 710
 720
 730
DEFPROCwalking_segment
 740 SYS K8055_ClearAllAnalog%
 750 SYS K8055_ClearAllDigital%
 760 REPEAT
 770   SYS K8055_ClearAllAnalog%
 780   SYS K8055_OutputAnalogChannel%,2,255
 790
 800  
FOR J%=1 TO 4
 810     SYS K8055_WriteAllDigital%,W%(J%)
 820     TIME=0
 830     REPEAT
 840       Key$=INKEY$(0)
 850     UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"  OR TIME >2
 860   NEXT
 870
 880  
SYS K8055_ClearAllAnalog%
 890   SYS K8055_OutputAnalogChannel%,1,255
 900   FOR J%=5 TO 8
 910     SYS K8055_WriteAllDigital%,W%(J%)
 920     TIME=0
 930     REPEAT
 940       Key$=INKEY$(0)
 950     UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"  OR TIME >2
 960   NEXT
 970 UNTIL Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
 980 SYS K8055_ClearAllAnalog%
 990 SYS K8055_ClearAllDigital%
1000 ENDPROC
1010
1020
1030
DEFPROCmultiplex
1040 LOCAL N1%,N2%
1050 N1%=0: N2%=0
1060 SYS K8055_ClearAllAnalog%
1070 SYS K8055_ClearAllDigital%
1080 REPEAT
1090   FOR J%= 0 TO 9
1100     FOR I%=0 TO 9
1110       FOR Waste%=1 TO 8
1120         SYS K8055_WriteAllDigital%,N%(J%)
1130         SYS K8055_OutputAnalogChannel%,1,255
1140         TIME=0:REPEAT UNTIL TIME>2
1150         SYS K8055_ClearAnalogChannel%,1
1160         SYS K8055_WriteAllDigital%,N%(I%)
1170         SYS K8055_OutputAnalogChannel%,2,255
1180         TIME=0:REPEAT UNTIL TIME>2
1190         SYS K8055_ClearAnalogChannel%,2
1200         Key$=INKEY$(0)
1210         IF Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"  ENDPROC
1220       NEXT
1230     NEXT
1240   NEXT
1250 UNTIL   Key$="R" OR Key$="r" OR Key$="Q" OR Key$="q"
1260 ENDPROC
1270
1280
1290
DEFPROCerror
1300 PRINT REPORT$;" at line ";ERL  :
1310 SYS K8055_ClearAllDigital%,1
1320 SYS K8055_ClearAllAnalog%,1
1330 SYS K8055_CloseDevice%,1
1340 SYS "FreeLibrary",K8055_Board%
1350 END
1360 ENDPROC
1370
1380
1390
DEFPROCinit
1400 Board%=0
1410 T%=-3
1420
1430
DIM N%(9)     : REM Pattern for numerals
1440 N%(0)=%11101110
1450 N%(1)=%01000010
1460 N%(2)=%11011100
1470 N%(3)=%11011010
1480 N%(4)=%01110010
1490 N%(5)=%10111010
1500 N%(6)=%10111110
1510 N%(7)=%11100010
1520 N%(8)=%11111110
1530 N%(9)=%11111010
1540
1550
DIM W%(8)     : REM Pattern for walking segment
1560 W%(1)=%10000000
1570 W%(2)=%01000000
1580 W%(3)=%00000010
1590 W%(4)=%00001000
1600 W%(5)=%00001000
1610 W%(6)=%00000100
1620 W%(7)=%00100000
1630 W%(8)=%10000000
1640 ENDPROC
1650
1660
1670
DEFPROCK8055_init
1680 REM  Typing errors in routine name do not generate an error message - they just hang up the program.
1690 REM These are all the system calls in the order found in the manual
1700 SYS"LoadLibrary","K8055D.dll" TO K8055_Board%
1710 SYS"GetProcAddress",K8055_Board%,"OpenDevice" TO K8055_OpenDevice%
1720 SYS"GetProcAddress",K8055_Board%,"CloseDevice" TO K8055_CloseDevice%
1730 SYS"GetProcAddress",K8055_Board%,"ReadAnalogChannel" TO K8055_ReadAnalogChannel%
1740 SYS"GetProcAddress",K8055_Board%,"ReadAllAnalog" TO K8055_ReadAllAnalog%
1750 SYS"GetProcAddress",K8055_Board%,"OutputAnalogChannel" TO K8055_OutputAnalogChannel%
1760 SYS"GetProcAddress",K8055_Board%,"OutputAllAnalog" TO K8055_OutputAllAnalog%
1770 SYS"GetProcAddress",K8055_Board%,"ClearAnalogChannel" TO K8055_ClearAnalogChannel%
1780 SYS"GetProcAddress",K8055_Board%,"ClearAllAnalog" TO K8055_ClearAllAnalog%
1790 SYS"GetProcAddress",K8055_Board%,"SetAnalogChannel" TO K8055_SetAnalogChannel%
1800 SYS"GetProcAddress",K8055_Board%,"SetAllAnalog"  TO K8055_SetAllAnalog%
1810 SYS"GetProcAddress",K8055_Board%,"WriteAllDigital" TO K8055_WriteAllDigital%
1820 SYS"GetProcAddress",K8055_Board%,"ClearDigitalChannel" TO K8055_ClearDigitalChannel%
1830 SYS"GetProcAddress",K8055_Board%,"ClearAllDigital" TO K8055_ClearAllDigital%
1840 SYS"GetProcAddress",K8055_Board%,"SetDigitalChannel" TO K8055_SetDigitalChannel%
1850 SYS"GetProcAddress",K8055_Board%,"SetAllDigital"  TO K8055_SetAllDigital%
1860 SYS"GetProcAddress",K8055_Board%,"ReadDigitalChannel" TO K8055_ReadDigitalChannel%
1870 SYS"GetProcAddress",K8055_Board%,"ReadAllDigital"  TO K8055_ReadAllDigital%
1880 SYS"GetProcAddress",K8055_Board%,"ResetCounter"  TO K8055_ResetCounter%
1890 SYS"GetProcAddress",K8055_Board%,"ReadCounter"  TO K8055_ReadCounter%
1900 SYS"GetProcAddress",K8055_Board%,"SedtCounterDebouceTime"  TO K8055_SetCounterDebounceTime%
1910 ENDPROC



Return to interfacing index


Back to the start
Tudor with sign