10-28-2020 07:25 AM - edited 10-28-2020 07:28 AM
Hi,
I am working on a project where I receive a string of numbers continuously from Arduino and then converting the string into a 2D array of x columns (x different data) and n number of rows which gets updated continuously as long as I run the program. It's basically output from x number of sensors.
However, the type and number of sensors are not fixed. For example, I might be reading data from a single temperature sensor or 2 humidity sensor at a given instance. hence, I would like my LabVIEW program to recognize this and dynamically change the UI (Graph, Numerical Indicators).
To recognize the type of sensor, I am reading the device ID of the sensor, comparing it with a constant number and then printing whether it is a temperature or humidity sensor. For the number of sensors, I am reading the array size and determining the number of sensors from number of columns.
The problem arises when I try to plot the graph. Please have a look at the attached screenshots.
When i read one sensor, i want the graph to plot value from one sensor. when, i read 2 sensors, i want the graph to dynamically plot values of 2 sensors. However, i'm not able to do it.
If I am missing any basic logic behind it, please bear with me. I am beginner with LabVIEW.
Can anyone help me with this?
Thanks in advance.
Regards,
VigViv
10-29-2020 10:41 AM
Hi,
Can you send your VIs? You told that you are receiving data from the Arduino, but I can't see how you do that.
Also I will be thankful if you can describe the logic of VI (for example using the comments).
Thank you in advance.
10-29-2020 10:57 AM
Hi VigViv,
@VigViv wrote:
The problem arises when I try to plot the graph. Please have a look at the attached screenshots.
We still cannot debug images using LabVIEW.
When you need real help then you should attach your VI.
11-04-2020 01:32 AM
Hi hovo90,
Apologies for the late reply. Arduino sends data to PC through serial port and I am using NI VISA to read this data from serial port. My block diagram is messy as i have not yet decided on certain algorithms yet. I am still working on them. once I am done with it, i will clean it and put labels.
and yes, i will attach the program below.
regards,
VigViv
11-04-2020 02:12 AM
Hi GerdW,
Apologies for the late reply. I think I found the solution. however, I am attaching a sample program and open to other ideas / solutions if it makes my life easier. Should i use case structure to dynamically add more array splitters? I need to split the 2D array as many times the number of columns in it. and then i need to plot a graph with n-1 columns. (1st column indicates the sensor type and doesn't needed to plotted.
regards,
VigViv
11-04-2020 03:27 AM - edited 11-04-2020 03:28 AM
Hi VigViv,
@VigViv wrote:
Should i use case structure to dynamically add more array splitters? I need to split the 2D array as many times the number of columns in it. and then i need to plot a graph with n-1 columns. (1st column indicates the sensor type and doesn't needed to plotted.
Using a case structure to handle an unknown number of entries is nonsense: use a loop to handle more than one array element!
In the snippet I used a Map to store your unknown number of sensor data (ID+value) entries:
It's the first time I used a Map ever - so check for errors on your own!
But the basic principle stays the same: each sensorID makes a new map entry, where you add the new data value (aka sample) to the array. Then you can read all map elements to create plots using a loop…
11-04-2020 07:07 AM
Hi GerdW,
Thanks for your reply. I'll look into it.
regards,
VigViv