简体   繁体   English

通过串口将流量计读数导入excel

[英]importing flow meter reading to excel via serial communication port

I'll be getting readings from an flow meter to serial port via serial communication.我将通过串行通信从流量计到串行端口获取读数。

I need to automatically collect incoming flow rate readings at 1 minute intervals for every hour.我需要每隔 1 分钟自动收集每小时的流入流量读数。

Then i need to automatically calculate an average for each hour.然后我需要自动计算每小时的平均值。

The hourly averages are calculated using the readings collected at 1 minute intervals.每小时平均值是使用以 1 分钟间隔收集的读数计算的。

The averages should then be displayed in MS excel.然后应将平均值显示在 MS excel 中。

  1. Can i use Visual basic for applications and excel or should i use NI lab view?我可以将 Visual basic 用于应用程序和 excel 还是应该使用 NI 实验室视图?
  2. Should i use another method?我应该使用另一种方法吗?

What is the best proven way to perform this?执行此操作的最佳行之有效的方法是什么?

I will be suggesting to use NI LabVIEW to connect to RS trough VISA.我将建议使用 NI LabVIEW 通过 VISA 连接到 RS。 There are build in and additional libs to work with RS there.那里有内置和额外的库可以与 RS 一起使用。 To export to excel you can use write to spreadsheet .vi or to do it professionally go with NI Report Generation Toolkit for LabVIEW.要导出到 excel,您可以使用写入电子表格 .vi 或使用 NI LabVIEW 报告生成工具包进行专业操作。

Please let me know if you need more info.如果您需要更多信息,请告诉我。

There are many ways of achieving this, but if you have access to LabVIEW and you have details of the data format used by your flowmeter then LabVIEW is a good choice.有很多方法可以实现这一点,但是如果您可以访问 LabVIEW 并且您有流量计使用的数据格式的详细信息,那么 LabVIEW 是一个不错的选择。

Use the serial functions in the Instrument I/O>Serial palette to read the data - look at the examples provided with LabVIEW to learn how to do this.使用 Instrument I/O>Serial 调色板中的串行函数读取数据 - 查看 LabVIEW 提供的示例以了解如何执行此操作。 You may want to use Scan from String to interpret the flowmeter's output and convert it into a number, then you'll probably want to put that code inside a While loop to accumulate the numbers into an array, and calculate the average once you have collected the required number of points.您可能希望使用 Scan from String 来解释流量计的输出并将其转换为数字,然后您可能希望将该代码放入 While 循环中以将数字累加到数组中,并在收集后计算平均值所需的点数。

To write the data to Excel you can use Write To Spreadsheet File to save it in tab- or comma-separated format, or Express>Output>Write to Measurement File which can save as .xslx.要将数据写入 Excel,您可以使用 Write To Spreadsheet File 将其保存为制表符或逗号分隔格式,或使用 Express>Output>Write to Measurement File 保存为 .xslx。

If you don't yet have access to the hardware, you can use a case structure or conditional disable structure to either perform the serial I/O or to return simulated data to the rest of your program.如果您还不能访问硬件,您可以使用 case 结构或条件禁用结构来执行串行 I/O 或将模拟数据返回到程序的其余部分。 Or (better) if you have two serial ports on your computer, you could physically connect the two ports with a null modem cable and either use a terminal program to send simulated data or write a second LabVIEW VI to emulate the flowmeter on the second serial port - LabVIEW should have no problem running the two VIs simultaneously.或者(更好)如果您的计算机上有两个串行端口,您可以使用空调制解调器电缆物理连接这两个端口,并使用终端程序发送模拟数据或编写第二个 LabVIEW VI 来模拟第二个串行上的流量计端口 - LabVIEW 同时运行两个 VI 应该没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM