· 2022年09月02日 · 甘肃

【MM32F5270开发板试用】一、基于MindSDK的电能监测

一 项目简介

本次测评基于实际项目需求,主要实现设备的本地控制,电能监测,设备状态在线监测等基本功能,所有采集信息在触摸屏上显示。目前主要实现电能监测功能的实现,将测量结果显示到陶晶驰串口屏上。

二 模块介绍

1 陶晶驰串口屏
      串口屏:用于简化屏幕开发的一个集成度比较高的屏幕,一般屏幕上集合了运算能力比较强的单片机,用于独立处理屏幕事件与通讯。通过串口协议与其他主控板进行通讯,从而对屏幕进行交互控制,搭配一个pc端图形化开发界面,用于降低开发难度。
 title=
 title=
 title=
2电能计量模块
        单相交直流自适应电能计量模块IM1266,是深圳艾锐达光电有限公司为产品用电情况监控而研发的模块。可测量电压,电流,功率,功率因数,频率等电气数据,通过串口与单片机通讯,实现自动化数据采集及监控功能。
 title=
 title=
 title=
与PLUS-F5270开发板连接示意图如下所示
 title=

三 代码实现

代码结构如下
 title=
串口读取IM1266参数指令

void do_IM1266(){  
  
    uint8_t hostSend_IM1266[8]={0x01,0x03,0x00,0x48,0x00,  
                                0x08,0xc4,0x1a};  
//发送读数据指令  
   for(uint8_t i=0;i<8;i++)  
   {  
     app_uart_putchar(hostSend_IM1266[i]);  
   }  
}

串口发送接收到的电能参数数据到串口屏

//显示电压  
  sprintf(buf,"JiaoLiu.x0.val=%#04x%04x",electricity_data[0],electricity_data[1]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  delay_ms(5);
  n = 4;
  sprintf(buf,"JiaoLiu.x0.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff); 
  
//显示电流   
  sprintf(buf,"JiaoLiu.x1.val=%#04x%04x",electricity_data[2],electricity_data[3]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  n = 4;
  sprintf(buf,"JiaoLiu.x1.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  delay_ms(5); 
  
//显示功率    、
  sprintf(buf,"JiaoLiu.x3.val=%#04x%04x",electricity_data[4],electricity_data[5]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  n = 4;
  sprintf(buf,"JiaoLiu.x3.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff); 
  delay_ms(5);  
  
//显示电量     
  sprintf(buf,"JiaoLiu.x2.val=%#04x%04x",electricity_data[6],electricity_data[7]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  n = 4;
  sprintf(buf,"JiaoLiu.x2.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff); 
  delay_ms(5);   
  
 //显示功率因数 
  sprintf(buf,"JiaoLiu.x5.val=%#04x%04x",electricity_data[8],electricity_data[9]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff); 
  n = 3;
  sprintf(buf,"JiaoLiu.x5.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);   
  
//显示频率 
  sprintf(buf,"JiaoLiu.x4.val=%#04x%04x",electricity_data[10],electricity_data[11]);  
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  delay_ms(5);
  n = 2;
  sprintf(buf,"JiaoLiu.x4.vvs1=%d",n);
  app_uart_putstr(buf);
  app_uart_putchar(0xff); 
  app_uart_putchar(0xff);
  app_uart_putchar(0xff);
  delay_ms(5);

四 效果演示

读取IM126数值的测试结果
 title= title=
陶晶驰串口屏界面开发
 title=
MM32F5270开发板成功读取IM266参数后显示在串口屏上
 title=

五 测评总结

通过这段时间对MindSDK的使用,整体感觉很好,高度封装便于移植,串口开发有现成的API函数,极大缩短了开发周期,后期还会继续此工程的开发。

推荐阅读
关注数
6151
内容数
276
灵动MM32 MCU相关技术知识,欢迎关注~
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息