2

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.

Then i need to automatically calculate an average for each hour.

The hourly averages are calculated using the readings collected at 1 minute intervals.

The averages should then be displayed in MS excel.

  1. Can i use Visual basic for applications and excel or should i use NI lab view?
  2. Should i use another method?

What is the best proven way to perform this?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
adrian
  • 284
  • 2
  • 4
  • 14

2 Answers2

1

I will be suggesting to use NI LabVIEW to connect to RS trough VISA. There are build in and additional libs to work with RS there. To export to excel you can use write to spreadsheet .vi or to do it professionally go with NI Report Generation Toolkit for LabVIEW.

Please let me know if you need more info.

Khachik Sahakyan
  • 1,982
  • 15
  • 24
  • Thank you very much i will let you know soon – adrian Nov 26 '14 at 10:01
  • At the moment i cannot physically make connection with hardware. I am thinking of using a Virtual serial port emulator software for the moment. Do u know of any reliable emulator softwares? – adrian Nov 26 '14 at 10:39
  • If the hardware is connected to a system on a network, you can load an NI-VISA Server on the remote system and access the hardware via TCP/IP. You need to pay attention to the setup of the server, but I've used this technique to control and read from a remote GPIB power supply with good results. http://digital.ni.com/public.nsf/allkb/F3AB0B5D7DBA367C86257982005BBF2C – Phil Brooks Nov 26 '14 at 11:47
  • Here are some free sources: https://en.wikipedia.org/wiki/COM_port_redirector#Open_source_solutions – Khachik Sahakyan Nov 26 '14 at 14:03
1

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.

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. 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.

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.

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. 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.

nekomatic
  • 5,988
  • 1
  • 20
  • 27
  • is there a way to do this without using labview? – adrian Dec 06 '14 at 04:48
  • I described LabVIEW because you asked about LabVIEW. You can do it in any programming language that can access the serial port. You could use Python and the pyserial and xlwt modules, for example. You may be able to do it directly in VBA - see http://stackoverflow.com/questions/14792502/read-from-serial-port-to-excel and http://stackoverflow.com/questions/569698/what-is-the-best-way-to-access-a-serial-port-from-vba - but I haven't tried any of that code. You may be able to do what you want without programming using third-party software (search on 'serial keyboard wedge'). – nekomatic Dec 08 '14 at 09:17