⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 work.s

📁 对于AVR单片机初学者来说
💻 S
📖 第 1 页 / 共 3 页
字号:
;    { 
;     M_DIR0;               //翻页电机反转
;     PulseXingZou();       //翻页电机驱动脉冲输出
;    }
; }
L40:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbend
	.dbfunc e Forward_Step _Forward_Step fV
	.even
_Forward_Step::
	.dbline -1
	.dbline 168
; //***************翻页电机行走上电后复位函数********************//
; void Forward_Step()
; {
	rjmp L50
L49:
	.dbline 170
	.dbline 171
	sbi 0x15,3
	.dbline 172
	rcall _PulseXingZou
	.dbline 173
L50:
	.dbline 169
;    while(SONSOR_6==0)     //检测传感器6
	sbis 0x16,6
	rjmp L49
	.dbline 174
;    { 
;     M_DIR1;               //翻页电机正转
;     PulseXingZou();       //翻页电机驱动脉冲输出
;    }
;     M_DIR0;               //翻页电机反转
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 175
;     for(u=0;u<400;u++)    //翻页电机居中
	clr R2
	clr R3
	sts _u+1,R3
	sts _u,R2
	rjmp L55
L52:
	.dbline 176
	.dbline 177
	rcall _PulseXingZou
	.dbline 178
L53:
	.dbline 175
	lds R24,_u
	lds R25,_u+1
	adiw R24,1
	sts _u+1,R25
	sts _u,R24
L55:
	.dbline 175
	lds R24,_u
	lds R25,_u+1
	cpi R24,144
	ldi R30,1
	cpc R25,R30
	brlo L52
	.dbline -2
	.dbline 179
;     {
;      PulseXingZou();      //翻页电机驱动脉冲输出
;     } 
; }
L48:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Judge1 _Judge1 fV
	.even
_Judge1::
	.dbline -1
	.dbline 182
; //***************字轮电机转动方向及步数判断函数1****************//
; void  Judge1()           //判断字轮正反转
;  {
	.dbline 183
;   if(b>10){R_Step=(20-b)*12; M_DIR1;}  
	ldi R24,10
	ldi R25,0
	lds R2,_b
	lds R3,_b+1
	cp R24,R2
	cpc R25,R3
	brsh L57
	.dbline 183
	.dbline 183
	ldi R18,20
	ldi R19,0
	sub R18,R2
	sbc R19,R3
	ldi R16,12
	ldi R17,0
	rcall mpy16s
	sts _R_Step,R16
	.dbline 183
	sbi 0x15,3
	.dbline 183
	rjmp L58
L57:
	.dbline 184
	.dbline 184
	lds R18,_b
	lds R19,_b+1
	ldi R16,12
	ldi R17,0
	rcall mpy16s
	sts _R_Step,R16
	.dbline 184
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 184
L58:
	.dbline -2
	.dbline 185
;   else {R_Step=b*12; M_DIR0; }  
;  }
L56:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Judge2 _Judge2 fV
	.even
_Judge2::
	.dbline -1
	.dbline 188
; //***************字轮电机转动方向及步数判断函数2****************//
; void  Judge2()           //判断字轮正反转
; {
	.dbline 189
;   if(b>10){R_Step=(20-b)*12; M_DIR0;}  
	ldi R24,10
	ldi R25,0
	lds R2,_b
	lds R3,_b+1
	cp R24,R2
	cpc R25,R3
	brsh L60
	.dbline 189
	.dbline 189
	ldi R18,20
	ldi R19,0
	sub R18,R2
	sbc R19,R3
	ldi R16,12
	ldi R17,0
	rcall mpy16s
	sts _R_Step,R16
	.dbline 189
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 189
	rjmp L61
L60:
	.dbline 190
	.dbline 190
	lds R18,_b
	lds R19,_b+1
	ldi R16,12
	ldi R17,0
	rcall mpy16s
	sts _R_Step,R16
	.dbline 190
	sbi 0x15,3
	.dbline 190
L61:
	.dbline -2
	.dbline 191
;   else {R_Step=b*12; M_DIR1; }  
; }
L59:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e MotorZhua_fangZhi _MotorZhua_fangZhi fV
	.even
_MotorZhua_fangZhi::
	.dbline -1
	.dbline 194
