LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial read, and data import into spreadsheet

I thought it would be important to include the vi, so if there are any glaring problems they can be easily identified.  To get everyone up to speed: I have resolved all issues except one (and I haven't actually hooked up the RS232 yet, so there may be more) - the issue is incrementing the row following each data read.  What happens is the data is only saved in one row (each read updates the row fields).  I'm looking for a way to read data every 5 seconds, and store in subsequent spreadsheet rows.

 

Noname.jpg

0 Kudos
Message 11 of 86
(395 Views)
  1. At a minimum, move the header-writing code outside of the loop, to the left. Wire in the path constant to the other Write vi inside the loop.
  2. Also, move the serial ports setup outside the loop to left (only need it once, right?).
  3. Move the Close Visa to outside the loop to the right.
  4. Put a delay of ~50mS between VISA Write & Read (use a flat sequence to put it in, wire the VISA resource & error through it.
  5. Hit Diagram Cleanup if you have it in your version.
Richard






0 Kudos
Message 12 of 86
(391 Views)

Here's the whole vi.  I'm guessing that I'm not properly incrementing the row data.

 

BTW, thanks for the help.

 

Noname.jpg

0 Kudos
Message 13 of 86
(384 Views)

That's just a repeat of what you've already posted. Did you do any of the edits I recommended?

 

Richard






0 Kudos
Message 14 of 86
(382 Views)

Brilliant.  I don't have a cleanup tool - I'm using version 8.5 - maybe it comes standard on newer versions?  Anyway, the next steps are to hook the device up to a serial port, and start collecting data.  I am awaiting a RS232 adapter for the scale we are using (it is expected to arrive in the next couple days).  In the meantime, here's the vi...

 

BTW, thanks for all the help - much appreciated.

 

Noname.jpg

0 Kudos
Message 15 of 86
(379 Views)

I'm using a serial-to-usb adapter (with a laptop) - com4.  I wasn't reading any data in the vi, so I placed a numeric indicator at the "Bytes at Port" output (from the Instr function).  I get zero bytes reported.  I'm guessing I have something hooked up incorrectly - not sure what.  Any ideas? 

0 Kudos
Message 16 of 86
(375 Views)

JUST the Serial Port Setup outside the VI, not the read and write! It'll never update like you have it.

 

If you can post the actual VI, not just a picture, maybe me or someone can edit it. Better yet, check out the Serial Port examples that ship with LabVIEW, and read the manual. You are missing some very basic knowledge which is making your job difficult.

Richard






0 Kudos
Message 17 of 86
(371 Views)

Thanks for the comments - you are correct, about me missing some basic knowledge.  I come from a command line background, and I'm having some growing pains - time will cure that.  I've attached the vi, as I don't really understand the proper use of the flat sequence.

 

Geddy.

0 Kudos
Message 18 of 86
(368 Views)

More like this below. Note that the flat sequences are just to force dataflow on the Delay function.

 

Doing the arbitrary 50mS wait after Writing to the serial port is, for now, just a quick method to see if you get data. The best way to read the data is to poll Bytes At Port until you know all the expected bytes have been received. Anyway, reconstruct you VI like this one and give it a try.

 

Serial Read example.png

Richard






0 Kudos
Message 19 of 86
(357 Views)

Do not put a shift register on the error wire.  If you ever get a stray error such as an occasional timeout, and that can certainly happen periodically with serial communications, it would prevent all of your VISA functions from operating on the next iteration of the while loop.  You'd be forced to stop the VI and restart in order to clear the error out of the register and start communicating again.

0 Kudos
Message 20 of 86
(352 Views)