Voice controlled infrared experiment

1, Introduction to experiment

A small experiment made by personal learning. The function is to use the voice and infrared functions of one board to control the LED light on and off and buzzer response of another board.

2, Modules used

1. Two stm32f4 series boards

2. One ld3320 speech recognition module

3. 2 infrared transceiver modules (with NEC encoding and decoding)

4. One buzzer module

5. One power supply module (5V, 3.3V)

3, Experimental principle

1.STM32 and LD3320 adopt SPI communication control

2. The STM32 and infrared module are controlled by USART serial port communication

4, Experimental operation

1. Transplant LD3320 code to the first F4 board;

2. Connect an infrared module to the first F4 board;

3. Connect one infrared module and buzzer module to the second F4 board.

Note: the operation is relatively simple, so the details are omitted. The only trouble in the whole experiment is the code transplantation of voice module. The LD3320 program provided by the manufacturer is the program of F1 series board. Transplanting to F4 series board takes some time and energy, and it is easy to make mistakes.

5, Experimental phenomenon

1. I set six instructions, which are

#define CODE_KHD      1 	 /* Turn on the yellow light*/
#define CODE_GDHD 	   two 	 /* Turn off the yellow light*/
#define CODE_KLD 	   three 	 /* Turn on the blue light*/
#define CODE_GDLD 	   four 	 /* Turn off the blue light*/
#define CODE_KFMQ 	   five 	 /* Turn on the buzzer*/
#define CODE_GDFMQ 	   six 	 /* Turn off the buzzer*/

2. Say the response command. After the first board is identified, issue the corresponding infrared command. After the second board receives the identification, execute the response command.

6, Experimental summary

1. Transplantation and debugging

The most time-consuming part of the whole experiment is the transplantation and debugging of LD3320 module code. Sometimes it's amazing to do hardware things. I don't know what's wrong. Is it code? Or hardware? Or power? Until the problem is found, it needs to be checked one by one. Something that looks simple may take a lot of time.

① If you don't want to spend too much time here, one thing to pay attention to is to buy modules. You should first check whether there are supporting materials, whether the materials are complete, etc., because generally, Taobao stores will not provide technical support. If you need to modify the driver of the purchased modules, they are very large and have high requirements for capability. Like this LD3320, there is no need for dynamic drive. When transplanting to F4 board, you only need to modify some simple things such as macro definition, pin and GPIO configuration. SPI timing does not need to be touched.

② I just got started and only used a few modules. I found that their programs are written based on F1 series boards. I speculate that the data routines of many modules on the Internet are based on F1 series. Therefore, taking F1 series boards to use these modules will save a lot of trouble. It's normal to think back, because the popular tutorials on the Internet also use F1 boards. Generally, F1 boards are also completely enough. But one advantage is that the transplantation of cross board models will make you learn better.

2. Power supply

The story about power supply, I hope this story can arouse our attention to power supply.

I bought two 5 V / 3.3 V power supply modules for a few yuan. The code I adjusted was reused after a period of time, and it was found that the voice function was abnormal. I thought it was because I didn't know when to change the code, and I suspected that there was a problem with the hardware connection, or some DuPont lines were broken, so I went through the whole process. Finally, I tested the power supply with the ADC function, and found that it was the power supply problem. I lost the first power module and used the second. The previous voice problem was solved, the whole operation was normal, and then there was a problem with the infrared. Because the voice problem was solved, I didn't immediately doubt the power supply. It's upside down. I suspect the infrared module may be broken. At that time, the new infrared module was added to the shopping cart. Finally, with the psychology of trying, the infrared 5V power supply was borne by the serial port CH340, and then... And then it was normal.

7, LD3320 instruction modification

1. Modify the array in LDCChip.c.

uint8 LD_AsrAddFixed(void)
{
	uint8 k, flag;
	uint8 nAsrAddLength;
	#define DATE_A 6 / * array 2D values * / / * correspond to 6 instructions*/
	#define DATE_B 40 		/* Array one-dimensional value * / / * maximum length of each instruction*/
	 uint8  sRecog[DATE_A][DATE_B] = {
	 											"da kai huang deng",\    /* Pinyin of instruction */
												"guan diao huang deng",\
												"da kai lan deng",\
												"guan diao lan deng",\
												"kai feng ming qi",\
												"guan diao feng ming qi"
															};	/*Add keywords, user modify*/
	 uint8  pCode[DATE_A] = {
	 															CODE_KHD,\
																CODE_GDHD,\
																CODE_KLD,\
																CODE_GDLD,\
																CODE_KFMQ,\
																CODE_GDFMQ\
															};	/*Add identification code, user can modify*/

2. Modify the macro definition in LDChip.h.

//Identification code (customer modification)
#define CODE_KHD      1 	 /* Turn on the yellow light*/
#define CODE_GDHD 	   two 	 /* Turn off the yellow light*/
#define CODE_KLD 	   three 	 /* Turn on the blue light*/
#define CODE_GDLD 	   four 	 /* Turn off the blue light*/
#define CODE_KFMQ 	   five 	 /* Turn on the buzzer*/
#define CODE_GDFMQ 	   six 	 /* Turn off the buzzer*/

3. Modify ld3320_ The case statement in main. C corresponds to the above macro definition.

							 switch(nAsrRes)		   /*Perform relevant operations on the results and modify them by the customer*/
						                    {
									  case CODE_KHD:			/*Command "turn on yellow light"*/
															
									  YELLOW_LED_ON();  /* Send an infrared command to turn on the yellow light */
													  
				Usart_SendString(USART1,""The "turn on yellow light" command is recognized successfully\r\n"); /*Send prompt to computer*/
																						 														break;																			  
									case CODE_GDHD:	 /*Command "turn off the yellow light"*/
															
									YELLOW_LED_OFF();
														
			    Usart_SendString(USART1,"""Turn off the yellow light" command is recognized successfully\r\n"); /*text.....*/
																						 														break;
																					
									case CODE_KLD:		/*Command "turn on blue light"*/
															
									BLUE_LED_ON();
														
				Usart_SendString(USART1,""The "turn on blue light" command is recognized successfully\r\n"); /*text.....*/
																																				break;																									
														
									case CODE_GDLD:		/*Command "turn off the blue light"*/
															
									BLUE_LED_OFF();
														
				Usart_SendString(USART1,""The "turn off blue light" command is recognized successfully\r\n"); /*text.....*/
																																				break;		
														
									case CODE_KFMQ:		/*Command "on buzzer"*/
															
									BEEP_ON();
														
				Usart_SendString(USART1,""The "on buzzer" command is recognized successfully\r\n"); /*text.....*/
														
														    																					break;	
														
									case CODE_GDFMQ:		/*Command "all out"*/
												
									BEEP_OFF();	
														
				Usart_SendString(USART1,""The "turn off buzzer" command is recognized successfully\r\n"); /*text.....*/
																																				break;
																			
														default:break;
													}	

8, Experimental image

1. Full picture of experiment

2.LD3320 voice module

3. Infrared transceiver module

Note: if necessary, go to my home page to download the supporting materials "LD3320, infrared data. zip", and the codes are in it (Standard Library).

Keywords: Embedded system stm32

Added by ProTec on Fri, 01 Oct 2021 07:03:43 +0300