05-04-2018 10:42 AM - edited 05-04-2018 10:51 AM
Hi All ,
I need some help please ,(labVIEW beginner)
I have a CAN message that comes in every 20mSec I then take out the 8 bytes of data out this is all working fine howver I would like to add 5 values (5 x20mSEC ) and build a Running average of the values as indicated in the attached sketch ,A and B.
I know that I can use the Mean pt to pt Vi and propably the compound artihmetic ,I tried a for loop with a shift register however it seem in every 20mSec the for loop execute 6 times and add the same value 5 times,
it does not take the sample add it once and then in the next 20mSec it add the second value .
How can I solve my problem .
I appreciate all help and directions
Regards
QMESAR
Solved! Go to Solution.
05-04-2018 10:49 AM - edited 05-04-2018 11:05 AM
05-04-2018 10:53 AM
You should just have to use the point by point Mean vi. It does not require a loop to work. Here is an example.
I would add the first call to make sure that when you start your program that the avg reinitialize. You could also add a button that you could press that would reset your running avg.
05-04-2018 11:35 AM
Dear aeast.
Thank you for your kind reply this seams to do what am am trying to do.I apprecaire your small example .I just added to my code and it is working fine ,
05-04-2018 11:40 AM
I'm glad I could help.
05-04-2018 11:45 AM - edited 05-04-2018 11:59 AM
Dear altenbach ,
Thank you for your reply !
As I can see from your signature you are very higly experienced with this which I am not ,This is my very first attempt at using labVIEW after doing a Basic 1 course,so yes I have very little knowledge and experience in this field .Secondly I am not trying to use big words ,I have found examples on this forum (and yes I did search the forum ) which shows how to do this by using a while loop with a shift register that puts the values in a Compound aritmetic vi and then divide it by the number of samples clearly mentioned an Average so this is where my big words come from.
Thank you for your comments I will look at all of it as I am trying to learn and are prepared to take a beating such as yours to learn .
The stacked sequencs is recomended by the machine manufacturer to read the CAN messages out as the LV application needs to send the command to get the received ID(over USB) then wait 1mSec and then send the command to the unit to send the received data bytes back all over USB . I will enquire with them why the stack sequence is necessary.
Send Command for ID then select the correct ID in the case structure
Thank you once again for your comments it is appreciated
Regards
QMESAR
05-04-2018 11:59 AM - edited 05-04-2018 12:02 PM
Since there is a data dependency between the code in frame 1 and the case structure in frame 2, execution order is fully determined and the sequence is obsolete.
How often does the rxid change? If it is constant during the run, it only needs to be obtained once at the start of the program.
Please stop showing us pictures, attach the actual vi for better help!
05-04-2018 01:43 PM - edited 05-04-2018 01:58 PM
Dear altenbach
Thank you for the reply, I have realized what you are saying about the data dependency and I corrected it in the RX loop and it is working fine (Thank you )
The Vi is attached I am still having probelms with the red dots I will look more closly,The RXID is constantly changing, it can be 1 of 5 different messages in the RX buffer .
Thank you for your advice
PS I select the data however I can not get the VI attached to the post how do I upload the files to the post
QMESAR
05-04-2018 05:43 PM
@QMESAR wrote:
PS I select the data however I can not get the VI attached to the post how do I upload the files to the post
It should just work using the [Choose File] Button below the edit window. Maybe try a different browser.
05-05-2018 08:30 AM
I have tried all known Browers not possible to uploaf a .rar file
it always report I should correct the errors however there is no marked errors to corrcet
Thank you all for your help so far