LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing data from excel to generate signal at each time step that is defined in the excel file

Hello everyone,

I am still leaning data acquisition and LabVIEW programming. I need to generate a voltage signal using NI-9263 module. The data to generate signal will be imported from an excel file at each time step that there is in the excel file. In other words, the excel file has a time column and a signal values column and at each time the corresponding signal will be sent to DAQ assistant. I wonder if the time column in the excel can be defined as a wait time in sending signal to DAQ assistant.

 

For example, in the attached excel file, at time zero, voltage 0.4 is sent to DAQ assistant, after 20 seconds voltage 0.8 and at time 35seconds, voltage 0.5 is sent to DAQ assistant and so on. 

 

I really appreciate your help and suggestions. 

 

Thank you.

0 Kudos
Message 1 of 6
(1,038 Views)

Hi FAZ,

 


@FAZ990 wrote:

For example, in the attached excel file, at time zero, voltage 0.4 is sent to DAQ assistant, after 20 seconds voltage 0.8 and at time 35seconds, voltage 0.5 is sent to DAQ assistant and so on. 


Is this really an "Excel" file (with suffix like XLSX) or a plain text file, maybe with suffix CSV? I guess/hope it's CSV…

 

After you read the CSV file (which is much easier to do) you just need to autoindex the resulting 2D array on a FOR loop border.

Inside the FOR loop you output the voltage value using a DAQmxWrite function (no DAQAssistent needed here) and you wait for the next step.

Maybe add a shift register to be able to calc the delay for the next voltage based on last time value and current time value.

 

This is a very basic LabVIEW exercise: did you notice those Training resources offered at the top of the LabVIEW board?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,031 Views)

Hi GerdW,

 

Thank you for your reply. 

The file can be saved as CVS file and I will use it as an input file.

Could you please let me know without a DAQ assistant how can I send signal to my physical channel? I searched about DAQmxWrite and I could not figure out how it can help for this purpose. Maybe DAQmxTask be a better option. I would appreciate it if you could explain it more. 

 

I have basic knowledge on LabView and I am still learning and using it for data acquisition from various NI modules. I have read the trainings in NI learning center, but this program still seems complicated to me. I appreciate if you suggest any additional material that you suggest to read in order to figure out how to solve this problem. 

 

Thank you so much for your help. 

 

 

0 Kudos
Message 3 of 6
(996 Views)

Go to the Web and search for the excellent NI White Paper "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications" (or something close to that name).  Ignore section 1, which describes the Dreaded DAQ Assistant.

 

Pay attention to the section on hooking your DAQ device to your PC and running MAX to get an idea of how to configure I/O for your device.  For your project, you probably want to output a single voltage every time you say "Go".  This involves defining a Channel (for example, AO0, Analog Output 0), scaling it, setting its (Output) Mode ("On Demand"), and possibly setting its sampling rate.  It also describes how to define a "Named Task" in MAX ("MyAnalogOut_Task"), or, if you are developing your VI as part of a LabVIEW Project, you can create a Task in the Project Manager.

 

If you've created a Task in MAX or the Project Manager, you can define your Digital Out Task with as few as 3-5 DAQmx calls.  You need to Start the Task (with all your parameters, saved in the Task definition in MAX or the Project), do a DAQmx Write to send a Voltage whenever you want to (so this will be inside a While Loop with a Wait (ms) inside the loop to control the spacing between the Writes, and a Stop control to stop the Loop), and a Close Task (or End Task, or both) to stop things.

 

Read the White Paper, play with MAX, write a simple program (preferably in a Project), hook up a Volt Meter (or oscilloscope) to your DAQ Output, and try it out.

 

Bob Schor

0 Kudos
Message 4 of 6
(966 Views)

Hi Bob_Schor,

 

Thank you for your response.

I could not assign the wait time through CVS file to reading data from that file and I decided to change the time steps into evenly distributed time steps(for example 10 seconds of wait time before sending each data to the physical module). I tried doing this by connecting the CVS file as input data to DAQ assistance with a wait time of 10 seconds in a loop but it did not work and I got the outlet voltage from the first row of my CVS file. Do you have an idea of how it can be done?

 

Thank you for your help.

 

 

0 Kudos
Message 5 of 6
(895 Views)

Well, it is difficult to tell someone how to do a fairly common task such as simultaneously acquiring data (what kind?  from what device?  how many channels?  at what data rate?) and saving the data to disk (or somewhere, such as displaying it on a screen as a scrolling chart).

 

Your Post title says "importing data from excel".  I don't think you are acquiring data from "Excel" (Microsoft's Spreadsheet application, part of Microsoft Office).  It is true that the Microsoft Operating System "hijacks" the .csv extension to make you think that this text file (technically with a comma separating data items, and <EOL>s separating rows of data).

 

What I think you are doing is using DAQmx to acquire data from some device and save it to disk.  Why don't you do the following:

  1. Find the Folder holding the Project you are trying to develop.  This Folder should include the Project file (.lvproj), the Main VI, and any sub-VIs or TypeDef or any other Project-specfic code you are using.
  2. Right-click this folder and choose "Send to:".  Select "Compressed (zipped) folder".  It will build a .zip file of the entire Project Folder.  Attach this Folder to your Reply.

Also, tell us more about the task you are trying to do.  Describe the data you are attempting to acquire.  What hardware device are you using?  If an A/D converter, how many channels, what is the Sampling Rate, how many samples do you convert at a time?  If a D/A converter (as seems to be the case here), same questions, how many channels, what is the desired update rate?

 

We also need to understand more about the .csv file you are using to "drive" this process.  You should also attach an example .csv file.  If you are outputting data at, say, 1 kHz, and intend to "play" your data for 5 minutes, note that this will be a fairly large text file with 1000 samples/second x 60 seconds/min x 5 min = 300,000 samples of text, so several MB.  Might want to compress it, too.

 

Bob Schor

0 Kudos
Message 6 of 6
(873 Views)