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