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

📄 regul.ls

📁 该程序是ST7MC驱动BLDC120
💻 LS
📖 第 1 页 / 共 2 页
字号:
 580  0092 2413          	jruge	L112
 581                     ; 161  DeltaVoltage_slip_s32 = ( Ki * SAMPLING_TIME_MidSpeed * (s32)Error_slip)/256;
 583  0094 b6fb          	ld	a,_regul_PI$L-5
 584  0096 befa          	ld	x,_regul_PI$L-6
 585  0098 cd0000        	call	c_itol
 587  009b aee8          	ld	x,#_regul_PI$L-24
 588  009d cd0000        	call	c_rtol
 590  00a0 c60000        	ld	a,_Ki
 591  00a3 ae1e          	ld	x,#30
 597  00a5 2011          	jra	L702
 598  00a7               L112:
 599                     ; 163  DeltaVoltage_slip_s32 = ( Ki * SAMPLING_TIME_HighSpeed * (s32)Error_slip)/256;  
 601  00a7 b6fb          	ld	a,_regul_PI$L-5
 602  00a9 befa          	ld	x,_regul_PI$L-6
 603  00ab cd0000        	call	c_itol
 605  00ae aee8          	ld	x,#_regul_PI$L-24
 606  00b0 cd0000        	call	c_rtol
 608  00b3 c60000        	ld	a,_Ki
 609  00b6 ae0a          	ld	x,#10
 614  00b8               L702:
 615  00b8 42            	mul	x,a
 616  00b9 cd0000        	call	c_itol
 617  00bc aee8          	ld	x,#_regul_PI$L-24
 618  00be cd0000        	call	c_lmul
 619  00c1 ae08          	ld	x,#high(L03)
 620  00c3 bf00          	ld	c_x,x
 621  00c5 ae08          	ld	x,#low(L03)
 622  00c7 cd0000        	call	c_xldiv
 623  00ca aefc          	ld	x,#_regul_PI$L-4
 624  00cc cd0000        	call	c_rtol
 625                     ; 165 if( ((Error_slip>0) && !MaxPiOut) || ((Error_slip<0) && !MinPiOut) )
 627  00cf b6fb          	ld	a,_regul_PI$L-5
 628  00d1 a001          	sub	a,#1
 629  00d3 b6fa          	ld	a,_regul_PI$L-6
 630  00d5 a200          	sbc	a,#0
 631  00d7 2b05          	jrmi	L122
 633  00d9 c60001        	ld	a,L5_MaxPiOut
 634  00dc 2709          	jreq	L712
 635  00de               L122:
 637  00de 3dfa          	tnz	_regul_PI$L-6
 638  00e0 2a7a          	jrpl	L512
 640  00e2 c60000        	ld	a,L7_MinPiOut
 641  00e5 2675          	jrne	L512
 642  00e7               L712:
 643                     ; 167 	if ((VoltageIntegralTerm >= 0) && (DeltaVoltage_slip_s32 >= 0))
 645  00e7 c60002        	ld	a,L3_VoltageIntegralTerm
 646  00ea 2b2f          	jrmi	L322
 648  00ec b6fc          	ld	a,_regul_PI$L-4
 649  00ee 2b2b          	jrmi	L322
 650                     ; 169 		if (( (u32)VoltageIntegralTerm + (u32)DeltaVoltage_slip_s32 ) > S32_MAX)
 652  00f0 ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 653  00f2 bf00          	ld	c_x,x
 654  00f4 ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 655  00f6 cd0000        	call	c_xltor
 657  00f9 aefc          	ld	x,#_regul_PI$L-4
 658  00fb cd0000        	call	c_ladd
 660  00fe ae0c          	ld	x,#high(L23)
 661  0100 bf00          	ld	c_x,x
 662  0102 ae0c          	ld	x,#low(L23)
 663  0104 cd0000        	call	c_xlcmp
 665  0107 2545          	jrult	L532
 666                     ; 170 			VoltageIntegralTerm = S32_MAX;	// Avoid IntTerm Overflow
 668  0109 a6ff          	ld	a,#255
 669  010b c70005        	ld	L3_VoltageIntegralTerm+3,a
 670  010e c70004        	ld	L3_VoltageIntegralTerm+2,a
 671  0111 c70003        	ld	L3_VoltageIntegralTerm+1,a
 672  0114 a67f          	ld	a,#127
 673  0116 c70002        	ld	L3_VoltageIntegralTerm,a
 675  0119 2041          	jra	L512
 676                     ; 171 		else VoltageIntegralTerm += DeltaVoltage_slip_s32; // "integral" output
 679  011b               L322:
 680                     ; 173 	else if ((VoltageIntegralTerm < 0) && (DeltaVoltage_slip_s32 < 0))
 682  011b c60002        	ld	a,L3_VoltageIntegralTerm
 683  011e 2a2e          	jrpl	L532
 685  0120 b6fc          	ld	a,_regul_PI$L-4
 686  0122 2a2a          	jrpl	L532
 687                     ; 175 		if (( (u32)VoltageIntegralTerm + (u32)DeltaVoltage_slip_s32 ) <= S32_MAX)
 689  0124 ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 690  0126 bf00          	ld	c_x,x
 691  0128 ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 692  012a cd0000        	call	c_xltor
 694  012d aefc          	ld	x,#_regul_PI$L-4
 695  012f cd0000        	call	c_ladd
 697  0132 ae0c          	ld	x,#high(L23)
 698  0134 bf00          	ld	c_x,x
 699  0136 ae0c          	ld	x,#low(L23)
 700  0138 cd0000        	call	c_xlcmp
 702  013b 2411          	jruge	L532
 703                     ; 176 			VoltageIntegralTerm = S32_MIN;	// Avoid IntTerm Overflow
 705  013d 4f            	clr	a
 706  013e c70005        	ld	L3_VoltageIntegralTerm+3,a
 707  0141 c70004        	ld	L3_VoltageIntegralTerm+2,a
 708  0144 c70003        	ld	L3_VoltageIntegralTerm+1,a
 709  0147 a680          	ld	a,#128
 710  0149 c70002        	ld	L3_VoltageIntegralTerm,a
 712  014c 200e          	jra	L512
 713  014e               L532:
 714                     ; 177 		else VoltageIntegralTerm += DeltaVoltage_slip_s32; // "integral" output
 717                     ; 180 		VoltageIntegralTerm += DeltaVoltage_slip_s32; // "integral" output 
 722  014e aefc          	ld	x,#_regul_PI$L-4
 723  0150 cd0000        	call	c_ltor
 724  0153 ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 725  0155 bf00          	ld	c_x,x
 726  0157 ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 727  0159 cd0000        	call	c_xlgadd
 729  015c               L512:
 730                     ; 183     if ((VoltageIntegralTerm >= 0) && (Voltage_slip_s32 >= 0))
 732  015c c60002        	ld	a,L3_VoltageIntegralTerm
 733  015f 2b2b          	jrmi	L342
 735  0161 b6f6          	ld	a,_regul_PI$L-10
 736  0163 2b27          	jrmi	L342
 737                     ; 185 		if (( (u32)VoltageIntegralTerm + (u32)Voltage_slip_s32 ) > S32_MAX)
 739  0165 ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 740  0167 bf00          	ld	c_x,x
 741  0169 ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 742  016b cd0000        	call	c_xltor
 744  016e aef6          	ld	x,#_regul_PI$L-10
 745  0170 cd0000        	call	c_ladd
 747  0173 ae0c          	ld	x,#high(L23)
 748  0175 bf00          	ld	c_x,x
 749  0177 ae0c          	ld	x,#low(L23)
 750  0179 cd0000        	call	c_xlcmp
 752  017c 253d          	jrult	L552
 753                     ; 186 			Newpi_32 = S32_MAX;	// Avoid IntTerm Overflow
 755  017e a6ff          	ld	a,#255
 756  0180 b7f5          	ld	_regul_PI$L-11,a
 757  0182 b7f4          	ld	_regul_PI$L-12,a
 758  0184 b7f3          	ld	_regul_PI$L-13,a
 759  0186 a67f          	ld	a,#127
 760  0188 b7f2          	ld	_regul_PI$L-14,a
 762  018a 2042          	jra	L152
 763                     ; 187 		else Newpi_32 = (VoltageIntegralTerm + Voltage_slip_s32); //  output
 767  018c               L342:
 768                     ; 189 	else if ((VoltageIntegralTerm < 0) && (Voltage_slip_s32 < 0))
 770  018c c60002        	ld	a,L3_VoltageIntegralTerm
 771  018f 2a2a          	jrpl	L552
 773  0191 b6f6          	ld	a,_regul_PI$L-10
 774  0193 2a26          	jrpl	L552
 775                     ; 191 		if (( (u32)VoltageIntegralTerm + (u32)Voltage_slip_s32 ) <= S32_MAX)
 777  0195 ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 778  0197 bf00          	ld	c_x,x
 779  0199 ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 780  019b cd0000        	call	c_xltor
 782  019e aef6          	ld	x,#_regul_PI$L-10
 783  01a0 cd0000        	call	c_ladd
 785  01a3 ae0c          	ld	x,#high(L23)
 786  01a5 bf00          	ld	c_x,x
 787  01a7 ae0c          	ld	x,#low(L23)
 788  01a9 cd0000        	call	c_xlcmp
 790  01ac 240d          	jruge	L552
 791                     ; 192 			Newpi_32 = S32_MIN;	// Avoid IntTerm Overflow
 793  01ae 4f            	clr	a
 794  01af b7f5          	ld	_regul_PI$L-11,a
 795  01b1 b7f4          	ld	_regul_PI$L-12,a
 796  01b3 b7f3          	ld	_regul_PI$L-13,a
 797  01b5 a680          	ld	a,#128
 798  01b7 b7f2          	ld	_regul_PI$L-14,a
 800  01b9 2013          	jra	L152
 801  01bb               L552:
 802                     ; 193 		else Newpi_32 = (VoltageIntegralTerm + Voltage_slip_s32); //  output
 806                     ; 197 		Newpi_32 = (VoltageIntegralTerm + Voltage_slip_s32); //  output 
 812  01bb ae02          	ld	x,#high(L3_VoltageIntegralTerm)
 813  01bd bf00          	ld	c_x,x
 814  01bf ae02          	ld	x,#low(L3_VoltageIntegralTerm)
 815  01c1 cd0000        	call	c_xltor
 816  01c4 aef6          	ld	x,#_regul_PI$L-10
 817  01c6 cd0000        	call	c_ladd
 818  01c9 aef2          	ld	x,#_regul_PI$L-14
 819  01cb cd0000        	call	c_rtol
 821  01ce               L152:
 822                     ; 202     NewPIoutput = (s16)( Newpi_32 /256);                                    
 824  01ce aef2          	ld	x,#_regul_PI$L-14
 825  01d0 cd0000        	call	c_ltor
 827  01d3 ae08          	ld	x,#high(L03)
 828  01d5 bf00          	ld	c_x,x
 829  01d7 ae08          	ld	x,#low(L03)
 830  01d9 cd0000        	call	c_xldiv
 832  01dc b603          	ld	a,c_lreg+3
 833  01de be02          	ld	x,c_lreg+2
 834  01e0 b7ed          	ld	_regul_PI$L-19,a
 835  01e2 bfec          	ld	_regul_PI$L-20,x
 836                     ; 205 if ( NewPIoutput < 0 )
 838  01e4 2a0b          	jrpl	L362
 839                     ; 207 	output = 0;
 841  01e6 3ff0          	clr	_regul_PI$L-16
 842  01e8 3ff1          	clr	_regul_PI$L-15
 843                     ; 208 	MinPiOut = TRUE;
 845  01ea a601          	ld	a,#1
 846  01ec c70000        	ld	L7_MinPiOut,a
 848  01ef 201f          	jra	L562
 849  01f1               L362:
 850                     ; 210 else if ( NewPIoutput > 1024 )
 852  01f1 a001          	sub	a,#1
 853  01f3 b6ec          	ld	a,_regul_PI$L-20
 854  01f5 a204          	sbc	a,#4
 855  01f7 2b0a          	jrmi	L762
 856                     ; 212 	output = 1024;
 858  01f9 a604          	ld	a,#4
 859  01fb b7f0          	ld	_regul_PI$L-16,a
 860  01fd 3ff1          	clr	_regul_PI$L-15
 861                     ; 213 	MaxPiOut = TRUE;  // Set ClampFlag if modulation reaches maximum value 
 863  01ff a601          	ld	a,#1
 865  0201 200a          	jp	LC003
 866  0203               L762:
 867                     ; 217 	output = NewPIoutput;
 869  0203 bff0          	ld	_regul_PI$L-16,x
 870  0205 b6ed          	ld	a,_regul_PI$L-19
 871  0207 b7f1          	ld	_regul_PI$L-15,a
 872                     ; 218 	MinPiOut = FALSE;
 874  0209 4f            	clr	a
 875  020a c70000        	ld	L7_MinPiOut,a
 876                     ; 219 	MaxPiOut = FALSE;
 878  020d               LC003:
 879  020d c70001        	ld	L5_MaxPiOut,a
 880  0210               L562:
 881                     ; 222 return (output);  // return PI output
 883  0210 b6f1          	ld	a,_regul_PI$L-15
 884  0212 bef0          	ld	x,_regul_PI$L-16
 887  0214 81            	ret	
 962                     	switch	.bss
 963  0000               L7_MinPiOut:
 964  0000 00            	ds.b	1
 965  0001               L5_MaxPiOut:
 966  0001 00            	ds.b	1
 967  0002               L3_VoltageIntegralTerm:
 968  0002 00000000      	ds.b	4
 969                     	xdef	_Adjust_INT_TERM_voltage
 970                     	xdef	_Adjust_INT_TERM_current
 971                     	xref	_Get_CurrentTargetSpeed
 972                     	xdef	_regul_PI
 973                     	xdef	_Period_To_Frequency
 974                     	xdef	_Init_PI
 975  0006               _Step_Z:
 976  0006 000000000000  	ds.b	12
 977                     	xdef	_Step_Z
 978                     	xref	_Kp
 979                     	xref	_Ki
 980                     	xref	_Freq_Motor
 981                     	xref.b	c_lreg
 982                     	xref.b	c_x
1002                     	xref	c_xlgadd
1003                     	xref	c_ltor
1004                     	xref	c_xlcmp
1005                     	xref	c_ladd
1006                     	xref	c_lmul
1007                     	xref	c_itol
1008                     	xref	c_xlglsh
1009                     	xref	c_rtoxl
1010                     	xref	c_xldiv
1011                     	xref	c_xltor
1012                     	xref	c_lgursh
1013                     	xref	c_ludv
1014                     	xref	c_rtol
1015                     	xref	c_uitol
1016                     	end

⌨️ 快捷键说明

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