軟(ruan)硬件全開源,航芯方案分(fen)享 | 智能(neng)電(dian)動牙刷方案
當代口腔問題(ti)頻發,讓人(ren)們越來越重視口腔衛生。傳(chuan)統的(de)刷牙(ya)(ya)(ya)方式,由于個人(ren)習慣和刷牙(ya)(ya)(ya)方式的(de)不(bu)(bu)同(tong),會不(bu)(bu)同(tong)程(cheng)(cheng)度地導致牙(ya)(ya)(ya)齦受損,牙(ya)(ya)(ya)菌(jun)斑(ban)去(qu)除(chu)不(bu)(bu)徹底等問題(ti)。而電動牙(ya)(ya)(ya)刷設備,基于其相對(dui)程(cheng)(cheng)序化的(de)刷牙(ya)(ya)(ya)方式,可根據(ju)個人(ren)口腔特(te)性支持(chi)自主選擇,調節(jie)刷牙(ya)(ya)(ya)力度。而且在刷牙(ya)(ya)(ya)過(guo)程(cheng)(cheng)中,不(bu)(bu)需要過(guo)多的(de)手部(bu)動作(zuo),僅需要調節(jie)刷牙(ya)(ya)(ya)的(de)角度,更多的(de)清(qing)潔工(gong)作(zuo)交付由牙(ya)(ya)(ya)刷本身的(de)特(te)性來完成。方便人(ren)們的(de)同(tong)時也(ye)更能有效(xiao)的(de)減少(shao)口腔問題(ti)。
電動牙刷類型
現在市(shi)面上(shang)電動(dong)牙刷(shua)品類繁多,從(cong)刷(shua)頭(tou)的方式可將其分為兩大類型:旋轉式和振(zhen)動(dong)式(也(ye)叫聲(sheng)波(bo)式)。參考(kao)
圖(tu)(tu)1. 電動牙刷工作(zuo)方式對比圖(tu)(tu)
旋(xuan)轉式電動(dong)(dong)(dong)牙(ya)刷是(shi)由(you)電機帶(dai)動(dong)(dong)(dong)刷頭(tou)旋(xuan)轉,牙(ya)面清潔(jie)度(du)高(gao),但牙(ya)縫清潔(jie)能力(li)薄弱且相較于振(zhen)(zhen)動(dong)(dong)(dong)式,更易損傷牙(ya)釉質。而振(zhen)(zhen)動(dong)(dong)(dong)式,由(you)電機帶(dai)動(dong)(dong)(dong)刷頭(tou)進行上下(xia)的高(gao)頻振(zhen)(zhen)動(dong)(dong)(dong),高(gao)頻擺動(dong)(dong)(dong)的刷頭(tou)能高(gao)效(xiao)完成洗刷牙(ya)齒(chi)的動(dong)(dong)(dong)作(zuo),可以(yi)讓牙(ya)膏與水的混合(he)物產生大量微小的氣泡(pao),氣泡(pao)爆裂時產生的壓力(li)可以(yi)更深入牙(ya)縫達(da)到深度(du)的清潔(jie)效(xiao)果。
振(zhen)動式的(de)實(shi)現(xian)有兩種(zhong)方(fang)式,一種(zhong)由(you)偏心振(zhen)動電機實(shi)現(xian),多用于中低檔的(de)電動牙刷方(fang)案。該(gai)種(zhong)方(fang)式的(de)電動牙刷振(zhen)動感強,振(zhen)動無(wu)序。另一種(zhong)則是(shi)采用線(xian)性(xing)電機,業內也稱(cheng)之為磁懸(xuan)浮電機。
圖2. 磁(ci)懸(xuan)浮電機示意圖
磁(ci)懸浮(fu)電機的(de)優點在(zai)于其在(zai)工作(zuo)運行(xing)噪(zao)聲小,機身(shen)振感低(di),振動(dong)能量(liang)集中(zhong),清潔(jie)效果佳。因此,本文采用(yong)ACM32F030作(zuo)為(wei)主控芯片,基于磁(ci)懸浮(fu)電機提出一款電動(dong)牙刷的(de)設計(ji)方(fang)案。
設計方案
本文描述的電(dian)動牙刷方案,是基于上海航芯ACM32F030系(xi)列的MCU進(jin)行設計,整(zheng)體的方案框圖如(ru)下所示:
圖(tu)3. 基于(yu)ACM32F030/070電動牙刷設計方案框(kuang)圖(tu)
ACM32F0X0 系列是(shi)一款(kuan)支(zhi)持多(duo)種低功(gong)(gong)耗(hao)模式的(de)(de)通用(yong)MCU。集成12位(wei)1.6 Msps高精(jing)度ADC以及(ji)比較(jiao)器(qi)、運放、觸控(kong)按(an)鍵(jian)控(kong)制器(qi)、段(duan)式LCD控(kong)制器(qi),內置高性能(neng)定(ding)時器(qi)、多(duo)路UART、LPUART、SPI、I2C等(deng)(deng)豐富的(de)(de)通訊外設(she),內建AES、TRNG等(deng)(deng)信(xin)息安全模塊,支(zhi)持多(duo)種低功(gong)(gong)耗(hao)模式,具有高整合度、高抗干擾(rao)、高可靠性的(de)(de)特(te)點(dian)。本產品采用(yong)ARM Cortex-M0系列內核(he),最高工作頻率64MHz。足以滿足一般的(de)(de)電動牙刷方案的(de)(de)需(xu)求。
掃碼即可立即購買ACM32F070KBU7
備注:ACM32F030和070軟硬件兼容
掃碼即可立即購買開發板
軟硬(ying)件下載鏈接如下:
? 人(ren)機交(jiao)互(hu)系統(tong)
本文論述(shu)的設計方(fang)案中的人(ren)機交互功(gong)(gong)能是采(cai)用(yong)簡單的LED和按(an)(an)鍵(jian)的方(fang)式(shi)進(jin)行實(shi)現。共有1個(ge)(ge)按(an)(an)鍵(jian)和6個(ge)(ge)LED。按(an)(an)鍵(jian)需(xu)實(shi)現設備(bei)的開關機以及模(mo)(mo)式(shi)切換功(gong)(gong)能。設備(bei)會根據按(an)(an)鍵(jian)按(an)(an)下時間的長短來判定當(dang)前的動作(zuo)是需(xu)要切換模(mo)(mo)式(shi)或是開關機操作(zuo)。6個(ge)(ge)LED中有3個(ge)(ge)用(yong)于工作(zuo)模(mo)(mo)式(shi)指(zhi)示,最大可支持(chi)7種工作(zuo)模(mo)(mo)式(shi)(23-1),本設計方(fang)案中僅提(ti)供(gong)了(le)三種模(mo)(mo)式(shi)。另(ling)外3個(ge)(ge)LED用(yong)于系統狀態指(zhi)示,包(bao)括正常(chang),欠壓(ya),充(chong)電,充(chong)滿4種電壓(ya)狀態。
長短按(an)識別程序:
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); } }
系統指示程序:
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); } } }
? 電源及功(gong)耗管(guan)理(li)
電動牙刷產品的(de)(de)續航能(neng)力也是一(yi)(yi)直(zhi)備(bei)受人們關注。本設計方案在(zai)低功耗(hao)的(de)(de)處理,摒棄了一(yi)(yi)般的(de)(de)休眠方式,直(zhi)接(jie)采(cai)用關閉電源來(lai)避(bi)免設備(bei)在(zai)不工作狀態下的(de)(de)設備(bei)功耗(hao)。整個(ge)設備(bei)的(de)(de)供(gong)電線(xian)路共有三種(zhong),如(ru)下圖所示。
圖(tu)4. 基于ACM32F030的電動牙刷(shua)供(gong)電電路(lu)(部分)
正(zheng)常情況下(xia),設(she)備不(bu)在(zai)充電(dian)(dian)(dian)時(shi),VCHARG電(dian)(dian)(dian)壓(ya)為0,需要關機(ji)(ji)時(shi),按鍵(jian)彈開(kai)(kai)(kai),PWR_KEY為低(di)電(dian)(dian)(dian)平,芯片內(nei)部程序也將PWR_LOCK拉(la)低(di),此(ci)時(shi)Q2關斷,Q2的D極電(dian)(dian)(dian)壓(ya)同VBAT,從而(er)引起Q1斷開(kai)(kai)(kai),VCCIN斷電(dian)(dian)(dian),系統(tong)關機(ji)(ji)。而(er)開(kai)(kai)(kai)機(ji)(ji)時(shi),按鍵(jian)按下(xia),PWR_KEY先被拉(la)至(zhi)高(gao)(gao)電(dian)(dian)(dian)平,Q2導(dao)通,Q2的D極拉(la)低(di),則Q1導(dao)通,設(she)備供電(dian)(dian)(dian),程序檢(jian)測(ce)到開(kai)(kai)(kai)機(ji)(ji),拉(la)高(gao)(gao)PWR_LOCK,此(ci)時(shi),盡管按鍵(jian)彈開(kai)(kai)(kai),PWR_LOCK仍然會(hui)提供Q2的導(dao)通電(dian)(dian)(dian)壓(ya),系統(tong)正(zheng)常工作。充電(dian)(dian)(dian)時(shi),Q2的導(dao)通電(dian)(dian)(dian)壓(ya)會(hui)由VCHARG提供,系統(tong)保持在(zai)工作狀態(tai),此(ci)時(shi)會(hui)程序會(hui)檢(jian)測(ce)系統(tong)的運行(xing)狀態(tai),在(zai)不(bu)需要啟動時(shi),進(jin)入(ru)休眠狀態(tai)。
電(dian)(dian)(dian)源管理(li)部分,則通(tong)過鋰電(dian)(dian)(dian)池(chi)充電(dian)(dian)(dian)芯片檢測(ce)是否進行充電(dian)(dian)(dian),同(tong)時通(tong)過一路ADC監測(ce)電(dian)(dian)(dian)池(chi)電(dian)(dian)(dian)壓(ya)(ya)。為減少芯片工(gong)作負擔,電(dian)(dian)(dian)池(chi)電(dian)(dian)(dian)壓(ya)(ya)的(de)欠(qian)壓(ya)(ya)和滿電(dian)(dian)(dian)通(tong)過ADC門(men)(men)限電(dian)(dian)(dian)壓(ya)(ya)功能來實(shi)現。ADC的(de)門(men)(men)限電(dian)(dian)(dian)壓(ya)(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 ;
? 智能管理系統
智(zhi)能管理系統分為兩個(ge)部(bu)分,一(yi)部(bu)分為上(shang)位機(ji)的數(shu)(shu)據(ju)(ju)處理,由云(yun)(yun)端處理,另一(yi)部(bu)分是電動牙刷(shua)數(shu)(shu)據(ju)(ju)記錄(lu)和(he)傳(chuan)輸(shu)。整個(ge)的實現過(guo)程可簡述為,電動牙刷(shua)通過(guo)慣(guan)性測(ce)量儀QMI8658C記錄(lu)電動牙刷(shua)在使用過(guo)程中的運動軌(gui)跡,并(bing)實時將該部(bu)分數(shu)(shu)據(ju)(ju)以(yi)及整個(ge)系統的工作(zuo)參數(shu)(shu)通過(guo)BLE發送到手(shou)(shou)機(ji),手(shou)(shou)機(ji)連接云(yun)(yun)端,并(bing)將數(shu)(shu)據(ju)(ju)傳(chuan)輸(shu)至(zhi)云(yun)(yun)平臺進行數(shu)(shu)據(ju)(ju)解析,分析用戶刷(shua)牙的健(jian)康指數(shu)(shu),并(bing)將相(xiang)關建議反饋至(zhi)手(shou)(shou)機(ji)。電動牙刷(shua)作(zuo)為數(shu)(shu)據(ju)(ju)采集設備,需上(shang)報(bao)實時數(shu)(shu)據(ju)(ju),結構如下:
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為三軸(zhou)的加(jia)速度,angle為三軸(zhou)的角度。定時上傳電動(dong)牙刷(shua)的相關實時數據。上位(wei)機根據一系(xi)列點位(wei)數據進行建(jian)模計算可得到整個牙刷(shua)的運動(dong)軌跡。
? 電機驅(qu)動系統(tong)
電動牙刷的驅動系統(tong)是通過H橋(qiao)芯片MX612E進行處理,MX612E的輸入端連接芯片的PWM互補輸出端口(kou)。如(ru)下(xia)圖(tu)所示:
圖5. 電(dian)動牙刷電(dian)機驅動電(dian)路
本設計中(zhong)的(de)電(dian)動牙刷(shua)(shua)采用磁懸浮(fu)電(dian)機(ji),內部構造和直流無(wu)刷(shua)(shua)電(dian)機(ji)相似,但相比于(yu)直流無(wu)刷(shua)(shua)電(dian)機(ji),其僅有(you)兩相輸(shu)入端。這也就造成(cheng)該電(dian)機(ji)在通電(dian)后(hou),正負極不(bu)變(bian)的(de)情況下,電(dian)機(ji)旋(xuan)轉至某一(yi)角度形(xing)成(cheng)平衡后(hou)將會(hui)停止旋(xuan)轉。切(qie)換正負極后(hou)則(ze)又會(hui)在另(ling)一(yi)個方向(xiang)旋(xuan)轉形(xing)成(cheng)平衡。在電(dian)動牙刷(shua)(shua)的(de)正常工作中(zhong),是通過兩相的(de)正負極切(qie)換來使電(dian)機(ji)正反旋(xuan)轉從而(er)帶動刷(shua)(shua)頭做(zuo)高頻運(yun)動的(de)。因此,其電(dian)機(ji)速(su)度的(de)控制(zhi)(zhi)依靠于(yu)輸(shu)出PWM的(de)輸(shu)出頻率而(er)非(fei)占空比。控制(zhi)(zhi)代(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; } }
上(shang)例中(zhong),PWM的占(zhan)空(kong)比(bi)為50%,使得在一(yi)個PWM周期內,電機(ji)可完成一(yi)次往(wang)返(fan)運動。
本文(wen)提(ti)出的(de)(de)設(she)計方(fang)案的(de)(de)主旨是將電動(dong)(dong)牙刷(shua)(shua)智能化,在提(ti)高人(ren)們(men)(men)刷(shua)(shua)牙效率的(de)(de)同時,也能達到(dao)進一步保證人(ren)們(men)(men)刷(shua)(shua)牙質量(liang)的(de)(de)目(mu)的(de)(de)。通過(guo)電動(dong)(dong)牙刷(shua)(shua)對慣(guan)性的(de)(de)數據采(cai)集,實時上傳至云端,并對數據進行(xing)處理,恢復用戶(hu)的(de)(de)刷(shua)(shua)牙軌跡,給(gei)出合理建議,糾正用戶(hu)不(bu)良的(de)(de)刷(shua)(shua)牙習慣(guan)。磁懸浮電機的(de)(de)高頻振動(dong)(dong)也能有(you)效清除口腔污漬。歲(sui)月恒久(jiu)遠,牙齒永相隨 ^-^。
上海航(hang)芯 · 原廠直連: