3899 views|9 replies

111

Posts

0

Resources
The OP
 

Buttonless kitchen timer [Copy link]

      Although using a 108MH microcontroller as a timer is a bit big and insignificant, this small work also uses modules such as timer, ADC, interrupt and GPIO. The principle of the work is mainly to use the three-axis acceleration sensor to collect angle information and convert it into the required timing time, and use it to collect action information as the timer control signal. 1. Development environment: The development tool used is True STUDIO, an integrated development environment based on ARM GCC. This development environment suitable for STM32 can also be used for the development of GD32F350, but you need to modify the connection file yourself, and it seems that the startup file does not need to be modified. 2. Software process: The software process is that the ADC collects the acceleration value of the three-axis acceleration, and judges whether there is an action based on the acceleration transformation of the Z axis, which is used to start or reset the timer. At the same time, the acceleration value of the XY axis is used to calculate the inclination angle of the acceleration sensor, and the timing time is confirmed according to the inclination angle meter. When the timing time is up, the buzzer beeps to remind you. 3. Usage: If you shake the acceleration sensor in the Z axis direction with your hand, the timer will be reset or restarted. The main difficulty is the motion detection using the acceleration sensor. No complex algorithms are used here, and the ADC is used to simulate the watchdog function. The motion recognition effect is average. 4. Summary of the work: Advantages of the work: No buttons are required, and the timer can be started or stopped by shaking it; Disadvantages: There is no timing display function, and a display screen can be considered in the future. 5. Main function source code: The main function is as follows, and the source file is attached at the end of the article, int main(void) { /* system clocks configuration */ rcu_config(); nvic_config(); /* systick configuration */ systick_config(); /* GPIO configuration */ gpio_config(); /* DMA configuration */ dma_config(); /* ADC configuration */ adc_config(); /*initial other devices*/ timer_config(); gpio_config_timer(); gd_eval_com_init(EVAL_COM1); gd_eval_led_init(LED1); gd_eval_led_init(LED2); gd_eval_led_init(LED3); gd_eval_led_init(LED4); gd_eval_led_init(LED5); Led_demo(); dis_frequency(); cpu_id(); delay_1ms(5000); p_func = alarm_msg; timer_enable(TIMER1); while (1) { ap_counter++; alarm_status1 = 3; alarm_status2 = 0; alarm_status0 = alarm_run(alarm_msg); data = 0; adc_interrupt_enable(ADC_INT_WDE); // delay_1ms(10); switch (ap_status) { case 0: if (1 == data) { ap_status = 1 ; } break; case 1: if (ap_counter % 1000 == 0) { delay_1ms(10); if (0 == data) { ap_status = 2; printf("!!\r\n"); } else { ap_status = 0; } } break; case 2: alarm_status2 = 1; ap_status = 0; break; default: break; } adc_disp(); alarm_status0 == 1 && alarm_status2 == 1) { alarm_status1 = 1; } else if (alarm_status0 == 0 && alarm_status2 == 1) { alarm_status1 = 0; } switch (alarm_status1) { case 1: alarm_reset(); printf("Alarm_reset.\r\n"); break; case 0: gd_eval_led_off(LED4); delay_ 1ms(200); gd_eval_led_on(LED4); g_dmacomplete_flag = 0; delay_1ms(1000); while (g_dmacomplete_flag != 1) ; alarm_init(get_angle() * 60000 / 6); alarm_start(); printf("Alarm start.\r\n"); break; default: break; } if (alarm_status0) { print f("Counter: %d minutes\r\n",(int) alarm_get_counter() / 60000); } } } 6.The system block diagram is as follows: Demonstration video: Video Supplementary content (2018-10-1 05:36): The oled screen display function was added later.

frame.PNG (12.57 KB, downloads: 0)

frame.PNG

GD32F350.zip

20.95 KB, downloads: 13

源码

This post is from GD32 MCU

Latest reply

nmg
Attached to the judges' supplementary materials: serialworldCan GD32 be developed with GCC? Click to viewserialworldGD-LINK reports an error when connecting to the GD32F350RB development board? Click to viewserialworldARM GCC GD32F350RB MCU startup file and connection file sharingClick to viewserialworldHow to download programs without IDE development environment for GD32Click to viewserialworldCan't use the math functions provided by the compiler after GD32F350 turns on FPU? Click to view   Details Published on 2018-10-25 08:59
 

5216

Posts

239

Resources
From 2
 
Attached to the judges' supplementary materials:
serialworld
Can GD32 be developed with GCC?
serialworld
GD-LINK reports an error when connecting to the GD32F350RB development board?
serialworld
ARM GCC GD32F350RB MCU startup file and connection file sharing
serialworld
How to download programs without IDE development environment for GD32
serialworld
Can't use the math functions provided by the compiler after GD32F350 turns on FPU?

This post is from GD32 MCU
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 
 

111

Posts

0

Resources
3
 
Occupy the building and use it for pictures of the works.
This post is from GD32 MCU
 
 
 

693

Posts

7

Resources
4
 
I am a newbie, I want to ask a few questions. 1. The ADC collects the acceleration value of the three-axis acceleration. Is your attitude sensor MPU6050? 2. The timer can be started or stopped by shaking it. Is this timer a physical module? ?
This post is from GD32 MCU
 
 
 

5216

Posts

239

Resources
5
 
I'm missing a demo video. Please refer to the competition selection rules: https://www.eeworld.com.cn/huodon ... 201808/index.html#5 Please follow the instructions to complete the submission of the work. Each part of the required submission has a score
This post is from GD32 MCU
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 
 

111

Posts

0

Resources
6
 
bqgup posted on 2018-9-23 08:53 OP, I am a rookie, I want to ask a few questions 1. ADC collects the acceleration value of three-axis acceleration, is your attitude sensor MPU6050? ...
1. The three-axis acceleration sensor uses ADXL335, you can check the information of this chip on the Internet. 2. The timer refers to the software timer in the program.
This post is from GD32 MCU

Comments

Thank you, this accelerometer is very good. I am a novice, thank you for your guidance.  Details Published on 2018-9-24 09:20
 
 
 

693

Posts

7

Resources
7
 
serialworld published on 2018-9-24 05:58 1. The three-axis accelerometer uses ADXL335. You can check the information of this chip online. 2. The timer refers to the software timer in the program...
Thank you, this accelerometer is very good. I am a novice. Thanks for your guidance.
This post is from GD32 MCU
 
 
 

111

Posts

0

Resources
8
 
This post was last edited by serialworld on 2018-9-30 22:33 Added project pictures, photos without and with oled screen.

photo.jpg (1.19 MB, downloads: 0)

photo.jpg

clock alarm.jpg (281.54 KB, downloads: 0)

clock alarm.jpg
This post is from GD32 MCU
 
 
 

111

Posts

0

Resources
9
 
This post was last edited by serialworld on 2018-10-8 18:51Demonstration video: Video
This post is from GD32 MCU
 
 
 

31

Posts

0

Resources
10
 
Not bad, support it.
This post is from GD32 MCU
 
Personal signature科技飞速发展,学习永无止境。变压器有载调压,一小时万次切换。
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list