LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why isn't my calculator working?

I'm building a calculator in LabVIEW, but I need it to run on the myRIO. As a result, I cannot use an event structure. I've built a VI that I think should work, but when I run the VI, it does not display numbers in the display or the result. I looked over the code, and I could not find where the project failed. I think it may have to do with the case structures. Why isn't the calculator working?

0 Kudos
Message 1 of 10
(362 Views)

I did some testing, and I've narrowed down the issue. The cluster does not register changes in the buttons. If I place indicators inside the case structures, I'm able to register information, but the case structures seem to be stuck on the 'None' state, regardless of my pressing input buttons. 

 

 

0 Kudos
Message 2 of 10
(351 Views)

Look into using an Event Structure.  It will make your life SOOOOO much easier.  Have an event for each button and do whatever you need to when that button is pressed.


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 3 of 10
(312 Views)

I don't use real time myself, but I have read that event structures don't fully work on real time targets because the front panel executes on the host while the block diagram executes on the real time system.

 

You may need to develop a system that has your main application run on the RIO but communicates with a second local application where event structures to work.  Probably over TCP/IP.

Message 4 of 10
(292 Views)

1) Actually if you probe shift register "A", you will see numbers being entered (there are other issues)

    Your "None" case wipes out the data going to the "Calculator Display 2" indicator.

     "None" of course runs all the time except for the short period when a button is pushed.

     Because of #2, this period is very short.

2) You should have a wait in you loop -  say 50 ms - save the planet and your CPU

3) The Array index nodes can be expanded rather than have to enter numbers for individual nodes.

4) Anytime you have to wire a whole bunch of nodes like this, consider that there must be another way

    This example (file attached) shows a way to get the button labels directly:

Calc wo Event.png

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 10
(282 Views)

The nice code submitted by @stevem181 is very nice, but misses the "hard requirement" that this code needs to run on a myRIO, which runs LabVIEW Real-Time Linux.  All of your Boolean controls are "latching" controls, which do not work as Front Panel Objects in LabVIEW Real-Time.

 

There is something really strange about this assignment.  It would be nice if the Original Poster could attach the actual assignment -- either there's an error in the Assignment (the Instructor doesn't realize "you can't do that"), a misunderstanding about the Assignment (Steven M misread or misinterpreted some aspect of the assignment), or something else weird is going on.

 

If you Google "LabVIEW Restrictions on Real Time", you can find some NI articles that explain the "Front Panel limitations" of the Linux Real-Time OS that they use.

 

Bob Schor

Message 6 of 10
(269 Views)

Good morning, all. Thanks for all the responses. The project needs to be on the myRIO so I can use a keypad. I wanted to get the calculator to work in a blank project before moving to a myRIO project. The keypad does not have latching keys, so the system should work on the myRIO.

0 Kudos
Message 7 of 10
(238 Views)

Here is an updated example based on stevem181's.

 

Keys' mechanical action has been set to Switch Until Released to simulate your keypad. To counteract the repetition of digits that comes with not having a latching action, you could just rely on the loop time wait function and set it to a comfortable rebounding time for your keypad. In this case, though, I have set the case structure to go through the False case if the key has not yet been unpressed after the first iteration, which is much more comfortable than manually setting a rebounding time.

 

afort_0-1711822835685.png

 

0 Kudos
Message 8 of 10
(215 Views)

@jb0375 wrote:

Good morning, all. Thanks for all the responses. The project needs to be on the myRIO so I can use a keypad. I wanted to get the calculator to work in a blank project before moving to a myRIO project. The keypad does not have latching keys, so the system should work on the myRIO.


When you submitted the Project (with the Project File), you explicitly put your "Calculator" code on the myRIO, and used "Latching Keys" for the keypad.  To make it work on the myRIO, you must make all the Booleans "non-latching" (and, I believe, not "Push-Button").  What you'll find, once you do that, is that your code to process key-presses needs to be a bit more sophisticated to work in the absence of an Event Structure (so it works on both the PC and on the myRIO).  Figure out how to do this on the PC (note -- you may need some type of "tight loop" to check all the keys for a "change of state" (i.e. going from False to True and/or from True to False), code that should work identically on the Host (PC) and RT Target (myRIO).

 

I'd suggest trying to create this "Keypad Monitor" on the PC makes the most sense, since you don't need to go through the Deployment process.  Once you have it working, you can try deploying it to the myRIO and seeing if it now works there.

 

Bob Schor

0 Kudos
Message 9 of 10
(197 Views)

Here is a version with buttons set to Switch When Released.

Calc wo Event B.png

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 10 of 10
(187 Views)