03-11-2022 07:15 PM
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.
03-12-2022 01:19 AM
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.
03-12-2022 01:57 AM
Forgot to attach my example
03-12-2022 08:59 AM - edited 03-12-2022 09:37 AM
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.
03-12-2022 09:33 AM - edited 03-12-2022 09:42 AM
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?)
03-12-2022 12:01 PM
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.
03-12-2022 12:04 PM
Hover over it and look at the context help to see the structure (array of cluster containing 7 booleans).
03-12-2022 12:26 PM
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.
03-12-2022 03:33 PM
The 7seg display details are irrelevant for the button logic. Do you know what a cluster is? An array of clusters?