跨越平台的INA3221驱动生态:从Arduino到Linux的兼容性与性能对比

INA3221的使用教程(IIC) INA3221使用方法和INA226基本上一致,多了选择多通道读取,根据数据手册制定不一样的初始化代码。 INA3221不能够直接读分流电阻的电流,但可以通过算得两端电压算出电流。 上代码: INA3221.c: #include "INA3221.h" static void delay_nns_3221(uint16_t D) //30纳秒ns 根据手册要用到IIC的HS高... 阅读详情

跨越平台的INA3221驱动生态:从Arduino到Linux的兼容性与性能对比

在当今物联网和边缘计算蓬勃发展的时代,精确的电源监控已成为系统设计不可或缺的一环。德州仪器的INA3221三通道电流/功率监测芯片凭借其高精度测量和灵活配置,成为众多开发者的首选。然而,面对从资源受限的微控制器到功能丰富的Linux系统的多样化平台,如何选择合适的驱动方案并实现最佳性能,成为开发者面临的实际挑战。

本文将深入探讨INA3221在不同平台上的驱动实现差异,从Arduino的简单易用到Linux内核驱动的强大功能,为跨平台开发者提供全面的技术视角和实用指南。无论您是嵌入式系统工程师、物联网设备开发者,还是开源硬件爱好者,都能在这里找到适合您项目的解决方案。

1. INA3221硬件特性与跨平台适配基础

INA3221是一款集成式三通道高侧电流和总线电压监测器,支持I2C和SMBus接口。其核心优势在于能够同时监测三个独立通道的分流电压和总线电压,精度达到±1%,测量范围覆盖0-26V总线电压和±3.2A电流。这种硬件特性使其特别适合多电源系统的监控需求,如电池供电设备、太阳能系统和工业控制装置。

关键硬件参数对比:

参数 规格 影响
总线电压范围 0-26V 决定可监测的电源电压等级
电流测量范围 ±3.2A 内置0.05Ω分流电阻的限制
转换时间 140μs-8.244ms 影响采样速率和功耗
平均模式 1-1024次采样 平衡噪声抑制和响应速度
接口 I2C/SMBus兼容 决定通信协议和速率

在实际跨平台开发中,理解这些硬件特性至关重要。不同的平台对硬件的抽象程度不同,从Arduino的直接寄存器操作到Linux的完整硬件监控子系统,驱动实现方式差异显著。选择适合的驱动方案需要综合考虑开发效率、性能要求和系统资源限制。

提示:虽然INA3221支持高达26V的总线电压监测,但实际应用中建议留出适当余量,避免瞬态电压峰值导致测量不准确或器件损坏。

2. Arduino平台驱动实现与优化策略

Arduino平台以其简单易用和丰富的生态系统著称,是快速原型开发和教育的理想选择。在Arduino环境下,INA3221通常通过专门的库文件实现,如Adafruit_INA3221库,这些库提供了高级API抽象,极大简化了开发流程。

典型Arduino驱动配置流程:

#include <Wire.h>
#include <Adafruit_INA3221.h>

Adafruit_INA3221 ina3221 = Adafruit_INA3221();

