Teach you to play real nixie tube

Keywords: Java Algorithm Back-end Programmer greedy algorithm

Our ultimate goal is to be lazy. Working together is to see you work hard, and I am lazy to enjoy. Therefore, in order to be lazy, frame programming is inevitable. In my blog in the future, I hope everyone is frame programming. Those who are irregular should be serious and diligent. We are too lazy to be worthy of you. joy:, remember that we are lazy people, so we should learn lazy things.

I don't play virtual this time. There's no concept of nixie tube. I'm too lazy to find it. I'll go straight to dry goods

image-20211002094753239

The picture above will give you a general idea first and take a detailed look at the following

First of all, you create the above files first, and then look at the code and circuit. I said it was only for lazy people. If you didn't write the files well, you should be diligent

image-20210930214127001

image-20211002095445294

image-20211002095902628

One nixie tube chip of my board is SN74LS244(SN is the manufacturer's name),

74LS244 is a three state eight buffer

Logic diagram

image-20211002100232513

This chip is used to drive. In a word, its driving ability is greater than that of MCU IO, that is, when 8-bit nixie tube works at the same time, it is still alive and kicking

He uses a lot of IO ports, but it facilitates the code, that is, we don't need to learn the code of this chip and don't need to look at the timing chart, which is very friendly to those who don't like to look at the timing chart. This chip is very different from HC595. Our teacher's one is this chip

In order to make you lazier, I'll look for the logic diagram and sequence diagram to show you the conversion from serial input to parallel output

Logic diagram

image-20211002102342522

Sequence diagram

image-20211002102023787

code

image-20211002102716173

If you don't know the principle of IO port, you can read this article. He was written by my brother MCU IO port.

SN74LS244_Drive.c

#include "all.h"

u8 SN74LS244_Write_Buffer[2] = {0};
void SN74LS244_IO_Mode()
{
	P4M1 = 0;
	P4M0 = 0;
	//P4 = SN74LS244_Write_Buffer[0];// Bit selection
	P7M1 = 0;
	P7M0 = 0;
	//P7 = SN74LS244_Write_Buffer[1];// Segment selection
}
Copy 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();
//extern void SN74LS244_Write_Data_Drive();


#endif
 Copy code

In fact, the above code will not report an error if there is no problem with the all.h file, but if there is a problem with all.h, the error report is SN74LS244_Drive.h error. I will explain this type of error in detail later. Today I only play nixie tube

At this time, we have reached 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};//Nixie tube cache
//Nixie tube segment selection
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 
//Nixie tube position selection
u8 code SMG_GRID[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};


void delay()
{
	u8 i = 0;
	for(i = 0;i<100;i++);
}

//Nixie tube display service
void SMG_Display_Ser()
{
	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 code

SMG_Ser.h

#ifndef SMG_Ser
#define SMG_Ser

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


#endif

Copy code

Finally, it's the main file

image-20211002132711660

At the beginning

After running for a period of time

Above is the place of dead garbage, just like a proud girl. She gets angry when she sees it

code

main.c

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

//Nixie tube distribution
void SMG_Allot()//The nixie tube needs to enter the service layer soon,
	//But the array doesn't have to be brushed all the time, so we can reduce the refresh times
{
	static xdata u16 count = 0;//Put it on the external RAM to reduce the space of the internal ROM
	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()
{
	static xdata u16 count = 0;
	count++;
	if(count>1000)
	{		
		count = 0;//More than 1000 counters are cleared
		WDT_CONTR=0x34;	//Start the watchdog and feed the dog
	}
}

void main()
{
	SN74LS244_IO_Mode();
	WKTCH = 0xff;//Power down wake-up timer high byte
	WKTCL = 0xff;//Power down wake-up timer low byte
	PCON |= 0x02;
	
	while(1)
    {
		SMG_Allot();
		//WDT_CONTR_Allot();
	}
}
Copy code

Project backbone

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"

Posted by nickk on Tue, 23 Nov 2021 08:40:05 -0800