Project actual combat: 51 single-chip Hall bicycle mileage speedometer design paper schematic diagram program PPT production detailed explanations are available

Share a Hall bicycle mileage speedometer made by 51 single chip microcomputer with friends of CSDN forum, the data is very full, the programming papers are there.
Explanation
1, the single chip microcomputer is the same whether 51 or 52, regardless of stc or at, pin function it's the same.
The procedure is the same.
2. The .ddb, .Bkp and other formats in the schematic diagram are to be opened with protelse. It does not matter if there is no software.
I have converted them to word format and pdf format.
3. The .c file in the program can be opened with Notepad (text document), which is the program. The other is that writing programs is automatically generated and is useless.
4. You can follow the front layout, do not weld according to the back of the real thing, but weld according to the schematic diagram.

Digital tube pin layout instructions:
face to yourself, the second is down, the left bottom is 1 foot, the counterclockwise is arranged, and the upper left is the last foot! Please clarify the foot layout before welding before welding! I wish you success!
Without further ado, go directly to the physical picture:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Schematic diagram of Hall bicycle speed measuring circuit:
Insert picture description here
Insert picture description here
parts list
Insert picture description here
Design paper of
Insert picture description here
Hall bicycle mileage speedometer: reference source program of single-chip Hall bicycle mileage speedometer:

// Purpose: Learning programming
// Description 1: P00—P07: a ----- dp P27—P24: com1 ----- com4 P34 switching display P32—INT0 a magnet
// Description 2: This program is aimed at The circumference of the wheel is 207cm, the circumference of other models, you can change the parameters
// Description 3: The digital tube is high from left to right ------ low
#include <reg51.h>
#include "juxun001.h"
//Main function=====================
void main ()
{
time0_int0_init (); // Initialization of timer 0 and external interrupt 0
while (! TR0) // Power on 0.0.0.0 is displayed when it has not been cut
{
init_display ();
}
while (1)
{
if (! Change) // Press the switch button to display the mileage
{
delay1m (5);
if (! Change)
{
flag = ~ flag;
}
while (! change);
}

    }

}

