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