zht9961020 发表于 2008-6-16 11:10:05

我的无刷电调(原理图+程序)

用的是德国人的开源资料,启动、调速都还可以,但有两个子程序我一直没看太明白(calculate_next_timing_values和set_new_duty),
希望高手能指点一下。
点击此处下载 ourdev_312762.rar(文件大小:77K) (原文件名:blmc.rar)
PCB:http://cache.amobbs.com/bbs_upload782111/files_10/ourdev_312822.JPG
(原文件名:blmc.JPG)

zht9961020 发表于 2008-6-16 12:05:18

.if RC_PULS == 1
evaluate_rc_puls:
                sbrs        state1, RC_PULS_UPDATED
                rjmp        eval_rc_p90
                mov        temp1, new_rcpuls_l
                mov        temp2, new_rcpuls_h
                cbr        state1, (1<<RC_PULS_UPDATED) ; rc impuls value is read out
                subi        temp1, low(MIN_RC_PULS)
                sbci        temp2, high (MIN_RC_PULS)
                brcc        eval_rc_p00
                clr        temp1
                clr        temp2
eval_rc_p00:        lsr        temp2
                ror        temp1
                lsr        temp2
                ror        temp1
                lsr        temp2
                ror        temp1
                mov        temp3, temp1               
                subi        temp1, low(POWER_RANGE)
                sbci        temp2, high (POWER_RANGE)
                brcs        eval_rc_p10
                ldi        temp3, low(POWER_RANGE)
eval_rc_p10:        mov        ZH, temp3
eval_rc_p90:        ret
.endif
这段控制信号计算程序也不太懂,汇编的计算真麻烦啊

nomoneyiv 发表于 2008-6-16 12:09:33

多少K的PWM频率呀,楼主?

zht9961020 发表于 2008-6-16 12:12:15

按我的理解应该是10k,用定时器0中断来控制pwm,周期100us

weihua 发表于 2008-6-16 14:35:12

楼主的PCB,SCH能发一份给我吗weihua@e-lan.cn

feng_matrix 发表于 2008-6-16 15:06:05

8位单片机做16位变量计算,每次操作两个寄存器,加减都要考虑进位
除法尽量用移位实现(2的整数次方),设计算法尽量非负

love12345 发表于 2008-6-16 15:51:43

这个程序不是用硬件的pwm吧. 与哪个修改towerpro电调的程序差不多.

zht9961020 发表于 2008-6-16 16:01:32

请问【5楼】 feng_matrix :
calculate_next_timing_values:
                rcall        tcnt1_to_temp
                ldi        temp4, EXT0_EN                ; ext0int enable
                out        GIMSK, temp4                ; enable ext0int
                sts        tcnt1_sav_l, temp1
                sts        tcnt1_sav_h, temp2
                sts        tcnt1_sav_x, temp3
                lds        YL, last_tcnt1_l
                lds        YH, last_tcnt1_h
                lds        ZL, last_tcnt1_x
                sub        temp1, YL
                sbc        temp2, YH
                sbc        temp3, ZL
               
; now temp-registers hold the time of 360° - means: 6 commutations

; each commutation is divided in two stages:
; a) wait for expected zero-crossing
; b) wait less than 30° and commutate

; divide by 12 would result in 0° timing ( 30° )
; ***   earlier zero-crossing as it is expected, cannot be detected
; ***   switch to next commutation not less than 30° - means: stall

; divide by 16 would result in 7.5 degree timing ( 30.0°-22.5° ), works !
; ***   start to look for zero-crossing 7.5° earlier than it is expected
; ***   switch to next commutation 7.5° earlier than 30°
; 7.5° value can be changed when setting <wt_FET_switch>

                ldi        temp4, 4                ; divide by 16
calc_OCT1_d16:        lsr        temp3
                ror        temp2
                ror        temp1
                dec        temp4
                brne        calc_OCT1_d16

                mov        YL, temp1
                mov        YH, temp2
                mov        ZL, temp3

; ZL should be zero - if not, use max value
                tst        temp3
                brne        calc_OCT1_res
                sts        OCT1_high, temp2
                tst        temp2
                breq        calc_OCT1_of10
                subi        temp1, low (defaultTIMEOUT)
                sbci        temp2, high(defaultTIMEOUT)
                brcc        calc_OCT1_res
                rjmp        calc_OCT1_of80
calc_OCT1_of10:        mov        temp2, tcnt0_power_on
                asr        temp2
                asr        temp2                ; (e7-ff)
                subi        temp2, 0xca        ; 9c->1b and ff->33
               
