Topic Requirements Dividing Line

> ... The drive part is designed with a brushed reduction motor, with a rated power of 1W and a rated speed of 100RPM. 1.1.2 This design divides power generation and drive into two parts, each with independent functions. In this way, the utilization efficiency of our power supply is very high, and we can walk a longer distance. The actual walking distance can be ten meters. 1.1.3 The detection circuit uses a capacitive proximity sensor with lower power consumption at the same accuracy and an infrared tracking module. At the same time, because some sensors only need to work for a short time during the test, in this project, a circuit system that is completely powered off after the detection is completed is designed specifically to avoid the situation where the sensor continues to consume power when it is not working. The above figure is the framework diagram of the entire system. It is mainly divided into 6 parts. First, the generator motor generates electricity to the farad capacitor, and then the capacitor boosts and bucks the voltage to the main control, sensor and motor. Why is boost and buck used here? Because when the capacitor voltage is lower than 5V, the boost mode will be automatically turned on to squeeze the capacitor to 1V, so that we can fully utilize the energy. Since the metal detector consumes more power, we use a control transistor to disconnect the power supply during the basic part and start the power supply during the performance part. 3 Schematic Design Description 2.1 CW32 Master Control The CW master control uses the CW32F030C8T6 minimum system development board, with a maximum main frequency of 64MHz, 64K bytes of FLASH, data retention for 25 years, 8K bytes of RAM, support for parity check 128 bytes of OTP memory, and a five-channel DMA controller, which completely surpasses STM32 and is widely used in aerospace and national defense military. It has a high cost performance and can apply for a development board for free. 2021 is the 20th anniversary of the establishment of CW, and it is also the year for Xinyuan Semiconductor to accelerate high-quality development. It is also a major turning point in the transformation of listed companies from agency distribution to a dual-core strategy of chip design and agency distribution. In the future, the company will continue to move forward steadily, specialize and strengthen in the field of chip research and development, and actively respond to and implement the country's great strategy of domestic substitution in the chip industry. CW32 Ecological Community: WeChat public account search: "CW32 Ecological Community" --> Click to follow, you can apply for development boards and chips for free. Dear friends, use your creativity and imagination, work together to promote the development and development of CW32! ! ! 2.2 Farad capacitor group circuit The figure above shows the car Farad capacitor circuit, which is 4 capacitors in series, with an indicator light at the motor end, which is the requirement of the first question of the basic part. When the motor generates electricity, the indicator light will light up. The role of the diode is unidirectional conduction to prevent the generated electricity from being put back. The maximum current of SS54 is 5A and the withstand voltage is 40V, which fully meets the parameters of our discharge motor. The connected 100nf capacitor is a decoupling capacitor. When the brushed motor generates electricity, high-frequency noise will be injected into the entire system, so connecting 100nf can reduce noise. The above picture shows the energy storage capacitor of the car. The above picture shows the generator motor of the car. 2.3 Motor drive circuit The above picture shows the motor drive circuit, which uses NPN plus PNP drive circuit. Because the question only requires our motor to move forward, our motor only needs to rotate in one direction. The role of the diode is to continue the current, because when the motor stops rotating, there will be a reverse electromotive force to prevent the microcontroller from burning. When the MOTO foot is high, Q7 is turned on, Q6 is turned on, and the motor runs. When MOTO is low, Q7 is turned off, Q6 is turned off, and the motor stops running. The above picture shows the walking motor, which has extremely low power consumption . 2.4 Metal sensor interface circuit The above picture shows the metal sensor. When metal is detected, Q4 is turned on, and the level of JC1 is 3.3V. When there is no metal, Q4 is turned off and JC1 is low. POWER2 is the power supply for controlling the sensor to prevent power waste in the basic part. The above picture shows the metal sensor used in the car, which is powered by 5V. 2.5 Power supply circuit The above picture shows the power supply circuit, which consists of an MT3608 boost chip and an MT2492 buck chip. The function of the output diode is to prevent current inflow. When the input voltage is higher than 5V, the buck circuit works and outputs 5V power to the microcontroller. When the voltage is lower than 5V, the MT3608 works and boosts the voltage to 5V for the entire system. The efficiency of these two chips is above 95%, which is very energy-saving and suitable for our power generation car project. 2.6 External circuit The above picture shows the external circuit, which is connected to the tracking sensor and OLED display. PCB design instructions The above picture shows the design of the PCB. When designing the PCB, we must pay attention to the fact that the capacitor part needs to be laid out in a separate part and cannot contact the low-voltage part to prevent the microcontroller from burning. At the same time, copper cannot be covered. Software Description The program consists of three parts. The first is the interrupt, the second is the main function to control the motor of the car, and the third is the function of the OLED display . void main() {











