LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with recording and reading data

Hello! I am new to LabView so forgive me for any mistakes. I needed to creat a VI that would conver an input temperature in either Celsius or Farenheit to its counterpart. I got that part done, but now need to record the input temperature to a binary file and graph every 10 seconds (take the measurement every 10 seconds). My professor said that he would give bonus points for not using express VIs for this part and this is what I am stuck on. I also need to be able to read an input file. Not sure What im doing wrong! 

 

First file is what is most complete, second file is what is only for converting temperatures.

Download All
0 Kudos
Message 1 of 5
(3,100 Views)

You have no loop in your VI where you are trying to log the data.  So you will only log one data point.

 

I also noticed that your byte orders are different between your write and read operations.  I recommend just getting rid of those controls and let the functions use the default (they will be consistent that way).

 

And use -1 for your numer of samples to read out of the file.  That will read the entire file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 5
(3,079 Views)

Good job getting started, looks like you have something functional.

 

You don't have any loops in your 111.vi, so I'm assuming you're using the Run Continuously button. This isn't the way to do it because you're running the entire code every single time.

That being said, you seem to have the concept of opening, writing, and closing the file using the binary VIs.

 

I would suggest you look in to how a State Machine architecture works. This can allow you to have states like "Create file", "Write", "Read", "Save and Close", "Convert to F", "Convert to C", etc.

The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.

Here's a broad example of how a state machine works:

  • States: Init, Idle, Exit, DoThing1, DoThing2, DoThing3
  • Each state contains code that might take some time. Ideally, not too long because that's how long your code could be unresponsive.
  • The Idle state contains an event structure for all user interaction.
  • The front panel has a button that says "Do Thing 1".
  1. Loop Iteration 0: Application begins, first state is Init. The Init state does some initialization stuff and tells the application to go to the Idle state when finished.
  2. Loop Iteration 1: Application goes to Idle state. It sits there, waiting at the event structure.
  3. Time goes by, then user presses button "Do Thing 1". There is no code, or minimal code, within this event case. The output of this event state tells the application to go to the DoThing1 state.
  4. Loop Iteration 3: Application goes to DoThing1 state. There is code here that does some stuff. The output of DoThing1 state tells the application to go back to the Idle state.
  5. Loop Iteration 4: Application goes to Idle state where it waits at the event structure again.
  • Each of the states can tell the application to go to any state they want. Want to reinitialize? Go to the Init state again. Want to end the program? Go to the Exit state. Want each state to trigger another (like a sequence)? Have DoThing1 output DoThing2, which outputs DoThing3,  which outputs Idle.

 

Also, since you're a student and interested in learning:

"Give me six hours to chop down a tree and I will spend the first four sharpening the axe."  - Abraham Lincoln

Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.

NI Learning Center

NI Getting Started

-Hardware Basics

-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)

-LabVEW Basics

-DAQ Application Tutorials

-cRIO Developer's Guide 

Learn NI Training Resource Videos

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 5
(3,077 Views)

Thank you very much for your help I will work on this!!

0 Kudos
Message 4 of 5
(3,024 Views)

This is great! I believe this might be the way to go! I will see if I can't figure out how to do this with the state structures. Thank you very much for the tutorials as well! I was working with the 'getting started' modules from NI and google searches only before.

0 Kudos
Message 5 of 5
(3,023 Views)