There are many ways to drive the LED digital tube with the single-chip microcomputer. There are static display and dynamic (scanning) display according to the display mode. The decoding can be divided into hardware decoding and software decoding. This example uses two 74LS164 dynamic scanning methods to drive two 7-segment display, as shown in the figure below. Because 74LS164 has no data latch, so the data in the transmission process, there are flashing phenomenon on the digital tube, the more the number of bits driven, the more obvious flashing phenomenon. In order to eliminate this phenomenon, a PNP-type transistor can be added to the circuit to control the ground of the digital tube. In this way, the transistor is turned off and the digital tube is turned off without displaying when the data is transmitted. After the data is transmitted, the transistor is immediately activated. through. This method can drive more than a dozen 74LS164 displays without flickering.
This example uses dynamic refresh mode to display numbers on two 7-segment digital tubes. P3.4 is used to control the 741s164's clear end, and two PNP triodes are used to control the power of the digital tube, thereby eliminating the process of digital data transmission. Tube display jitter problem.
code:
SCM control 74LS164 drive digital tube
Using the 74LS164 to drive the digital tube, we first figured out how the 74LS164 works, and then learned how to connect lines on our own board.
When using the digital tube, it is necessary to distinguish between these two different connections: common cathode and common anode. When the common cathode, 1 is bright; when the common anode, 0 is bright.
In order to display numbers or characters, numbers or characters must be encoded. Seven-segment digital tube plus a decimal point, a total of 8 paragraphs. These segments are represented by the letters a, b, c, d, e, f, g, dp, respectively. When a voltage is applied to a particular segment of the nixie tube, these specific segments will light up to form what our eyes see.
For example, if the common cathode is connected to the digital tube and “1†is displayed, the code is 0x3f, ie, 00111111 (dp gfedcba ).
The static display program is as follows:
/*-----------------------------------
Function: Digital tube static display 0-F
Microcontroller: AT89S52
------------------------------------*/
#include "reg52.h"
#define uint unsigned int
#define uchar unsigned char
Sbit DAT=P0^3;
Sbit CLK=P0^2;
Void sendbyte(uchar byte);
Void delay(uint z);
Uchar code tab[]={
0xed, 0x09, 0xbc, 0x9d, 0x59, 0xd5,
0xf5, 0x0d, 0xfd, 0xdd, 0x7d, 0xf1,
0xe4, 0xb9, 0xf4, 0x74, 0x00} ; //0-F, all off
/*========================
Main function
=========================/
Void main()
{
Unsigned char h;
While(1)
{
For(h=0;h<<17;h++)
{
Delay(500); //The delay is about 0.5s
Sendbyte(h);
Delay(500);
}
h=0;
}
}
/*====================================
Use 74LS164 to output an 8-bit data
Light the corresponding pin of the digital tube to display the number
======================================
Void sendbyte(uchar byte)
{
Uchar num,c;
Num=tab[byte];
For(c=0;c"8;c++)
{
CLK=0;
DAT=num&0x01; // Output per bit
CLK=1; //One bit of data is output at each rising edge
Num "" = 1; / / right shift assignment for the next output
}
}
/*==============================
Delay subroutine
===============================*/
Void delay(uint z)
{
Uint x,y;
For(x=z;x"0;x--)
For(y=110;y"0;y--);
}
74ls164 microcontroller programming (3)51 single-chip driver 74ls164 marquee, the advantage is that only 2 ports can be achieved, the circuit shown in the following figure:
#include
#include
#define uint unsigned int
#define uchar unsigned char
Sbit dat=P2^6;
Sbit clk=P2^7;
Uchar ii;
Uchar code seg7code[]=
{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00, 0xff}; //0-9,-, all off
Void sendbyte(uchar seg)
{
Uchar num,c;
Num=seg7code[seg];
For(c=0;c"8;c++)
{
Dat=num&0x80;
Num=_crol_(num,1);
Clk=0;
Clk=1;
}
}
Void delayms(int ms)
{
Uchar mi,mj;
For(;ms0;ms--)
For(mi=6;mi"0;mi--)
For(mj=82;mj"0;mj--);
}
Void main()
{
For(ii=0;ii《10;ii++)
{
Sendbyte(ii);
Delayms(200);
}
}
SHENZHEN CHONDEKUAI TECHNOLOGY CO.LTD , https://www.szsiheyi.com