LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial DaQ: How do I set a limiter on data I am collecting and create an xy graph in LabVIEW while the VI is running?

I have modified a VI I found while searching through the forums for help regarding Serial reading and writing. I am currently trying to limit the amount of values and/or to fit within a certain time range. I would also like to connect an XY graph to the data that is being collected but none of the bundles or arrays I have tried work with the XY graph. If anyone could help, I have attached the code, VI, and text document with one of the trial runs of the VI.

 

const int potPin = A0;      // Analog pin the potentiometer is connected to
const int loadCellPin = A1; // Analog pin the amplified load cell is connected to

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging
}

void loop() {
  // Read the potentiometer value
  int potValue = analogRead(potPin);

  // Read the analog voltage from the load cell
  int loadCellValue = analogRead(loadCellPin);
 
  // Convert the analog value of the potentiometer to an angle
  int angle = map(potValue, 0, 1023, 0, 270); // Assuming a 0-180 degree potentiometer from 150-850
 
  // Convert the analog value of the load cell to force (assuming linear relationship)
  float force = map(loadCellValue, 0, 1023, 0, 100); // Change the mapping based on load cell specifications

  // Print the readings to the serial monitor
  //Serial.print("Potentiometer Angle: ");
  Serial.print(angle);
  //Serial.print(" degrees\t");
  Serial.print(" ")
  //Serial.print("Load Cell Force: ");
  Serial.print(force);
  //Serial.println(" lbs");

  // Add a delay before the next reading
  delay(500);
}
Download All
0 Kudos
Message 1 of 6
(533 Views)

Hi Sean,

 


@SeanRobert wrote:

I would also like to connect an XY graph to the data that is being collected but none of the bundles or arrays I have tried work with the XY graph. If anyone could help, I have attached the code, VI, and text document with one of the trial runs of the VI.


Have you tried to build the XY plots as is shown in the context help or in the example VI mention in the context help?

 

Unfortunately your VI is for LabVIEW2023: you would reach more audience when you would attach downconverted versions of your VI(s) (File->Save for previous). Most like LabVIEW upto 2021, I prefer LabVIEW2019…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(507 Views)

I have for both and it isn't working as anticipated. I have included a screen shot and the VI (saved for previous) as you mentioned. 

0 Kudos
Message 3 of 6
(473 Views)

I have written a code to actively read the analog data from two sensors on an Arduino. I have both sets of data actively being recorded and plotted against one another on an XY graph in LABView. However, I want to limit the data that is being plotted to only be the values at intervals of 5 along the x-axis as the VI is running. For example, when the VI starts the x-axis will read 0 and will continuously read all the values from 0-n until I stop the VI, but I only want the x and y values at every 5 of x. (0,10) (5,12), (10,26), .... (_,_). I believe it can be done with case structures but I would love some advice on this. 

 

How would I modify/adjust my VI to only show graph the values at an interval of 5 but continuously collect all the other data points? 

 

I have included the VI along with screenshots of the VI and a Word document that consists of the graphs after a few test runs of the VI as it is currently.

0 Kudos
Message 4 of 6
(454 Views)

Hi Sean,

 


@SeanRobert wrote:

I have for both and it isn't working as anticipated.


It does exactly what YOU have programmed: the XYgraph shows 1 (one) plot, containing exactly 1 (one) point. (You create two arrays, each containing one sample. Then you create one plot from those two arrays.)

 

What else do you expect from your VI?

Best regards,
GerdW


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

I understand that's how I programmed my VI, but I used a Serial Read and Write template I found in the forums.

 

Is there any option to filter what is being read but keeping the overall data anyway? Maybe parsing the data through a filter or a case structure?

 

Thanks for all the help GerdW!

 

 

0 Kudos
Message 6 of 6
(394 Views)