From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-initializing my array with reset button

Solved!
Go to solution

@cbutcher wrote:

I think maybe you missed my post describing your transposition usage.

I'm attaching a VI which demonstrates the equivalence of the two methods, but you can't give them different inputs and expect the same output 😉

 

You have one of the inputs transposed (your more complicated loop) and the other takes the string array before it is passed through Transpose 2D Array.

 

You can play with this VI and check how you want the output to look (I think the input should match your system - A, B, C are different sensors and 1,2,3,4 should be like different times). Transposing before and after doesn't have the same effect.


Yeah, I actually spotted that difference and rectified it. However, I realize there is one problem with the "time log" again. The problem here now is that in my report generation, it is a 2D array. However, in my front panel it is a 1D array. If I were to change the 1D array into 2D array, the front panel will not display the same information again. 

 

Attached below is the front panel and the block diagram for you to understand better.

I am really sorry and appreciative of your help, cbutcher! Thank you very much!

Download All
0 Kudos
Message 21 of 93
(1,445 Views)

@cbutcher wrote:

Moving back to your real, original problem (sorry for the enormous detours) the issue is that the feedback node is still holding the values. The next time you press start, it goes through the Logging Temp case again (I assume?) and then the feedback node still holds all the previous data.

 

The normal solution to this kind of problem is to use Shift Registers, rather than Feedback Nodes. With a shift register, you can write the register from the Initialization or Reset cases, and just wire an empty 2D array (or whatever your shift array datatype is). The problem you face with that approach at the moment is you have quite a lot of feedback nodes, and a shift register must always be wired - in the case where you're not using the data and you don't want to delete it, you still have to connect the left side to the right side with no changes.

 

This would, for you, result in a lot of wires going all the way across your diagram, which you might not want (especially because it is still quite wide). In this case, you should probably consider a Cluster containing all of your arrays, which you can then use on the Shift Register. When you want to write the values, use Bundle By Name, and when you want to access the data, use Unbundle by Name. You can use simply Bundle and Unbundle if you want, but it's less clear what you're doing, and then if you change the order of the elements of your cluster, you can silently break code. If you use .. By Name, then they will move around for you. As a side note, you should make the cluster a typedef!

 

Once you have a cluster full of values, you're halfway to an Object Oriented version of your code. I have no idea if that's something you'd want to consider, but maybe focusing on the smaller steps first is a good plan!


Is it possible for you to show me an example so that i can better relate and learn from it, cbutcher?

0 Kudos
Message 22 of 93
(1,441 Views)

Hey cbutcher, 

 

Ive tried creating those clusters but I dont really understand what you meant by this

"In this case, you should probably consider a Cluster containing all of your arrays, which you can then use on the Shift Register. When you want to write the values, use Bundle By Name, and when you want to access the data, use Unbundle by Name. You can use simply Bundle and Unbundle if you want,"

 

I am not sure how to go about doing it. I have tried switching those feedback nodes back to shift registers and indeed, the wires are all over the place. 

 

Attached is my cluster, let me know if I am right or wrong 🙂

 

BD2.JPG

Cheers !

 

0 Kudos
Message 23 of 93
(1,435 Views)
Solution
Accepted by topic author Jarrold

Jarrold wrote:Is it possible for you to show me an example so that i can better relate and learn from it, cbutcher?

Yes. I'm attaching your VI (possibly you've made improvements since this copy, but hopefully you can see the idea and just implement it in your code if you have) with a cluster for Time and Temp measurements. The cluster is defined in the case that measures the temperature (but it probably shouldn't be!) and then a Linked Input Tunnel is used to ensure the wire is passed by default through other cases.

 

The reset case wires empty arrays to both in the Bundle By Name node we discussed.

 

You should make the cluster a typedef (right click on the little pink box and click Make Type Def.) and add it to your project. You can do similar things for the readings on other panels, hopefully allowing you to reclaim some of your screen space 🙂

 

I also removed the confusing (to me) loop for the Time Array. Hopefully it still does what you want, if not, just use what you already have. I use a Build Array with only one input to make a 2D array if you want that display - I didn't really understand what you meant in your recent post about the 1D/2D indicator, so I wasn't sure which you wanted.

 


GCentral
Message 24 of 93
(1,429 Views)

@cbutcher wrote:

Jarrold wrote:Is it possible for you to show me an example so that i can better relate and learn from it, cbutcher?

Yes. I'm attaching your VI (possibly you've made improvements since this copy, but hopefully you can see the idea and just implement it in your code if you have) with a cluster for Time and Temp measurements. The cluster is defined in the case that measures the temperature (but it probably shouldn't be!) and then a Linked Input Tunnel is used to ensure the wire is passed by default through other cases.

 

The reset case wires empty arrays to both in the Bundle By Name node we discussed.

 

You should make the cluster a typedef (right click on the little pink box and click Make Type Def.) and add it to your project. You can do similar things for the readings on other panels, hopefully allowing you to reclaim some of your screen space 🙂

 

I also removed the confusing (to me) loop for the Time Array. Hopefully it still does what you want, if not, just use what you already have. I use a Build Array with only one input to make a 2D array if you want that display - I didn't really understand what you meant in your recent post about the 1D/2D indicator, so I wasn't sure which you wanted.

 


Hi cbutcher,

 

Firstly, I would like to thank you for all your help. I am really really thankful for the kind guidance and advice you gave me. Without your assistance, I wouldn't have been able to complete it. 

 

So back to the project, I am actually very curious because initially, I right-click the small box and selected "Use default if unwired" but it didn't work the right way. Then i tried to connect up all the boxes individually and it worked. What is the logic behind it? Visually, I can see that the little box is different but I do not understand what is the difference. Care to share? 🙂

 

Meanwhile, I will try to implement it on other panels as well. Anyway, with regards to your query as to why I need to convert it into 2D, it is for report generation purpose. In my report generation VI, it requires a 2D array as input that's why.

 

Once again , thank you and hopefully you will not stop here cause I still have many things i could perfect on. 

 

Yours sincerely,

Jarrold

0 Kudos
Message 25 of 93
(1,424 Views)

@Jarrold wrote:


Hi cbutcher,

 

So back to the project, I am actually very curious because initially, I right-click the small box and selected "Use default if unwired" but it didn't work the right way. Then i tried to connect up all the boxes individually and it worked. What is the logic behind it? Visually, I can see that the little box is different but I do not understand what is the difference. Care to share? 🙂

 


If you're talking about the cluster wire at the edge of the case structure, then I clicked "Linked Input Tunnel > Create and Wire unwired cases" or something similar. If you use "Default when Unwired" you'll get the default value of the cluster, which is empty arrays. You could do this for the Reset case, if you wanted, but then the icon becomes a box in a box, or something. This indicates that not all cases have a value wired to that connection. For shift registers, you usually don't want this - in most cases, you want to keep the value (or change it) and resetting to default is probably only one case.

 

If you wire it explicitly, then it becomes a filled box. This indicates that all cases have a value specified.

 

If you make a linked tunnel, it adds a small arrow. This indicates that if you create a new case, it will have a wire straight through it, connecting the two sides by default.


GCentral
Message 26 of 93
(1,421 Views)

@cbutcher wrote:

@Jarrold wrote:


Hi cbutcher,

 

So back to the project, I am actually very curious because initially, I right-click the small box and selected "Use default if unwired" but it didn't work the right way. Then i tried to connect up all the boxes individually and it worked. What is the logic behind it? Visually, I can see that the little box is different but I do not understand what is the difference. Care to share? 🙂

 


If you're talking about the cluster wire at the edge of the case structure, then I clicked "Linked Input Tunnel > Create and Wire unwired cases" or something similar. If you use "Default when Unwired" you'll get the default value of the cluster, which is empty arrays. You could do this for the Reset case, if you wanted, but then the icon becomes a box in a box, or something. This indicates that not all cases have a value wired to that connection. For shift registers, you usually don't want this - in most cases, you want to keep the value (or change it) and resetting to default is probably only one case.

 

If you wire it explicitly, then it becomes a filled box. This indicates that all cases have a value specified.

 

If you make a linked tunnel, it adds a small arrow. This indicates that if you create a new case, it will have a wire straight through it, connecting the two sides by default.


Hey cbutcher, I bumped into another issue. Not exactly a problem but I just dont understand why.

 

Attached are two VIs, one of which is my main VI while the other one is a subVI for my clock. 

The issue here is that inside my subVI, it can be observed that my indicator is moving. But when I insert the subVI into my "LoggingTemp" and run it, I observe that the indicator does not react the same as it should in my clock's VI. 

 

Any idea why?

 

0 Kudos
Message 27 of 93
(1,413 Views)

@cbutcher wrote:

@Jarrold wrote:


Hi cbutcher,

 

So back to the project, I am actually very curious because initially, I right-click the small box and selected "Use default if unwired" but it didn't work the right way. Then i tried to connect up all the boxes individually and it worked. What is the logic behind it? Visually, I can see that the little box is different but I do not understand what is the difference. Care to share? 🙂

 


If you're talking about the cluster wire at the edge of the case structure, then I clicked "Linked Input Tunnel > Create and Wire unwired cases" or something similar. If you use "Default when Unwired" you'll get the default value of the cluster, which is empty arrays. You could do this for the Reset case, if you wanted, but then the icon becomes a box in a box, or something. This indicates that not all cases have a value wired to that connection. For shift registers, you usually don't want this - in most cases, you want to keep the value (or change it) and resetting to default is probably only one case.

 

If you wire it explicitly, then it becomes a filled box. This indicates that all cases have a value specified.

 

If you make a linked tunnel, it adds a small arrow. This indicates that if you create a new case, it will have a wire straight through it, connecting the two sides by default.


I manage to find this link 

https://forums.ni.com/t5/Example-Programs/Displaying-a-subvi-indicator-value-on-a-main-vi-front-pane...

to assist me for the problem mentioned above but I am unable to carry out a few steps particularly the following:

4.  Create a control refnum on the subvi front panel and tie this control refnum to a terminal pane.

5.  In the subvi block diagram, create a value property node, and wire the control refnum to the property node. You may have to right click on the property node and change the mode to Write.

6.  Wire the subvi indicator to the value input of the property node.

 

Once again, your help is much appreciated! 

 

I have no ways of thanking you, but still, I want you to know you've really helped me in many ways !

 

Regards,

Jarrold

 

0 Kudos
Message 28 of 93
(1,411 Views)

on your frontpanel of the subvi, hit right mouse -> search for "refnum"

 

add the refnum control (abreviated as CTL) to your frontpanel

 

at the top right there are two squares, the left one is the terminal connector pane

 

click first on an empty box of the terminal-connector-pane and then on your control

(this means if you drop your sub vi into another vi, you can connect an input to it)


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 29 of 93
(1,407 Views)

Hey,

 

I can't use LabVIEW right now so I can't check your VIs but hopefully you found the solution.

 

Another way to add a refnum control that can be useful when you need more specific property nodes is to create the reference to the control in the main VI and then drag it onto the front panel of the SubVI. You can also drag it to the block diagram but then it drops a constant - you'd need to right click it and choose Change to Control to get a control then.

 

As jwscs already wrote, you should then add the front panel control to the connector pane and wire the reference in the main VI into the connection on the SubVI's icon.


GCentral
Message 30 of 93
(1,402 Views)