; //***************机械手配合翻页电机翻页过程函数*****************//
; void MotorZhua_fangZhi()
; {Reverse_Step();
	.dbline 194
	rcall _Reverse_Step
	.dbline 195
;  u=0;
	clr R2
	clr R3
	sts _u+1,R3
	sts _u,R2
	.dbline 196
;  DelayLong(5);           //吸纸延时10*(1000)	 
	ldi R16,5
	ldi R17,0
	rcall _DelayLong
	rjmp L64
L63:
	.dbline 198
;   while(SONSOR_6==0)     //检测传感器6
;    {   
	.dbline 199
;       M_DIR1;            //翻页电机正转  
	sbi 0x15,3
	.dbline 200
;       u++;
	lds R24,_u
	lds R25,_u+1
	adiw R24,1
	sts _u+1,R25
	sts _u,R24
	.dbline 201
;       PulseXingZou();    //翻页电机驱动脉冲输出 
	rcall _PulseXingZou
	.dbline 202
;       if(u==380){ GRASP_ACT0;}   //抓纸机械手后翻页电机往正转380步放纸
	lds R24,_u
	lds R25,_u+1
	cpi R24,124
	ldi R30,1
	cpc R25,R30
	brne L66
	.dbline 202
	.dbline 202
	in R24,0x15
	andi R24,254
	out 0x15,R24
	.dbline 202
L66:
	.dbline 203
L64:
	.dbline 197
	sbis 0x16,6
	rjmp L63
	.dbline -2
	.dbline 204
;     }
; }
L62:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Motor3QianZou _Motor3QianZou fV
	.even
_Motor3QianZou::
	.dbline -1
	.dbline 207
; //******************装票步进电机出仓过程函数********************//
; void Motor3QianZou()
; {
	.dbline 208
;  M_DIR1;                   //装票步进电机出仓方向
	sbi 0x15,3
	rjmp L70
L69:
	.dbline 210
	rcall _PulseZhuangPiao
L70:
	.dbline 209
;  while(SONSOR_0==0)        //检测前传感器                  
	sbis 0x16,0
	rjmp L69
	.dbline -2
	.dbline 211
;       PulseZhuangPiao();   //承票板往前走	 
; }
L68:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Motor3HouZhong _Motor3HouZhong fV
;              e -> R20
	.even
_Motor3HouZhong::
	rcall push_gset1
	.dbline -1
	.dbline 214
; //******************装票步进电机入仓过程函数********************//
; void Motor3HouZhong()
; {
	rjmp L74
L73:
	.dbline 217
	.dbline 218
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 219
	rcall _PulseZhuangPiao
	.dbline 220
L74:
	.dbline 216
;  uchar e;
;  while(SONSOR_1==0)             //检测中传感器
	sbis 0x16,1
	rjmp L73
	.dbline 221
; 	     {
;          M_DIR0;                //装票步进电机入仓方向
; 		 PulseZhuangPiao();     //装票步进电机驱动脉冲输出
; 		 }
; 		 for(e=0;e<55;e++)      //修正传感器位置误差55
	clr R20
	rjmp L79
L76:
	.dbline 222
	.dbline 223
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 224
	rcall _PulseZhuangPiao
	.dbline 225
L77:
	.dbline 221
	inc R20
L79:
	.dbline 221
	cpi R20,55
	brlo L76
	.dbline -2
	.dbline 226
; 		 {
; 		  M_DIR0;               //装票步进电机入仓方向
; 		  PulseZhuangPiao();    //装票步进电机驱动脉冲输出
;           }
; }
L72:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r e 20 c
	.dbend
	.dbfunc e Motor3HouZou _Motor3HouZou fV
	.even
_Motor3HouZou::
	.dbline -1
	.dbline 229
; //*********装票步进电机入仓后再进入盖章位置的过程函数***********//
; void Motor3HouZou()
; {
	.dbline 230
;        M_DIR0;                  //装票步进电机入仓方向
	in R24,0x15
	andi R24,247
	out 0x15,R24
	rjmp L82
L81:
	.dbline 232
	rcall _PulseZhuangPiao
L82:
	.dbline 231
; 	while(SONSOR_2==0)          //检测后传感器
	sbis 0x16,2
	rjmp L81
	.dbline -2
	.dbline 233
;        PulseZhuangPiao();       //装票步进电机驱动脉冲输出
; }
L80:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Motor3 _Motor3 fV
	.even
_Motor3::
	.dbline -1
	.dbline 236
; //*********************装票过程函数*****************************//
; void Motor3()
; {
	.dbline 237
; Motor3QianZou();                //调用装票步进电机出仓过程函数
	rcall _Motor3QianZou
	.dbline 238
; Motor3HouZhong();               //调用装票步进电机入仓过程函数
	.dbline -2
	.dbline 239
; }
L84:
	.dbline 0 ; func end
	rjmp _Motor3HouZhong
	.dbend
	.dbfunc e Motor3QianZhong _Motor3QianZhong fV
;              i -> R20,R21
	.even
_Motor3QianZhong::
	rcall push_gset1
	.dbline -1
	.dbline 242
