📄 acmotor.ls
字号:
1 ; C Compiler for ST7 (COSMIC Software)
2 ; Generator V4.4a - 17 Dec 2001
3 ; Optimizer V4.2g - 21 Dec 2001
38 ; 66 void ACM_Init(void)
38 ; 67 {
39 switch .text
40 0000 _ACM_Init:
43 ; 69 MTC_InitPeripheral(); // Initialize peripheral for three phase PWM generation
45 0000 cd0000 call _MTC_InitPeripheral
47 ; 70 MTC_InitSineGen(); // Configure SW variables for sinewave generation
49 0003 cd0000 call _MTC_InitSineGen
51 ; 72 MTC_Set_ClockWise_Direction();
53 0006 cd0000 call _MTC_Set_ClockWise_Direction
55 ; 74 ART_SetSpeedRegPeriod(SAMPLING_TIME);
57 0009 a60a ld a,#10
59 ; 76 }
62 000b cc0000 jp _ART_SetSpeedRegPeriod
114 ; 91 u8 ACM_VoltageMaxAllowed(u16 StatorFrequency)
114 ; 92 {
115 switch .text
117 xref.b _ACM_VoltageMaxAllowed$L
118 000e _ACM_VoltageMaxAllowed:
120 000e b701 ld _ACM_VoltageMaxAllowed$L+1,a
121 0010 bf00 ld _ACM_VoltageMaxAllowed$L,x
123 ; 95 if ( StatorFrequency <= VF_LOWFREQ_LIMIT )
125 0012 a0c9 sub a,#201
126 0014 9f ld a,x
127 0015 a200 sbc a,#0
128 0017 2403 jruge L37
129 ; 97 VoltageMax = V_MIN;
131 0019 a61e ld a,#30
134 001b 81 ret
135 001c L37:
136 ; 99 } else if ( StatorFrequency >= VF_HIGHFREQ_LIMIT )
138 001c b601 ld a,_ACM_VoltageMaxAllowed$L+1
139 001e a0e8 sub a,#232
140 0020 b600 ld a,_ACM_VoltageMaxAllowed$L
141 0022 a203 sbc a,#3
142 0024 2503 jrult L77
143 ; 101 VoltageMax = V_MAX;
145 0026 a6ff ld a,#255
148 0028 81 ret
149 0029 L77:
150 ; 105 Buffer = (u16)(StatorFrequency * VF_COEFF) - VF_OFFSET;
152 0029 b601 ld a,_ACM_VoltageMaxAllowed$L+1
153 002b 3f00 clr c_y
154 002d 90ae48 ld y,#72
155 0030 cd0000 call c_imul
157 0033 a040 sub a,#64
158 0035 88 push a
159 0036 9f ld a,x
160 0037 a238 sbc a,#56
161 0039 b7fd ld _ACM_VoltageMaxAllowed$L-3,a
162 003b 84 pop a
163 ; 106 VoltageMax = (u8)(V_MIN + (u8)((u16)Buffer / (u16)256));
165 003c b6fd ld a,_ACM_VoltageMaxAllowed$L-3
166 003e ab1e add a,#30
167 ; 111 return ( VoltageMax );
171 0040 81 ret
228 ; 123 void ACM_InitSoftStart(u16 StatorFreq)
228 ; 124 {
229 switch .text
231 xref.b _ACM_InitSoftStart$L
232 0041 _ACM_InitSoftStart:
234 0041 b701 ld _ACM_InitSoftStart$L+1,a
235 0043 bf00 ld _ACM_InitSoftStart$L,x
237 ; 125 u8 VoltageMax = ACM_VoltageMaxAllowed( StatorFreq );
239 0045 adc7 call _ACM_VoltageMaxAllowed
241 0047 b7fd ld _ACM_InitSoftStart$L-3,a
242 ; 129 MTC_InitTachoMeasure( );
244 0049 cd0000 call _MTC_InitTachoMeasure
246 ; 130 MTC_UpdateSine(0, StatorFreq);
248 004c be00 ld x,_ACM_InitSoftStart$L
249 004e bf01 ld _MTC_UpdateSine$L+1,x
250 0050 b601 ld a,_ACM_InitSoftStart$L+1
251 0052 b702 ld _MTC_UpdateSine$L+2,a
252 0054 4f clr a
253 0055 cd0000 call _MTC_UpdateSine
255 ; 131 MTC_EnableMCOutputs(); // PWM is present on MCO outputs
257 0058 cd0000 call _MTC_EnableMCOutputs
259 ; 133 TimeUnit = START_TIMEOUT / VoltageMax;
261 005b a608 ld a,#8
262 005d ae07 ld x,#7
263 005f 90befd ld y,_ACM_InitSoftStart$L-3
264 0062 3f00 clr c_y
265 0064 cd0000 call c_udiv
267 0067 b7ff ld _ACM_InitSoftStart$L-1,a
268 0069 bffe ld _ACM_InitSoftStart$L-2,x
269 ; 134 if ( TimeUnit == 0 )
271 006b bafe or a,_ACM_InitSoftStart$L-2
272 006d 2607 jrne L131
273 ; 136 TimeUnit = 1; /* Avoid applying full voltage directly */
275 006f a601 ld a,#1
276 0071 b7ff ld _ACM_InitSoftStart$L-1,a
277 0073 5f clr x
278 0074 bffe ld _ACM_InitSoftStart$L-2,x
279 0076 L131:
280 ; 138 ART_Set_TimeInMs(TimeUnit); // Set soft start slope
282 0076 b6ff ld a,_ACM_InitSoftStart$L-1
283 0078 cd0000 call _ART_Set_TimeInMs
285 ; 140 ART_SetSequenceDuration(START_TIMEOUT + EXTRA_TIMEOUT);
287 007b a6f0 ld a,#240
288 007d ae0a ld x,#10
290 ; 142 }
293 007f cc0000 jp _ART_SetSequenceDuration
390 ; 168 StartStatus_t ACM_SoftStart(u16 MinRotorFreq)
390 ; 169 {
391 switch .text
393 xref.b _ACM_SoftStart$L
394 0082 _ACM_SoftStart:
396 0082 b701 ld _ACM_SoftStart$L+1,a
397 0084 bf00 ld _ACM_SoftStart$L,x
399 ; 174 StatorFreq = MTC_GetStatorFreq();
401 0086 cd0000 call _MTC_GetStatorFreq
403 0089 b7ff ld _ACM_SoftStart$L-1,a
404 008b bffe ld _ACM_SoftStart$L-2,x
405 ; 175 CurrentVoltage = MTC_GetVoltage();
407 008d cd0000 call _MTC_GetVoltage
409 0090 b7fd ld _ACM_SoftStart$L-3,a
410 ; 176 VoltageMax = ACM_VoltageMaxAllowed( StatorFreq );
412 0092 b6ff ld a,_ACM_SoftStart$L-1
413 0094 befe ld x,_ACM_SoftStart$L-2
414 0096 cd000e call _ACM_VoltageMaxAllowed
416 0099 b7fc ld _ACM_SoftStart$L-4,a
417 ; 178 if ( MinRotorFreq >= StatorFreq )
419 009b b601 ld a,_ACM_SoftStart$L+1
420 009d b0ff sub a,_ACM_SoftStart$L-1
421 009f b600 ld a,_ACM_SoftStart$L
422 00a1 b2fe sbc a,_ACM_SoftStart$L-2
423 00a3 2503 jrult L771
424 ; 180 return ( START_FAIL ); // Input parameter is not correct
426 00a5 a602 ld a,#2
429 00a7 81 ret
430 00a8 L771:
431 ; 183 if (MTC_ValidSpeedInfo(MinRotorFreq))
433 00a8 b601 ld a,_ACM_SoftStart$L+1
434 00aa be00 ld x,_ACM_SoftStart$L
435 00ac cd0000 call _MTC_ValidSpeedInfo
437 00af 4d tnz a
438 00b0 2706 jreq L102
439 ; 185 MTC_StartTachoFiltering();
441 00b2 cd0000 call _MTC_StartTachoFiltering
443 ; 186 return (START_OK); // Soft start completed successfully
445 00b5 a601 ld a,#1
448 00b7 81 ret
449 00b8 L102:
450 ; 190 if (ART_IsSequenceCompleted())
452 00b8 cd0000 call _ART_IsSequenceCompleted
454 00bb 4d tnz a
455 00bc 2706 jreq L502
456 ; 192 MTC_DisableMCOutputs(); // PWM is disabled on MCO outputs
458 00be cd0000 call _MTC_DisableMCOutputs
460 ; 193 return (START_FAIL); // Motor not correctly started after time out period
462 00c1 a602 ld a,#2
465 00c3 81 ret
466 00c4 L502:
467 ; 198 if ( (CurrentVoltage < VoltageMax) && (ART_Is_TimeInMsElapsed()) )
469 00c4 b6fd ld a,_ACM_SoftStart$L-3
470 00c6 b1fc cp a,_ACM_SoftStart$L-4
471 00c8 2415 jruge L112
473 00ca cd0000 call _ART_Is_TimeInMsElapsed
475 00cd 4d tnz a
476 00ce 270f jreq L112
477 ; 200 CurrentVoltage++;
479 00d0 3cfd inc _ACM_SoftStart$L-3
480 ; 201 MTC_UpdateSine(CurrentVoltage, StatorFreq);
482 00d2 befe ld x,_ACM_SoftStart$L-2
483 00d4 bf01 ld _MTC_UpdateSine$L+1,x
484 00d6 b6ff ld a,_ACM_SoftStart$L-1
485 00d8 b702 ld _MTC_UpdateSine$L+2,a
486 00da b6fd ld a,_ACM_SoftStart$L-3
487 00dc cd0000 call _MTC_UpdateSine
489 00df L112:
490 ; 204 return (START_ONGOING);
492 00df 4f clr a
495 00e0 81 ret
532 ; 217 void ACM_InitSoftStart_OL(u16 StatorFreq)
532 ; 218 {
533 switch .text
535 xref.b _ACM_InitSoftStart_OL$L
536 00e1 _ACM_InitSoftStart_OL:
539 ; 221 MTC_UpdateSine(0, StatorFreq);
541 00e1 b702 ld _MTC_UpdateSine$L+2,a
542 00e3 bf01 ld _MTC_UpdateSine$L+1,x
543 00e5 4f clr a
544 00e6 cd0000 call _MTC_UpdateSine
546 ; 222 MTC_EnableMCOutputs(); // PWM is present on MCO outputs
548 00e9 cd0000 call _MTC_EnableMCOutputs
550 ; 230 ART_Set_TimeInMs(VOLT_SLEWRATE); // Set soft start slope
552 00ec 5f clr x
553 00ed a60a ld a,#10
555 ; 233 }
558 00ef cc0000 jp _ART_Set_TimeInMs
605 ; 252 BOOL ACM_SoftStartOL(u8 TargetVoltage)
605 ; 253 {
606 switch .text
608 xref.b _ACM_SoftStartOL$L
609 00f2 _ACM_SoftStartOL:
611 00f2 b700 ld _ACM_SoftStartOL$L,a
613 ; 256 CurrentVoltage = MTC_GetVoltage();
615 00f4 cd0000 call _MTC_GetVoltage
617 00f7 b7ff ld _ACM_SoftStartOL$L-1,a
618 ; 257 if (MTC_GetVoltage() < TargetVoltage)
620 00f9 cd0000 call _MTC_GetVoltage
622 00fc b100 cp a,_ACM_SoftStartOL$L
623 00fe 2416 jruge L352
624 ; 259 if ( ART_Is_TimeInMsElapsed() )
626 0100 cd0000 call _ART_Is_TimeInMsElapsed
628 0103 4d tnz a
629 0104 270e jreq L552
630 ; 261 CurrentVoltage++;
632 0106 3cff inc _ACM_SoftStartOL$L-1
633 ; 262 MTC_UpdateSine(CurrentVoltage, MTC_GetStatorFreq());
635 0108 cd0000 call _MTC_GetStatorFreq
637 010b b702 ld _MTC_UpdateSine$L+2,a
638 010d bf01 ld _MTC_UpdateSine$L+1,x
639 010f b6ff ld a,_ACM_SoftStartOL$L-1
640 0111 cd0000 call _MTC_UpdateSine
642 0114 L552:
643 ; 264 return (FALSE);
645 0114 4f clr a
648 0115 81 ret
649 0116 L352:
650 ; 268 ART_Set_TimeInMs(SLEW_LIMIT);
652 0116 5f clr x
653 0117 a614 ld a,#20
654 0119 cd0000 call _ART_Set_TimeInMs
656 ; 269 return (TRUE);
658 011c a601 ld a,#1
661 011e 81 ret
728 ; 280 void ACM_SustainSpeed(u16 Time)
728 ; 281 {
729 switch .text
731 xref.b _ACM_SustainSpeed$L
732 011f _ACM_SustainSpeed:
734 011f b701 ld _ACM_SustainSpeed$L+1,a
735 0121 bf00 ld _ACM_SustainSpeed$L,x
737 ; 282 u16 StatorFreq = MTC_GetStatorFreq();
739 0123 cd0000 call _MTC_GetStatorFreq
741 0126 b7ff ld _ACM_SustainSpeed$L-1,a
742 0128 bffe ld _ACM_SustainSpeed$L-2,x
743 ; 284 ART_Set_TimeInMs(Time);
745 012a b601 ld a,_ACM_SustainSpeed$L+1
746 012c be00 ld x,_ACM_SustainSpeed$L
747 012e cd0000 call _ART_Set_TimeInMs
750 0131 2021 jra L513
751 0133 L313:
752 ; 288 if ( ART_IsRegPeriodElapsed() ) // Do periodically the regulation
754 0133 cd0000 call _ART_IsRegPeriodElapsed
756 0136 4d tnz a
757 0137 271b jreq L513
758 ; 292 OptimumSlip = ACM_GetOptimumSlip( StatorFreq );
760 0139 b6ff ld a,_ACM_SustainSpeed$L-1
761 013b befe ld x,_ACM_SustainSpeed$L-2
762 013d cd03b6 call _ACM_GetOptimumSlip
764 0140 b7fc ld _ACM_SustainSpeed$L-4,a
765 ; 293 NewVoltage = ACM_SlipRegulation( OptimumSlip );
767 0142 cd020b call _ACM_SlipRegulation
769 0145 b7fd ld _ACM_SustainSpeed$L-3,a
770 ; 295 MTC_UpdateSine(NewVoltage, StatorFreq);
772 0147 befe ld x,_ACM_SustainSpeed$L-2
773 0149 bf01 ld _MTC_UpdateSine$L+1,x
774 014b b6ff ld a,_ACM_SustainSpeed$L-1
775 014d b702 ld _MTC_UpdateSine$L+2,a
776 014f b6fd ld a,_ACM_SustainSpeed$L-3
777 0151 cd0000 call _MTC_UpdateSine
779 0154 L513:
780 ; 286 while ( !ART_Is_TimeInMsElapsed() ) // This defines routine duration
782 0154 cd0000 call _ART_Is_TimeInMsElapsed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -