LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-initializing my array with reset button

Solved!
Go to solution

Hi there, I am currently facing a problem of shifting my array's pointer back to the start. 

 

What I am trying to do here is to create a "RESET" button such that the user would be able to start the whole program all over without having to stop and run the program again. Everything is working as per normal such that my arrays are cleared, however when I clicked on "Start" again, the array displayed the old data again despite me re-initializing it to default. I am unsure what is happening here.

 

Below attached are the images of what is happening

1 - Start of program

2 - "Start" button is pressed three times. 

3 - "Reset" button is pressed

4 - "Start" button is pressed again.

(DO note that it is suppose to display only 1 set of data and not 4 sets of data here)

 

Any help is appreciated. 

Download All
0 Kudos
Message 1 of 93
(4,192 Views)

Please attach a VI. Since we can't see any part of your code (even a picture of the Block Diagram) it's very unlikely we will specify the problem accurately enough to help you.


GCentral
0 Kudos
Message 2 of 93
(4,186 Views)

Attached is the VI. Do let me know if you are unsure with how my program works.

 

Appreciate your help!

0 Kudos
Message 3 of 93
(4,171 Views)

Dear Jarrold,

 

Thank you for uploading the VI. Unfortunately, my monitor is not large enough to work out how your VI works. My first suggestion would be that a large amount of space seems to be taken up by case structures containing a large number of property nodes, setting the same property for each node - for example "Visible". 

 

You can greatly improve readability by instead creating a cluster containing all of the references to controls in your application, then creating a subVI containing for example "Cluster to Array" then an autoindexed For loop, then the Property Node inside the loop with a constant value.

 

If you always want to operate on all of the values, and don't need to ever control specific references, then you can alternatively just build an array of references and forget about using a cluster - this is simpler, but problematic when you decide you want to change only one value, for example. Therefore, I would suggest a cluster (possibly including arrays of references rather than individual references, if you have a set of the same type of references and know that the index is sufficient to pick out the reference you need).

 

As a concrete example, in the Logging Volt case, under a True case, there is a case structure wired to what looks like a custom control Enum, or possibly radio button control, in which each case makes one control visible and hides 8 other controls. With an array of those 9 references, you could create a subVI which first uses 'Delete from Array' node to split based on the index, using the "Control Panel" value (make sure you have the references in the same order as the enum values!) and then a For loop to make 8 controls invisible, and a separate property node to make one property visible. An example is given below. The attached VI is backsaved to 2012.

 

controlRefs.png


GCentral
Message 4 of 93
(4,151 Views)

OMG I cannot even begin to comment on that code... The sheer size makes it impossible to even look at let alone follow what is going on.

 

When the size of your block diagram gets bigger than your monitor you need to STOP right there. Take a step back and think about what you are doing.

 

Because you are doing it wrong if you printed your block diagram and it would cover a 4x8 sheet of plywood.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 93
(4,110 Views)

There are some fairly strange constructs in there.  My favorite so far is the darnedest reverse columns Iv'e ever seen

Capture.png

Which is slightly flawed in implementation.  had we shifted the decremented size we could avoid swapping the center column with itself!


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 93
(4,104 Views)

Hi cbutcher,

 

I am actually pretty new to Labview, in fact this is my very first project. I really appreciate your advice and I will try to implement it. Hopefully I will be able to reduce the size of my codes because it is really getting out of hand! Hopefully you will help me along the way!

 

Cheers !

Jarrold

0 Kudos
Message 7 of 93
(4,057 Views)

Hi RTSLVU

 

Sorry for giving you such a headache because I am pretty new to Labview. I am trying to work on it and improve on my codes! Smiley Embarassed

0 Kudos
Message 8 of 93
(4,056 Views)

Hey Jeff!

 

Appreciate your advice, because I am rather new to Labview, thus I am trying to get my program to work first without thinking much on how to improve my codes. But i truly appreciate your help. I would post a few more pieces of my codes here, hoping to gain some new advice from you !

 

Cheers,

Jarrold

0 Kudos
Message 9 of 93
(4,053 Views)

Hi Jarrold,

 


@Jarrold wrote:

 

I am actually pretty new to Labview, in fact this is my very first project. I really appreciate your advice and I will try to implement it. Hopefully I will be able to reduce the size of my codes because it is really getting out of hand! Hopefully you will help me along the way!

 


I would suggest that the greatest single step you can take to aid understanding of your code (not just for forum users, but far more importantly for yourself, or people you work with/for) is to use (more?) subVIs.

 

These are just 32x32 pixels on a block diagram, and when they have a suitable icon set, can reduce vast swathes of the diagram to a small, easily understood block. They additionally prevent the need to copy and paste code into multiple places, which rapidly becomes a maintenance nightmare when you need to change something in that code.

 

I'm not sure if you're already using a project file, but if not you should also use one of those. They are used to collect groups of VIs so that they form one entity (but don't upload a .viproj file to the forums - they don't contain code). Instead zipped directories can be uploaded if the problem is larger than one VI.


GCentral
0 Kudos
Message 10 of 93
(4,051 Views)