找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 13903|回复: 22
打印 上一主题 下一主题
收起左侧

51单片机计步器Proteus仿真和源程序 基于MAX7219

  [复制链接]
跳转到指定楼层
楼主
单片机max7219计步器仿真图 原理图






计步器的所有仿真和源码下载: 计步器Proteus仿真和源程序.rar (85.34 KB, 下载次数: 389)

如果需要基于adxl345加速度 计步器程序在这里: http://www.51hei.com/bbs/dpj-50085-1.html
下面是部分源码预览:
  1. #include "reg51.h"

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

  4. sbit DIN = P1^0;
  5. sbit CLK = P1^1;
  6. sbit LOAD = P1^2;
  7. sbit StartKey = P1^3;
  8. sbit StopKey = P1^4;
  9. sbit StepKey = P1^5;

  10. uchar StartFlag=0;



  11. #define NoOp 0x00
  12. #define Digit0 0x01
  13. #define Digit1 0x02
  14. #define Digit2 0x03
  15. #define Digit3 0x04
  16. #define Digit4 0x05
  17. #define Digit5 0x06
  18. #define Digit6 0x07
  19. #define Digit7 0x08
  20. #define DecodeMode 0x09
  21. #define Intensity 0x0a
  22. #define ScanLimit 0x0b
  23. #define ShutDown 0x0c
  24. #define DisplayTest 0x0f

  25. #define ShutdownMode 0x00
  26. #define NormalOperation 0x01

  27. #define ScanDigit 0x07
  28. #define DecodeDigit 0xff
  29. #define IntensityGrade 0x0a

  30. #define TestMode 0x01
  31. #define TextEnd 0x00

  32. uchar DisBuffer[8]= {0,0,0,0,0,0,0,0};

  33. void delay(uint t)
  34. {
  35.         uint i;
  36.         while(t--)
  37.         {
  38.                 for(i=0; i<8; i++);
  39.         }
  40. }

  41. void SendChar(uchar ch)
  42. {
  43.         uchar i,temp;
  44. //        _nop_();
  45.         for(i=0; i<8; i++)
  46.         {
  47.                 temp=ch&0x80;
  48.                 ch=ch<<1;
  49.                 if(temp)
  50.                 {
  51.                         DIN=1;
  52.                         CLK=0;
  53.                         CLK=1;
  54.                 }
  55.                 else
  56.                 {
  57.                         DIN=0;
  58.                         CLK=0;
  59.                         CLK=1;
  60.                 }
  61.         }
  62. }

  63. void WriteWord(uchar addr,uchar num)
  64. {
  65.         LOAD=0;
  66. //        _nop_();
  67.         SendChar(addr);
  68. //        _nop_();
  69.         SendChar(num);
  70. //        _nop_();
  71.         LOAD=1;
  72. }

  73. void InitDisplay()
  74. {
  75.         WriteWord(ScanLimit,ScanDigit);
  76.         WriteWord(DecodeMode,DecodeDigit);
  77.         WriteWord(Intensity,IntensityGrade);
  78.         WriteWord(ShutDown,NormalOperation);
  79. }

  80. void main()
  81. {
  82.         unsigned long StepCount = 0;
  83.         uchar i;
  84.         InitDisplay();
  85.         WriteWord(DisplayTest,TestMode);
  86.         delay(3000);
  87.         WriteWord(DisplayTest,TextEnd);

  88.         while(1)
  89.         {
  90.                 if(StartKey == 0)
  91.                 {
  92.                         delay(100);
  93.                         if(StartKey == 0)
  94.                         {
  95.                                 StartFlag = 1;
  96.                                 for(i = 0;i < 8;i++)
  97.                                 {
  98.                                         WriteWord(Digit0+i,0);
  99.                                 }
  100.                         }
  101.                         while(!StartKey);
  102.                 }
  103.                 else if(StopKey == 0)
  104.                 {
  105.                         delay(100);
  106.                          if(StopKey == 0)
  107.                          {
  108.                                 StartFlag = 0;
  109.                          }
  110.                          while(!StopKey);
  111.                 }

  112.                 if(StartFlag)
  113.                 {
  114.                         if(StepKey == 0)
  115.                         {
  116.                                 delay(100);
  117.                                 if(StepKey == 0)
  118.                                 {
  119.                                         StepCount++;
  120.                                 }
  121.                                 while(!StepKey);
  122.                         }
  123.                 }
  124.                
  125.                 WriteWord(Digit7,StepCount%10);
  126.                 WriteWord(Digit6,StepCount/10%10);
  127.                 WriteWord(Digit5,StepCount/100%10);
  128.                 WriteWord(Digit4,StepCount/1000%10);
  129.                 WriteWord(Digit3,StepCount/10000%10);
  130.                 WriteWord(Digit2,StepCount/100000%10);
  131.                 WriteWord(Digit1,StepCount/1000000%10);
  132.                 WriteWord(Digit0,StepCount/10000000%10);


  133.         }
  134. }

