02-01-2021 01:32 AM
Hello,
I am trying to do calculations in the formula node with DBL data. The if statements, to filter the data are working fine. When is time to do calculations, which is the last formula node is not working well. The code supposed to do calculations when the value is different than zero but is not working well..
I have spotted the reason, which is the 10 samples per channel...So what the formula node does is: Doing the calculations (continues summation) for 10 elements, and then when it detects that is the 11th element, it starts the calculations again for the next 10 elements... without taking into consideration the previous calculations
I cant understand why is doing that...I need to have it continuously. For example continuous summation of 1000 elements, but after the filtering part..
I am attaching the VI for your reference.
Thank you in advance and any feedback is highly appreciated!
Solved! Go to Solution.
02-01-2021 02:10 AM - edited 02-01-2021 02:14 AM
Hi Alexis,
@Alexis_Koul wrote:
Hello,
I am trying to do calculations in the formula node …
I have spotted the reason, which is the 10 samples per channel...So what the formula node does is: Doing the calculations (continues summation) for 10 elements, and then when it detects that is the 11th element, it starts the calculations again for the next 10 elements... without taking into consideration the previous calculations
I cant understand why is doing that...I need to have it continuously. For example continuous summation of 1000 elements, but after the filtering part..
Why do you use formula nodes at all? Why not use pure plain LabVIEW/G code?
This is a very literal translation from your formula nodes to LabVIEW G code: you can join the content of both loops!
The variable "S_Time" isn't defined (or initialized) very well, according to your formula node it will be zero all the time!
Why do you need to calculate all elements when you only need the 2nd element as result???
When you want to "take into consideration" values from previous iterations you should use shift registers. This is pretty basic LabVIEW stuff!
When you "don't understand" shift registers: take the Training resources as offered in the header of the LabVIEW board!
02-01-2021 02:45 AM
Dear GerW,
Thank you very much for your answer! As always very helpful!
The reason that I didnt you shift register is that the calculation is working but only for 10 data points. Will try what you sent!
Thanks again!
02-04-2021 07:04 AM
Dear GerW,
Could you please explain me why the formula node is starting again the summation/calculation for 10 elements and initiate again in the 11th?
As I said in my initial message, I know that is because of the 10 samples per channel, so is this a limitation?
If I use Mathscript Node, may work better?
Appreciate your support..
02-04-2021 07:29 AM
Hi Ale_is,
@Alexis_Koul wrote:
Could you please explain me why the formula node is starting again the summation/calculation for 10 elements and initiate again in the 11th?
As I said in my initial message, I know that is because of the 10 samples per channel, so is this a limitation?
If I use Mathscript Node, may work better?
There are 10 samples per channel, so in each iteration those 10 samples are processed.
But it doesn't matter if you use a FormulaNode or Mathscript: it's your programming if you use values from last iteration or not!
Learn to use shift registers when you need to forward values to the next iteration of a loop!
02-04-2021 09:15 AM
Hello GerdW,
I apologize for writing your name wrong.
In what you have sent me, I added the following statement between. If the current value is equal to the previous, then to put 0, else to put the actual value.. But obviously I am doing something wrong, and even if the current with the previous value is equal, it takes the actual value.
Would be great if you can give a feedback. As always I appreciate your help.
02-04-2021 11:04 AM
Hi Alexis,
@Alexis_Koul wrote:
But obviously I am doing something wrong, and even if the current with the previous value is equal, it takes the actual value.
I see two three main problems with your image:
Minor problems:
02-05-2021 04:43 AM
Dear GerdW,
Attached you can find the code. I initiated the shift register and also I changed the equality with a subtraction. So if the subtraction is less than a value, which should be actually 0, then it should be that it is zero else the actual value..... but still is not working...
I appreciate your support
02-05-2021 04:50 AM
Hi Alexis,
@Alexis_Koul wrote:
I initiated the shift register…
There are still two uninitialized shift registers. And there are "default if unwired" tunnels…
@Alexis_Koul wrote:
I changed the equality with a subtraction. So if the subtraction is less than a value, which should be actually 0, then it should be that it is zero else the actual value..... but still is not working...
There is only one subtract node in the VI, and you don't compare with zero after this subtraction…
Can you set some typical values in the "data" array to default? (Edit -> set current values as default) Then save the VI and attach it again…
02-05-2021 05:00 AM
Dear GerdW,
Thank you for your quick reply and support.
Attached find the VI with values. Please see the results from <<Array3>>. I dont compare with zero because it didnt work, so thats why I put a value of 0.5...so element 5 and 6 in Array 3 should be zero..
Thank you!