07-03-2024 05:34 AM
Hi,
Sorry to disturb you again I prepared avarage part in code but it is giving random/rong values.
Kindly please guide where I am doing mistake.
Kind regards
Hasham
07-03-2024 06:05 AM
I guess that Channel Data looks very strange due to how you've constructed that For loop.
07-03-2024 06:22 AM - edited 07-03-2024 06:23 AM
Hi Hasham,
@Hasham622x wrote:
Sorry to disturb you again I prepared avarage part in code but it is giving random/rong values.
Kindly please guide where I am doing mistake.
Placing the averaging code inside the while loop is nonsense as your 2D array consists of just one row of data (and so only one element per column)!
Placing the averaging after the while loop looks better and should do what you asked for.
Unfortunately we still cannot debug/edit/run images in LabVIEW, so you need to debug on your own!
Suggestion:
Btw. what's your problem with creating block diagrams with straight wires? Ever heard of LabVIEW Style Guide?
07-03-2024 07:25 AM
Hi,
Thanks for your reply. Yes, you are right, and I didn't hear of LabView Style Guide.
I attached code to this reply as an attachment, and I am getting data in two 8 bits formats.
Kind regards
Hasham
07-03-2024 08:19 AM
Hi Hasham,
@Hasham622x wrote:
I attached code to this reply as an attachment,
You forgot about message #22…
07-03-2024 10:18 AM - edited 07-03-2024 11:46 AM
I still cannot look at any of your code because you don't "save for previous" before attaching.
If you like an answer, give it kudos. It is not helpful to basically mark almost every comment as solution to the thread. Typically there should only be one solution for each thread (unless there are two very different, but equally good solutions).
You are streaming the data to disk one row at a time and you can do a ptbypt average at the same time avoiding the need to store an ever-growing array in an autoindexing tunnel or other mechanism. All you need is keep the sum of all data and the number of averages, you could even display the running average of all data processed so far in an indicator. Nothing should ever be outside the toplevel loop. Think state machine.
On another note, your entire string processing is still extremely convoluted. Long ago, I asked how the received string looks like, so we can offer guidance how to do all that with code the size of a postage stamp. Most likely all you need to do is unflatten the string to a U16 array (swap byte order as needed). Each data "packet" seems to be fixed size, so growing an array in a shift register is just plain Rube Goldberg! Also, why would you build your "dt" into an array if you never use that array? Why would you append dt AND write to file even if no new data has arrived?
07-03-2024 11:36 AM - edited 07-03-2024 11:57 AM
See if this quick simulation can give you some ideas at simplifications. All you need to do is substitute your serial read, potentially change the byte order, and implement some error handing as needed.
07-03-2024 06:20 PM
Hi,
I attached code in older version of LV19
"I am sorry to disturb you again. I am stuck in code and need your guidance. I tried calculating the averages of columns of the 2D array, but it gave the wrong values. My data is in the form of two 8 bits, and I am confused about how to convert it into floating format and at which point of code... I tried all three options to calculate the averages."
Kind regards
Hasham
07-03-2024 07:19 PM
sorry, my bad data is in 12-bit format 0 to 3000
07-03-2024 07:19 PM - edited 07-03-2024 07:25 PM
As an example, let's have a look at your inner loop. All three produce the same output, but some versions are arguably simpler!