03-29-2024 02:46 AM
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?
03-29-2024 03:10 AM
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.
03-29-2024 07:13 AM
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.
03-29-2024 11:49 AM
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.
03-29-2024 01:25 PM
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:
03-29-2024 02:57 PM
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
03-30-2024 07:03 AM
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.
03-30-2024 01:22 PM - edited 03-30-2024 01:30 PM
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.
03-30-2024 03:30 PM
@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
03-30-2024 06:37 PM
Here is a version with buttons set to Switch When Released.