aerobotics

2021 Electric Competition H-Electrical appliance identification and analysis device

 
Overview
# Table of contents* 1. Foreword* 2. Team introduction* 3. Question requirements* 4. Solution introduction* 5. Specific design* 6. Test results* 7. Summary# 1. Foreword The total list of the recent e-sports national awards is finally down Well, we originally entered the retest only to ensure that we were in the second place in the country. When we checked the list of winners, we found that there was an eye-catching red *first place in the country* behind our team. When the whole group was excited,~~I made a big meal that night. Meat, eggs and milk (bushi). ~~It just so happened that Lichuang launched this open source event again. At the invitation of Lichuang, we will open source this project. # 2. Team introduction Our team comes from the automation major of a university for nationalities in Wuhan. The team configuration is two hardware designers and one software designer. # 3. Question requirements![Topic requirements.png] ![Topic requirements 2.png] This question requires the design and production of a device that analyzes the type of electrical appliances in use based on the electrical parameter information of the power line current. The device has two working modes: learning and analysis and recognition. In the learning mode, the characteristic parameters used to identify each single electrical appliance are tested and stored; in the analysis and recognition mode, the category of the electrical appliance in use is indicated in real time. The key points and difficulties are: 1. The power grid has a large fluctuation range at different times and locations, which will affect the measurement of high-power electrical appliances, so that the power fluctuation can be as high as ±50W, which brings difficulties to the accurate identification of electrical appliances. great difficulty. 2. When measuring the combination of high-power electrical appliances and low-power electrical appliances, the spectrum characteristics of high-power electrical appliances will cover up the spectrum characteristics of low-power appliances, making identification extremely difficult. 3. How to identify electrical appliances with the same current but different impedance characteristics. 4. The choice of electrical appliances needs to be carefully considered. A good combination of electrical appliances will make your initial test results much better. # 4. Solution introduction ## System composition This system solution mainly uses STM32 F407 microcontroller as the system main control, communicates with the SUI-101A energy measurement module through the serial port, obtains active power, voltage, current and other electrical parameters, and uses these parameters to perform Appliance identification function. The SUI-101A module is connected to the socket through a current transformer to monitor electrical parameters. ![System block diagram.png] ![System diagram.jpg] ## Hardware circuit During the summer vacation, we have already adopted two methods: using current transformer mutual inductance and using CS5463 module. The current mutual inductance scheme used multiple electrical appliances or had large currents. FFT did not find any differences at the time. To be honest, CS5463 is much more stable than using a current transformer differential amplification. However, it is generally poor when identifying multiple electrical appliances at the same time, especially the same current. with large current. During the competition, I heard about the SUI-101A, and the unscrupulous merchant happened to refuse to ship the CS5463, so I quickly bought two of them, and found that they were easier to use than the CS (it was faster, which was a blessing in disguise). Therefore, this system mainly uses the SUI-101A module to obtain electric energy parameters. The overall layout of the module is as shown below, ![QQ picture 20211214155323.jpg] The module obtains current and voltage signals from the load line through current and voltage transformers respectively, and sends them to a 24-bit high-precision ADC for processing, and then sends the waveform data to The current, voltage and other parameter values ​​are calculated in the STM8 microcontroller, and finally transmitted to the STM32 F407 through the serial port for data analysis and identification of electrical appliances. Other than that, the circuit making part only made homemade electrical appliances (in the project). There is not much to say, but time was tight, so I made them directly with perforated boards. (So ​​strictly speaking, Lichuang was not used in the competition, orz! (But I have been using it all the time) Thanks to the boss for the bonus, hehehe~ The schematic diagram of the FFT scheme I made during the summer vacation was also included in the project, but the pcb was not used during the competition. A lot of changes have been made, and I will not put it up until it is basically deleted. However, it should be noted that this solution will directly expose the 220V high voltage. During the summer vacation, we made a double-layer structure, hot sol to prevent electric shock and other methods. If you want to reproduce For this question, I still recommend the fft solution, which can train your abilities. You can refer to another open source project (written by a bald man who stayed up late, really a boss, Risby) # 5. Specific design ## Program design Program design is relatively simple , the specific process is as follows: ![H question program flow chart.png] *Identification part: Since only active power among the measured parameters can satisfy linear superposition, I only used active power as the identification criterion. First, the parameters of the electrical appliances are stored in the structure of the corresponding electrical appliances, and different combinations of electrical appliances are generated through the cyclic remainder of the seven-digit binary code. Then the active power on the current load circuit is combined with the generated 128 combinations of electrical appliances. The power is compared. If the error of a certain combination is less than the threshold, it is determined that the combination is a combination of electrical appliances on the current load circuit, and then the binary code of the combination is decoded to obtain the electrical appliance combination. * Learning part: First clear the parameters in all electrical appliance structures, and then press up and down on the infrared remote control the number of the electrical appliance to be learned. Then the electrical appliance parameters can be recorded into the structure of the applied electrical appliance number. This completes the study. The core code is as follows: ``` C //Learning mode void learn_mode(void) { char tbuf[32]; float voltage; //Measure voltage float Current; //Measure current float Pow_fac; //Power factor float Pactive_pow; / /Active power float frequency; if(learn_flag_0==1){ learn_flag_0=0; app1.Pactive_pow=0; app2.Pactive_pow=0; app3.Pactive_pow=0; app4.Pactive_pow=0; app5.Pactive_pow=0; app6. Pactive_pow=0; app7.Pactive_pow=0; if(SUI_101A_Get(1,&Current_proper.voltage,&Current_proper.Current,&Current_proper.Pactive_pow,&Current_proper.Pow_fac,&Current_proper.frequency)==0){ //LCD_ShowString(20,60,200,16 ,16,"Learning...Please wait."); if(app_num==1) { app1.Current =Current_proper.Current; app1.voltage =Current_proper.voltage; app1.Pactive_pow =Current_proper.Pactive_pow; app1.Pow_fac = Current_proper.Pow_fac; } if(app_num==2) { app2.Current =Current_proper.Current; app2.voltage =Current_proper.voltage; app2.Pactive_pow =Current_proper.Pactive_pow; app2.Pow_fac =Current_proper.Pow_fac; } if(app_num= =3) { app3.Current =Current_proper.Current; app3.voltage =Current_proper.voltage; app3.Pactive_pow =Current_proper.Pactive_pow; app3.Pow_fac =Current_proper.Pow_fac; } if(app_num==4) { app4.Current =Current_proper .Current; app4.voltage =Current_proper.voltage; app4.Pactive_pow =Current_proper.Pactive_pow; app4.Pow_fac =Current_proper.Pow_fac; } if(app_num==5) { app5.Current =Current_proper.Current; voltage; app5.Pactive_pow =Current_proper.Pactive_pow; app5.Pow_fac =Current_proper.Pow_fac; } if(app_num==6) { app6.Current =Current_proper.Current; app6.voltage =Current_proper.voltage; app6.Pactive_pow =Current_proper.Pactive_pow ; app6.Pow_fac =Current_proper.Pow_fac; } if(app_num==7) { app7.Current =Current_proper.Current; app7.voltage =Current_proper.voltage; app7.Pactive_pow =Current_proper.Pactive_pow; app7.Pow_fac =Current_proper.Pow_fac; } } } } void JudgeSta(void) { int ElectricalSta[7]={0}; int len=7; int i=0,j=0; float p_sta[7]; //Working status of electrical appliances float p_sum; / /Total power float current; float power[7]={app1.Pactive_pow,app2.Pactive_pow,app3.Pactive_pow,app4.Pactive_pow,app5.Pactive_pow,app6.Pactive_pow,app7.Pactive_pow}; int times=0,timestmp=0 ; for( i=0;i<7;i++) { switch(i) { case 0:app1.sta="off"; break; case 1:app2.sta="off"; break; case 2:app3. sta="off"; break; case 3:app4.sta="off"; break; case 4:app5.sta="off"; break; case 5:app6.sta="off"; break; case 6: app7.sta="off"; break; } } for(times=0;times<128;times++) { timestmp=times; for(i=0;i<7;i++) ElectricalSta[i]=0; i=0; while(timestmp) { ElectricalSta[i]=timestmp%2; timestmp=timestmp/2; i++; } for(i = 0; i < len; i ++)//Traverse the array. { p_sta[i] = ElectricalSta[i]*power[i]; } for(i=0;i<7;i++) { p_sum+=p_sta[i]; } if(p_sum<1000){ if(fabsf(p_sum -Current_proper.Pactive_pow)<0.2) //Match assuming matching PowerSum { for( i=0;i<7;i++) { if(ElectricalSta[i]==1) { switch(i) { case 0:app1. sta="on"; break; case 1:app2.sta="on"; break; case 2:app3.sta="on"; break; case 3:app4.sta="on"; break; case 4: app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0; break; } p_sum=0; } else { if(fabsf(p_sum-Current_proper.Pactive_pow)<0.2) //Match assuming matching PowerSum { for( i=0;i<7;i++) { if(ElectricalSta[i]==1) { switch( i) { case 0:app1.sta="on"; break; case 1:app2.sta="on"; break; case 2:app3.sta="on"; break; case 3:app4.sta=" on"; break; case 4:app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0 ; break; } p_sum=0; } } } u8 SUI_101A_Get(u8 adder,float *vol,float *cur,float *pow,float *pf,float *fre){ u8 t=20; u8 rxlen=0; u8 i =0; u8 sum=0; u8 n=0; u8 CmdTxBuf[]={0x55,0x55,0x01,0x02,0x00,0x00,0xAD}; CmdTxBuf[2]=adder; Uart2_RxCnt=0; char buf[6] ; CmdTxBuf[6]=CmdTxBuf[0]+CmdTxBuf[1]+CmdTxBuf[2]+CmdTxBuf[3]+CmdTxBuf[4]+CmdTxBuf[5];//ÖØÐ¼ÆËãУÑéºÍ USART_SendBuf(USART2,CmdTxBuf,7); delay_ms(10); //µÈ´ý10ms,µÐ´ýÊý¾Ý·µ»Ø while(t){ t--; rxlen=Uart2_RxCnt; delay_ms(30); //µÈ´ý5ms,Á¬Ðø³¬¹ý5msûÓнÓÊÕµ½Ò» ¸öÊý¾Ý,ÔòÈÏΪ½ÓÊÕ½áÊø if((rxlen==Uart2_RxCnt)&&(rxlen!=0)){//½ÓÊÕµ½ÁËÊý¾Ý,ÇÒ½ÓÊÕÍê³ÉÁË if(rxlen==(Uart2_RxBuf[5] +7)){ //Êý¾Ý³¤¶ÈÕýË· } else { return 3;//Òì³£,Êý¾Ý³¤¶È´íÎó } sum=0; rxlen-=1;//³ýȥУÑéλµÄ³¤¶È for(i=0;i ```app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0; break; } p_sum=0; } else { if(fabsf(p_sum-Current_proper.Pactive_pow)<0.2) //Match assuming matching PowerSum { for( i=0;i<7;i++) { if(ElectricalSta[i]==1) { switch( i) { case 0:app1.sta="on"; break; case 1:app2.sta="on"; break; case 2:app3.sta="on"; break; case 3:app4.sta=" on"; break; case 4:app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0 ; break; } p_sum=0; } } } u8 SUI_101A_Get(u8 adder,float *vol,float *cur,float *pow,float *pf,float *fre){ u8 t=20; u8 rxlen=0; u8 i =0; u8 sum=0; u8 n=0; u8 CmdTxBuf[]={0x55,0x55,0x01,0x02,0x00,0x00,0xAD}; CmdTxBuf[2]=adder; Uart2_RxCnt=0; char buf[6] ; CmdTxBuf[6]=CmdTxBuf[0]+CmdTxBuf[1]+CmdTxBuf[2]+CmdTxBuf[3]+CmdTxBuf[4]+CmdTxBuf[5];//ÖØÐ¼ÆËãУÑéºÍ USART_SendBuf(USART2,CmdTxBuf,7); delay_ms(10); //µÈ´ý10ms,µÐ´ýÊý¾Ý·µ»Ø while(t){ t--; rxlen=Uart2_RxCnt; delay_ms(30); //µÈ´ý5ms,Á¬Ðø³¬¹ý5msûÓнÓÊÕµ½Ò» ¸öÊý¾Ý,ÔòÈÏΪ½ÓÊÕ½áÊø if((rxlen==Uart2_RxCnt)&&(rxlen!=0)){//½ÓÊÕµ½ÁËÊý¾Ý,ÇÒ½ÓÊÕÍê³ÉÁË if(rxlen==(Uart2_RxBuf[5] +7)){ //Êý¾Ý³¤¶ÈÕýË· } else { return 3;//Òì³£,Êý¾Ý³¤¶È´íÎó } sum=0; rxlen-=1;//³ýȥУÑéλµÄ³¤¶È for(i=0;i ```app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0; break; } p_sum=0; } else { if(fabsf(p_sum-Current_proper.Pactive_pow)<0.2) //Match assuming matching PowerSum { for( i=0;i<7;i++) { if(ElectricalSta[i]==1) { switch( i) { case 0:app1.sta="on"; break; case 1:app2.sta="on"; break; case 2:app3.sta="on"; break; case 3:app4.sta=" on"; break; case 4:app5.sta="on"; break; case 5:app6.sta="on"; break; case 6:app7.sta="on"; break; } } } p_sum=0 ; break; } p_sum=0; } } } u8 SUI_101A_Get(u8 adder,float *vol,float *cur,float *pow,float *pf,float *fre){ u8 t=20; u8 rxlen=0; u8 i =0; u8 sum=0; u8 n=0; u8 CmdTxBuf[]={0x55,0x55,0x01,0x02,0x00,0x00,0xAD}; CmdTxBuf[2]=adder; Uart2_RxCnt=0; char buf[6] ; CmdTxBuf[6]=CmdTxBuf[0]+CmdTxBuf[1]+CmdTxBuf[2]+CmdTxBuf[3]+CmdTxBuf[4]+CmdTxBuf[5];//ÖØÐ¼ÆËãУÑéºÍ USART_SendBuf(USART2,CmdTxBuf,7); delay_ms(10); //µÈ´ý10ms,µÐ´ýÊý¾Ý·µ»Ø while(t){ t--; rxlen=Uart2_RxCnt; delay_ms(30); //µÈ´ý5ms,Á¬Ðø³¬¹ý5msûÓнÓÊÕµ½Ò» ¸öÊý¾Ý,ÔòÈÏΪ½ÓÊÕ½áÊø if((rxlen==Uart2_RxCnt)&&(rxlen!=0)){//½ÓÊÕµ½ÁËÊý¾Ý,ÇÒ½ÓÊÕÍê³ÉÁË if(rxlen==(Uart2_RxBuf[5] +7)){ //Êý¾Ý³¤¶ÈÕýË· } else { return 3;//Òì³£,Êý¾Ý³¤¶È´íÎó } sum=0; rxlen-=1;//³ýȥУÑéλµÄ³¤¶È for(i=0;i ``` ** 6. Test results ** [Specific test results](https://www.bilibili.com/video/BV15r4y1D7wN?from=search&seid=15783606942855832458&spm_id_from=333.337.0.0) are placed in the video. If you are interested, you can take a look ** 7. Summary ** This question involves a lot of luck, because I had already done question K in 2017 during summer training. It was also the first time I was exposed to 220V voltage, and I had several accidents, and I used FFT. The actual effect of the finished product of the solution is really mediocre. The amplitude of the fundamental wave is unstable and even jitters up to ±10%. Moreover, the analysis value of the other harmonics except the fundamental wave is really not great. After thinking about it for a long time, I still can’t figure out how to deal with it. Finally, I changed the electric energy measurement module and used a single parameter criterion, and finally found that the effect was good. It can only be said that the best solution is simplicity, and the solution that can complete the task is a good solution! Tsk, I thought back to the situation when this year's competition was postponed. The resurgence of the epidemic caused panic in the entire laboratory. At that time, I just wanted to run away, but I didn't expect that I was now in the first grade of the country... In addition, after the game, I found that this Ji Guoyi is really lucky. Most teams that use FFT solutions to analyze electrical harmonics have different problems during testing. Teams like ours that use off-the-shelf modules and only use a single parameter as a criterion are promoted to the top. The first country in the country, and even the most critical code for generating binary encoding combinations was found on CSDN, so this country one really deserves it. But I have to say that as the only award I have received since I was a child, it was Qin Shihuang who touched the wires - he won!
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-19 05:13:05
  • Socket programming problems
  • Good resource recommendation of the week: 2016.11.28-2016.12.4
  • IAR for 8051 error [e16] for beginners
  • 【C2000 LaunchPad】Build your own C2000 LaunchPad project
  • Floating lights powered by ocean waves
  • Good resource of the week - PCB layout guide

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号