int main(){ unsigned int key_1=0,i=0; RCC_Configuration(); //System clock is configured as 64M GPIO_Configuration(); //LED&KEY initialization ATIMER_init(); track_gpio_config(); I2C_Configuration(); //OLED init OLED_Init(); OLED_CLS();//Clear screen while(1) { if(GPIO_ReadPin(CW_GPIOB,GPIO_PIN_14)==GPIO_Pin_SET)key_1=0; //Falling edge detection corresponds to the middle button else if(key_1==0) { for(i=0;i<2000;i++); //Debounce if(GPIO_ReadPin(CW_GPIOB,GPIO_PIN_14)==GPIO_Pin_RESET) { key_1=1;fache=1;} } Black_Line_Detection(); if(fache==1) { if(XJ03==Black_Line_Found) { ATIM_SetCompare1A(40); //Control the speed of the right wheel ATIM_SetCompare2A(40); //Control the speed of the left wheel } else if(XJ02==Black_Line_Found) { ATIM_SetCompare1A(40); //Control the speed of the right wheel ATIM_SetCompare2A(0); //Control the speed of the left wheel } else if(XJ04==Black_Line_Found) { ATIM_SetCompare1A(0); //Control the speed of the right wheel ATIM_SetCompare2A(40); //Control the speed of the left wheel } else { ATIM_SetCompare1A(40); //Control the speed of the right wheel ATIM_SetCompare2A(0); //Control the speed of the left wheel }
}
OLED_ShowCN(0,0, 0); //Hard OLED_ShowCN(18,0, 1); //coin OLED_ShowCN(36,0, 2); //coin OLED_ShowCN(100,0, 3); //coin count_flag++; if(count_flag>=500) { count++; count_flag=0; } if(count>=3) { count=3; } sprintf(temp_buff,"%d",count); //display number OLED_ShowStr(75,0,temp_buff,2); }}
void RCC_Configuration(void){ /* 0. Enable and calibrate HSI*/ RCC_HSI_Enable(RCC_HSIOSC_DIV6);
/* 1. Set the division coefficient of HCLK and PCLK*/ RCC_HCLKPRS_Config(RCC_HCLK_DIV1); RCC_PCLKPRS_Config(RCC_PCLK_DIV1); /* 2. Enable PLL, multiply the frequency to 64MHz through PLL */ RCC_PLL_Enable(RCC_PLLSOURCE_HSI, 8000000, 8); // HSI default output frequency 8MHz // RCC_PLL_OUT(); //PC13 pin outputs PLL clock ///< When the clock source HCLK used is greater than 24M and less than or equal to 48MHz: set the FLASH read wait cycle to 2 cycles ///< When the clock source HCLK used is greater than 48MHz: set the FLASH read wait cycle to 3 cycles __RCC_FLASH_CLK_ENABLE(); FLASH_SetLatency(FLASH_Latency_3); /* 3. Switch the clock to PLL */ RCC_SysClk_Switch(RCC_SYSCLKSRC_PLL); RCC_SystemCoreClockUpdate(64000000); }
void GPIO_Configuration(void){ GPIO_InitTypeDef GPIO_InitStruct; __RCC_GPIOA_CLK_ENABLE(); __RCC_GPIOB_CLK_ENABLE();
GPIO_InitStruct.IT = GPIO_IT_NONE; //KEY1 PB14 as button GPIO_InitStruct.Mode = GPIO_MODE_INPUT_PULLUP; GPIO_InitStruct.Pins = GPIO_PIN _14; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_Init(CW_GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.IT = GPIO_IT_NONE; //LED1 LED2 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pins = GPIO_PIN_7|GPIO_PIN_8; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_Init(CW_GPIOA, &GPIO_InitStruct); GPIO_WritePin(CW_GPIOA, GPIO_PIN_7|GPIO_PIN_8,GPIO_Pin_SET);}
void ATIMER_init(void){ ATIM_InitTypeDef ATIM_InitStruct; ATIM_OCInitTypeDef ATIM_OCInitStruct; GPIO_InitTypeDef GPIO_InitStruct; __RCC_ATIM_CLK_ENABLE(); __RCC_GPIOA_CLK_ENABLE(); PA08_AFx_ATIMCH1A(); PA09_AFx_ATIMCH2A(); GPIO_InitStruct.IT = GPIO_IT_NONE; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pins = GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_Init(CW_GPIOA, &GPIO_InitStruct);
ATIM_InitStruct.BufferState = DISABLE; //时基单元配置 ATIM_InitStruct.ClockSelect = ATIM_CLOCK_PCLK; ATIM_InitStruct.CounterAlignedMode = ATIM_COUNT_MODE_EDGE_ALIGN; ATIM_InitStruct.CounterDirection = ATIM_COUNTING_UP; ATIM_InitStruct.CounterOPMode = ATIM_OP_MODE_REPETITIVE; ATIM_InitStruct.OverFlowMask = DISABLE; ATIM_InitStruct.Prescaler = ATIM_Prescaler_DIV32; // 计算时钟1MHz ATIM_InitStruct.ReloadValue = 100; // 20K ATIM_InitStruct.RepetitionCounter = 0; ATIM_InitStruct.UnderFlowMask = DISABLE; ATIM_Init(&ATIM_InitStruct);
ATIM_OCInitStruct.BufferState = DISABLE; ATIM_OCInitStruct.OCDMAState = DISABLE; ATIM_OCInitStruct.OCInterruptSelect = ATIM_OC_IT_UP_COUNTER; ATIM_OCInitStruct.OCInterruptState = ENABLE; ATIM_OCInitStruct.OCMode = ATIM_OCMODE_PWM1; ATIM_OCInitStruct.OCPolarity = ATIM_OCPOLARITY_NONINVERT; ATIM_OC1AInit(&ATIM_OCInitStruct); ATIM_OC2AInit(&ATIM_OCInitStruct);
ATIM_SetCompare1A(0); ATIM_SetCompare2A(0); ATIM_PWMOutputConfig(OCREFA_TYPE_SINGLE, OUTPUT_TYPE_COMP, 0); ATIM_CtrlPWMOutputs(ENABLE); ATIM_Cmd(ENABLE);
}
void ATIM_IRQHandler(void){ if (ATIM_GetITStatus(ATIM_IT_OVF)) { ATIM_ClearITPendingBit(ATIM_IT_OVF); }}
printf(""/n);
}
实物展示说明


注意事项
发电的时候会有阻力,我们得用全力,但是也要小心电机齿轮磨损,在推电机发电的时候得匀速前进。
演示视频
提示:演示视频上传附件即可,附件最大只能长传50M的文件,大于50M的文件可放置在其他网盘或视频网站上,只需把地址链接放入这里即可