找回密码
 立即注册

QQ登录

只需一步,快速开始

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

直流电动机正反转51单片机源码及仿真

[复制链接]
跳转到指定楼层
楼主
直流电机仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)


直流电机正反转单片机源程序如下:
  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int
  4. sbit IN1 = P2^0;
  5. sbit IN2 = P2^1;
  6. sbit PWM = P2^2;
  7. sbit Key1 = P1^7;
  8. sbit Key2 = P1^6;
  9. sbit Key3 = P1^5;
  10. sbit Key4 = P1^4;
  11. sbit Key5 = P1^3;
  12. uint t = 46082;
  13. void delay_ms(uchar t)
  14. {
  15. uchar x,y;
  16. for(x = t;x > 0;x--)
  17.   for(y = 110;y > 0;y--);
  18. }
  19. void Timer0_Init()
  20. {
  21. TMOD = 0X01;
  22. TH0 = (65536 - 46082)/256;
  23. TL0 = (65536 - 46082)%256;
  24. EA = 1 ;
  25. ET0 = 1;
  26. TR0 = 1;
  27. }
  28. void Positive_Rotation()
  29. {
  30. IN1 = 0;
  31. IN2 = 1;
  32. }
  33. void Reverse_Rotation()
  34. {
  35. IN1 = 1;
  36. IN2 = 0;
  37. }
  38. void Stop_Rotation()
  39. {
  40. IN1 = 1;
  41. IN2 = 1;
  42. }
  43. void Key_Scan()
  44. {
  45. if(Key1 == 0)
  46. {
  47.   delay_ms(20);
  48.   if(Key1 == 0)
  49.   {
  50.    Positive_Rotation();  
  51.   }
  52. }
  53. else if(Key2 == 0)
  54. {
  55.   delay_ms(20);
  56.   if(Key2 == 0)
  57.   {
  58.    Reverse_Rotation();
  59.   }
  60. }
  61. else if(Key3 == 0)
  62. {
  63.   delay_ms(20);
  64.   if(Key3 == 0)
  65.   {
  66.    Stop_Rotation();
  67.   }
  68. }


复制代码

所有资料51hei提供下载:
直流电机Keil Proteus仿真.zip (80.07 KB, 下载次数: 43)


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

使用道具 举报

沙发
ID:342685 发表于 2018-6-5 14:17 | 只看该作者
请问接在单片机上怎么接
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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