LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Average from 5 Samples taken at 20mSec appart!

Solved!
Go to solution

Don't use rar files.  Use zip.

 

Not many people have utilities to open rar files.

Message 11 of 29
(1,368 Views)

Attached the .zip version of the VI thank you evry much for your help 

QMESAR

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 12 of 29
(1,365 Views)

I managed to post the VI I was not aware the the Forum does not like .rar files used WIN .zip now 

 

Regrads

 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 13 of 29
(1,362 Views)
Solution
Accepted by topic author QMESAR

@QMESAR wrote:

I managed to post the VI I was not aware the the Forum does not like .rar files used WIN .zip now 

 


Windows has zipping built-in. No need for any questionable software (winzip?). Just "right-click...send to...compressed folder."

 

A few comments for your code:

  • The actually used part of your main front panel is about 700x500, so why would you maximize the front panel to fill the screen??? Very annoying! Sometimes we work on several things.  A maximized front panel covers everything and makes debugging (e.g. execution highlighting) nearly impossible. Keep the window at a reasonable size!
  • I guess you solved the "running average" part, so here are just a few suggestions to make the code more streamlined .A picture probably shows it best. You should also ensure that "disconnect" is FALSE first thing.
  • A: See red comments in the image.
  • B: No idea why you would need a reference and value property just to change a boolean indicator? It is also not even clear why you need to do that when the program stops (once the program is no longer running, the LED state is irrelevant. To make sure it is initially FALSE when the program starts and before the terminal is written for the first time, go to "VI options...execution" and enable "clear indicator when called.
  • C: Using a local variable right next to it's disconnected terminal shows a basic misunderstanding of local variables and causes race conditions.
  • There are many more issues. this is just the tip of the iceberg, but should give you some ideas. 

 

CodeCleanup.png

Message 14 of 29
(1,351 Views)

Dear altenbach

Thank you very much for you time and efforts to help me,I appreciate it ,

This is the exact problem from doing te basics course and then to apply all of it ,

Your commnets are very valuable for me and help me to see some light,

As for the referance at the closing of the USB port, I also have no idea why it is like that however my code is build on a Template from the Controller supplier which consist

  •  3 framed sequence structure 
  • In the first frame the OPEN USB Port with Connected LED
  • Second frame  the While loop with the stop Button-(The Timed loops I added  for the cyclic timing of the CAN protocol ,wheather this is correct use of Timed loops is still open question with me )
  • Third Frame with the Close referance to the LED .

It is 23H00 at my location now I will tomorrow work on all your comments and change the code and also try to understand the reasons for it.

 

Thank you very much once again Smiley Happy

QMESAR

 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 15 of 29
(1,343 Views)

Dear All 

Thank you very much for your kind help and teaching me!

I have done the modifications as to the info from altenbach and the running average as   indicated by aeastet 

and ran the Vi on the machine today allwent well so far 

1.jpg

Regards 

QMESAR

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 16 of 29
(1,325 Views)

You don't need the "first call?" primitive, the ptbypt mean does that automatically. You only need one "5" diagram constant and it should be blue (I32 integer). You can branch the wire.

Many of the indicators have coercion dots. Pick the right representation!

0 Kudos
Message 17 of 29
(1,300 Views)

Hi All,

 

Thank you for that ,I have worked on the coercion dots after your last post and I have no pink dots any more I also fixed the other issues (and I am learning thank you very much for all the help) however by the  Temp indicators I seam not to get the reason for it 

This is how the vi looks now.

2.jpg 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 18 of 29
(1,295 Views)

As my data coming in from the CAN data array is U8 (values between 0-200) and a offset of 40 I did now all calculations in U8 and also set the representation of the Indicators to U8 then I have no pink (red)dots  not sure if my thinking is correct by keeping all to the same representation as the Temperature reported from the machine does not contain decimal places 1° resolution as best .

I also have 1 LED that is controlled over a Local Variable on the front panel not sure if this is "ok" to do/the bit is masked out from an Error array of bits.

2.jpg

 

---------------------------------------------------------------------------------------
Learning is an endless process but needs to start some where
0 Kudos
Message 19 of 29
(1,291 Views)

If you can guarantee that the result of the -40 subtraction still fits in the U8 range (i.e. the original values is guaranteed to be >=40) you are fine. If not, you need to convert the U8 value before the mathematical operations (e.g. to I16) to allow positive and negative results. Blindly subtracting two U8 values might give you a wraparound. Connecting a DBL indicator to a U8 value does not change the value to a higher resolution or change the sign.

 

Unless you also write to the LED from elsewhere in the code, you should replace the local variable with the actual indicator terminal. Where is the terminal? Form how many places do you need to write to it?

 

 

Message 20 of 29
(1,275 Views)