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.
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.
03-12-2020 05:49 PM
Hi,
I need to build a simple calculator using the simple state machine template in Labview. The requirements are
I have seen different posts about creating a simple "old fashioned" calculator and I have tried following their procedure, but because the operations are enumerated controlled and the values are horizontal sliders I don't know how to set up my block diagram. Any help would be much appreciated.
03-12-2020 05:58 PM
So you're going to have two sliders for the numbers, then four buttons. When pressed, each button will execute a state. When you look for examples, don't just look for calculator examples, look for state machine examples, period. On any LabVIEW VI, or the startup screen, Help --> Find Examples is a great place to start.
03-14-2020 05:09 PM - edited 03-14-2020 05:10 PM
Your requirements are much simpler than needed for a "state machine". You really don't require one! You just have two numeric inputs, a mode selector (enum with four items), and a result display. Whenever any of the controls change, the result needs to be recalculated. There are no "states" that need to be communicated across iterations, for example. You can do it polling or using an event structure.
If your teacher wants a "state machine", maybe it should be explained why. Seems to just complicate things unnecessarily... 😉
03-15-2020 01:57 AM
Perhaps there is only one horizontal slider intended? The original post was a bit unclear - it mentions a slider, then not knowing what to do about the sliders.
If you have only one slider, and an "Equals" button as well as the methods, then you can imagine there might be some "state" in this system (i.e. the result so far of previous operations or the previously entered value, depending on if this is the first operation used or they are chained together).
It's still a little bit of a stretch to require a state machine, but at that point you do have some history requirements.
Of course, it could be implemented with an array of inputs including methods and then a parsing operation when "Equals" is pressed, and so no states would be needed (just an Event Structure and a shift register, perhaps with array of strings) but this would be less efficient.
If you allow parenthesis, things become more complicated but that sounds outside of the original scope...
03-15-2020 11:49 AM - edited 03-15-2020 11:55 AM
@cbutcher wrote:The original post was a bit unclear - it mentions a slider, then not knowing what to do about the sliders.
Well, it could be a single slide control with two sliders ... 😉
(Of course, the order matters for subtract and divide, so they need to be identified in some way, e.g. by color)