Hubei Hannas Tech Co.,Ltd-Professional Piezoceramic Elements Supplier
News
You are here: Home / News / Ultrasonic Transducer information / Design of Ultrasonic Distance Measuring Module Based on Single Chip Computer

Design of Ultrasonic Distance Measuring Module Based on Single Chip Computer

Views: 1     Author: Site Editor     Publish Time: 2020-10-14      Origin: Site

Inquire

facebook sharing button
twitter sharing button
line sharing button
wechat sharing button
linkedin sharing button
pinterest sharing button
whatsapp sharing button
sharethis sharing button

Ultrasonic distance measurement module,single-chip microcomputer connected to 12864 LCD, HC-SR04 ultrasonic level sensor mould, the hardware of the ultrasonic proximity sensor module is also not known.

 79ECL6XN8B)938CE9()N_U


Ultrasonic ranging 51 single-chip 12864 LCD source program:

#include

#include

//Pin definition

sbitRX=P1 ^ 1;

sbitTX=P1 ^ 2;

sbitCS=P3 ^ 3;//Chip select High level active Single-chip LCD can be fixed high level

sbitSID=P3 ^ 4;//data

sbitSCLK=P3 ^ 5;//clock

//Function DefiniTIon function declaration

void Delay(int num);

void Init_DS18B20(void);

unsigned char ReadOneChar(void);

void WriteOneChar(unsigned char dat);

unsigned int ReadTemperature(void);

void clock_out(unsigned char dd);

unsigned char clock_in(void);

unsigned char read_clock(unsigned char ord);

void write_clock(unsigned char ord, unsigned char dd);

void Disp(void);

void id_case1_key(void);

void id_case2_key(void);

void Set_TIme(unsigned char sel,bit sel_1);

void TImer0_Init(void);

void Init_1302(void);

void Set_Bell(unsigned char sel, bit sel_1);

void Bell(void);

//12864

void Write_char(bit start, unsigned char ddata);

void Send_byte(unsigned char bbyte);

void Delaynms(unsigned int di);

void Lcd_init(void);

void Disp_img(unsigned char *img);

void LCD_Write_string(unsigned char X,unsigned char Y,unsigned char *s);

void LCD_set_xy( unsigned char x, unsigned char y );

unsigned char code num[]={“0123456789 :。-”};

unsigned char code waves[]={"Ultrasonic Ranging System"};

unsigned char code znwk[] ={"Smart Microcontrol Studio"};

unsigned char code CM[] ={“M”};

unsigned intTIme=0;

long S=0;

bitflag =0;

unsigned char disbuff[4]={ 0,0,0,0,};