; the maximum of allowed RPM is dependent from PWM
; therefore 134000 RPM (refered to 6 commutations each) is reached now
;temp2        rpm (6 Kom.)        rpm Achse
;0x1b        138888                23148                ; full power
;0x33       73529                12254                ; lowest power
                   cp        temp1, temp2
                brcc        calc_OCT1_of80
calc_OCT1_res:        rcall        set_default_timeout
                rjmp        calc_OCT1_of90
calc_OCT1_of80:
                sts        wt_comp_scan_l, YL        ; capture compare offset for time from switch to comparator scanning
                sts        wt_comp_scan_h, YH

                sts        wt_FET_switch_l, YL        ; capture compare offset for time from zero-crossing to switch
                sts        wt_FET_switch_h, YH
calc_OCT1_of90:        lds        temp1, tcnt1_sav_l
                lds        temp2, tcnt1_sav_h
                lds        temp3, tcnt1_sav_x
                sts        last_tcnt1_l, temp1
                sts        last_tcnt1_h, temp2
                sts        last_tcnt1_x, temp3
                ret
这段程序是从T1中得到转一周360度(6次换相)的时间,然后除以16得到延迟22.5度的时间,一下的部分有什么用呢
; ZL should be zero - if not, use max value
                tst        temp3
                brne        calc_OCT1_res
                sts        OCT1_high, temp2
                tst        temp2
                breq        calc_OCT1_of10
                subi        temp1, low (defaultTIMEOUT)
                sbci        temp2, high(defaultTIMEOUT)
                brcc        calc_OCT1_res
                rjmp        calc_OCT1_of80
calc_OCT1_of10:        mov        temp2, tcnt0_power_on
                asr        temp2
                asr        temp2                ; (e7-ff)
                subi        temp2, 0xca        ; 9c->1b and ff->33
               
; the maximum of allowed RPM is dependent from PWM
; therefore 134000 RPM (refered to 6 commutations each) is reached now
;temp2        rpm (6 Kom.)        rpm Achse
;0x1b        138888                23148                ; full power
;0x33       73529                12254                ; lowest power

zht9961020 发表于 2008-6-16 16:02:38

【6楼】 (敏感词0386)123

不是硬件的pwm

feng_matrix 发表于 2008-6-16 16:15:21

to : 【7楼】 zht9961020

呵呵,我只是讲了两个原则,并未看懂你的程序
我的电调没做延时,电角度提前30度换向,这样程序最精简

zht9961020 发表于 2008-6-16 16:24:45

我按自己的理解用C重写了一遍,也尝试了检测到过零后直接换相,但就是不好使,郁闷中

nomoneyiv 发表于 2008-6-16 17:05:24

顶技术讨论帖!

likedev 发表于 2008-6-16 17:10:41

支持多大电流啊!!

zht9961020 发表于 2008-6-16 17:20:12

最大电流3A,电压2.7~5.5V

zkymcu 发表于 2010-3-4 13:58:00

能传一份原理图和程序给我吗?
来好好的学习一下.

qbh319 发表于 2010-3-20 10:10:12

想学电调LZ能否公开资料呢

215661599 发表于 2011-7-12 12:43:13

xinmoqingxian 发表于 2011-9-14 17:11:50

楼主能传一份电调的原理图和你用的资料吗?大家一起学习学习,小弟在此多谢了!邮箱928183452@qq.com

codenull 发表于 2011-9-16 20:03:24

回复【18楼】xinmoqingxian
-----------------------------------------------------------------------

同求原理图和PCB,邮箱zengyong5868@126.com

codenull 发表于 2011-9-16 20:04:30

如果有做好的板子就更好了

lovewwy 发表于 2011-9-16 20:11:18

mark.

danxie 发表于 2011-9-17 14:45:30

小电流换向调速可以使用三极管直接驱动,要是用MOS管就复杂多了。

zjqiufeng 发表于 2011-11-10 09:54:42

先看资料后面再交流,mark!

acef3c 发表于 2011-12-12 22:55:30

mark

without 发表于 2011-12-16 21:24:36

学习了,谢谢楼主。

yue435 发表于 2012-1-31 20:06:09

学习了,谢谢楼主!~~~

lwz258 发表于 2012-5-17 17:56:01

其实我想找一些基本的知识

就是一枪 发表于 2012-7-16 17:27:37

同求楼主的sch电路原理图。谢过。{:handshake:}

WUST_LJS 发表于 2013-5-28 20:53:24

标记 。电调
页: [1]
查看完整版本: 我的无刷电调(原理图+程序)