复制代码



评分

参与人数 1黑币 +5 收起 理由
兜蔸窦 + 5 很给力!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏9 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:140197 发表于 2016-9-23 11:06 | 只看该作者
学习一下
回复

使用道具 举报

板凳
ID:141382 发表于 2016-10-6 01:39 | 只看该作者
学习了
回复

使用道具 举报

地板
ID:143128 发表于 2016-10-19 18:50 | 只看该作者
只可以显示步数? 仿真的时候怎样让他可以加步数,你做过实物出来了吗

回复

使用道具 举报

5#
ID:146464 发表于 2016-11-7 21:20 | 只看该作者
可以喔!
回复

使用道具 举报

6#
ID:147464 发表于 2016-11-17 09:53 | 只看该作者
学习学习
回复

使用道具 举报

7#
ID:150971 发表于 2016-11-29 14:18 | 只看该作者
怎么没有ADSL345的仿真?
回复

使用道具 举报

8#
ID:151085 发表于 2016-11-29 20:01 | 只看该作者
很厉害,学习了
回复

使用道具 举报

9#
ID:159974 发表于 2017-1-6 22:53 | 只看该作者
感觉好厉害
回复

使用道具 举报

10#
ID:197695 发表于 2017-5-7 14:26 | 只看该作者
仿真的时候显示步数吗?
回复

使用道具 举报

11#
ID:204636 发表于 2017-5-25 17:13 | 只看该作者
按键好像没用啊,启动不了
回复

使用道具 举报

12#
ID:211227 发表于 2017-6-14 17:13 | 只看该作者
非常好!
回复

使用道具 举报

13#
ID:211258 发表于 2017-6-14 23:04 | 只看该作者
很厉害,学习了
回复

使用道具 举报

14#
ID:211258 发表于 2017-6-15 17:16 | 只看该作者
谢谢分享!收藏了!
回复

使用道具 举报

15#
ID:213903 发表于 2017-6-23 00:38 | 只看该作者
学习了!
回复

使用道具 举报

16#
ID:33848 发表于 2017-6-30 10:31 | 只看该作者
厉害了,学学
回复

使用道具 举报

17#
ID:257406 发表于 2017-12-4 22:22 | 只看该作者
求问你的这些程序实现的有哪些功能?
回复

使用道具 举报

18#
ID:208643 发表于 2018-8-8 17:23 | 只看该作者
学习学习,谢谢分享
回复

使用道具 举报

19#
ID:92810 发表于 2019-5-27 10:51 | 只看该作者
谢谢分享了,学习了
回复

使用道具 举报

20#
ID:565777 发表于 2019-6-18 15:21 | 只看该作者
想学习一下大神的做法
回复

使用道具 举报

21#
ID:575213 发表于 2019-7-1 18:38 | 只看该作者
我的怎么不显示啊   着急啊
回复

使用道具 举报

22#
ID:729922 发表于 2020-4-15 18:35 | 只看该作者
aa864894787 发表于 2019-7-1 18:38
我的怎么不显示啊   着急啊

我也是导入了程序,但是不显示,你弄出来了吗
回复

使用道具 举报

23#
ID:848824 发表于 2022-1-13 14:49 | 只看该作者
非常好用感谢分享
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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