开源工程系列之INA219功率计

我比较好奇各种低压用电设备的工作电流是多少,USB供电的自不必说,还有路由器啊、ONU什么的。想起TI有专门的电流检测芯片,看了一下,INA219挺适合我,于是决定动手了。显示就用闲置的1602液晶,单片机自然还是用库存的51单片机了。

电流/功率零点校准 空载 电子负载漏电流 电流满量程校准/测量 U盘电流测量 WNDR3700静态电流测量

 

特性:

  • 输入电压4.6V~13V,自身从电源取电,无需多挂一个电源适配器,电流小于25mA(背光开启)
  • 电流量程0~2.5A
  • 电压显示颗粒度4mV,电流显示颗粒度1mA,功率显示颗粒度1mW
  • 支持USB 3.0设备
  • USB数据透传
  • 支持5.5-2.1mm DC电源插头
  • 显示总线电压、负载电流和负载功率
  • 0.5秒/0.8秒刷新时间可切换

 

 

附件(原理图、光绘文件、源代码)

空白PCB在闲鱼有售

 

题外话:在3.3V系统中使用本是5V供电的1602液晶

这个闲置的液晶是5V供电的,直接安装到底板上无法显示内容,原因是对比度无法调节到合适值。液晶第三脚是对比度控制脚,在供电电压是3.3V的情况下加到3脚上的电压应在-1V左右液晶方能正常显示。

通常液晶模块上已预留一个负压产生电路的位置,输出端和液晶第三脚是相连的,芯片是7660(TL7660/LMC7660/ICL7660/JRC7660/LTC660……),配上两个10µF电容和分压电阻就可以工作了,不过纹波很大。我在7660负压输出端增加了滤波电容,在液晶第三脚上增加了去耦电容。有些液晶模块的负压发生电路可能有跳线焊盘,需要反推原理图,按需连接。假如没有负压发生电路,在底板上做一个即可。

3.3V供电时这个液晶的背光电流大概4mA(接通背光开关的情况下)。为了进一步降低功耗并且保持背光常亮,我在背光开关上又并联了225欧电阻,在不接通背光开关的情况下背光电流大概2mA。为了增加亮度,我把液晶的背光纸也去掉了。

 

转载于:https://www.cnblogs.com/elysium/p/INA219_Power_Meter.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
51单片机IINA219 测电流电压和功率。 #include "LCD1602\LCD1602.h" #include "INA219_DRV\INA219_DRV.h" #include "common\common.h" #define TH0_VALUE 0x4B #define TL0_VALUE 0xFF //50ms per cycle. sbit BtnRefreshMode = P3^2; bit RefreshRate = 0; //0: 0.8s, 1: 0.5s bit RefreshFlag = 0; void RefreshData(void) { unsigned short BusVolt, Current, Power; unsigned short OffsetCurrent, OffsetPower; BusVolt = INA219_GetBusVolt(); PrintChar(0, 0, BusVolt/10000+48); PrintChar(1, 0, (BusVolt000)/1000+48); PrintChar(3, 0, (BusVolt00)/100+48); PrintChar(4, 0, (BusVolt0)/10+48); PrintChar(5, 0, BusVolt+48); OffsetCurrent = (BusVolt >> 9) + 2; //Gather statistics of the measured current under various voltage conditions when no load is connected to the output port. Use Excel to do curve fitting. Current = INA219_GetCurrent(); if(Current > OffsetCurrent) Current -= OffsetCurrent; else Current = 0; PrintChar(10, 0, Current/1000+48); PrintChar(12, 0, (Current00)/100+48); PrintChar(13, 0, (Current0)/10+48); PrintChar(14, 0, Current+48); OffsetPower = ((BusVolt >> 3) * OffsetCurrent)/125 + 6; Power = INA219_GetPower(); if(Power > OffsetPower) Power -= OffsetPower; else Power = 0; PrintChar(0, 1, Power/10000+48); PrintChar(1, 1, (Power000)/1000+48); PrintChar(3, 1, (Power00)/100+48); PrintChar(4, 1, (Power0)/10+48); PrintChar(5, 1, Power+48); } int main(void) { INA219_Init(); LCD_Init(); TMOD &= 0xF0; TMOD |= 0x01; //Timer 0 works in Mode 1 (16-bit Timer). TH0 = TH0_VALUE; TL0 = TL0_VALUE; PrintChar(2, 0, '.'); PrintChar(6, 0, 'V'); PrintChar(11, 0, '.'); PrintChar(15, 0, 'A'); PrintChar(2, 1, '.'); PrintChar(6, 1, 'W'); PrintStr(10, 1, "R:0.8s"); RefreshData(); EA = 1; //Global Interrupt Enable ET0 = 1; //Timer 0 Interrupt Enable TR0 = 1; //Enable Timer 0. while(1) { if(RefreshFlag) { RefreshData(); RefreshFlag = 0; } if(BtnRefreshMode == 0) //If the

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值