LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making a Pause and Reset Function on a 2 seven segment digital counter

So I am attempting to implement the pause and reset functions on my block diagram; however, I am not sure how to do that with my setup. In the past, I have used the select function but I just do not know how to add that to this setup. Also, I was told that I might not even need to use case and/or event sturctures, not sure though. I'd appreciate the help. 

0 Kudos
Message 1 of 9
(1,396 Views)

A couple of points:

- Be aware of having loops with no ability to slow them down. They will run as quickly as they can and utilise an entire CPU core of your machine. Have a look at task manager when your first loop is running.

- Have a look at event structures and event driven programming. I would recommend using an event structure to run specific code when certain buttons are presses. It makes your code much more scalable

- Have a look at shift registers if you don't already know what they are

- Consider putting your code to draw your 7 segment displays into a subVI. The code in your two case structures are identical and if one changed the other would need to be changed too. Putting it in a subVI means you would only need to change your code in one place and also makes your BD neater. Search DRY code

- I would also recommend putting your seven segment display in a type def, especially if you are implementing the point above.

 

I have added the structure of a possible way of doing it. You would need to add your code to draw generate your displays either in the timeout case or in the top level while loop so they get drawn every iteration.

0 Kudos
Message 2 of 9
(1,372 Views)

Forgot to attach my example

0 Kudos
Message 3 of 9
(1,365 Views)

You already got some good advice. All you need is a simple state machine, no local variables and no sequence structures. One loop. One case structure, a shift register to hold the numeric (00..99) value (so it becomes independent of [i]) and some logic to transition between states based on the user input.

 

  • Start in an idle state
  • make sure that the number cannot exceed 99
  • Simplify! Simplify!
  • Work out all the logic using a simple numeric indicator, then create a simple subVI that converts the numeric to your 14 booleans (use an array of booleans!).
  • You have four identical case structures, each with 9 cases and 63 local variables (for a total of 252!!) . Sounds silly, right?
0 Kudos
Message 4 of 9
(1,349 Views)

To give you some ideas, here's a quick modification based on some earlier discussion. See if you understand it. (I run it 10x faster so we can more easily play).

 

(Of course we need much more accurate requirements to finalize the code. For example should reset also stop the timer or just start over at zero?)

 

altenbach_0-1647099067649.png

 

0 Kudos
Message 5 of 9
(1,344 Views)

How did you make that array constant with all the true and falses? I'm attempting to recreate it and I am not sure how to create all those elements. 

0 Kudos
Message 6 of 9
(1,329 Views)

Hover over it and look at the context help to see the structure (array of cluster containing 7 booleans).

0 Kudos
Message 7 of 9
(1,325 Views)

I see that but when I connect a Boolean, it only allows me to put one Boolean. Not seven like you have. 

And for the front panel, not sure how you inserted the corresponding Booleans to the display because when I open the help menu, it states 7SEG. Not sure how you got that option. 

0 Kudos
Message 8 of 9
(1,319 Views)

The 7seg display details are irrelevant for the button logic. Do you know what a cluster is? An array of clusters?

0 Kudos
Message 9 of 9
(1,307 Views)