找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4813|回复: 5
收起左侧

基于单片机的速度里程表仿真设计与源码(按键代替霍尔传感器)

[复制链接]
ID:303101 发表于 2018-5-8 21:57 | 显示全部楼层 |阅读模式
单片机速度里程表仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
51hei.png 51hei.png TIM截图20180508215513.png

0.jpg

单片机源程序如下:
  1. #include<reg51.h>

  2. #define uchar unsigned char
  3. #define uint unsigned int

  4. #include "Data.h"
  5. #include "DS1302.h"
  6. #include "AT24C02.h"

  7. sbit COUNT_IN=P3^2;

  8. //定义1602相关管脚
  9. sbit rs=P1^4;
  10. sbit en=P1^0;

  11. //键盘定义
  12. sbit K1=P3^4;        //设置时间
  13. sbit K3=P3^6;        //减按键
  14. sbit K2=P3^5;        //加按键
  15. sbit K4=P3^7;        //设置半径安全距离
  16. sbit BEEP=P3^0;

  17. uint count;
  18. unsigned long Velocity,Mileage;

  19. uchar code tab1[]={"  /  /     :    "}; //14/09/10 16:34 3           
  20. uchar code tab2[]={"  0.000km 00km/h"};        //000.000km 00km/h
  21. uchar code tab3[]={"Wheel Radius  cm"};
  22. uchar code tab4[]={"Safe Speed  km/h"};
  23. uchar code tab5[]={"Sec :           "};
  24.                                                    
  25. uchar Mode=0;
  26. uchar bike_set=0;
  27. uchar a;
  28. char RADIUS,SAFE_SPEED;
  29. bit LED_SEC;
  30. uchar before_sec;        

  31. //自定义字符
  32. uchar code num[]={
  33.                                                 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//1         
  34.                                                 0x1f,0x01,0x01,0x1f,0x10,0x10,0x1f,0x00,//2
  35.                                                 0x1f,0x01,0x01,0x1f,0x01,0x01,0x1f,0x00,//3         
  36.                                                 0x11,0x11,0x11,0x1f,0x01,0x01,0x01,0x00,//4
  37.                                                 0x1f,0x10,0x10,0x1f,0x01,0x01,0x1f,0x00,//5         
  38.                                                 0x1f,0x10,0x10,0x1f,0x11,0x11,0x1f,0x00,//6
  39.                                                 0x1f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,//7         
  40. };
  41. void READS();
  42. void SETS();
  43. void delay(uint x)
  44. {
  45.         uint i,j;
  46.         for(i=0;i<x;i++)
  47.         for(j=0;j<110;j++);
  48. }
  49. void init()
  50. {
  51.         IT0=1;        //INT0负跳变触发        
  52.     TMOD=0x01;//定时器工作于方式1
  53.         TH0=0x3c;          //50ms
  54.         TL0=0xb0;
  55.         EA=1; //CPU开中断总允许
  56.         ET0=1;//开定时中断
  57.         EX0=1;//开外部INTO中断
  58.     TR0=1;//启动定时
  59. }
  60. /********液晶写入指令函数与写入数据函数,以后可调用**************/

  61. void write_1602com(uchar com)//****液晶写入指令函数****
  62. {
  63.         rs=0;//数据/指令选择置为指令
  64.         P0=com;//送入数据
  65.         delay(1);
  66.         en=1;//拉高使能端,为制造有效的下降沿做准备
  67.         delay(1);
  68.         en=0;//en由高变低,产生下降沿,液晶执行命令

  69. }


  70. void write_1602dat(uchar dat)//***液晶写入数据函数****
  71. {
  72.         rs=1;//数据/指令选择置为数据
  73.         P0=dat;//送入数据
  74.         delay(1);
  75.         en=1; //en置高电平,为制造下降沿做准备
  76.         delay(1);
  77.         en=0; //en由高变低,产生下降沿,液晶执行命令
  78. }
  79. //自定义字符集
  80. void Lcd_ram()      
  81. {
  82.         uint i,j,k=0,temp=0x40;
  83.         for(i=0;i<7;i++)
  84.         {
  85.            for(j=0;j<8;j++)
  86.            {
  87.             write_1602com(temp+j);
  88.             write_1602dat(num[k]);
  89.             k++;
  90.            }
  91.            temp=temp+8;
  92.         }
  93. }

  94. void lcd_init()//***液晶初始化函数****
  95. {
  96.         Lcd_ram();
  97.         write_1602com(0x38);//设置液晶工作模式,意思:16*2行显示,5*7点阵,8位数据
  98.         write_1602com(0x0c);//开显示不显示光标
  99.         write_1602com(0x06);//整屏不移动,光标自动右移
  100.         write_1602com(0x01);//清显示

  101.         write_1602com(0x80);//显示固定符号从第一行第1个位置之后开始显示
  102.         for(a=0;a<16;a++)
  103.         {
  104.                 write_1602dat(tab1[a]);//向液晶屏写固定符号部分
  105.         }
  106.         write_1602com(0x80+0x40);//显示固定符号写入位置,从第2个位置后开始显示
  107.         for(a=0;a<16;a++)
  108.         {
  109.                 write_1602dat(tab2[a]);//写显示固定符号
  110.         }
  111. }

  112. void display()
  113. {
  114.         //                        1km/h=100m/0.1h                   360s
  115.         //                        10km/h=100m/0.01h          36s
  116.         //                        100km/h=100m/0.001h  3.6s
  117.         if(Mode==0&&bike_set==0)
  118.         {
  119.                 //读时间
  120.                         Ds1302_Read_Time();
  121.                         //显示时间
  122.                         write_1602com(0x80);
  123.                         write_1602dat(0x30+time_buf1[1]/10);
  124.                         write_1602dat(0x30+time_buf1[1]%10);
  125.                         write_1602com(0x80+3);
  126.                         write_1602dat(0x30+time_buf1[2]/10);
  127.                         write_1602dat(0x30+time_buf1[2]%10);
  128.                         write_1602com(0x80+6);
  129.                         write_1602dat(0x30+time_buf1[3]/10);
  130.                         write_1602dat(0x30+time_buf1[3]%10);
  131.                         write_1602com(0x80+9);
  132.                         write_1602dat(0x30+time_buf1[4]/10);
  133.                         write_1602dat(0x30+time_buf1[4]%10);
  134.                         write_1602com(0x80+12);
  135.                         write_1602dat(0x30+time_buf1[5]/10);
  136.                         write_1602dat(0x30+time_buf1[5]%10);
  137.                         write_1602com(0x80+15);
  138.                         write_1602dat(time_buf1[7]-1);               

  139.                         if(before_sec!=time_buf1[6])
  140.                         {
  141.                                 before_sec=time_buf1[6];
  142.                                 write_1602com(0x80+11);
  143.                                 write_1602dat(':');
  144.                                 LED_SEC=1;
  145.                         }
  146.                         if(LED_SEC==0)
  147.                         {
  148.                                 write_1602com(0x80+11);
  149.                                 write_1602dat(' ');        
  150.                         }

  151.                         write_1602com(0x80+0x40);
  152.                         if(Mileage/1000000==0)
  153.                         write_1602dat(' ');
  154.                         else
  155.                         write_1602dat(0x30+Mileage/1000000);//数字+0x30得到该数字的LCD1602显示码
  156.                         if(Mileage%1000000/100000==0)
  157.                         write_1602dat(' ');
  158.                         else        
  159.                         write_1602dat(0x30+Mileage%1000000/100000);//数字+0x30得到该数字的LCD1602显示码
  160.                         write_1602dat(0x30+Mileage%1000000%100000/10000);//数字+0x30得到该数字的LCD1602显示码
  161.                         write_1602com(0x80+0x40+4);
  162.                         write_1602dat(0x30+Mileage%1000000%100000%10000/1000);//数字+30得到该数字的LCD1602显示码
  163.                         write_1602dat(0x30+Mileage%1000000%100000%10000%1000/100);//数字+30得到该数字的LCD1602显示码
  164.                         write_1602dat(0x30+Mileage%1000000%100000%10000%1000%100/10);//数字+30得到该数字的LCD1602显示码
  165.                         SETS();
  166.         
  167.                         write_1602com(0x80+0x40+10);
  168.                         write_1602dat(0x30+Velocity/10);
  169.                         write_1602dat(0x30+Velocity%10);//数字+30得到该数字的LCD1602显示码
  170.         }
  171.         else if(Mode!=0)
  172.         {
  173.                 switch(Mode)
  174.                 {
  175.                         case 1:        
  176.                                 write_1602com(0x80+0x40);//显示固定符号写入位置
  177.                                 for(a=0;a<16;a++)
  178.                                 {
  179.                                         write_1602dat(tab5[a]);//写显示固定符号
  180.                                 }
  181.                                 write_1602com(0x80+0x40+14);
  182.                                 write_1602dat(0x30+time_buf1[6]/10);
  183.                                 write_1602dat(0x30+time_buf1[6]%10);        
  184.                                 write_1602com(0x0F);         //打开闪烁
  185.                                 write_1602com(0x80+1);
  186.                                 break;                                                  
  187.                         case 2:
  188.                                 write_1602com(0x80+4);
  189.                                 break;
  190.                         case 3:
  191.                                 write_1602com(0x80+7);
  192.                                 break;
  193.                         case 4:
  194.                                 write_1602com(0x80+10);
  195.                                 break;
  196.                         case 5:
  197.                                 write_1602com(0x80+13);
  198.                                 break;
  199.                         case 6:
  200.                                 write_1602com(0x80+0x40+15);
  201.                                 break;
  202.                         case 7:
  203.                                 write_1602com(0x80+15);
  204.                                 break;
  205.                         case 8:
  206.                                 write_1602com(0x0c);
  207.                                 write_1602com(0x80);//显示固定符号从第一行第1个位置之后开始显示
  208.                                 for(a=0;a<16;a++)
  209.                                 {
  210.                                         write_1602dat(tab1[a]);//向液晶屏写固定符号部分
  211.                                 }
  212.                                 write_1602com(0x80+0x40);//显示固定符号写入位置,从第2个位置后开始显示
  213.                                 for(a=0;a<16;a++)
  214.                                 {
  215.                                         write_1602dat(tab2[a]);//写显示固定符号
  216.                                 }
  217.                                 break;
  218.                 }
  219.         }
  220.         else if(bike_set!=0)
  221.         {
  222.                 switch(bike_set)
  223.                 {
  224.                         case 1:        
  225.                                 write_1602com(0x80);//显示固定符号写入位置
  226.                                 for(a=0;a<16;a++)
  227.                                 {
  228.                                         write_1602dat(tab3[a]);//写显示固定符号
  229.                                 }
  230.                                 write_1602com(0x80+0x40);//显示固定符号写入位置
  231.                                 for(a=0;a<16;a++)
  232.                                 {
  233.                                         write_1602dat(tab4[a]);//写显示固定符号
  234.                                 }
  235.                                 write_1602com(0x80+12);
  236.                                 write_1602dat(0x30+RADIUS/10);                   //车轮半径
  237.                                 write_1602dat(0x30+RADIUS%10);
  238.                                 write_1602com(0x80+0x40+10);
  239.                                 write_1602dat(0x30+SAFE_SPEED/10);                   //安全速度
  240.                                 write_1602dat(0x30+SAFE_SPEED%10);        
  241.                                 write_1602com(0x0F);         //打开闪烁
  242.                                 write_1602com(0x80+13);
  243.                                 break;                                                  
  244.                         case 2:
  245.                                 write_1602com(0x80+0x40+11);
  246.                                 break;
  247.                         case 3:
  248.                                 write_1602com(0x0c);
  249.                                 write_1602com(0x80);//显示固定符号从第一行第1个位置之后开始显示
  250.                                 for(a=0;a<16;a++)
  251.                                 {
  252.                                         write_1602dat(tab1[a]);//向液晶屏写固定符号部分
  253.                                 }
  254.                                 write_1602com(0x80+0x40);//显示固定符号写入位置,从第2个位置后开始显示
  255.                                 for(a=0;a<16;a++)
  256.                                 {
  257.                                         write_1602dat(tab2[a]);//写显示固定符号
  258.                                 }
  259.                                 break;
  260.                 }
  261.         }        
  262. }

  263. void KEY()
  264. {        
  265.         if(bike_set==0&&K1==0)
  266.         {
  267.                 delay(20);
  268.                 if(bike_set==0&&K1==0)
  269.                 {
  270.                         BEEP=0;
  271.                         delay(50);
  272.                         BEEP=1;
  273.                         Mode++;
  274.                         display();
  275.                         if(Mode>=8)
  276.                         {
  277.                                 Mode=0;
  278.                                 Ds1302_Write_Time();
  279.                         }
  280.                 }
  281.                 while(bike_set==0&&K1==0);
  282.         }
  283.         if(K4==0&&Mode==0)
  284.         {
  285.                 delay(20);
  286.                 if(K4==0&&Mode==0)
  287.                 {
  288.                         BEEP=0;
  289.                         delay(50);
  290.                         BEEP=1;
  291.                         bike_set++;
  292.                         display();
  293.                         if(bike_set>=3)
  294.                         {
  295.                                 bike_set=0;
  296.                                 SETS();
  297.                         }
  298.                 }
  299.                 while(Mode==0&&K4==0);
  300.         }

  301.         //+
  302.         if(K2==0&&(Mode!=0||bike_set!=0))
  303.         {
  304.                 delay(20);
  305.                 //调时
  306.                 if(K2==0&&(Mode!=0||bike_set!=0))
  307.                 {
  308.                         BEEP=0;
  309.                         delay(50);
  310.                         BEEP=1;        
  311.                         switch(Mode)
  312.                         {
  313.                                 case 1:
  314.                                         time_buf1[1]++;
  315.                                         if(time_buf1[1]>=100)
  316.                                                 time_buf1[1]=0;
  317.                                         write_1602com(0x80);
  318.                                         write_1602dat(0x30+time_buf1[1]/10);
  319.                                         write_1602dat(0x30+time_buf1[1]%10);
  320.                                         write_1602com(0x80+1);
  321.                                         break;
  322.                                 case 2:
  323.                                         time_buf1[2]++;
  324.                                         if(time_buf1[2]>=13)
  325.                                                 time_buf1[2]=1;
  326.                                         write_1602com(0x80+3);
  327.                                         write_1602dat(0x30+time_buf1[2]/10);
  328.                                         write_1602dat(0x30+time_buf1[2]%10);
  329.                                         write_1602com(0x80+4);
  330.                                         break;
  331.                                 case 3:
  332.                                         time_buf1[3]++;
  333.                                         if(time_buf1[3]>=YDay(time_buf1[1],time_buf1[2])+1)
  334.                                                 time_buf1[3]=1;
  335.                                         write_1602com(0x80+6);
  336.                                         write_1602dat(0x30+time_buf1[3]/10);
  337.                                         write_1602dat(0x30+time_buf1[3]%10);
  338.                                         write_1602com(0x80+7);
  339.                                         break;
  340.                                 case 4:
  341.                                         time_buf1[4]++;
  342.                                         if(time_buf1[4]>=24)
  343.                                                 time_buf1[4]=0;
  344.                                         write_1602com(0x80+9);
  345.                                         write_1602dat(0x30+time_buf1[4]/10);
  346.                                         write_1602dat(0x30+time_buf1[4]%10);
  347.                                         write_1602com(0x80+10);
  348.                                         break;
  349.                                 case 5:
  350.                                         time_buf1[5]++;
  351.                                         if(time_buf1[5]>=60)
  352.                                                 time_buf1[5]=0;
  353.                                         write_1602com(0x80+12);
  354.                                         write_1602dat(0x30+time_buf1[5]/10);
  355.                                         write_1602dat(0x30+time_buf1[5]%10);
  356.                                         write_1602com(0x80+13);
  357.                                         break;
  358.                                 case 6:
  359.                                         time_buf1[6]++;
  360.                                         if(time_buf1[6]>=60)
  361.                                                 time_buf1[6]=0;
  362.                                         write_1602com(0x80+0x40+14);
  363.                                         write_1602dat(0x30+time_buf1[6]/10);
  364.                                         write_1602dat(0x30+time_buf1[6]%10);
  365.                                         write_1602com(0x80+0x40+15);
  366.                                         break;
  367.                                 case 7:
  368.                                         time_buf1[7]++;
  369.                                         if(time_buf1[7]>=8)
  370.                                                 time_buf1[7]=1;
  371.                                         write_1602com(0x80+15);
  372.                                         write_1602dat(time_buf1[7]-1);
  373.                                         write_1602com(0x80+15);
  374.                                         break;
  375.                         }
  376.                         switch(bike_set)
  377.                         {
  378.                                 case 1:
  379.                                         RADIUS++;
  380.                                         if(RADIUS>=71)
  381.                                         RADIUS=0;
  382.                                         write_1602com(0x80+12);
  383.                                         write_1602dat(0x30+RADIUS/10);
  384.                                         write_1602dat(0x30+RADIUS%10);
  385.                                         write_1602com(0x80+13);
  386.                                         break;
  387.                                 case 2:
  388.                                         SAFE_SPEED++;
  389.                                         if(SAFE_SPEED>=100)
  390.                                         SAFE_SPEED=0;
  391.                                         write_1602com(0x80+0x40+10);
  392.                                         write_1602dat(0x30+SAFE_SPEED/10);
  393.                                         write_1602dat(0x30+SAFE_SPEED%10);
  394.                                         write_1602com(0x80+0x40+11);
  395.                                         break;
  396.                         }
  397.                 }
  398.                 while(K2==0);
  399.         }

  400.         //-
  401.         if(K3==0&&(Mode!=0||bike_set!=0))
  402.         {
  403.                 delay(20);
  404.                 //调时
  405.                 if(K3==0&&(Mode!=0||bike_set!=0))
  406.                 {
  407.                         BEEP=0;
  408.                         delay(50);
  409.                         BEEP=1;
  410.                         switch(Mode)
  411.                         {
  412.                                 case 1:
  413.                                         time_buf1[1]--;
  414.                                         if(time_buf1[1]<0)
  415.                                                 time_buf1[1]=99;
  416.                                         write_1602com(0x80);
  417.                                         write_1602dat(0x30+time_buf1[1]/10);
  418.                                         write_1602dat(0x30+time_buf1[1]%10);
  419.                                         write_1602com(0x80+1);
  420.                                         break;
  421.                                 case 2:
  422.                                         time_buf1[2]--;
  423.                                         if(time_buf1[2]<=0)
  424.                                                 time_buf1[2]=12;
  425.                                         write_1602com(0x80+3);
  426.                                         write_1602dat(0x30+time_buf1[2]/10);
  427.                                         write_1602dat(0x30+time_buf1[2]%10);
  428.                                         write_1602com(0x80+4);
  429.                                         break;
  430.                                 case 3:
  431.                                         time_buf1[3]--;
  432.                                         if(time_buf1[3]<=0)
  433.                                                 time_buf1[3]=YDay(time_buf1[1],time_buf1[2]);
  434.                                         write_1602com(0x80+6);
  435.                                         write_1602dat(0x30+time_buf1[3]/10);
  436.                                         write_1602dat(0x30+time_buf1[3]%10);
  437.                                         write_1602com(0x80+7);
  438.                                         break;
  439.                                 case 4:
  440.                                         time_buf1[4]--;
  441.                                         if(time_buf1[4]<0)
  442.                                                 time_buf1[4]=23;
  443.                                         write_1602com(0x80+9);
  444.                                         write_1602dat(0x30+time_buf1[4]/10);
  445.                                         write_1602dat(0x30+time_buf1[4]%10);
  446.                                         write_1602com(0x80+10);
  447.                                         break;
  448.                                 case 5:
  449.                                         time_buf1[5]--;
  450.                                         if(time_buf1[5]<0)
  451.                                                 time_buf1[5]=59;
  452.                                         write_1602com(0x80+12);
  453.                                         write_1602dat(0x30+time_buf1[5]/10);
  454.                                         write_1602dat(0x30+time_buf1[5]%10);
  455.                                         write_1602com(0x80+13);
  456.                                         break;
  457.                                 case 6:
  458.                                         time_buf1[6]--;
  459.                                         if(time_buf1[6]<0)
  460.                                                 time_buf1[6]=59;
  461.                                         write_1602com(0x80+0x40+14);
  462.                                         write_1602dat(0x30+time_buf1[6]/10);
  463.                                         write_1602dat(0x30+time_buf1[6]%10);
  464.                                         write_1602com(0x80+0x40+15);
  465.                                         break;
  466.                                 case 7:
  467.                                         time_buf1[7]--;
  468.                                         if(time_buf1[7]<1)
  469.                                                 time_buf1[7]=7;
  470.                                         write_1602com(0x80+15);
  471.                                         write_1602dat(time_buf1[7]-1);
  472.                                         write_1602com(0x80+15);
  473.                                         break;
  474.                         }
  475.                         switch(bike_set)
  476.                         {
  477.                                 case 1:
  478.                                         RADIUS--;
  479.                                         if(RADIUS<0)
  480.                                         RADIUS=70;
  481.                                         write_1602com(0x80+12);
  482.                                         write_1602dat(0x30+RADIUS/10);
  483.                                         write_1602dat(0x30+RADIUS%10);
  484.                                         write_1602com(0x80+13);
  485.                                         break;
  486.                                 case 2:
  487.                                         SAFE_SPEED--;
  488.                                         if(SAFE_SPEED<0)
  489.                                         SAFE_SPEED=99;
  490.                                         write_1602com(0x80+0x40+10);
  491.                                         write_1602dat(0x30+SAFE_SPEED/10);
  492.                                         write_1602dat(0x30+SAFE_SPEED%10);
  493.                                         write_1602com(0x80+0x40+11);
  494.                                         break;
  495.                         }
  496.                 }
  497.                 while(K3==0);
  498.         }        
  499.         if(K2==0&&K3==0&&Mode==0&bike_set==0)
  500.         {
  501.                 BEEP=0;
  502.                 delay(100);
  503.                 BEEP=1;
  504.                 delay(100);
  505.                 BEEP=0;
  506.                 delay(100);
  507.                 BEEP=1;
  508.                 delay(100);
  509.                 Mileage=0;
  510.                 SETS();
  511.                 while(K2==0&&K3==0);
  512.         }
  513. }
  514. void BJ_SAFE()
  515. {
  516.         if(Velocity>SAFE_SPEED)
  517.         {
  518.                 BEEP=0;
  519.         }
  520.         else
  521.         {
  522.                 BEEP=1;
  523.         }
  524. }

  525. void main()
  526. {
  527.         //初始化
  528.         Ds1302_Init();
  529.         lcd_init();
  530.         initeeprom();
  531.         //读取初始参数
  532.         READS();
  533.         //定时器初始化
  534. //        InitTimer0();
  535.         init();
  536.         lcd_init();
  537.         before_sec=time_buf1[6];
  538.         while(1)
  539.         {
  540.                 if(Mode==0&&bike_set==0)
  541.                 {
  542.                         display();
  543.                         BJ_SAFE();
  544.                 }
  545.                 KEY();
  546.         }
  547. }

  548. void EXINT0() interrupt 0
  549. {
  550.         count++;
  551. }

  552. void time0() interrupt 1
  553. {
  554.         uchar m,n;
  555.         TH0=0x3c;
  556.         TL0=0xb0;         //50ms
  557.         m++;
  558.         if(LED_SEC==1)
  559.         {
  560.                 n++;
  561.                 if(n>=10)
  562.                 {
  563.                         n=0;
  564.                         LED_SEC=0;
  565.                 }
  566.         }
  567.         
  568.         if(m>=10)
  569.         {
  570.                 m=0;
  571.                 Mileage=Mileage+10*(Velocity/3.6)/2;                 //里程m=里程+速度km/h/3.6/2
  572.                 Velocity=count *2*3.14*RADIUS /100000*2*3600  /40;//将500ms的距离经过运算得到km/h,将速度/100,方便显示
  573.                 count=0;        
  574.         }
  575. }

  576. //读初值
  577. void READS()
  578. {
  579.         uchar Mileage_H,Mileage_M,Mileage_L;
  580.         delay(10);
  581.         RADIUS=read_add(0x01);
  582.         delay(10);
  583.         SAFE_SPEED=read_add(0x02);

  584.         delay(10);
  585.         Mileage_H=read_add(0x03);
  586.         delay(10);
  587.         Mileage_M=read_add(0x04);
  588.         delay(10);
  589.         Mileage_L=read_add(0x05);

  590.         Mileage=Mileage_H*100000+Mileage_M*1000+Mileage_L*10;
  591. }


  592. //写初值
  593. void SETS()
  594. {
  595.         delay(10);
  596.         write_add(0x01,RADIUS);
  597.         delay(10);
  598.         write_add(0x02,SAFE_SPEED);

  599. /*        Mileage_H=Mileage/10000;                         //123.4560
  600.         Mileage_M=Mileage%10000/100;
  601.         Mileage_L=Mileage%10000%100; */
  602.         delay(10);
  603.         write_add(0x03,Mileage/100000);
  604.         delay(10);
  605.         write_add(0x04,Mileage%100000/1000);
  606.         delay(10);
  607.         write_add(0x05,Mileage%100000%1000/10);
  608. }
