PDA

View Full Version : Space vector PWM and ASM translation



pxidr84
- 6th October 2014, 08:46
Hello,

I'm implementing Space Vector PWM in PBP in order to control with variable speed an 3-phase AC motor.

The base of my work is the AN955 from Microchip.
http://ww1.microchip.com/downloads/en/AppNotes/00955a.pdf

In order to modify the output frequency, you have to modify the speed of the rotating vector Vs. (page 3)

So a "Degree_constant" is pre-defined (in my case 39)
The "Required_motor_speed" is in my case 50
So the "Vector_update_step_size" is 39*50=1950
And "Vector_angle"="Vector_angle"+1950

This is explained in page 8.

But I don't really understand the source code provided, especially that "Carry" thing (in ASM) :


;************************************************* ************************************
;ISR FOR VECTOR ROTATION AND PHASE PWM DUTY CYCLE UPDATE
;************************************************* ************************************
ISR_PWM
BCF PIR3,PTIF ;CLEAR PWM TIMER INTERUPT FLAG
BTFSS ACSVM_FLAGS_1,FWD_REV
BRA FIND_VECTOR_ANGLE_FOR_REV_DIR
MOVFF PARAMETER_BUFFER+LOC_UPDATE_STEP_LSB,WREG ;INCREMENT VECTOR BY UPDATE STEP SIZE
ADDWF VECTOR_ANGLE_LSB,F
MOVFF PARAMETER_BUFFER+LOC_UPDATE_STEP_MSB,WREG
ADDWFC VECTOR_ANGLE_MSB,F
BNC READ_TIME_TB_COUNT ;DUE TO VECTOR INCREMENT, FOR CARRY = 0, CALCULATE CORRESPONDING TIME VALUES
INCF SECTOR_NO,F ;DUE TO VECTOR INCREMENT, FOR CARRY = 1, INCREMENT SECTOR NO
BRA CHECK_SECTOR_OF
FIND_VECTOR_ANGLE_FOR_REV_DIR
MOVFF PARAMETER_BUFFER+LOC_UPDATE_STEP_LSB,WREG
SUBWF VECTOR_ANGLE_LSB,F
MOVFF PARAMETER_BUFFER+LOC_UPDATE_STEP_MSB,WREG
SUBWFB VECTOR_ANGLE_MSB,F
BC READ_TIME_TB_COUNT
INCF SECTOR_NO,F
CHECK_SECTOR_OF
MOVLW 0X05
CPFSGT SECTOR_NO
BRA READ_TIME_TB_COUNT
CLRF SECTOR_NO ;FOR SECTOR NO. ROLL OVER, REINITIALIZE SECTOR NO. TO 0
READ_TIME_TB_COUNT
[...]

Can anyone would translate this ASM part of code in something more "PBPish"? :p

Thanks

pxidr84
- 8th October 2014, 08:40
Finally found myself the carry problem... just to have to read the STATUS system register.

if STATUS.0=%1 then
@ incf _sector
STATUS.0=%0
endif