//==Timer 0 interrupt function
void time0_interrupt () interrupt 1
{
TL0 = ( 65536-5000 )% 256; // 12M crystal, 5ms timing
TH0 = ( 65536-5000 ) / 256;
display_function ();
time_counter ++;
time_counter8 ++;
if (time_counter8> = 1600) / / If it is not cut for more than 8s, the car is regarded as stopped, the speed is: 0, but the mileage is also recorded
{
time_counter8 = 0;
speed = 0; // The speed is 0
point1 = 0;
buf1 [3] = speed% 10; buf1 [2] = speed / 10% 10;
buf1 [1] = speed / 100% 10; buf1 [0] = speed / 1000% 10;
}
}
// ==========External interrupt 0 interrupt function=
void int0_interrupt()interrupt 0
{

external_counter ++;
if (external_counter == 1) TR0 = ~ TR0; // The first cut opens the timer 0
if (external_counter == 65535) external_counter = 0;
time_counter8 = 0; // As long as there is a cut within 8 seconds, the car will take over Running

if (external_counter% 2 == 0) // The speed of cutting 2 updates
{// * 5 is because the interruption is 5MS
if (flag10){speed =((ulong)(36000)*zhouchang)/(time_counter * 5);flag1=1;}
else if(flag1
1) {speed = ((ulong) (36000) 2 zhouchang) / (time_counter * 5);} // Speed: unit is m / h, * 1000 purpose is not to appear floating point

if((speed >= 100)&&(speed < 1000)) //100 ---- 1000 3位整数
{
point1 = 1;buf1[3] = speed%10;buf1[2] = speed/10%10;
buf1[1] = speed/100%10;buf1[0] = 0;}
else if((speed >= 1000)&&(speed < 10000)) //1000 ---- 10000 4位整数
{
point1 = 1;speed = (uint)speed;
buf1[3] = speed%10;buf1[2] = speed/10%10;
buf1[1] = speed/100%10;buf1[0] = speed/1000%10;}
else if((speed >= 10000)&&(speed < 100000)) //10000 ----- 100000 5位整数
{
point1 = 2;
buf1[3] = speed/10%10;buf1[2] = speed/100%10;
buf1[1] = speed/1000%10;buf1[0] = speed/10000%10;}
else if((speed >= 100000)&&(speed < 1000000)) //100000 ------ 1000000 6位整数
{
point1 = 3;
buf1 [3] = speed / 100% 10; buf1 [2] = speed / 1000% 10;
buf1 [1] = speed / 10000% 10; buf1 [0] = speed / 100000% 10;}
time_counter = 0;
}
if (external_counter% 8 == 0) // The mileage is updated every 8 times of cutting
{
s = (ulong) external_counter * zhouchang; // The mileage: the unit is cm
if ((s> = 1000) && (s <10000))
{
point2 = 1; // 0.012 001212
buf2 [3] = s / 100% 10; buf2 [2] = s / 1000% 10;
buf2 [1] = 0; buf2 [0] = 0;} // 4 digits Integer
else if ((s> = 10000) && (s <100000))
{
point2 = 1;
buf2 [3] = s / 100% 10; buf2 [2] = s / 1000% 10;
buf2 [1] = s / 10000% 10; buf2 [0] = 0;} // 5-digit integer 0.123 012345
else if ((s> = 100000) && (s <1000000))
{
point2 = 1;
buf2[3] = s/100%10;buf2[2] = s/1000%10;
buf2[1] = s/10000%10;buf2[0] = s/100000%10;} // 6位整数 1.234 1234 56
else if((s >= 1000000)&&(s < 10000000))
{
point2 = 2;
buf2[3] = s/1000%10;buf2[2] = s/10000%10;
buf2[1] = s/100000%10;buf2[0] = s/1000000%10;}// 7位整数 1234 567
else if((s >= 10000000)&&(s < 100000000))
{
point2 = 3;
buf2[3] = s/10000%10;buf2[2] = s/100000%10;
buf2[1] = s/1000000%10;buf2[0] = s/10000000%10;} // 8位整数 1234 5678
}
}
//==========The data displayed when the power is turned on, the initial display speed
void init_display()
{
uchar i;
for(i = 0;i < 4;i++)
{
wei = bitcode[num - 1];
led = display1[buf1[num–]];
delay1m(4);
if(num == 0)num = 4;
}
}
//==Display function=
void display_function ()
{
if (flag == 0) // Display speed
{
switch (point1)
{
case 0: wei = bitcode [num-1]; led = display1 [buf1 [num-1]]; num–; break; // Speed ​​display 0
case 1: if (num == 1) {wei = bitcode [num-1]; led = 0x7f & display1 [buf1 [num-1]]; num–;}
else {wei = bitcode [num -1]; led = display1 [buf1 [num-1]]; num –;} break; // The most significant decimal point lights up

case 2: if (num == 2) {wei = bitcode [num-1]; led = 0x7f & display1 [buf1 [num-1]]; num–;}
else {wei = bitcode [num-1]; led = display1 [buf1 [num-1]]; num –;} break; // The second highest decimal point lights up

case 3: if (num == 3) {wei = bitcode [num-1]; led = 0x7f & display1 [buf1 [num-1]]; num–;}
else {wei = bitcode [num-1]; led = display1 [buf1 [num-1]]; num –;} break; // The third highest decimal point lights up
default: break;

}
if (num == 0) num = 4;
}
else if (flag == 1) // display mileage
{
switch (point2)
{
case 0: wei = bitcode [num-1]; led = display1 [buf2 [num -1]]; num–; break; // Miles display 0

case 1: if (num == 1) {wei = bitcode [num-1]; led = 0x7f & display1 [buf2 [num-1]]; num–;}
else {wei = bitcode [num-1]; led = display1 [buf2 [num-1]]; num –;} break; // The most significant decimal point lights up

case 2: if (num == 2) {wei = bitcode [num-1]; led = 0x7f & display1 [buf2 [num-1]]; num–;}
else {wei = bitcode [num-1]; led = display1 [buf2 [num-1]]; num –;} break; // The second highest decimal point lights up

case 3: if (num == 3) {wei = bitcode [num-1]; led = 0x7f & display1 [buf2 [num-1]]; num–;}
else {wei = bitcode [num-1]; led = display1 [buf2 [num-1]]; num –;} break; // The third highest decimal point lights up
default: break;

}
if(num == 0)num = 4;
}
}
//=================Initialization function of timer 0 and external interrupt 0=
void time0_int0_init ()
{
TMOD | = 0x01;
TMOD & = 0xfd; // Timer 0 works in mode 1
TL0 = ( 65536-5000 )% 256; // 12M crystal, 5ms timing
TH0 = (65536-5000) / 256;
IT0 = 1; // External interrupt 0, negative transition trigger mode
TR0 = 0;
ET0 = 1;
EX0 = 1;
EA = 1;
}
// ==========ms level delay function=
void delay1m (uchar x)
{
uchar i, j;
for (i = 0; i <x; i ++) // Continuous x times, about x ms
for (j = 0; j <120; j ++); // 120 times, about 1 ms
}

Finally, if you have any comments or suggestions, you are welcome to leave a message to me, let us learn together and progress together.
If you need the complete code or design file, please leave a message or private message me below.

Thank you!

Published 97 original articles · 200 praises · 80,000+ views

Guess you like

Origin blog.csdn.net/weixin_44212493/article/details/104335363