复制代码

所有资料51hei提供下载(只能用Proteus7.5打开):
Proteus7.5版本的仿真与Keil4程序.7z (151.48 KB, 下载次数: 110)
回复

使用道具 举报

ID:341946 发表于 2018-5-31 09:31 | 显示全部楼层
            Mileage=Mileage+10*(Velocity/3.6)/2;                 //里程m=里程+速度km/h/3.6/2
            Velocity=count *2*3.14*RADIUS /100000*2*3600  /40;//将500ms的距离经过运算得到km/h,将速度/100,方便显示
麻烦能不能解释一下这两句啊,特别是第二句速度的计算
回复

使用道具 举报

ID:341946 发表于 2018-5-31 09:33 | 显示全部楼层
   Mileage=Mileage+10*(Velocity/3.6)/2;                 //里程m=里程+速度km/h/3.6/2                 Velocity=count *2*3.14*RADIUS /100000*2*3600  /40;//将500ms的距离经过运算得到km/h,将速度/100,方便显示,麻烦再详细解释下这两句可以吗
回复

使用道具 举报

ID:349564 发表于 2018-6-13 15:46 | 显示全部楼层
proteus仿真电路图只能用Proteus7.5才能成功
回复

使用道具 举报

ID:453411 发表于 2018-12-24 14:25 来自手机 | 显示全部楼层
正确吗
回复

使用道具 举报

ID:743448 发表于 2020-5-15 17:05 | 显示全部楼层
请问怎么开始骑行啊。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表