LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing to output file

Solved!
Go to solution

I don't understand how that only returns a single sample per second for the torque stream of data but not the thrust stream.  Can you elaborate?  Also that does not change the skipped samples for the timer array.

0 Kudos
Message 11 of 20
(531 Views)
Solution
Accepted by jseele69

Note that each 2nd value written in your Thrust column is the same are the Torque value:

Basjong53_0-1718610526289.png

 

Dynamic data is often discouraged from using, as it hides some details. It is better to use the DAQmx library directly, this also gives you way more control over you measurement. In fact, the DAQassistant express vi uses this. To see how it is built, right-click the DAQ assistant and click open front panel and look at the block diagram. There is some extra stuff, but the core is simple. Here is a minimal example that works for your case:

DAQmx read.png

 

Message 12 of 20
(505 Views)

On 14 Jun, BasJong53 explained to you that your code did what you told it to do.  You took the 1D Array of Thrust and asked for the Array Subset from index 0 to the end, which gives you a 1D Array of Thrust, the same as the input array.  But for Torque, you input a 1D Array of Torque and asked for an Array Subset from index 1 to the end (which is also index 1), so you get Torque minus the first element (since you told it to ignore 0, start with 1).

 

Please learn to use (and distinguish between) the LabVIEW Array functions!

 

Bob Schor

0 Kudos
Message 13 of 20
(485 Views)

Basjong53, thank you for taking the time to explain to me.  I very much appreciate it.

 

0 Kudos
Message 14 of 20
(466 Views)

Bob_Schor your aggressive comment contributes nothing to this post.  People go to forums to ask questions because they are still learning LabVIEW, and nobody learns it overnight.  If you aren't going to offer solutions to the problem, don't bother to reply.  

0 Kudos
Message 15 of 20
(465 Views)

Hallo jseele,

 

Bob hat sehr sachlich geantwortet und sogar das Wörtchen "Bitte" benutzt: wo genau siehst du ein "aggressives" Verhalten?

 

Und ja: es würde dir (und uns) helfen, wenn du LabVIEW-Grundlagen und den Umgang mit Arrays lernst…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 20
(443 Views)

@jseele,

 

I apologize if my earlier post offended you.  I was surprised that you didn't see the earlier post that I cited which pointed out the error in using the wrong Array function.

 

In the spirit of making amends, here is (in part) how I would introduce some of the concepts in a slightly different way than the solution you chose.

 

Here's a picture of the VI.  I didn't save it as a snippet, as it is all "out there in the open", and sometimes "coding it yourself" gives you some additional "muscle memory" to remember the key concepts.

DEMO jseele.png

I'll highlight some points:

  • The path code at the top creates an output file for the .csv (not an Excel file) with the name "jseele.csv" in the same folder as this VI (it won't work if you haven't yet saved the VI, as I forgot, myself).
  • I added a Waveform Chart so I could see the data as it arrived, so the first function clears the Chart.
  • I then start DAQmx rolling, specifying sampling at 2 Hz and taking 2 samples at a time (seems odd, to me, but that's what you wanted).  I bring the # samples/channel in to wire to the DAQmx Read function.
  • I'm ignoring (for now) saving the time of sample.  If you really want this, you should consider saving as an Array of Waveform, as Waveform embeds the DAQmx hardware clock (probably "better" than the PC's).
  • When you do a 2D sample, the data are saved "by channel", that is, the two samples from Channel 6, then the two from Channel 7, then the two from Channel 0.  You want them "by time", 3 channels, then three channels.  Transposing the 2D Array does this for you.  Now you can plot and save it to a SpreadSheet Array.  Note the first time, you want to write a new Array (probably), but after that, you want to append, hence the Shift Register wired to "Append to File" (False only the first time).

I hope this makes sense to you.  When I was testing it, I found it much easier to understand what was going on if I made the number of samples collected larger than 2, say 5 or 10, especially when dealing with a 3 x 2 array (3 x 10 is much easier to distinguish from a 10 x 3!).

 

Bob Schor

0 Kudos
Message 17 of 20
(435 Views)

Bob, I appreciate your apology and your explanation.  I will make sure to use daqmx and array functions in the future instead of daq assistant.  However, I am curious about the output of the daq assistant in my original code.  Is it outputting a 1D array, alternating between values for torque and thrust?  I also don't understand why the element indices only went to 2 (whether that was because there are 2 quanities being measured or if there were 2 measurements per iteration...).

0 Kudos
Message 18 of 20
(412 Views)

When you configure the DAQmx Timing function, you feed it two parameters -- the sampling rate (2 Hz), and the number of samples to take during a DAQmx Read (which you also set to 2).  So when you do a DAQmx Read, it has an input parameter (if you are doing NChan NSamp) for "number of samples per channel".  You told the Clock you wanted to read two samples at a time, so I wired the 2 (from the Timing function) to the Read (# of samples) so that when the Read occurs, you will get Sample 0 and Sample 1, the next time Sample 2 and Sample 3, and so on.

 

Note that one rarely sees such low sampling rates and # samples.  The default values for Sample Clock are 1000 samples at 1000 samples/sec, which means that the corresponding DAQmx Read will "fire" once a second, giving you 1000 samples (from time 0 to 0.999, then 1.000 to 1.999, etc.).  In your case, you'll get (again, one read / second) samples 0 and 1, a second later samples 2 and 3, etc.

 

Bob Schor

0 Kudos
Message 19 of 20
(401 Views)

Just to clarify, the parameter "samples to read" is total samples read across all channels at an instant in time?  So then samples per channel would have to be equal to the total # of instantaneous samples divided by the # of channels?  That doesn't seem to make sense because there could be cases where you could sample a channel twice at the same time.

0 Kudos
Message 20 of 20
(389 Views)