电机仿真机器车仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
流程说明:
1,一上电,先通过按按键设置物块的高度和体积
2,注意,物块高度或者体积只要有其中一个为0时,不能开始搬运
3,按下开始搬运按键,即开始搬运,
流程是
机械臂先把物块抓取到机器车上,
机械臂减速
机器车带着物块前往目的地
机器车减速
机械臂把物块放下来
机械臂减速
机器车回到物块堆积处(此时机器车是空车)
机器车减速
蜂鸣器响,提示本次搬运已经完成
4,这时候按下机器复位按键,开始下一次设置物块参数和搬运
搬运物块完成提示模块
第一行显示的是物块的高度和机器车与物块堆积处的距离
第二行显示的是物块的体积或者直径或者质量
单片机源程序如下:
- #include"DS18B20.h"
- #include "Lcd1602.h"
- #include"KEY.h"
- #define uint unsigned int
- extern bit Start18B20();
- extern bit Get18B20Temp(int *temp);
- extern uchar keyvalue;
- void display(uint num);
- void read_del8b20();
- unsigned char PuZh[]="Temperature";
- unsigned char SetL[7]="L:";
- unsigned char SetH[7]="H:";
- extern uchar m;
- unsigned char shu[4]={0};
- unsigned char Ltemp[3]={1,2,3};
- unsigned char Htemp[3]={3,2,1};
- extern uchar LNextBit;
- extern uchar HNextBit;
- unsigned char pwm=0,count=0;
- bit res;
- int temp;
- int intT=0,decT;
- int i=0;
- int cha=0;
- int time1=0;
- void main(void)
- {
- unsigned n=0;
- InitLcd1602();
- Start18B20();
-
- while(1)
- {
- read_del8b20();
- delay1(1300);
- if(intT != 85)
- {
- i=intT;
- }
- deal();
- display(i*10);
- alarm();
- }
- }
- void read_del8b20()
- {
- res=Get18B20Temp(&temp);
- if(res)
- {
- intT=(temp>>4);
- decT=temp&0xf;
- }
- Start18B20();
- DelayX10us(5);
- }
- void display(uint num)
- {
- shu[0]=num/100+0x30;
- shu[1]=num%100 /10+0x30;
- shu[2]='.';
- shu[3] = num%10+0x30;
- SetL[2] = Ltemp[0]+0x30;
- SetL[3] = Ltemp[1]+0x30;
- SetL[4] = '.';
- SetL[5] = Ltemp[2]+0x30;
- SetH[2] = Htemp[0]+0x30;
- SetH[3] = Htemp[1]+0x30;
- SetH[4] = '.';
- SetH[5] = Htemp[2]+0x30;
- LcdShowStr(0,0,PuZh);
- LcdShowStr(0,1,SetL);
- LcdShowStr(9,1,SetH);
- LcdShowStr(12,0,shu);
- }
复制代码
所有资料51hei提供下载:
搬运机器人.zip
(226.18 KB, 下载次数: 78)
|