This is the 23rd day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021″

Teach you to play with a real nixie tube

Our final goal is to be lazy, to work together is to see you work hard, I am lazy to enjoy, so in order to lazy programming framework is the will, after my blog I hope everyone is framework programming, that there is no rule of conscientious, we are too lazy don’t deserve you to see: joy:, remember we are lazy, you should learn to lazy.

This time do not play virtual, there is no concept of digital tube, I am too lazy to find, directly on dry goods

image-20211002094753239


The above picture also lets you have a general understanding of the first, look at the following in detail

First of all, above the file you first create good, and then look at the code and circuit I said only to lazy people to see, that write documents have not built you for diligence

image-20210930214127001


image-20211002095445294


image-20211002095902628


The digital tube chip of my board is SN74LS244(SN is the name of the manufacturer).

74LS244 is a tri-state eight buffer

Logic diagram

image-20211002100232513


This chip is used to drive, in a word, his drive ability than the SINGLE-chip IO drive ability, that is, 8 digital tube at the same time when still alive and lively

He used a lot of IO ports, but the code is convenient, that is, we do not need to learn the chip code, do not need to see the sequence diagram, this is very friendly to those who do not like to see the sequence diagram, this is very different from the HC595 chip, our teacher’s chip is this

And just to make you even lazier let me look at the logic diagram and the sequence diagram to show you the serial input to parallel output

Logic diagram

image-20211002102342522


Sequence diagram

image-20211002102023787


code

image-20211002102716173


If you do not know the principle of IO port can see this article, he is my brother wrote the SINGLE-chip IO port.

SN74LS244_Drive.c

#include "all.h"

u8 SN74LS244_Write_Buffer[2] = {0};
void SN74LS244_IO_Mode(a)
{
	P4M1 = 0;
	P4M0 = 0;
	//P4 = SN74LS244_Write_Buffer[0]; / / a choice
	P7M1 = 0;
	P7M0 = 0;
	//P7 = SN74LS244_Write_Buffer[1]; / / segment
}
Copy the code

SN74LS244_Drive.h

#ifndef SN74LS244_Drive
#define SN74LS244_Drive


// External declaration
extern u8 SMG_Write_Buffer[8];
extern u8 SN74LS244_Write_Buffer[2];


extern void SN74LS244_IO_Mode(a);
//extern void SN74LS244_Write_Data_Drive();


#endif
Copy the code

Sn74ls244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h: sn74LS244_drive. h

This is the middle part of the service layer

image-20211002112241885


image-20211002111825484


image-20211002112048871


image-20211002123940101



image-20211002130748018


image-20211002131403005


code

SMG_Ser.c

#include "all.h"
u8 SMG_Write_Buffer[8] = {0xff.0xff.0xff.0xff.0xff.0xff.0xff.0xff};// Nixtube cache
// Select digital pipe segment
u8 code SMG_SEG[] = {0xC0.0xF9.0xA4.0xB0./ / 0 1 2 3
                     0x99.0x92.0x82.0xF8./ / 4 5 6 7
                     0x80.0x90.0x88.0x83.//8 9 a b
                     0xC6.0xA1.0x86.0x8E}; //c d e f 
// Select digital tube
u8 code SMG_GRID[] = {0x01.0x02.0x04.0x08.0x10.0x20.0x40.0x80};


void delay(a)
{
	u8 i = 0;
	for(i = 0; i<100; i++); }// Nixie display service
void SMG_Display_Ser(a)
{
	static u8 count = 0;
	switch(count)
	{
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
			SN74LS244_Write_Buffer[1] = ~SMG_GRID[count];
			SN74LS244_Write_Buffer[0] = SMG_SEG[SMG_Write_Buffer[count]];
			P4 = SN74LS244_Write_Buffer[1];
			P7 = SN74LS244_Write_Buffer[0];
		    delay();
		    break;
	}
	count++;
	count = count%8;	
	
}
Copy the code

SMG_Ser.h

#ifndef SMG_Ser
#define SMG_Ser

// External declaration
extern u8 code SMG_SEG[];
extern void SMG_Display_Ser(a);


#endif

Copy the code

Finally, you get to the main file

image-20211002132711660


At the beginning


After running for a while


Above is the dead waiting for the garbage place, like a proud woman, to see the anger

code

main.c

#include "all.h"
sbit LED1 = P3^2;
sbit LED2 = P3^3;

// Nixie tube allocation
void SMG_Allot(a)// The nixie tube needs to enter the service layer quickly,
	// But arrays don't have to keep brushing, so we can reduce the number of flushes
{
	static xdata u16 count = 0;// Put it on external RAM to reduce internal ROM space
	count++;
	if(count>200)
	{
		count = 0;
		SMG_Write_Buffer[0] = 9;
		SMG_Write_Buffer[1] = 8;
		SMG_Write_Buffer[2] = 7;
		SMG_Write_Buffer[3] = 6;
		SMG_Write_Buffer[4] = 5;
		SMG_Write_Buffer[5] = 4;
		SMG_Write_Buffer[6] = 3;
		SMG_Write_Buffer[7] = 2;
	}	
	SMG_Display_Ser();
}
//void SN74LS244__Allot()
/ / {
//	static xdata u8 count = 0;
//	count++;
//	if(count>200)
/ / {
// count = 0;
// SN74LS244_Write_Buffer[0] = 0xf0;
//	}
/ /}
/ / watchdog
void WDT_CONTR_Allot(a)
{
	static xdata u16 count = 0;
	count++;
	if(count>1000)
	{		
		count = 0;// If the value exceeds 1000, the counter is cleared
		WDT_CONTR=0x34;	// Start the watchdog and feed the dog}}void main(a)
{
	SN74LS244_IO_Mode();
	WKTCH = 0xff;// The power failure wake timer is high in bytes
	WKTCL = 0xff;// Low bytes of the power-off wake timer
	PCON |= 0x02;
	
	while(1)
    {
		SMG_Allot();
		//WDT_CONTR_Allot();}}Copy the code

The project back

image-20211001013324843


code

all.h

#include <STC15.h>


typedef unsigned char     u8;
typedef unsigned short    u16;
typedef unsigned long     u32;


#include "SN74LS244_Drive.h"
#include "SMG_Ser.h"
Copy the code