系统功能:
1、系统具有语音识别功能,可以对厨余垃圾、其他垃圾、有害垃圾、可回收垃圾进行语音识别;
2、系统可根据语音识别结果直接开启对应类别的垃圾桶,引导分类投放;
3、系统具有语音播报功能,可以语音播报出识别到的垃圾类型。
主要功能模块原理图:
电源时钟烧录接口:
单片机和按键输入电路:
离线语音模块电路:
资料获取地址
系统主要功能模块代码
初始化代码:
/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration--------------------------------------------------------*//* Reset of all peripherals, Initializes the Flash interface and the Systick. */HAL_Init();/* USER CODE BEGIN Init */InitVar();/* USER CODE END Init *//* Configure the system clock */SystemClock_Config();/* USER CODE BEGIN SysInit *//* USER CODE END SysInit *//* Initialize all configured peripherals */MX_GPIO_Init();MX_USART1_UART_Init();MX_TIM3_Init();/* USER CODE BEGIN 2 */HAL_Delay(100);//uart1打开接收中断HAL_UART_Receive_IT(&huart1, (uint8_t*)&uart1RecBuff, 1);HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);/* USER CODE END 2 */
系统控制代码:
/************************************************************************功能描述:控制舵机状态入口参数:无返 回 值:无**************************************************************************/void SystemControl(void){uint8_t i = 0;//遍历四通道舵机for(i=0; i<CAN_CHANNEL_MAX; i++){switch(canSystem[i].systemState){//系统初始化状态case CAN_SYSTEM_INIT:if(canSystem[i].systemFlag==1){canSystem[i].ledState = LED_TOG_STATE;canSystem[i].systemState = CAN_SYSTEM_OPENING;}break;//四路舵机缓慢打开状态 case CAN_SYSTEM_OPENING:canSystem[i].pwmPulse+=PWM_PULSE_STEP;if(canSystem[i].pwmPulse>=PWM_PULSE_OPEN){canSystem[i].pwmPulse = PWM_PULSE_OPEN;canSystem[i].systemState = CAN_SYSTEM_WAITING;canSystem[i].ledState = LED_ON_STATE;}//修改舵机占空比__HAL_TIM_SetCompare(&htim3, channelTab[i], canSystem[i].pwmPulse);break;//舵机打开后等待一段时间再关闭,模拟垃圾桶打开后等待一段时间 case CAN_SYSTEM_WAITING:canSystem[i].openingCnt++;if(canSystem[i].openingCnt>=CAN_OPENING_CNT){canSystem[i].openingCnt = 0;canSystem[i].systemState = CAN_SYSTEM_CLOSING;canSystem[i].ledState = LED_TOG_STATE;}break;//舵机缓慢关闭状态 case CAN_SYSTEM_CLOSING:canSystem[i].pwmPulse-=PWM_PULSE_STEP;if(canSystem[i].pwmPulse<=PWM_PULSE_CLOSE){canSystem[i].pwmPulse = PWM_PULSE_CLOSE;canSystem[i].systemFlag = 0;canSystem[i].systemState = CAN_SYSTEM_INIT;canSystem[i].ledState = LED_OFF_STATE;}//修改舵机占空比__HAL_TIM_SetCompare(&htim3, channelTab[i], canSystem[i].pwmPulse);break;default:break;}}}
系统显示代码:
void LedStateControl(void){ uint8_t i = 0;for(i=0; i<CAN_CHANNEL_MAX; i++){if(canSystem[i].ledState==LED_OFF_STATE){HAL_GPIO_WritePin(LED_GPIO_Port, ledTab[i], GPIO_PIN_SET);}else if(canSystem[i].ledState==LED_TOG_STATE){HAL_GPIO_TogglePin(LED_GPIO_Port, ledTab[i]);}else if(canSystem[i].ledState==LED_ON_STATE){HAL_GPIO_WritePin(LED_GPIO_Port, ledTab[i], GPIO_PIN_RESET);}}}
此设计提供的资料包含原理图PCB(包含PDF,AD,立创EDA三个版本),源代码,系统框图,主程序流程图,物料清单(包含使用到的器件手册),功能操作说明等。