LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Export to excel from express VI table is not working

I think the built-in example for Thermocouple - Continuous Input.vi (DAQmx) will do almost everything you want.

 

You can find it by:

  1. Open LabVIEW
  2. Click Help - Find Examples
  3. Open the folders in order, when browsing according to "Task",
    1. Hardware Input and Output
    2. DAQmx
    3. Thermocouple - Continuous Input.vi
  4. Your "untitled4.vi" in the previous thread shows thermocouple configuration for two thermocouples with different ranges. To select multiple channels for this VI, click on the "Physical Channel" control and select Browse. Hold shift or control to select multiple items in that view (standard behaviour)
  5. Set the desired Rate in the "Timing Settings" part of the front panel
  6. Your previous CJC method was "Built-In", or specify the temperature of the cRIO system with the Constant Value input (read more about CJC here: https://www.omega.co.uk/techref/thermoref.html, or Google and choose your preferred page)
  7. Select the Thermocouple Type (you selected K before, I'm not sure if that's what you have or the default)
  8. (Optional) Between the Trigger case structure and the Start VI, insert the DAQmx Configure Logging node. Pictured are the inputs and their types - set them as you need (path, group name, opening behaviour). This will log to a .tdms file (which can be opened in Excel using the NI Excel Reader addin: http://www.ni.com/example/27944/en/)
  9. An alternative time logging method below the image.

modDAQMXexample.pngAdd the following code:

  1. Reciprocal to the output of the SampClk.Rate (to get dt)
  2. Move "Samples per Loop" outside of the While loop (this prevents changing the size during running, but that should be fine?)
  3. For loop before the While loop, N wired to Samples per Loop, containing multiplication of 1/sample rate with i (generate a list of times starting at 0)
  4. Outside the For loop, multiply Samples per loop with 1/sample rate to get loop iteration time.
  5. Wire the array output of the For loop to a Shift Register on the While loop. Pass the scalar value (from step 4) to a tunnel (not shift register) on the While loop.
  6. Add the two wires and wire to the other side of the SR.
  7. Place Build Array inside the While loop. Right click on it and choose "Concatenate Inputs". Drag it down to create 2 inputs.
  8. Connect the thick orange wire (array of times) to the top input of Build Array. Branch the wire BEFORE the Add node.
  9. Select the dropdown box under the DAQmx Read, and choose Analog > Multiple Channels > Multiple Samples > 2D DBL (note the graph updates automatically)
  10. Connect this double-orange wire to the second input of Build Array.
  11. Wire the output of the Build Array node to the 2D Data input of "Write Delimited Spreadsheet". Right click on each of Path, transpose?, append to file? and delimiter and choose to create constants.
  12. Make the booleans True, the delimiter "," (without quotation marks), and the path whatever you want.
  13. Optionally create a constant for the "format", and increase the number to have more decimal places. Note that thermocouples are not very accurate, so you might be just storing more noise.
  14. ???
  15. Success (and step 14 is a joke... you're already done after 13).

Here's an image showing those modifications:

modDAQMXexample2.png

Message 11 of 64
(179 Views)

Ive got two input channels and I'm just getting the readings of one, and the readings r pretty much incorrect.

 I'm just getting one set of readings while I'm supposed to get two sets for the two channels. 

 

0 Kudos
Message 12 of 64
(162 Views)

Zaqf, please provide more information when you respond. For example:

  • Attach your VI (ideally with data saved, as Bob Schor has described a few times using the Save as Default Values option)
  • Incorrect how? Wrong number of samples? Wrong number of sensors only (since you described that specifically)? Temperature values are unbelievable? I'd guess the latter, and I imagine it's because your scaling is set incorrectly, but without more information it's just that - a guess.
  • Regarding number of channels, did you select both channels you need as described in the first section, number 4?
  • Are you sure about the type of thermocouple you're using? Did you check that the VI was set to use that type?

 

0 Kudos
Message 13 of 64
(159 Views)

Sorry. The readings r correct but since there r two channels , readings for one channel is missing.  And still I'm not able to save the data 

0 Kudos
Message 14 of 64
(153 Views)

Guess you're still not a fan of DAQmx. In your While loop, you're using the Convert from DDT to Scalar that was suggested for a single channel. You have multiple channels, so you need an array of values to be outputted there. Double clicking on it should allow you to change it to 1D array of scalars.

0 Kudos
Message 15 of 64
(150 Views)

Tried with daqmxfnctions . 

0 Kudos
Message 16 of 64
(148 Views)

For Newmod123, click on the From DDT function.  Change it from Scalar to 1-D array of scalars automatic,  For the Build array inside the loop, right click on it and pick "Concatenate Inputs".

 

For the DAQmx code, that is a mess right now as you go from a 2-D to a 3-D to a 4-D array.  Don't throw down a Build Array function without knowing why you are doing it.

To fix the DAQmx code, and make it behave like your original DAQ Assistant code does,

1.  Change the DAQmx Read to N channels, 1 sample.

2.  Put in your time column stuff you have in the DAQ Assistant code, but left out of here.

3.  Go a Build Array with Concatenate between the time and the DAQmx Read's 1-D array.

4.  Feed that into the 1-D array input of the Write to Spreadsheet function.

5.  Get rid of the lonely Build Array that you have in there now.

 

Better yet, use Build Array and a shift register with the array indicator inside the loop and you can see the table grow as the code runs.

daqmx_BD

Message 17 of 64
(134 Views)

Thank you so much. Could you attach as VI. I'm not able to read png file. 

0 Kudos
Message 18 of 64
(130 Views)

It is a VI snippet.  Save the PNG to your desktop.  Then drag the png file to your block diagram.

 

It also isn't that much different than what you have now, so you ought to be able to modify your own code to match.

0 Kudos
Message 19 of 64
(128 Views)

I'm not able to connect the second built array to the loop . 

0 Kudos
Message 20 of 64
(126 Views)