BASIC4MCU | 모터 | BLDC모터 | 쿼드콥터 변속기 - 무늬만 있는 과전류 에러
페이지 정보
작성자 키트 작성일2017-09-05 15:04 조회911회 댓글0건본문
evaluate_sys_state:
cbr flags1, (1<<EVAL_SYS_STATE) ;//Rd,K // Clear Bit(s) in Register // Rd←Rd^(0xFF-K)
sbrs flags0, T1OVFL_FLAG ;//Rr,b // Skip if Bit in Register is Set // if(Rr(b)=1)PC←PC+2or3
rjmp eval_sys_s99; do it not more often as every 65탎
cbr flags0, (1<<T1OVFL_FLAG) ;//Rd,K // Clear Bit(s) in Register // Rd←Rd^(0xFF-K)rjmp eval_sys_s99 ; disabled ;-)
; control current
eval_sys_i: rjmp eval_sys_i_okmov temp1, current_err ;//Rd,Rr // Move Between Registers // Rd←Rr
cpi temp1, CURRENT_ERR_MAX ;//Rd,K // Compare Register with Immediate // Rd-K
brcc panic_exit ;//k // Branch if Carry Cleared // if(C=0)PC←PC+k+1
inc current_err ;//Rd // Increment // Rd←Rd+1
rjmp eval_sys_ubeval_sys_i_ok: tst current_err ;//Rd // Test for Zero or Minus // Rd←Rd&Rd
breq eval_sys_ub ;//k // Branch if Equal // if(Z=1)PC←PC+k+1
dec current_err ;//Rd // Decrement // Rd←Rd?1; control voltage
eval_sys_ub: rjmp eval_sys_ub_okmov temp1, sys_control ;//Rd,Rr // Move Between Registers // Rd←Rr
cpi temp1, POWER_RANGE ;//Rd,K // Compare Register with Immediate // Rd-K
brcc eval_sys_s99 ;//k // Branch if Carry Cleared // if(C=0)PC←PC+k+1
inc sys_control ;//Rd // Increment // Rd←Rd+1
rjmp eval_sys_s99eval_sys_ub_ok: tst sys_control ;//Rd // Test for Zero or Minus // Rd←Rd&Rd
breq eval_sys_s99 ;//k // Branch if Equal // if(Z=1)PC←PC+k+1
dec sys_control ;//Rd // Decrement // Rd←Rd?1
eval_sys_s99: retpanic_exit: ; !!!!!! OVERCURRENT !!!!!!!!
cli
rjmp reset
코드가 좀 복잡하죠?
제일 아래에 있는 적색 문구를 보고서 과전류 검출을 하고 있구나...생각을 했는데...
evaluate_sys_state:
cbr flags1, (1<<EVAL_SYS_STATE) ;//Rd,K // Clear Bit(s) in Register // Rd←Rd^(0xFF-K)
sbrs flags0, T1OVFL_FLAG ;//Rr,b // Skip if Bit in Register is Set // if(Rr(b)=1)PC←PC+2or3
rjmp eval_sys_s99; do it not more often as every 65탎
cbr flags0, (1<<T1OVFL_FLAG) ;//Rd,K // Clear Bit(s) in Register // Rd←Rd^(0xFF-K)rjmp eval_sys_s99 ; disabled ;-)
; control current
eval_sys_i: rjmp eval_sys_i_okmov temp1, current_err ;//Rd,Rr // Move Between Registers // Rd←Rr
cpi temp1, CURRENT_ERR_MAX ;//Rd,K // Compare Register with Immediate // Rd-K
brcc panic_exit ;//k // Branch if Carry Cleared // if(C=0)PC←PC+k+1
inc current_err ;//Rd // Increment // Rd←Rd+1
rjmp eval_sys_ubeval_sys_i_ok: tst current_err ;//Rd // Test for Zero or Minus // Rd←Rd&Rd
breq eval_sys_ub ;//k // Branch if Equal // if(Z=1)PC←PC+k+1
dec current_err ;//Rd // Decrement // Rd←Rd?1; control voltage
eval_sys_ub: rjmp eval_sys_ub_okmov temp1, sys_control ;//Rd,Rr // Move Between Registers // Rd←Rr
cpi temp1, POWER_RANGE ;//Rd,K // Compare Register with Immediate // Rd-K
brcc eval_sys_s99 ;//k // Branch if Carry Cleared // if(C=0)PC←PC+k+1
inc sys_control ;//Rd // Increment // Rd←Rd+1
rjmp eval_sys_s99eval_sys_ub_ok: tst sys_control ;//Rd // Test for Zero or Minus // Rd←Rd&Rd
breq eval_sys_s99 ;//k // Branch if Equal // if(Z=1)PC←PC+k+1
dec sys_control ;//Rd // Decrement // Rd←Rd?1
eval_sys_s99: retpanic_exit: ; !!!!!! OVERCURRENT !!!!!!!!
cli
rjmp reset
과전류 코드도 엉터리지만 함수 들어가자마자 바로 아래로 번지 점프해서 빠져 나가버립니다. ㅋ~
void evaluate_sys_state(){
EVAL_SYS_STATE_flag=0;
if(T1OVFL_flag==0)return;
T1OVFL_flag=0; // do it not more often as every 65탎
return; // // disabled //-)
//
if(current_err>=CURRENT_ERR_MAX){ cli(); goto reset } // !!!!!! OVERCURRENT !!!!!!!!
//
if(sys_control<POWER_RANGE)sys_control++; // control voltage
}코드가 엉터리라서 c로 변환이 안됩니다.;;;^^
전류 뿐만 아니라 전압 감시도 하지 않고 있습니다.
전류 및 전압 관련 코드가 들어있긴 하지만 쓰레기 코드입니다.
댓글 0
조회수 911등록된 댓글이 없습니다.