void setup() {
  Serial.begin(9600);
  while (!Serial) { delay(10); }
  
  if (!ina3221.begin()) {
    Serial.println("找不到INA3221芯片");
    while (1);
【Arduino+ESP32专题】案例:使用INA3221监控电压电流 买的INA3221模块为什么就不能用,到底是什么点会导致的纠结? 阅读详情

相关推荐

【Arduino+ESP32专题】一起来读INA3221数据手册 1

INA3221感测的总线电压范围为0~26V,电源输入电压2.7V~5.5V(因此可以用3.3V或5V电源供电),有三个通道并且是高侧电流检测,能反馈总线电压和分流电压等。分流电压(shunt voltage)是VIN+和VIN-之间的电流采样电阻的差分电压,总线电压(bus voltage)是VIN-对地的电压,​​​​​​​可以独立或顺序测量。

一点硬件 2864

【Arduino+ESP32专题】案例:使用INA3221监控电压电流 2

硬件焊接完成,软件程序也要跟上,先将硬件驱动起来,应用再慢慢优化。

一点硬件 2052

【Arduino+ESP32专题】案例:INA228芯片能读到芯片地址却无法读到电压电流数据

遇到异常时,最简单的方法就是ABA交叉互换。

一点硬件 1758

INA3221芯片的太阳能监控与BMS应用教程与评估

INA3221是一款三通道电流/电压监控器,设计用于测量和监测功率应用中的电压和电流。它拥有高精度和灵活的配置选项,可以广泛应用于太阳能系统、电池管理系统(BMS)和电源监控等多个领域。INA3221EVM评估板是为工程师设计的,便于评估和测试INA3221芯片的功能。它支持电压、电流的测量与监控,并提供了灵活的硬件配置选项,以适应不同的应用场景。EVM评估板通常包含了多个通道的电压和电流测量能力,以及可编程的GPIO接口,使得工程师能够进行个性化的测试配置。

weixin_31185473的博客 1171

Arduino-INA3221:用于INA3221三通道电流和电压传感器的Arduino库

INA3221库 用于INA3221电流和电压传感器的Arduino库。

STM32INA3221电压电流实时显示OLED工程

使用STM32单片机做主控,驱动INA3221模块采集电压和电流,实时显示在OLED上。cubeMX配置HAL库开发

ina3221_ina3221_

INA3221 三通道、高侧测量、分流和总线电压监视器模块资料

ina3221.pdf

ina3221.pdf

第七章 Wi-Fi连接过程

系列文章目录 第一章 国内下载AOSP最新源码的方法 第二章 下载AOSP WiFi相关的代码 第三章 将源码导入Android Studio(无需编译idegen) 文章目录系列文章目录前言一、Wi-Fi连接是什么?二、Wi-Fi连接的过程1. 手动连接总结 前言 Wi-Fi连接分为下面几种过程,每种的流程都有些许差异: 手动连接 自动连接 在BSS之间漫游 Passpoint热点连接 一、Wi-Fi连接是什么? Wi-Fi连接是指STA(手机)连接到AP(无线路由器)的过程,这个过程分为链路

Frank.Zhang的专栏 2527

C++上机——2023年“信息与未来”小学生编程思维展示官方题解

本次活动前三题是“根据问题描述实现代码”类型的问题,题解和示例代码由人工智能GPT-4直接阅读题面后生成――只要熟悉C++的语法和基本的编程、调试,即可解决p1、p2、p3。后三题有一定的算法性,我们给出命题思路和一些可能的解法。注意:本题解是面向指导教师的;指导教师在讲解时可以根据学生掌握程度进行调整。

qq_39127687的博客 2297

二阶锥松弛在配电网最优潮流计算中的应用(IEEE33节点配电网最优潮流算例matlab程序)(yalmip+cplex)

文献[7]建立了以支路潮流计算为基础的OPF模型,针对OPF中的非凸性约束,采用SOCR技术将其松弛为二阶锥约束,整个 OPF 模型则被转化为二阶锥规划( Second Order Cone Programming,SOCP)问题,对其求解可以得到全局最优解。其次结合辐射型配电网潮流特点建立支路潮流约束,并考虑配电网中的可控单元,包括分布式电源和离散、连续无功补偿装置,建立其出力约束,该模型为非凸非线性模型;式中,αj,t和βij,t分别为t时段内节点i电压的二次方和支路ij电流的二次方。

weixin_47365903的博客 1万+

Python逆向爬取Tik Tok,MsToken,X-Bogus以及signature

tiktok作为字节海外的自媒体平台,具有很非常大的价值,本文旨在教会大家实现Tik Tok的签名获取以及数据的最终爬取。

weixin_74305707的博客 3271

【dify】 dify环境变量配置说明

SMTP_SERVER、SMTP_PORT、SMTP_USERNAME、SMTP_PASSWORD、SMTP_USE_TLS、SMTP_OPPORTUNISTIC_TLS:当 MAIL_TYPE 为 smtp 时,SMTP服务器的相关配置。UPLOAD_IMAGE_FILE_SIZE_LIMIT、UPLOAD_VIDEO_FILE_SIZE_LIMIT、UPLOAD_AUDIO_FILE_SIZE_LIMIT:分别为上传图像、视频、音频文件的大小限制(MB)。

tonysh_zds的博客 7357

dbt+Snowflake实战:数据建模、权限隔离与性能优化全指南

dbt(data build tool)作为现代数据栈的核心建模工具,其与Snowflake的深度协同远不止于SQL编译执行——它本质是将软件工程实践(如版本控制、测试驱动、CI/CD)注入数据交付流程。理解dbt的声明式建模原理与Snowflake的虚拟仓库、Time Travel、TRANSIENT表、聚簇键等底层机制如何咬合,是实现可维护、可审计、低成本数据产品交付的关键。本文聚焦dbt在Snowflake环境中的真实落地挑战,涵盖schema与warehouse的物理映射设计、role级硬隔离策略、

weixin_34389926的博客 314

从XSA到Linux应用:Petalinux与Vitis的嵌入式开发全流程解析

本文详细解析了从XSA文件到Linux应用的嵌入式开发全流程,重点介绍了Petalinux与Vitis工具链的使用技巧和实战经验。通过XSA硬件描述、Petalinux工程搭建、系统镜像优化及Vitis开发配置等关键步骤,帮助开发者高效完成ZYNQ平台开发,解决常见问题并提升开发效率。

weixin_29195217的博客 192

windows10 + wsl2安装docker

一、安装wsl https://docs.microsoft.com/zh-cn/windows/wsl/install-win10 1.1以管理员身份运行powershell 1.2执行如下命令 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 1.3重启电脑 1.4 重启电脑后,如果需要安装wsl2, 则安装官方文档继续后续操作,因我...

happytree001的博客 1570

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 从AUXR寄存器探秘:STC单片机定时器2的1T/12T模式设计与性能调优实战
下一篇: KDE的数学之美:从核函数选择到带宽优化的原理探秘
pluto
博客等级 码龄25年 46粉丝 1562原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值