; //*******装票步进电机入仓后再进入盖章位置的逆过程函数***********//
; void Motor3QianZhong()
; {uint i;
	.dbline 243
;  M_DIR1;                         //装票步进电机出方向
	sbi 0x15,3
	rjmp L87
L86:
	.dbline 245
	.dbline 246
	rcall _PulseZhuangPiao
	.dbline 247
L87:
	.dbline 244
;  while(SONSOR_1==0)              //检测中传感器
	sbis 0x16,1
	rjmp L86
	.dbline 248
; 	     {
; 		 PulseZhuangPiao();      //装票步进电机驱动脉冲输出
; 		 }
;  for(i=0;i<20;i++)               //修正传感器位置误差20
	clr R20
	clr R21
	rjmp L92
L89:
	.dbline 249
	rcall _PulseZhuangPiao
L90:
	.dbline 248
	subi R20,255  ; offset = 1
	sbci R21,255
L92:
	.dbline 248
	cpi R20,20
	ldi R30,0
	cpc R21,R30
	brlo L89
	.dbline -2
	.dbline 250
;     PulseZhuangPiao();           //装票步进电机驱动脉冲输出
; }
L85:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbend
	.dbfunc e Motor1_Fuwei _Motor1_Fuwei fV
	.even
_Motor1_Fuwei::
	.dbline -1
	.dbline 253
; //***************翻页电机打印页码过程中复位函数*****************//
; void Motor1_Fuwei()
; {
	.dbline 254
;   Reverse_Step();               //翻页电机行走抓纸张函数
	rcall _Reverse_Step
	.dbline 255
;   DelayLong(5);    
	ldi R16,5
	ldi R17,0
	rcall _DelayLong
	rjmp L95
L94:
	.dbline 257
	.dbline 258
	sbi 0x15,3
	.dbline 259
	rcall _PulseXingZou
	.dbline 260
L95:
	.dbline 256
;    while(SONSOR_6==0)           //检测中传感器5
	sbis 0x16,6
	rjmp L94
	.dbline 261
;    { 
;     M_DIR1;                     //翻页电机正转
;    PulseXingZou();              //翻页电机行驱动脉冲输出
; 	}
;     M_DIR0;                     //翻页电机反转
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline -2
	.dbline 262
; }
L93:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Motor2_Fuwei _Motor2_Fuwei fV
	.even
_Motor2_Fuwei::
	.dbline -1
	.dbline 265
; //***************字轮电机打印页码过程中复位函数*****************//
; void Motor2_Fuwei()
; {
	.dbline 266
;    M_DIR0;                      //字轮电机反转            
	in R24,0x15
	andi R24,247
	out 0x15,R24
	rjmp L99
L98:
	.dbline 268
	.dbline 269
	rcall _PulseZiLun
	.dbline 270
L99:
	.dbline 267
;    while(SONSOR_4==0)           //检测字轮定位传感器
	sbis 0x16,4
	rjmp L98
	.dbline -2
	.dbline 271
;      {
;       PulseZiLun();             //字轮电机行驱动脉冲输出 
;      }
; }
L97:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Motor12_Dama _Motor12_Dama fV
;              p -> R22
;              k -> R20
	.even
_Motor12_Dama::
	rcall push_gset2
	.dbline -1
	.dbline 274
; //***********字轮电机与翻页电机配合打印页码过程函数*************//
; void Motor12_Dama()
; {
	.dbline 275
; uchar k=0;
	clr R20
	rjmp L103
L102:
	.dbline 278
; uchar p;
; while(SONSOR_3==0)              //纸张传感器为0(有票据)时执行循环
;  {
	.dbline 279
;     for(u=0;u<150;u++)          //字轮电机进入打印位置
	clr R2
	clr R3
	sts _u+1,R3
	sts _u,R2
	rjmp L108
L105:
	.dbline 280
	.dbline 281
	in R24,0x15
	andi R24,247
	out 0x15,R24
	.dbline 282
	rcall _PulseXingZou
	.dbline 283
L106:
	.dbline 279
	lds R24,_u
	lds R25,_u+1
	adiw R24,1
	sts _u+1,R25
	sts _u,R24
L108:
	.dbline 279
	lds R24,_u
	lds R25,_u+1
	cpi R24,150
	ldi R30,0
	cpc R25,R30
	brlo L105
	.dbline 284
;      {
; 	  M_DIR0;                   //字轮电机反转
;       PulseXingZou();	        //字轮电机行驱动脉冲输出
;      }                          
;      Motor2_Fuwei();            //字轮电机复位 
	rcall _Motor2_Fuwei
	.dbline 285
;      p=0;
	clr R22

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -