LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting a numeric in a sequence to zero

Hello all,

I was hoping that I could get some help on a project I am working on.

In this sequence, I would like a way to:

A) Reset the numeric called "Holes" to zero after every time the sequence runs

B) reset the numeric called "Acceptable (Clearable) to zero with the push of the "Clear" button yet have it begin counting again from zero

Thanks in advance, LabView has a very steep learning curve.

 

0 Kudos
Message 1 of 15
(4,854 Views)

Do you just want the values in the indicators to be set back to 0 or do you want the values in the feedback nodes/shift registers to be reset back to 0?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 15
(4,838 Views)

Yikes! Smiley Surprised  It might be best if you explained what you're trying to do so we can guide you to the right solution from the beginning rather than try to salvage the...  ummm...  "attempt" you have made so far.  LabVIEW does not have a steep learning curve unless you fail to learn the basics before you jump into the deep end as you have obviously done.

 

http://www.ni.com/academic/students/learn-labview/

 

I suspect you need a basic state machine which is provided as a LabVIEW template along with some simple logic and timing functions to control the states but I really can't fathom what you hope to accomplish by looking at the code you posted.  Smiley Frustrated

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 3 of 15
(4,832 Views)

@NIquist wrote:

Yikes! Smiley Surprised


I wonder what thought process led to this code fragment? 😮

 

 

 

I agreee with everything NIquest said!

0 Kudos
Message 4 of 15
(4,822 Views)

Ok, so I am working on trying to build a washer sorting machine for my engineering group project.

Firstly, the program was supposed to activate a solenoid to push the washers into a chute where they would cross over a photosensor.

labview solenoid.PNG

Then, the machine is supposed to use a photosensor to determine if the washer has a hole in it or not. labview 1.PNG 

The photosensor is suppoded to determine if there is a hole by telling the counter how many times the beam between the infrared LED light was broken. If it was broken twice, the washer is acceptable and will add one to the acceptable counter. If it was broken once, it is unacceptable because the washer has no hole in it and will add one to the rejected counter.

labview2.PNGlabview 3.PNG

Then, it will need to turn a motor with a brush attached to it to push the washer into either an acceptable bin or a rejected bin based on the number of times the beam to the photosensor has been broken.

Labview motor.PNG

However, the machine is supposed to stop operation after there have been 25 acceptable washers which is why I wanted to be able to clear the clearable acceptable counter in order to allow the operations to be run again.

I'm sorry if this coding is painful to look at. I am very new to this and was placed in this position because apparently I was the most competent at using LabView.

As for this, labview failing.PNG,this was to let me know when the photosensor was reading so I could test my coding by running a washer over the hole the light shone through to the photosensor

0 Kudos
Message 5 of 15
(4,792 Views)

Start to learn about state machines. They are a very good program structure for the kind of program you are trying to write.

 

They will also help you eliminate the sequence structures.

 

Lynn

0 Kudos
Message 6 of 15
(4,773 Views)

I want the values of the indicators to be able to be reset to zero, but then still be able to count after being reset.

I just tested it and most of the other coding works right now as the motor turns the the proper direction for rejected and acceptable washers, the solenoid works after I changed the time for the delay in between the true and false statement, and the photosensor accurately responds when the washer breaks the path of the light from the infrared LED. 

I now know that it is a mess and that a state machine would work much better, but with this alrady working in the sequence that I want it to (as well as a rapidly approaching deadline), I just need something that will work for the time being and, aside from being unable to reset the "Holes" and "Acceptable (Clearable)" numeric displays while the program is running, this program seems to work.

I really appreciate all of the help on this. I don't want to sound ignorant or anything as I am very much a newbie on this and am probably way out of my league in much of this. Smiley Embarassed

0 Kudos
Message 7 of 15
(4,742 Views)

Here's the problem you're running into:  You're using the flat sequence structure.  This has to start and then perform each frame in sequence.  It doesn't have a clean way to go back to another point and reset values while continuing the process.  You'll have to introduce variables into the equation (where we can already tell you don't know when to use these).  That makes things more muddy.

 

With the state machine (that wouldn't take a great deal of time to put together), you'd easily be able to move back to a reset state, then go back to what you were doing in the first place.

 

The reason people are questioning the constant being fed into the boolean is something you won't be able to answer.  There is NEVER a reasonable answer to the question you're being asked.  If you delete the local variable, you can wire directly into the indicator next to it.  As the indicator is sitting right next to the local variable and has nothing wired into it, it doesn't begin to make sense to create the variable here.  In most cases, you won't need to use variables in LabVIEW. 

 

You bring up the deadline.  As crazy as it sounds, taking a quick crash course in LabVIEW often saves you more time troubleshooting and debugging than skipping the course and trying to see if you can figure out what's giving you a hard time.  In this case, there's lots of strange coding that is likely to give you a hard time (a 0 ms wait, excessive variables, etc).  If you REALLY only want something janky, you'll want to read whatever you're using as a reset in pretty much every frame to see if you need to reset the holes count.  That's the introduction of a large number of variables and is incredibly janky.  But, it's also the only way you're going to be able to update this mid-sequence.

Message 8 of 15
(4,708 Views)

@natasftw wrote:

Here's the problem you're running into:  You're using the flat sequence structure.  This has to start and then perform each frame in sequence.  It doesn't have a clean way to go back to another point and reset values while continuing the process.  You'll have to introduce variables into the equation (where we can already tell you don't know when to use these).  That makes things more muddy.

 

With the state machine (that wouldn't take a great deal of time to put together), you'd easily be able to move back to a reset state, then go back to what you were doing in the first place.

 

The reason people are questioning the constant being fed into the boolean is something you won't be able to answer.  There is NEVER a reasonable answer to the question you're being asked.  If you delete the local variable, you can wire directly into the indicator next to it.  As the indicator is sitting right next to the local variable and has nothing wired into it, it doesn't begin to make sense to create the variable here.  In most cases, you won't need to use variables in LabVIEW. 

 

You bring up the deadline.  As crazy as it sounds, taking a quick crash course in LabVIEW often saves you more time troubleshooting and debugging than skipping the course and trying to see if you can figure out what's giving you a hard time.  In this case, there's lots of strange coding that is likely to give you a hard time (a 0 ms wait, excessive variables, etc).  If you REALLY only want something janky, you'll want to read whatever you're using as a reset in pretty much every frame to see if you need to reset the holes count.  That's the introduction of a large number of variables and is incredibly janky.  But, it's also the only way you're going to be able to update this mid-sequence.


Ok, is there any way that I can still have the hardware run in a specific sequence with the state machine? I had made many of the steps in the sequence as single labviews that would turn on and control the direction of a motor, would activate a solenoid, and would read a photosensor based on the instructions of my professors and I had thought that a sequence structure would be best for this, but I guess I thought wrong.Smiley Sad

0 Kudos
Message 9 of 15
(4,683 Views)

Yes, the hardware/program/steps running in a certain order is the main benefit of a state machine and you should very rarely use a sequence srtucture. Here are three online articles that will probably help you most at this point:

If you still need more information, try browsing the included examples in LabVIEW through the "Find Examples..." (under the Help Menu) to use as reference.

Message 10 of 15
(4,671 Views)