Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:36 15 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : 4 digit display from Qifei

Author Message
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 01:51am 08 Mar 2016
Copy link to clipboard 
Print this post

Hello,

Inspired by this link:
idea

This is an example for interfacing the 4 digit display from Qifei.
Sorry, the display can only show one single digit at a time.
So we need to time multiplex the display fast enough, and
with the Basic interpreter is not so good. (like software controlling
a stepper motor...)
Here are the picture, and MM44 program.



The program:


'48-7SEG7495.BAS
'4-BIT DIGITAL TUBE MODULE BY QUIFEI
'2016.03.08
'DRK V1.0
'VCC SCLK RCLK DIO GND
'3.3V CLK STRB MOSI GND
'TWO 8 BIT SHIFT REGISTER (74HC595)
'ONE FOR 7 SEGMENTS + DP
'+--0--+
'| |
'5 1
'+--6--+
'| |
'4 2
'+--3--+ +7
'THE OTHER FOR DRIVING DIGITS WITH MULTIPLEXING:1,2,4,8
'======[ INITIALISING ]================================================
OPTION EXPLICIT
'BUTTONS
CONST KEY1=2,KEY2=3,KEY3=4,KEY4=5
SETPIN KEY1,DIN,PULLUP:SETPIN KEY2,DIN,PULLUP
SETPIN KEY3,DIN,PULLUP:SETPIN KEY4,DIN,PULLUP
'7495+STROBE
CONST STRB=8: SETPIN STRB,DOUT:PIN(STRB)=0 'CONFIGURE DISPLAY LATCH PIN
'PRG
DIM I,I1,J,K=1,DP=0,N$,N1$,D(4)
'=========================================
'SETUP SIMPLE ARRAY TO STORE DIGIT BITMAPS
'=========================================
DIM INTEGER DIGIT(10)
DIGIT(0)=&B00111111:DIGIT(1)=&B00000110:DIGIT(2)=&B01011011
DIGIT(3)=&B01001111:DIGIT(4)=&B01100110:DIGIT(5)=&B01101101
DIGIT(6)=&B01111101:DIGIT(7)=&B00000111:DIGIT(8)=&B01111111
DIGIT(9)=&B01101111
'======[ PROGRAM ]=====================================================
FOR I=0 TO 9
DIGIT(I)=DIGIT(I) XOR 255 'ALL BITS INVERTED
NEXT I
'TEST CHOICE
CONST CLOCK=1 ' IF 0 THEN NUM DISPLAY
IF CLOCK=0 THEN
SETTICK 5,CLOCK_DSP 'CLOCK DISPLAY
DO:LOOP
ELSE
SETTICK 5,NUM_DSP 'NUMBERS DISPLAY
ENDIF
'------[ NUM TEST ]-----------------------------------------------------
VARKA1:
N$="____"
INPUT "NUMBER (MAX 4 DIGIT + DP)= ",N1$ 'WAIT, TICK DOESN'T OPERATES!
N$=N1$
J=5-LEN(N$)
IF J<>0 THEN
FOR I1=1 TO J
N$="_"+N$
NEXT I1
ENDIF
DP=0
FOR I1=1 TO 5
IF MID$(N$,I1,1)="." THEN DP=I1-1
NEXT I1
N$=LEFT$(N$,DP)+RIGHT$(N$,4-DP)
VARKA:
IF PIN(KEY4)=1 THEN GOTO VARKA 'PUSH KEY4-NEW DATA FOR DISPLAY
N$="____":DP=0 'DISPLAY CLEAR
PAUSE 100
GOTO VARKA1
'
SUB NUM_DSP
LEDSP(N$,DP)
DIG4KI
END SUB
'
SUB CLOCK_DSP 'CLOCK DISPLAY
IF PIN(KEY1)=0 THEN
N$=LEFT$(TIME$,2)+MID$(TIME$,4,2) 'HOURS.MINS
ELSE
N$=MID$(TIME$,4,2)+RIGHT$(TIME$,2)'MINS,SECS
ENDIF
DP=2
LEDSP(N$,DP)
DIG4KI
END SUB
'
'======[ SUBROUTINES, FUNCTIONS ]======================================
'CONVERTING STRING-CHARACTER FORMATS FOR DISPLAY
SUB LEDSP(N$,DP)
FOR I=1 TO 4
IF MID$(N$,I,1)="_" THEN '_ - MEANS BLANK DIGIT
D(I)=255
ELSE
D(I)=DIGIT(VAL(MID$(N$,I,1)))
ENDIF
NEXT I
IF DP<>0 THEN D(DP)=D(DP)-128
END SUB
'
'SEND ONLY ONE DIGIT TO THE DISPLAY VIA SPI
SUB DIG4KI
SPI OPEN 5000000,0,8
K=K+1:
IF K>4 THEN K=1
SELECT CASE K
CASE 1
SPI WRITE 2,D(4),1
CASE 2
SPI WRITE 2,D(3),2
CASE 3
SPI WRITE 2,D(2),4
CASE 4
SPI WRITE 2,D(1),8
END SELECT
PULSE STRB,1 'LATCH
SPI CLOSE
END SUB
END '**[ PROGRAM END ]*************************************************


drkl
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025