LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Knob and Meter not working

Hello,

 

Everything on my VI works as expected (it is a traffic light controller with some special features).

 

I am trying to make some tests with a Knob changing the value of a Meter and it does not work. If I put a Knob connected to a meter on a blank VI exactly same way it works...

Attached is a photo of my VI.

 

Any comments would be appreciated. Please forgive my lack of knowledge on labview. I am starting to see tutorials, forums web material and learn making this "small project".

0 Kudos
Message 1 of 16
(2,534 Views)

How would you react. to my asking for your help with a C++ program and attaching a "photo" of the 5 pages of printout of my code?

 

Please do not attach photos of your code.  Particularly do not attach tiny hard-to-read images.  Attach the actual code, which are typically files that have the extension .vi (or possibly .ctl if you include a Control, Indicator, or TypeDef, maybe even .lvproj if you are using LabVIEW Project).  Or you could attach a Snippet (Edit menu, "Create Snippet from Selection), anything to save us the drudgery of squinting at your image and trying to recreate it, hidden wires and all, ourselves.

 

Bob Schor

0 Kudos
Message 2 of 16
(2,520 Views)

Have you ever tried to debug a picture of code before?

 

Here is what I do see.

1.  A rube goldberg with the select statement.  (If True, send True, if False, send False)

2.  An abuse of local variables.

3.  Terminals that I don't know what they do because they don't have labels.  One while loop dependent on another while loop.

4.  A knob control and meter indicator that should be re-positioned so the wire doesn't run backwards.

5.  A knob control and meter indicator that only execute once when the VI starts.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
Learn LabVIEW

Message 3 of 16
(2,514 Views)

I assume you have been using the Run Continuously button, which is why your knob/meter combination work in a new VI.  Run Continuously is not the proper method for calling the same code over and over.  Use a while/for loop instead.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 16
(2,490 Views)

It also appears as though you have multiple loops that are being chosen between based on controls (although you're using a lot of local variables, as was already mentioned).

You should instead consider using a Case structure, and perhaps further, a State Machine.

This may allow significant reduction in duplicated code (although that's just a guess, because I can't really see most of the code!)


GCentral
0 Kudos
Message 5 of 16
(2,468 Views)

Apologies. You are absolute right! Here is my VI attached.

 

I supposedly wrongly it was something simple and stupid I was doing and easy to identify.

0 Kudos
Message 6 of 16
(2,406 Views)

@aputman  escreveu:

I assume you have been using the Run Continuously button, which is why your knob/meter combination work in a new VI.  Run Continuously is not the proper method for calling the same code over and over.  Use a while/for loop instead.


I tired to put everything inside a while loop (stop condition with  a constant) or create a new while loop just for the Knob+Meter and did not work as well. On the first option seems the while loop ("main while loop") only works after all the loops or something finishes its own cycles. On the second option the Knob+meter works but 2 of the other loops stop working...

 

This can be caused by the local variables? I can use notifiers but each while loop will control 5 LED (3 LED for cars traffic light and 2 for pawns traffic light). And this 5 LED will be also 5 digital outputs on a USB NI Board. 

So the amount of send notification and wait for notification for the stop buttons (where I am using local variables) nad for the LED (where I am using local variables too) will be like a massive thing. There is any other way to do the same thing but with minimal stuff in other to have a clean design ?

0 Kudos
Message 7 of 16
(2,400 Views)

One while loop doesn't mean put one around everything you have now.  It means put the contents of the 3 while loops into a single while loop.

 

Why does the top right loop run after the top left loop?

What is the purpose of the Knob and Meter?

What is the function purpose each of the 3 loops that you have now?

What is the red/green only light supposed to be?

0 Kudos
Message 8 of 16
(2,379 Views)

@RavensFan  escreveu:

One while loop doesn't mean put one around everything you have now.  It means put the contents of the 3 while loops into a single while loop.

 

Why does the top right loop run after the top left loop?

What is the purpose of the Knob and Meter?

What is the function purpose each of the 3 loops that you have now?

What is the red/green only light supposed to be?


The idea is to have LED's: red, yellow and green for cars traffic light and LED's green and red for pawns traffic light. 

There is :

- Automatic mode (car and pawns traffic light work automatically

- Night Mode (yellow for car blinks and all the others should be OFF)

- Manual Mode (control car traffic lights manually)

 

I tough use one while loop for each "operation mode" making the stop condition of each one depending of conditions like: when the switch is set for automatic only the while loop that contains the automatic mode case runs, if set to manual then one of the other two while loops will run. I prevent that one one per time will work and they work well.

 

The only thing that do not work is the knob+meter. The idea to use them is to "simulate" a LDR connected to a USB data acquisition board (from NI). Meaning: when the LUX level is less then a value the night mode will be activated automatically (means its night so the yellow LED for cars will blink....).

 

I revised my VI to use one while loop that contains inside a case for implement a state machine considering every state and the transitions between them.

 

So for me the previous problem is related to the amount of while loop, local variables or combination of both.

I saw in many places using local variables is dangerous and not advised. So most probably it is why it was happening the problem described. Just want to confirm that now to learn with that.

 

If someone has a better way to do it I will be glade to know why. Knowledge don't take place in our minds (its a Portuguese saying).

 

0 Kudos
Message 9 of 16
(2,351 Views)

As cbutcher suggested I believe that your application would benefit from a state machine architecture. The state of your state machine would be determined by the Mode that you selected. You need exactly 1 while loop to accomplish this.

0 Kudos
Message 10 of 16
(2,331 Views)