LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in acquiring multiple analogue signals

Solved!
Go to solution

Hi.

I am trying to acquire two analog current and one analog voltage signal. I am able to acquire two analog current in one vi and that is working fine. Now I am trying to add one analog voltage so that I can plot a graph but when I add in vi either it runs both with analog current or only analog voltage one. Please guide me with this And also I made a table of values for all three of them. For the two sensors with analogue current they work fine but with the analog voltage it varies a lot. For example if I am getting 22mA on pin 8 & 9 i.e. analog channel 2 for DAQ 6009 according to table it should display 1000 pounds but it varies from 0 to 1300 pounds. And if I try to add delay of 200msec in while loop it gives me error that signal which was trying to read is not available now. Please guide me with these problems.

 

I want to add analog voltage block diagram in sensors with cases for led. This is a table I made. Every voltage corresponds to value for pounds. loadcell.vi is which I made to acquire load

 

Thank You

 

Download All
0 Kudos
Message 1 of 17
(3,717 Views)

Hi,

 

I took a look at your two VIs.  Are you trying to use the "loadcell.vi" inside of the "sensor with cases for led.vi" or vice versa?  The "loadcell" VI looks good and should work to read voltage.  The "sensor with cases for led" VI uses a AI Current DAQmx call and the USB6009 can't directly measure current.  Are you using another type of work around to accomplish this?

 

Regards,

 

Greg H.

Applications Engineer

National Instruments

Applications Engineer
National Instruments
0 Kudos
Message 2 of 17
(3,678 Views)

Hi Greg,

 

Thanks for replying. I was trying to get loadcell.vi in sensor with cases for led. Now I am using DAQ assistant box which is working fine. can you please guide me few things:

1. I am trying to plot a graph. When i run i see changes but it does not draw a line. I can see a point when i stop the graph. I want to see the line b/w load and elongation

2. I am able to save data but it is possible that i can enter time. for example i want to save data every minute. write now it saves every 250 millisecond which is wait time. How can I do this? Otherwise i have lot of data

3. I get fix voltage on pins example 22mA so it should show load 1000 pounds according to table. It varies from 960-1100 pounds. I am trying to take average and get it closer is there anyother way i can get accurate.

 

Please guide me through these problems.

 

Thank You

 

Himanshu

0 Kudos
Message 3 of 17
(3,664 Views)

Himanshu,

 

I took another look at your VIs and it seems like you are on the right track.  To answer your questions:

 

1.  I assume you are having the problem with the graph in the "switch with load" VI.  The reason you are having this issue is because you are only keeping track of one value.  So each time the XY graph function is called it only sees the latest value and plots this point.  To make the graph plot all of the points and add on the latest value you will need to use shift registers and build arrays.  I have attached an example VI which shows to do this.

 

2.  What I am gathering is your wait time is 250 ms which means your save to file VI is called every 250 ms and you want your loop to still run at 250 ms but save only every second?  This will lead to you accumulating data, since you mentioned it's to much data, then I suspect you only want to save the latest sample and not all of the accumulated data.  The easiest way to do this is just change your loop time to 1 second (1000 ms).  If you still want to run the loop at 250 ms then you would have to use some sort of case structure that will only call the save data to file VI every fourth time (1 second/250 ms = 4).  You could accomplish by monitoring the number of loop iterations or adding another timing feature.

 

3.   There are a number of reasons you could be seeing such a variation in data.  What sensor are you using?  Since you are acquiring an analog signal I would take a look at this page  https://www.ni.com/en/shop/data-acquisition/measurement-fundamentals/field-wiring-and-noise-consider....  Another reason is that you are averaging all of your data to calculate weight.  For example lets say there was nothing on the loadcell for the first iteration of the loop then it would display 0 pounds (this is correct).  Now lets add 1000 pounds for the second iteration.  This means you have (0 lbs + 1000 lbs)/2=500 lbs, this is way off.  What I would use is the point by point mean tool (search Mean PtByPt.vi [NI_PtbyPt.lvlib]).  This will allow you to specify the window over which the average is taken.

 

One other issue I noticed is both your main VI (sensor with cases for led) and your subVI (loadcell) have while loops.  This means if you place the loadcell VI inside of the sensor with cases for led VI then the program is going to get stuck inside the loadcell VI while loop as soon as this VI is called.  The only way the program will leave this while loop is if there is an error on the analog read or if you manually press the stop button on the loadcell VI front panel.  Also in the loadcell VI it is not necessary to use shift registers when passing the task and error on the DAQmx calls inside of the while loop.

 

I hope this helps.

 

Regards,

 

Greg H.

Applications Engineer

National Instruments

Applications Engineer
National Instruments
Message 4 of 17
(3,660 Views)

Thanks Greg for suggestions,

 

I am still not able to plot a continuous graph. Can you please see my vi and tell where I am wrong. And I need to run vi continuously but save after 1 minute or 2 minute. In this vi I used for loop but the problem is if I add wait, program will wait till for loop runs. 

I also tried using case structure and wiring from elapsed time express vi. I entered 15 sec. After 15 sec it runs case structure but it save all data of 15 seconds and after next 15 sec it replaces last data and add new data. I don't want to replace old data i wanted to note latest data after 15 seconds.

 

Can you guide me with this?

 

Thanks

0 Kudos
Message 5 of 17
(3,640 Views)
Solution
Accepted by topic author Hnagpal

Himanshu,

 

I modified your code so that your XY graph should plot multiple points as your program runs, see attached.  As far as saving the data every minute here is my suggestion:

 

1.  Move the write to spreadsheet VI outside of your while loop

2.  Create an array for each type of data you want to save

3.  Every time you want to save data (a minute or 2) add those values to the array

4.  When you while loop ends send the arrays to the write to spreadsheet tool

 

This will allow you to store only the data you want in an array for each type and then at the end save all of the data to a file one time.  The way you are doing it now the write to spreadsheet tool opens the file, writes, and closes the file.  Then the next time it executes it just writes over the previous file.  There are several ways you can implement a timing feature in step three.  Your loop is going to execute a little less than 4 times a second.  So if you write to the data arrays every 240 times the loop executes then you will be saving about every minute (4 times a second, 60 seconds in a minute, 4*60=240 times a minute).  You could also use the timing features in LabVIEW.

 

Hope this helps.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
Message 6 of 17
(3,633 Views)

Greg can you please attach vi. If possible in version 8.6

 

Thank You

0 Kudos
Message 7 of 17
(3,630 Views)

Sorry about that.  It should be attached.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
Message 8 of 17
(3,626 Views)

Hi Greg,

I am trying to plot a graph. I want to refrence my initial position so that if there is change in values it will be elongation. So I want my graph to start plotting after initial refrence position is marked. Right now what is happening is it take iniatial reading as zero and distance between two sensors is like 7.5meters so it draws a line at 7.5 meter and then come to elongation after initial reference is clicked. Since change is going to be 10-20 mm it does not show the curve. So what can i do to make graph start after i click initial reference position and ignore previous values.

0 Kudos
Message 9 of 17
(3,586 Views)

Himanshu,

 

The graph is going to plot what ever is in the array.  If you only want to plot data after a certain point then I would use a case structure such that data is only written to the array in the true case.  Then use whatever criteria you want to select between true and false.  You will need to put the build arrays in the true case and then just pass the wire straight through in the false case.  Hope this helps, let me know if you need a more detailed explanation.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
0 Kudos
Message 10 of 17
(3,578 Views)