用软件PWM怎么样做到恒压充电啊!这是我现在做的,想不出来啊!
用单片机的软件PWM怎么样控制mos的导通频率,即做到定频率,变duty的方波输出,来做到恒压啊,就像3842或者3843一样,当电压升高,就缩duty;当电压下降,就升duty!!!
全部回复(116)
正序查看
倒序查看
现在还没有回复呢,说说你的想法
@vssv
9454的PWM挺好用,不用外部晶振就可以做到40KHzPID算法控制,我没使用中断PWM_Init;fosc/1,reloadfrom8bitcounter,Disableinterrupt,ldPWMCON,#11001001bldPWMDATA,#04hret
;-------------------------------------------------------------
;
PWM_TurnOn
and P0CONH, #11001111b
or P0CONH, #00010000b
or PWMCON, #(PWMCON_CLEAR | PWMCON_START)
ret
;-------------------------------------------------------------
;
PWM_TurnOff
and PWMCON, #~(PWMCON_START)
and P0CONH, #11001111b
or P0CONH, #00100000b
and P0DATA, #10111111b
ld P0, P0DATA
ret
;
PWM_TurnOn
and P0CONH, #11001111b
or P0CONH, #00010000b
or PWMCON, #(PWMCON_CLEAR | PWMCON_START)
ret
;-------------------------------------------------------------
;
PWM_TurnOff
and PWMCON, #~(PWMCON_START)
and P0CONH, #11001111b
or P0CONH, #00100000b
and P0DATA, #10111111b
ld P0, P0DATA
ret
0
回复
提示
@vssv
;-------------------------------------------------------------;PWM_TurnOnandP0CONH,#11001111borP0CONH,#00010000borPWMCON,#(PWMCON_CLEAR|PWMCON_START)ret;-------------------------------------------------------------;PWM_TurnOffandPWMCON,#~(PWMCON_START)andP0CONH,#11001111borP0CONH,#00100000bandP0DATA,#10111111bldP0,P0DATAret
如果你不开中断的话,你把这个程序放在什么地方???
不开中断的意思就是说在RESET的时候不对PWMCON和PWMDATA赋值吗???
你能解释一下你括号里面是什么意思吗???那我怎么根据电压的变化来调整占空比的大小啊?
不开中断的意思就是说在RESET的时候不对PWMCON和PWMDATA赋值吗???
你能解释一下你括号里面是什么意思吗???那我怎么根据电压的变化来调整占空比的大小啊?
0
回复
提示
@vssv
;-------------------------------------------------------------;PWM_TurnOnandP0CONH,#11001111borP0CONH,#00010000borPWMCON,#(PWMCON_CLEAR|PWMCON_START)ret;-------------------------------------------------------------;PWM_TurnOffandPWMCON,#~(PWMCON_START)andP0CONH,#11001111borP0CONH,#00100000bandP0DATA,#10111111bldP0,P0DATAret
不管怎么样,对你的无私帮助我表示深深的感谢!希望以后能更好的交流,我的邮箱是ck4221982@yahoo.com.cn!
0
回复
提示
@vssv
;-------------------------------------------------------------;PWM_TurnOnandP0CONH,#11001111borP0CONH,#00010000borPWMCON,#(PWMCON_CLEAR|PWMCON_START)ret;-------------------------------------------------------------;PWM_TurnOffandPWMCON,#~(PWMCON_START)andP0CONH,#11001111borP0CONH,#00100000bandP0DATA,#10111111bldP0,P0DATAret
40khz是指频率还是精度(粒度)??
0
回复
提示
@vssv
;-------------------------------------------------------------;PWM_TurnOnandP0CONH,#11001111borP0CONH,#00010000borPWMCON,#(PWMCON_CLEAR|PWMCON_START)ret;-------------------------------------------------------------;PWM_TurnOffandPWMCON,#~(PWMCON_START)andP0CONH,#11001111borP0CONH,#00100000bandP0DATA,#10111111bldP0,P0DATAret
我想将两个A/D口的电压相减,用得到的值的大小作为一个条件!当条件为真时,即FLAG为51h时,才执行另外程序,否则不执行!但是加上这个程序后,不管任何情况下,另外一个程序都会执行!不知道这个条件程序执行了没有,谢谢帮我看看!
LD Acc1, #1 ; 1th channel
LD Acc0, #6 ; 6 sample times
CALL AdcConvert
LD Acc0, #6 ; 6 adjust number
CALL AdcDataAdjust
CALL AverageValue
LD CellVoltageL, AverageValueL
LD CellVoltageH, AverageValueH
LD Acc9, CellVoltageL
LD Acc10, CellVoltageH
;---------------
LD Acc1, #0 ; 0th channel
LD Acc0, #6 ; 6 sample times
CALL AdcConvert
LD Acc0, #6 ; 6 adjust number
CALL AdcDataAdjust
CALL AverageValue
LD CellVoltageL, AverageValueL
LD CellVoltageH, AverageValueH
LD Acc7, CellVoltageL
LD Acc8, CellVoltageH
SUB Acc9, Acc7
SBC Acc10, Acc8
SUB Acc9, #>41 ; 0.2v
SBC Acc10, #<41
JR ULT, CJV_Down_0v2
INC Counter_Up_0v2
CP Counter_Up_0v2,#2 ;2*0.5s
JR ULT, DCC_Exit
LD Counter_OutputUp, #51h
JR CJV_Exit
CJV_Down_0v2:
CLR Counter_OutputUp
CLR Counter_Up_0v2
CJV_Exit:
RET
LD Acc1, #1 ; 1th channel
LD Acc0, #6 ; 6 sample times
CALL AdcConvert
LD Acc0, #6 ; 6 adjust number
CALL AdcDataAdjust
CALL AverageValue
LD CellVoltageL, AverageValueL
LD CellVoltageH, AverageValueH
LD Acc9, CellVoltageL
LD Acc10, CellVoltageH
;---------------
LD Acc1, #0 ; 0th channel
LD Acc0, #6 ; 6 sample times
CALL AdcConvert
LD Acc0, #6 ; 6 adjust number
CALL AdcDataAdjust
CALL AverageValue
LD CellVoltageL, AverageValueL
LD CellVoltageH, AverageValueH
LD Acc7, CellVoltageL
LD Acc8, CellVoltageH
SUB Acc9, Acc7
SBC Acc10, Acc8
SUB Acc9, #>41 ; 0.2v
SBC Acc10, #<41
JR ULT, CJV_Down_0v2
INC Counter_Up_0v2
CP Counter_Up_0v2,#2 ;2*0.5s
JR ULT, DCC_Exit
LD Counter_OutputUp, #51h
JR CJV_Exit
CJV_Down_0v2:
CLR Counter_OutputUp
CLR Counter_Up_0v2
CJV_Exit:
RET
0
回复
提示