Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Follow+Star Public Account Number, don’t miss the wonderful content

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Arrangement | strongerHuang

Source | CW32 Ecological Community

There are often friends asking【Where can I find reference open source projects】and similar questions.In fact, I periodically share some excellent open source projects with everyone.
Today, I will share another open source project based on the CW32 microcontroller, which includes many commonly used functions such as RTOS, GUI, Bluetooth, and power management.

Main Functions

I received a physical product and have used it for a while, but some functions are not yet perfected. However, overall it is quite good, and it is completely fine for learning or as a reference for projects.

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Main functions include:
1. Voltage measurement + threshold judgment, the threshold level can be set according to requirements to meet different logic level scenarios, and retains the useful red and green light prompt function of the “simple logic level tester“;
2. On-off measurement, and the threshold resistance can be adjusted according to requirements;
3. Diode measurement, lighting up a diode (note! Not a transistor!!!);
4. PWM output, convenient to provide a known quantity for system testing in some scenarios, and can also test passive buzzers, etc.
5. PWM input, can measure frequency (even perform simple decoding display functions for serial data, etc., but currently limited technology has not yet been realized)
6. DC output, simulating a required DC level for testing.
7. Can connect expansion boards for cooperative measurement.

Circuit Design

Design Concept:

When designing the tester, I divided the overall structure into five parts: analog front-end, power and battery management, microcontroller and peripherals, display, user control. Based on modular design principles, we can be more organized when drawing circuit diagrams and can roughly distinguish layouts according to modules when performing PCB Layout to facilitate wiring operations.

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

We refine the design of each part according to requirements to achieve the established goals. Below, I will provide a detailed explanation of my design and design concept in conjunction with circuit diagrams and PCBs.
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
(Power and Battery Management)
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
(Microcontroller and Peripherals)
Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management
(Analog Front-End)

Software Code and Debugging

The open source address of this project:
https://gitee.com/multifunction_test_pen/test_pen
File Structure:

1. GUI — LCD Driver and UI

2. FreeRTOS — RTOS System

3. USER — Low-level Drivers and App

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

This includes common peripherals and application codes for microcontrollers. Below, I will show you some code.
Battery Voltage Measurement
The BAT_ADC_ResultBuff array stores the ADC values collected from the battery.
1. Calculate the average value of the BAT_ADC_ResultBuff array, removing the maximum and minimum values to prevent data spikes.
2. Use the calculated average value.
uint16_t get_bat_val(void){    uint32_t sum = 0;    uint16_t bat_val;    uint32_t len = sizeof(BAT_ADC_ResultBuff) / 2;    uint16_t max = 0;    uint16_t min = 0xffff;    int i;    for ( i = 0; i < len; i++)    {        sum += BAT_ADC_ResultBuff[i];        if(BAT_ADC_ResultBuff[i] > max)        {            max = BAT_ADC_ResultBuff[i];        }        if(BAT_ADC_ResultBuff[i] < min)        {            min = BAT_ADC_ResultBuff[i];        }    }    sum -= max + min;    sum = sum / (len - 2);    sum = dynamic_mean(bat_cahe,sum,len_cahe);    // sum -= 30;    bat_val = sum * 2500 * 2 /4095;    return bat_val;}
Duty Cycle Adjustment
The duty cycle is modified in the PWM interrupt by changing the PosWidth value.
void GTIM1_IRQHandler(void) {     static uint16_t TimeCnt = 0;     GTIM_ClearITPendingBit(CW_GTIM1, GTIM_IT_OV);     if (TimeCnt++ >= 100)     {         TimeCnt = 0;         GTIM_SetCompare1(CW_GTIM1, PosWidth);     }     /* USER CODE END */ }
Interface Display
The interface display includes display content and function detection.

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

To facilitate testing, upper computer tools are also introduced, such as using virtual instrument software for measurement:

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Oscilloscope display:

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

For more related descriptions, you can refer to:
https://dwi41yhz703.feishu.cn/docx/HDypdqqapoMlVpxNuH0cdr08nEh?from=from_copylink
(The public account does not support external links, please copy the link to open in the browser)
For more source code, you can refer to:
https://gitee.com/multifunction_test_pen/test_pen
(The public account does not support external links, please copy the link to open in the browser)
This open source project uses the CW32 domestic microcontroller as the main control, and currently the schematic diagram, PCB, production materials, and source code are all public. Interested friends can also sample and make one set by themselves.
Finally, let me show you the product rendering and the video of the design scheme:

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Comprehensive Open Source Project Integrating RTOS, GUI, Bluetooth, and Power Management

Leave a Comment

Your email address will not be published. Required fields are marked *