unsigned char code logo[]={

0x00,0x03,0xC6,0x3C,0x00,0x33,0x9F,0xF0,0x03,0x8F,0xC0,0x00,0x30,0xC1,0xC0,0x00,

0x00,0x3F,0xEF,0xFE,0x00,0x03,0x1C,0xE0,0x07,0x01,0xCC,0x00,0x31,0xF1,0x80,0x00,

0x00,0x79,0xDF,0xBC,0x00,0x06,0x18,0xC0,0x0E,0x01,0xFE,0x00,0x77,0xF9,0x80,0x00,

0x00,0x01,0xB0,0x30,0x01,0xC6,0x19,0xC0,0x1E,0x7F,0xDE,0x00,0x6F,0x83,0x80,0x00,

0x00,0x23,0xAC,0x60,0x0F,0xE6,0xF1,0x80,0x3E,0x7B,0x38,0x00,0x61,0x83,0x00,0x00,

0x00,0x37,0x0E,0x00,0x0F,0xC7,0xB7,0x80,0xEC,0x63,0x30,0x00,0xE3,0x03,0x00,0x00,

0x00,0x3E,0x0E,0x00,0x01,0x8F,0x37,0x01,0xCC,0x6F,0xF0,0x00,0xC7,0xF7,0x00,0x00,

0x00,0x1E,0x0C,0x00,0x03,0x1E,0x66,0x03,0x0C,0x7F,0x00,0x01,0xFF,0xE6,0x00,0x00,

0x00,0x1E,0x1C,0x00,0x03,0x1C,0x60,0x02,0x19,0xAC,0x00,0x01,0x96,0x06,0x00,0x00,

0x00,0x3E,0x3E,0x00,0x03,0x18,0x60,0x00,0x19,0xFC,0x00,0x03,0x86,0x0E,0x00,0x00,

0x00,0x7E,0x36,0x00,0x03,0x00,0xC0,0x00,0x38,0x78,0x00,0x03,0x06,0x0C,0x00,0x00,

0x00,0xE6,0x67,0x00,0x03,0x00,0xC0,0x00,0x30,0x78,0x00,0x06,0x0C,0x0C,0x00,0x00,

0x01,0xC6,0xC3,0x80,0x7F,0xF0,0xC0,0x00,0x30,0xFE,0x00,0x0E,0x0C,0x1C,0x00,0x00,

0x03,0x81,0x83,0xC0,0x78,0xFF,0x80,0x00,0x61,0xCF,0x80,0x1C,0x08,0x18,0x00,0x00,

0x06,0x07,0x03,0xE0,0x00,0x1F,0xFF,0xE0,0x67,0x07,0xE0,0x38,0x18,0xF8,0x00,0x00,

0x08,0x0E,0x01,0xF8,0x00,0x07,0xFF,0x80,0xCE,0x03,0xF8,0x60,0x00,0x70,0x00,0x00,

0x00,0x18,0x01,0xF8,0x00,0x01,0xFC,0x00,0xC0,0x01,0xFC,0xC0,0x00,0x70,0x00,0x00,

0x00,0x01,0xFE,0x00,0x00,0x7F,0xF8,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x00,

0x00,0x03,0xB7,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x3C,0x00,0xC0,0x03,0x00,0x00,

0x00,0x07,0x67,0x00,0x00,0x60,0x00,0x00,0x03,0x9F,0xFE,0x00,0x80,0x02,0x00,0x00,

0x00,0x0E,0x63,0x80,0x00,0xE0,0x00,0x01,0xFF,0xCF,0x1E,0x01,0x80,0x06,0x00,0x00,

0x00,0x1C,0xE1,0xE0,0x00,0xC0,0x00,0x00,0xE3,0x9C,0x38,0x01,0x80,0x06,0x00,0x00,

0x00,0x38,0xC1,0xF8,0x01,0xC0,0x00,0x00,0xC3,0x18,0x30,0x00,0x00,0x00,0x00,0x00,

0x00,0xE0,0xFC,0xFE,0x03,0x80,0x00,0x01,0xC7,0x18,0x60,0x00,0x00,0x00,0x00,0x00,

0x01,0xDF,0xF8,0xFE,0x03,0x00,0x00,0x01,0x8E,0x1B,0xE0,0x07,0x00,0x1C,0x00,0x00,

0x07,0x07,0x80,0x00,0x07,0x00,0x00,0x01,0xFF,0x3F,0xE0,0x07,0x00,0x1C,0x00,0x00,

0x0C,0x03,0x80,0x00,0x0E,0x00,0x00,0x01,0xF0,0x38,0x00,0x0F,0x00,0x3C,0x00,0x00,

0x00,0x03,0x00,0x00,0x1C,0x00,0x00,0x01,0x00,0x20,0x00,0x06,0x00,0x18,0x00,0x00,

0x00,0x03,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x03,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x02,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

void Lcd_init(void)//Initialize LCD

Delaynms(10); //Start waiting, wait for LCM to talk to the working state

CS=1;

Write_char (0, 0x30);//8 bit interface, basic instruction set

Write_char (0, 0x0c);//The display is on, the cursor is off, and the reverse is off

Write_char (0, 0x01);//Clear the screen, reset the address counter of DDRAM to zero

void Write_char (bit start, unsigned char ddata) //Write instruction or data

unsigned char start_data, Hdata, Ldata;

if(start==0)

start_data=0xf8;//write command

else

start_data=0xfa;//write data

Hdata=ddata&0xf0;//Take the upper four bits

Ldata=(ddata《》4)&0xf0;//Take the lower four bits

Send_byte(start_data);//Send start signal

Delaynms(5); //Delay is necessary

Send_byte(Hdata);//Send high four bits

Delaynms(1);//Delay is necessary

Send_byte(Ldata);//Send the lower four bits

Delaynms(1);//Delay is necessary

void Send_byte (unsigned char bbyte) //Send a byte

unsigned char i;

for(i=0;i《8;i++)

SID=bbyte&0x80; //take out the highest bit

SCLK=1;

SCLK=0;

bbyte《》=1; //shift left

void Delaynms (unsigned int di) // Delay

unsigned int da, db;

for(da=0;da

for(db=0;db《10;db++);

void Disp_img(unsigned char*img)//graphic mode 12864 display font 221 horizontal film removal

unsigned char i, j;

unsigned int k = 0;

Write_char(0, 0x36); //graphic mode

for(i=0;i《32;i++)

Write_char(0, 0x80+i);

Write_char(0, 0x80);

for(j=0;j《16;j++)

Write_char(1, img[k++]);

for(i=0;i《32;i++)

Write_char(0, 0x80+i);

Write_char(0, 0x88);

for(j=0;j《16;j++)

Write_char(1, img[k++]);

void Clr_Scr(void)//Clear screen function

Write_char(0, 0x01);


Feedback
Hubei Hannas Tech Co.,Ltd  is a professional piezoelectric ceramics and ultrasonic transducer manufacturer, dedicated to ultrasonic technology and industrial applications.                                    
 

RECOMMEND

CONTACT US

Add: No.302 Innovation Agglomeration Zone, Chibi Avenu ,Chibi City, Xianning, Hubei Province,China
E-mail: sales@piezohannas.com
Tel: +86 07155272177
Phone: +86 +18986196674         
QQ: 1553242848 
Skype: live:mary_14398
​        
Copyright 2017  Hubei Hannas Tech Co.,Ltd All rights reserved. 
Products