07-15-2024 06:19 AM
Hi,
Thanks for your reply. Actually, I placed elapsed time (orange LINE counter) so I could note the code run time as I set the input sampling rate to 100 Hz per second. Due to that, I placed it, and the blue counter shows a number of iterations. Yes, I used two separate file saving options for RAW and Average values as I don't know how to save both within the same file.
Kind regards
Hasham
07-15-2024 06:36 AM
Hi,
Sorry for disturbing you all. As I am trying to run code by replacing while loop with for loop and for which I set 100Hz/sec sampling rate and set number of iterations 100 in FOR loop but it completed before one second around 0.03 sec and give only three samples data and when I am setting value in thousands like 3000 or more than it is completing run near to one second and give 100 samples data. Could you please guide me why my code is behaving like this in FOR loop environment and can I set or control number iterations in while loop as it is continues loop.
Kindly please guide me.
Kind regards
Hasham
07-15-2024 07:29 AM
Hi Hasham,
we already asked you more than once to cleanup your code, but you failed again.
Didn't you say you want to learn from our suggestions & recommendations?
@Hasham622x wrote:
As I am trying to run code by replacing while loop with for loop and for which I set 100Hz/sec sampling rate and set number of iterations 100 in FOR loop but it completed before one second around 0.03 sec and give only three samples data and when I am setting value in thousands like 3000 or more than it is completing run near to one second and give 100 samples data.
Where exactly do you define the sample rate?
All you do is reading data from an external device, connected by serial port!?
07-15-2024 08:56 AM
can you elaborate more what you are trying to achieve ?
How fast you need your loop to run ? You may need to add a timing function (wait (ms) function
inside the loop to time the code every iteration
07-15-2024 11:02 AM - edited 07-15-2024 11:07 AM
This is now the third place where you post this exact VI. Why can't you keep it all in one place? And why can't you clean up your code! (see also). In comparison, most of my programs are 100x more complex and still comfortably fit on one screen. With your "programming style" (for lack of a better term), my code would fill a football field and would not be manageable.
A toplevel VI should be a state machine, not a downhill run and you have plenty of ways to stop your loop after a certain number of rows have been collected (you even count the number of acquisition twice at the moment!). You cannot (Yes!!!! cannot!!!) use a FOR loop here, because the number of loop iterations is not necessarily linked to the number of acquisitions because it also iterates if the "bytes at ports" is low. Of course all bets are off, but I assume you want to control the number of acquisitions, not iterations, right???
@Hasham622x wrote:
g
Sorry for disturbing you all. As I am trying to run code by replacing while loop with for loop and for which I set 100Hz/sec sampling rate and set number of iterations 100 in FOR loop but it completed before one second around 0.03 sec and give only three samples data and when I am setting value in thousands like 3000 or more than it is completing run near to one second and give 100 samples data. Could you please guide me why my code is behaving like this in FOR loop environment and can I set or control number iterations in while loop as it is continues loop.
There is no reasonable unit of Hz/sec (Hz is 1/s, so Hz/s is 1/s²) and I can't even imagine what that means, except maybe for a chirp signal, for example.
Your loop speed is limited by the speed of the serial communication and that entirely is the responsibility of the sender. You have no control over that!
07-20-2024 06:39 AM
Hi,
Sorry for disturbing you by controlling the while loop; I introduce a comparison function inside the loop, in which x represents required iterations and y starts from 0. As it reaches the required value, the loop will stop. Outside while loop from averages, first, subtract the same constant value from each average value, then subtract the average values like a veg Val1 - a veg Val2, .... Kindly please guide me if I am doing the correct stepping, or again I am making a mistake?
I also attached the LV code (LV19 version).
Kind regards
Hasham
07-20-2024 06:40 AM
Hi,
Sorry for disturbing you by controlling the while loop; I introduce a comparison function inside the loop, in which x represents required iterations and y starts from 0. As it reaches the required value, the loop will stop. Outside while loop from averages, first, subtract the same constant value from each average value, then subtract the average values like a veg Val1 - a veg Val2, .... Kindly please guide me if I am doing the correct stepping, or again I am making a mistake?
I also attached the LV code (LV19 version).
Kind regards
Hasham
07-20-2024 11:03 AM - edited 07-20-2024 11:09 AM
This is still a horrible hairball and you did not implement most of our suggestions:
Then you have pure Rube Goldberg code to subtract adjacent elements, for example here's an alternative that would take seconds (instead of minutes) to code (equivalent of raising your hourly wage by a factor of 10!)
07-20-2024 11:22 AM
@Hasham622x wrote:
Outside while loop from averages, first, subtract the same constant value from each average value, then subtract the average values like a veg Val1 - a veg Val2, .... Kindly please guide me if I am doing the correct stepping, or again I am making a mistake?
Your description has no resemblance to your code and is very ambiguous, but if you want to subtract the average of the array averages and take the pairwise difference, here's what to do;
Note that the array of averages is a 1D array, i.e. the second row of your 2D array. Your first row is the last non-averaged record that you already saved to file. Follow the wire!
07-21-2024 04:55 AM
Hi,
Thanks for your guidance. I tried to use the 1D decimate array option, but it gives an error as after the loop, the average array is 2D due to that I tried other options, and please guide me on how I could save each file with the current date and time so it should not have fixed same file name as at the moment I have to delete or shift data file after code run.
Once again, thanks for your reply.
Kind regards
Hasham