LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reseting a shift register dynamically

Solved!
Go to solution

Hi, I have a large VI which effectively connects to a DAQ and performs testing. When testing is complete, I want a batch counter to increment +1. This works fine.

I am using a SR and want to be able to somehow set the SR to 0.

 

I have tried an event structure which sets the counter display to 0, but this works only until the next cycle and the the SR is displayed again. I imagine this is because I am not affecting the SR at all, merely the display temporarily.

 

I cant think of another way to affect the SR from within the while loop in which it resides.

I thought that using an SR was the simpliest way to get the counter working, but of course I welcome other ideas.

Again, all I want is a counter that increments if an input is True, a display for the counter, and a button which can reset the counter (in my example I have used 3 to see if my reset actually works).

 

Any help is greately appreciated.

 

I have reproduced a simplier version of my VI and can be seen below (and attached).

EdenR_0-1741766502366.png

Using Labview 21

0 Kudos
Message 1 of 6
(208 Views)

@EdenR wrote:

Hi, I have a large VI which effectively connects to a DAQ and performs testing. When testing is complete, I want a batch counter to increment +1. This works fine.

I am using a SR and want to be able to somehow set the SR to 0.

 

I have tried an event structure which sets the counter display to 0, but this works only until the next cycle and the the SR is displayed again. I imagine this is because I am not affecting the SR at all, merely the display temporarily.

 

I cant think of another way to affect the SR from within the while loop in which it resides.

I thought that using an SR was the simpliest way to get the counter working, but of course I welcome other ideas.

Again, all I want is a counter that increments if an input is True, a display for the counter, and a button which can reset the counter (in my example I have used 3 to see if my reset actually works).

 

Any help is greately appreciated.

 

I have reproduced a simplier version of my VI and can be seen below (and attached).

EdenR_0-1741766502366.png

Using Labview 21


Think about your logic here.  What good does it do to set the counter display to zero?  Don't you want to set the counter itself to zero?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 6
(201 Views)

In order for this to work, you'll need a state machine where one state is "reset the counter".

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 6
(192 Views)
Solution
Accepted by topic author EdenR

No need for the Event Structure here. Just use the same logic you used for the increment, but with the reset. I would also recommend using the Select? primitive instead of the Case Structure as it is easier to read (does not hide functionality).


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
0 Kudos
Message 4 of 6
(165 Views)

yeah so it took me a while to realise I am stupid and just used a select, as you said (but within a case structure).

 

EdenR_0-1741849782292.png

 

Not sure why it took me so long to think of doing this, but I appreciate your input too!

0 Kudos
Message 5 of 6
(129 Views)

Hi Eden,

 


@EdenR wrote:

Not sure why it took me so long to think of doing this, but I appreciate your input too!


Why do you hide the reset feature inside the case structure?

Does the reset depend on another boolean condition?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 6
(124 Views)