軟硬(ying)件全開源(yuan),航芯方案分享 | 智能電動牙刷方案
當代口(kou)腔(qiang)問(wen)題頻(pin)發,讓人們(men)越來越重視口(kou)腔(qiang)衛生(sheng)。傳統的(de)(de)(de)刷(shua)(shua)牙(ya)方(fang)式(shi)(shi)(shi),由(you)于個(ge)人習慣和刷(shua)(shua)牙(ya)方(fang)式(shi)(shi)(shi)的(de)(de)(de)不(bu)同(tong),會不(bu)同(tong)程(cheng)度地導致牙(ya)齦(yin)受損,牙(ya)菌斑去(qu)除不(bu)徹底等問(wen)題。而電(dian)動(dong)牙(ya)刷(shua)(shua)設備(bei),基于其(qi)相對程(cheng)序化的(de)(de)(de)刷(shua)(shua)牙(ya)方(fang)式(shi)(shi)(shi),可根(gen)據個(ge)人口(kou)腔(qiang)特性(xing)支持(chi)自主選擇,調節刷(shua)(shua)牙(ya)力(li)度。而且(qie)在刷(shua)(shua)牙(ya)過(guo)程(cheng)中,不(bu)需(xu)要過(guo)多的(de)(de)(de)手部(bu)動(dong)作,僅需(xu)要調節刷(shua)(shua)牙(ya)的(de)(de)(de)角度,更(geng)多的(de)(de)(de)清(qing)潔工作交付由(you)牙(ya)刷(shua)(shua)本身的(de)(de)(de)特性(xing)來完成。方(fang)便人們(men)的(de)(de)(de)同(tong)時也更(geng)能有效(xiao)的(de)(de)(de)減少(shao)口(kou)腔(qiang)問(wen)題。
電(dian)動牙刷類型
現在市面(mian)上電動(dong)(dong)牙刷品類(lei)(lei)繁(fan)多,從刷頭的方式(shi)可將其分為(wei)兩大類(lei)(lei)型:旋轉式(shi)和振動(dong)(dong)式(shi)(也(ye)叫聲波(bo)式(shi))。參考
圖1. 電動牙刷工(gong)作方(fang)式(shi)對比圖
旋(xuan)轉(zhuan)式(shi)電動(dong)(dong)牙(ya)刷(shua)是(shi)由電機(ji)帶(dai)動(dong)(dong)刷(shua)頭(tou)旋(xuan)轉(zhuan),牙(ya)面清潔度高(gao),但牙(ya)縫(feng)清潔能(neng)(neng)力(li)薄弱且相較于振(zhen)(zhen)動(dong)(dong)式(shi),更易損傷牙(ya)釉質。而振(zhen)(zhen)動(dong)(dong)式(shi),由電機(ji)帶(dai)動(dong)(dong)刷(shua)頭(tou)進行上下的(de)(de)高(gao)頻振(zhen)(zhen)動(dong)(dong),高(gao)頻擺動(dong)(dong)的(de)(de)刷(shua)頭(tou)能(neng)(neng)高(gao)效完成洗刷(shua)牙(ya)齒的(de)(de)動(dong)(dong)作,可以(yi)(yi)讓牙(ya)膏與(yu)水的(de)(de)混合物產(chan)生大(da)量微小的(de)(de)氣泡(pao),氣泡(pao)爆裂(lie)時產(chan)生的(de)(de)壓力(li)可以(yi)(yi)更深(shen)入牙(ya)縫(feng)達(da)到深(shen)度的(de)(de)清潔效果。
振(zhen)(zhen)動(dong)(dong)(dong)式(shi)的實(shi)現有兩種方(fang)式(shi),一(yi)種由偏心振(zhen)(zhen)動(dong)(dong)(dong)電(dian)機(ji)實(shi)現,多用(yong)于中低檔的電(dian)動(dong)(dong)(dong)牙(ya)刷方(fang)案。該種方(fang)式(shi)的電(dian)動(dong)(dong)(dong)牙(ya)刷振(zhen)(zhen)動(dong)(dong)(dong)感強(qiang),振(zhen)(zhen)動(dong)(dong)(dong)無序。另一(yi)種則是采用(yong)線性電(dian)機(ji),業內也稱之為磁懸浮(fu)電(dian)機(ji)。
圖2. 磁懸浮電機示意(yi)圖
磁懸(xuan)浮電機的優(you)點在于其在工作運(yun)行噪聲(sheng)小,機身振(zhen)感低,振(zhen)動(dong)能量集中(zhong),清(qing)潔(jie)效(xiao)果佳。因此,本文采用ACM32F030作為主控芯片,基于磁懸(xuan)浮電機提(ti)出(chu)一款電動(dong)牙刷的設計(ji)方案(an)。
設計方案
本文描述的(de)電動牙(ya)刷方案,是(shi)基于上(shang)海航(hang)芯ACM32F030系列的(de)MCU進行設計,整體的(de)方案框圖如下所(suo)示:
圖3. 基于ACM32F030/070電(dian)動牙(ya)刷設計(ji)方案框圖
ACM32F0X0 系列(lie)(lie)是一款(kuan)支持多(duo)種(zhong)低(di)功耗模(mo)式的通用MCU。集成12位1.6 Msps高(gao)精度ADC以及比較(jiao)器、運放、觸(chu)控(kong)按鍵(jian)控(kong)制器、段式LCD控(kong)制器,內置(zhi)高(gao)性能定時器、多(duo)路UART、LPUART、SPI、I2C等豐富的通訊外設,內建AES、TRNG等信息安全模(mo)塊,支持多(duo)種(zhong)低(di)功耗模(mo)式,具有高(gao)整合度、高(gao)抗(kang)干擾、高(gao)可靠性的特點(dian)。本產(chan)品(pin)采用ARM Cortex-M0系列(lie)(lie)內核,最高(gao)工作(zuo)頻率(lv)64MHz。足以滿足一般的電動牙刷方案的需(xu)求。
掃碼即可立即購買ACM32F070KBU7
備注:ACM32F030和070軟硬件兼容
掃碼即可立即購買開發板
軟硬件下(xia)載鏈接如下(xia):
? 人機交互系統
本文論(lun)述的(de)(de)(de)設計方(fang)案中(zhong)的(de)(de)(de)人機(ji)交互功能(neng)(neng)是(shi)采用(yong)簡單(dan)的(de)(de)(de)LED和(he)按鍵(jian)的(de)(de)(de)方(fang)式(shi)進(jin)行實現(xian)(xian)。共有1個(ge)按鍵(jian)和(he)6個(ge)LED。按鍵(jian)需(xu)實現(xian)(xian)設備的(de)(de)(de)開(kai)關機(ji)以及模(mo)式(shi)切(qie)換功能(neng)(neng)。設備會根據按鍵(jian)按下時(shi)間的(de)(de)(de)長短來判定當前的(de)(de)(de)動作(zuo)(zuo)是(shi)需(xu)要切(qie)換模(mo)式(shi)或是(shi)開(kai)關機(ji)操作(zuo)(zuo)。6個(ge)LED中(zhong)有3個(ge)用(yong)于工(gong)作(zuo)(zuo)模(mo)式(shi)指(zhi)示,最(zui)大(da)可支持7種工(gong)作(zuo)(zuo)模(mo)式(shi)(23-1),本設計方(fang)案中(zhong)僅提供了三種模(mo)式(shi)。另外3個(ge)LED用(yong)于系統狀態(tai)指(zhi)示,包括正常,欠壓(ya),充電,充滿4種電壓(ya)狀態(tai)。
長短按識別程序:
void keyPressHandler(void) { key.isPressed = Key_GetPressValue(); switch(key.pressState) { case 0: if(key.isPressed) { key.pressTime = 0; key.pressState = 1; } break; case 1: /* eliminate jitter */ if(key.isPressed) { if(++key.pressTime > 10) key.pressState = 2; } else key.pressState = 0; break; case 2: /* whether long press is existed */ if(key.isPressed) { if(++key.pressTime > LONG_PRESS_TIME) key.pressState = 3; } else { if(key.shortPressHandler != NULL) key.shortPressHandler(); else DEBUG_KEY("have no short press handler!!\r\n"); key.pressState = 0; } break; case 3: if(key.longPressHandler != NULL) key.longPressHandler(); else DEBUG_KEY("have no long press handler!!\r\n"); key.pressState = 4; break; case 4: /* wait for releasing key */ if(key.isPressed == 0) key.pressState = 0; break; } }
工作指示程序:
void appMotorModeLedControl(void) { static uint8_t state = 0xFF; if(sys.status == SYSTEM_RUNMODE) { if(state != sys.motorStatus) { state = sys.motorStatus; if(sys.motorStatus == 0) { ModeLed_Select(MODE_LED_1, MODE_LED_ON); } else if(sys.motorStatus == 1) { ModeLed_Select(MODE_LED_2, MODE_LED_ON); } else if(sys.motorStatus == 2) { ModeLed_Select(MODE_LED_3, MODE_LED_ON); } } } else { state = 0xFF; ModeLed_Select(MODE_LED_UNKNOWN, MODE_LED_OFF); } }
系(xi)統指示程(cheng)序:
void appSysLedController(void) { static uint8_t led_state = 0xFF; if(led_state != led.state) { led_state = led.state; if(led.state == LED_OFF) { led.duty = 0; PowerLed_Select(PWR_LED_UNKNOWN, PWR_LED_OFF); PWM_dutySet(PWM_LED, led.duty); } else if(led.state == LED_TWINKLE) // low power warning { led.duty = 0; PowerLed_Select(PWR_LED_R, PWR_LED_ON); PWM_dutySet(PWM_LED, led.duty); } else if(led.state == LED_ON) { led.duty = 0; PowerLed_Select(PWR_LED_R, PWR_LED_OFF); PWM_dutySet(PWM_LED, led.duty); } else if(led.state == LED_BREATHE) { if(led.duty == PWM_DUTY_MAX) led.dir = LED_FADE; else led.dir = LED_BRIGHTER; } else led.state = LED_OFF; } else{ if(led.state == LED_BREATHE) { PowerLed_Select(PWR_LED_UNKNOWN, PWR_LED_OFF); if(led.dir == LED_BRIGHTER) { if(led.duty < PWM_DUTY_MAX) led.duty += BREATHE_INTERVAL; else { if(++led.cnt > BREATHE_HOLD_TIME) { led.dir = LED_FADE; led.cnt = 0; } } } else { if(led.duty > BREATHE_INTERVAL) led.duty -= BREATHE_INTERVAL; else { led.duty = 0; if(++led.cnt > BREATHE_HOLD_TIME) { led.dir = LED_BRIGHTER; led.cnt = 0; } } } PWM_dutySet(PWM_LED, led.duty); } } }
? 電源(yuan)及功(gong)耗管理
電(dian)動牙刷產品的(de)續航能力也是一(yi)直(zhi)備(bei)(bei)受人(ren)們關注。本設(she)計方案在低功(gong)耗的(de)處理(li),摒棄了一(yi)般的(de)休眠方式,直(zhi)接采用關閉電(dian)源來(lai)避免設(she)備(bei)(bei)在不工作狀態下的(de)設(she)備(bei)(bei)功(gong)耗。整個設(she)備(bei)(bei)的(de)供電(dian)線路共(gong)有(you)三種,如下圖所(suo)示。
圖(tu)4. 基于ACM32F030的電動牙刷供電電路(部分(fen))
正(zheng)常情況下,設備不在充電(dian)(dian)時(shi)(shi)(shi),VCHARG電(dian)(dian)壓為0,需(xu)要(yao)(yao)關機(ji)(ji)時(shi)(shi)(shi),按(an)鍵(jian)彈開,PWR_KEY為低(di)電(dian)(dian)平(ping),芯片內(nei)部程序也將(jiang)PWR_LOCK拉(la)(la)(la)低(di),此時(shi)(shi)(shi)Q2關斷(duan),Q2的(de)D極(ji)電(dian)(dian)壓同VBAT,從而引起Q1斷(duan)開,VCCIN斷(duan)電(dian)(dian),系(xi)(xi)統關機(ji)(ji)。而開機(ji)(ji)時(shi)(shi)(shi),按(an)鍵(jian)按(an)下,PWR_KEY先(xian)被(bei)拉(la)(la)(la)至高電(dian)(dian)平(ping),Q2導(dao)(dao)(dao)通,Q2的(de)D極(ji)拉(la)(la)(la)低(di),則Q1導(dao)(dao)(dao)通,設備供電(dian)(dian),程序檢測(ce)到開機(ji)(ji),拉(la)(la)(la)高PWR_LOCK,此時(shi)(shi)(shi),盡(jin)管按(an)鍵(jian)彈開,PWR_LOCK仍(reng)然會(hui)提供Q2的(de)導(dao)(dao)(dao)通電(dian)(dian)壓,系(xi)(xi)統正(zheng)常工(gong)作。充電(dian)(dian)時(shi)(shi)(shi),Q2的(de)導(dao)(dao)(dao)通電(dian)(dian)壓會(hui)由VCHARG提供,系(xi)(xi)統保(bao)持在工(gong)作狀態,此時(shi)(shi)(shi)會(hui)程序會(hui)檢測(ce)系(xi)(xi)統的(de)運行狀態,在不需(xu)要(yao)(yao)啟動時(shi)(shi)(shi),進入休眠(mian)狀態。
電(dian)(dian)源管(guan)理(li)部分(fen),則通過(guo)鋰(li)電(dian)(dian)池(chi)(chi)充電(dian)(dian)芯(xin)片檢測是否進(jin)行(xing)充電(dian)(dian),同時通過(guo)一路ADC監測電(dian)(dian)池(chi)(chi)電(dian)(dian)壓(ya)。為(wei)減(jian)少(shao)芯(xin)片工作負擔(dan),電(dian)(dian)池(chi)(chi)電(dian)(dian)壓(ya)的欠壓(ya)和滿電(dian)(dian)通過(guo)ADC門限(xian)電(dian)(dian)壓(ya)功能(neng)來實現。ADC的門限(xian)電(dian)(dian)壓(ya)初始化程序如下:
// ADC Watchdog config ADC_WDT_Handle.ITMode = ENABLE; ADC_WDT_Handle.WatchdogMode = ADC_ANALOGWATCHDOG_RCH_ALL; ADC_WDT_Handle.Channel = channel; ADC_WDT_Handle.HighThreshold = (HIGH_POWER_THS * 0x0FFF) / VREF ; ADC_WDT_Handle.LowThreshold = (LOW_POWER_THS * 0x0FFF) / VREF ;
? 智能管理系統
智能管(guan)理系統分(fen)為兩個(ge)(ge)部分(fen),一部分(fen)為上(shang)位機(ji)的(de)數(shu)據(ju)處(chu)理,由云端處(chu)理,另一部分(fen)是電(dian)動牙刷(shua)數(shu)據(ju)記錄(lu)和傳輸。整(zheng)個(ge)(ge)的(de)實(shi)現過(guo)(guo)(guo)程(cheng)可簡(jian)述為,電(dian)動牙刷(shua)通(tong)過(guo)(guo)(guo)慣性測量儀(yi)QMI8658C記錄(lu)電(dian)動牙刷(shua)在使用(yong)過(guo)(guo)(guo)程(cheng)中的(de)運動軌跡,并(bing)實(shi)時將(jiang)該部分(fen)數(shu)據(ju)以及整(zheng)個(ge)(ge)系統的(de)工作參(can)數(shu)通(tong)過(guo)(guo)(guo)BLE發送到手(shou)機(ji),手(shou)機(ji)連接云端,并(bing)將(jiang)數(shu)據(ju)傳輸至云平(ping)臺進行數(shu)據(ju)解析,分(fen)析用(yong)戶刷(shua)牙的(de)健康指數(shu),并(bing)將(jiang)相(xiang)關(guan)建議反饋至手(shou)機(ji)。電(dian)動牙刷(shua)作為數(shu)據(ju)采集設(she)備,需上(shang)報實(shi)時數(shu)據(ju),結(jie)構如下:
typedef __packed struct{ uint32_t time; // This shows the relative time of each activity uint16_t location[3]; // This shows the acceleration of brush when using uint16_t pressure; // This is the force between tooth and brush uint16_t angle[3]; // This shows the angle between brush }BLE_RealTimeDataDef; // This define the data structure about brushing tooth in real time
其中,location為三軸的(de)加速度,angle為三軸的(de)角度。定時上(shang)傳電動牙刷的(de)相關實時數(shu)據。上(shang)位機(ji)根據一系(xi)列點位數(shu)據進行建模計算(suan)可(ke)得(de)到整個牙刷的(de)運動軌跡(ji)。
? 電機驅動系(xi)統
電動牙刷的驅動系統(tong)是通過(guo)H橋芯(xin)片MX612E進行處理(li),MX612E的輸入端連接芯(xin)片的PWM互補輸出端口。如下圖所示:
圖5. 電動(dong)牙(ya)刷(shua)電機驅動(dong)電路
本(ben)設(she)計中的電(dian)動(dong)牙(ya)刷采(cai)用(yong)磁懸浮(fu)電(dian)機(ji),內部(bu)構造和直(zhi)流(liu)無刷電(dian)機(ji)相(xiang)(xiang)似(si),但(dan)相(xiang)(xiang)比(bi)于直(zhi)流(liu)無刷電(dian)機(ji),其(qi)僅有兩相(xiang)(xiang)輸入端。這也就造成該電(dian)機(ji)在(zai)(zai)通電(dian)后,正(zheng)負極不變的情況下,電(dian)機(ji)旋轉(zhuan)至某一角度形成平(ping)衡后將會停止旋轉(zhuan)。切(qie)換正(zheng)負極后則又會在(zai)(zai)另一個方向旋轉(zhuan)形成平(ping)衡。在(zai)(zai)電(dian)動(dong)牙(ya)刷的正(zheng)常工作中,是(shi)通過兩相(xiang)(xiang)的正(zheng)負極切(qie)換來使電(dian)機(ji)正(zheng)反旋轉(zhuan)從而(er)帶動(dong)刷頭做(zuo)高頻(pin)(pin)運(yun)動(dong)的。因此(ci),其(qi)電(dian)機(ji)速度的控制依靠(kao)于輸出PWM的輸出頻(pin)(pin)率而(er)非占空比(bi)。控制代(dai)碼如下:
void PWM_freqSet(uint8_t PWMx, uint16_t freq) { uint32_t arr; if(IS_PWM_INSTANCE(PWMx) == 0) return; if(freq == 0) { TIM15->ARR = 0; return; } if(freq > PWM_FREQ_MAX) freq = PWM_FREQ_MAX; if(freq < PWM_FREQ_MIN) freq = PWM_FREQ_MIN; arr = (PWM_TIMER_FRE / freq); if(PWMx == PWM_MOTOR) { TIM15->ARR = arr-1; TIM15->CCR1 = arr / 2; } }
上例中(zhong),PWM的占空比為50%,使得在一個PWM周(zhou)期內,電機可完(wan)成一次往(wang)返運動。
本文提出(chu)的(de)(de)(de)設計方案的(de)(de)(de)主旨(zhi)是將電(dian)動(dong)牙(ya)刷(shua)(shua)智(zhi)能(neng)(neng)化,在提高人們刷(shua)(shua)牙(ya)效率的(de)(de)(de)同(tong)時(shi),也能(neng)(neng)達到進一步保證人們刷(shua)(shua)牙(ya)質(zhi)量的(de)(de)(de)目的(de)(de)(de)。通過電(dian)動(dong)牙(ya)刷(shua)(shua)對(dui)慣性的(de)(de)(de)數據(ju)采集,實(shi)時(shi)上傳至云端,并對(dui)數據(ju)進行(xing)處理,恢復(fu)用戶的(de)(de)(de)刷(shua)(shua)牙(ya)軌跡,給出(chu)合理建(jian)議(yi),糾(jiu)正用戶不良的(de)(de)(de)刷(shua)(shua)牙(ya)習慣。磁(ci)懸浮(fu)電(dian)機的(de)(de)(de)高頻振動(dong)也能(neng)(neng)有效清(qing)除(chu)口腔(qiang)污漬。歲月(yue)恒久遠,牙(ya)齒(chi)永相隨 ^-^。
上海(hai)航芯(xin) · 原(yuan)廠(chang)直(zhi)連: