LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming suggestions: Lamp test

Solved!
Go to solution

Hello,

I have several sensors in a system and Indicators, for whole system I am developing a sub-VI for three kind of operation, Normal, Warning and Alarm mode.

for AI inputs of sensors::::::I have planned to make a moving average of the sensor values based on that and based on the peak value,,,the lamp value will glow and buzzer will be activated.

For DI inputs::::::if all the indicators are true that will directly to the alarm mode if all indicator are false will go to normal operation.

Please suggest for the attached VI.

0 Kudos
Message 1 of 5
(2,355 Views)

I think you need to spend some time clearly defining what this VI is to do.  You say you want it to be a subVI eventually.  As such I presume that the slides and motor buttons will eventually be inputs from the calling VI.

 

The user generally does not see or interact with a subVI. So how will this stop?

 

Only the value present on the input controls when the subVI is called will be used.  None of those values will change until the subVI ends and is called again.  Do you even need or want a loop?  Perhaps the looping and the shift register feedback should be in the loop of the calling VI.

 

While trying to eliminate the local variables, I found that you are writing to your output booleans in at least two places in parallel.  Which one do you want?  You have no way of knowing which will execute last, becoming the output.

 

When used as a subVI, it is not clear what the Elapsed Time VI is accomplishing.  Again, it might be better to manage the timing in the calling VI.

 

Lynn

0 Kudos
Message 2 of 5
(2,316 Views)

Hi Lynn,

Re: Programming suggestions: Lamp test
 

I think you need to spend some time clearly defining what this VI is to do.  You say you want it to be a subVI eventually.  As such I presume that the slides and motor buttons will eventually be inputs from the calling VI.

 

The user generally does not see or interact with a subVI. So how will this stop?

 

Only the value present on the input controls when the subVI is called will be used.  None of those values will change until the subVI ends and is called again.  Do you even need or want a loop?  Perhaps the looping and the shift register feedback should be in the loop of the calling VI.

Agreed we need do not need a loop or stop function for a subVI. But presently if we forget that it is a sub-VI, I need to attain the conditions for all the AI or DI inputs for normal, warning and alarm mode with the buzzer.

 

While trying to eliminate the local variables, I found that you are writing to your output booleans in at least two places in parallel.  Which one do you want?  You have no way of knowing which will execute last, becoming the output.

 

When used as a subVI, it is not clear what the Elapsed Time VI is accomplishing.  Again, it might be better to manage the timing in the calling VI.

I have removed the elapsed time function, which didnt make much sense as suggested.

If I just consider it as a VI. Please can you suggest about the attached VI. How can I acheive peak detection and moving average?

0 Kudos
Message 3 of 5
(2,291 Views)

Hi,

 

For peak detections you may want to consider the Waveform Peak Detection VI found in the Waveform Palette. I did not see a VI specifically for doing a moving average but you could incorporate shift registers to build an array of previous values. Lets say you wanted a moving average of the last ten values. Then you would build a ten element array using the shift registers and sum the values and divide by then. That would be a simplistic way to have a moving average.

 

Regards,


Josh B. 

Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(2,270 Views)
Solution
Accepted by topic author KRAZE4LV

You still have several problems with your VI.  I have attached a cleaned up version with comments on several areas.

 

1. You do not need most of the shift registers because most of the data neve changes inside the loop.

2. The output of the ANDs connected to the comparisons against the sum of sliders/y is always False: (x<100) AND (x >= 180) = False.  This means that the case structures with Warning Mode, Alarming Mode, and Normal Operation are always False.

3. You have race conditions on Sound Enable and its local variables. The Read local will execute before any value has been assigned to the terminal on the first iteration.  I think that will cause it to return the default value of False.  The Write locals are all in cases which never execute as mentioned in 2.

4. The values going to Mean never change inside the loop so the calculation and indicator should move outside the loop.  Same for Alarm.

 

Lynn

Message 5 of 5
(2,249 Views)