YS-LDV7 voice module secondary development

1. YS-LDV7 voice module:

  • Working voltage: 5V
  • Communication method: serial communication
  • Single chip microcomputer model: STC11L08XE

2. Source code modification:

(1) Use Keil uVision4 to modify and open the code:

Insert picture description here

(2)main.c:(Part of the code is omitted here

#ifdef TEST			//不执行测试命令则去掉 TEST
PrintCom("一级口令:小杰\r\n"); /*text.....*/
PrintCom("二级口令:1、代码测试\r\n"); /*text.....*/
PrintCom("	2、开发板验证\r\n"); /*text.....*/
PrintCom("	3、开灯\r\n"); /*text.....*/
PrintCom("	4、关灯\r\n"); /*text.....*/
PrintCom("  5、北京\r\n"); /*text.....*/
PrintCom("	6、上海\r\n"); /*text.....*/
PrintCom("	7、广州\r\n"); /*text.....*/
#endif

#define TEST		 //测试命令

TESTforTest commandMacro, add TESTit to run the code, here the code is to print the corresponding data to the serial port, do not want to executeTest command, Then #ifdef TESTremove the TESTmacro at

(3) LDChip.c: Modify keywords and identification codes (Part of the code is omitted here

uint8 LD_AsrAddFixed()
{
    
    

	#define DATE_A 50   /*数组二维数值*/				//关键词数量(可修改),建议不超过 50个
	#define DATE_B 70		/*数组一维数值*/			//关键词最长的长度(可修改),建议不长于 70
	uint8 code sRecog[DATE_A][DATE_B] = {
    
    
																				 "xiao jie",\		
																				 "kai fa ban yan zheng",\
																				 "dai ma ce shi",\
																				 "kai deng",\
																				 "guan deng",\
																				 "bei jing",\
																				 "shang hai",\
																				 "guang zhou"
																			};	/*添加关键词,用户修改*/
	uint8 code pCode[DATE_A] = {
    
    
															CODE_CMD,\
															CODE_KFBYZ,\
															CODE_DMCS,\
															CODE_KD,\
															CODE_GD,\
															CODE_BJ,\
															CODE_SH,\
															CODE_GZ
														 };	/*添加识别码,用户修改*/

The content to be added is the pinyin input method, for example, I want to add "Turn on the lights"Command, then write "kai deng", the pinyin between each Chinese character is usedSpaceSeparate;
the added identification code is a predefined macro definition constant value, and at the same timehave toAnd keywordsOne-to-one correspondence,As shown in FIG,"and even say itThe identification code corresponding to the command isCODE_DMCS

(4) LDChip.h: Modify the corresponding identification code according to the keyword (Part of the code is omitted here

//识别码客户修改处 
#define CODE_CMD  0x00   		//该命令码0x00用户不可进行修改。
#define CODE_DMCS	0x01		//代码测试
#define CODE_KFBYZ	0x02		//开发板验证
#define CODE_KD 0x04			//开灯
#define CODE_GD 0x05			//关灯
#define CODE_BJ 0x16			//关灯
#define CODE_SH 0x17			//上海
#define CODE_GZ	0x2f			//广州

Here is the addition and modification of the identification code. You can define the identification code and macro name arbitrarily according to your needs and preferences, but it must be paired with the previously used identification code, otherwise an undefined error will be prompted. The parameter range of the identification code is 01-FF. It is free to choose and has no specific meaning, as long as there is no duplicate.

(5) main.c: Modify the processing function (Part of the code is omitted here

switch(dat)		   /*对结果执行相关操作,客户可删除Printcom 串口输出语句替换为其他需要控制的代码*/
			  {
    
    
				  case CODE_DMCS:			/*命令“测试”*/
						PrintCom("“代码测试”命令识别成功\r\n"); /*text.....*/
													 break;
					case CODE_KFBYZ:	 /*命令“全开”*/
						PrintCom("“开发板验证”命令识别成功\r\n"); /*text.....*/
													 break;
					case CODE_KD:		/*命令“复位”*/				
						PrintCom("“开灯”命令识别成功\r\n"); /*text.....*/
													break;
					case CODE_GD:		/*命令“复位”*/				
						PrintCom("“关灯”命令识别成功\r\n"); /*text.....*/
													break;
					case CODE_BJ:		/*命令“复位”*/				
						PrintCom("“北京”命令识别成功\r\n"); /*text.....*/
													break;
					case CODE_SH:		/*命令“复位”*/				
						PrintCom("“上海”命令识别成功\r\n"); /*text.....*/
													break;
					case CODE_GZ:		/*命令“复位”*/				
						PrintCom("“广州”命令识别成功\r\n"); /*text.....*/
													break;
							default:PrintCom("请重新识别发口令\r\n"); /*text.....*/break;
				}

Users can add operations after successful identification after the corresponding identification code according to their own usage. Then after the device reaches a certain sentence, the corresponding action will be executed. In fact, this program is to judge the identification code and then execute the corresponding action. It belongs to the program application processing part of the single-chip microcomputer.

(6) After the modification is completed, check whether it can be compiled normally:

Insert picture description here

3. Module debugging:

(1) Module program download:

The program download of this module is actually the program download method of STC single-chip microcomputer. First, we need to install the USB to TTL driver (if installed, no need to install it), then connect the USB to TTL, and open STC-ISP:
Insert picture description here
①Select the MCU model
②Select the corresponding Serial port number
③Open program file>Open source program>Open objfolder>Select suffix .hexfile
④Pay attention to check "The reset pin is used as an I/O port",
⑤ Click "after settingDownload/program”And cold start
⑥After the cold start, the bottom progress bar will display the progress

(2) Debugging:

Insert picture description here
①Open the serial port assistant
②Select the receiving buffer "Text mode
③Select the corresponding serial port number
④Select 9600 baud rate ⑤Open the
serial port

Guess you like

Origin blog.csdn.net/lcx1837/article/details/114026233