LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculator using OK buttons

hello guys 

can someone help me with this calculator thing using ok buttons 

 

Thank you so much

0 Kudos
Message 1 of 10
(5,368 Views)

Help how?

 

Do you have a specific question?

 

Tip.  All your buttons should have labels.  Right now your block diagram has a bunch of terminals and you can't tell which goes to which button.

You can always hide the label on the front panel.  But every control/indicator should have label and be visible on the block diagram

0 Kudos
Message 2 of 10
(5,362 Views)

i made it till here. how do i concantenate the items in the calculator 

 

 

0 Kudos
Message 3 of 10
(5,309 Views)

Hi akshay,

 

did you notice the "Training" section on top of the LabVIEW board?

Guess what its for!?

 

how do i concantenate the items in the calculator 

Right now your VI will run just once and stop immediatly (or better: as soon as an event occurs).

This way you will never have any chance to concatenate anything to the string…

 

1. When an algorithm needs to iterate more than once you need a loop in your code.

2. To keep values from one iteration of a loop to the next iteration you should use shift registers.

Both are very basic concepts in LabVIEW: please take those free online learning resouces!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(5,305 Views)

@akshay321 wrote:

i made it till here. how do i concantenate the items in the calculator 


  • Please do NOT maximize the front panel and diagram to the screen, especially since they don't contain much. Most of us can multitask and handle several windows at the same time. During editing, it is important to be able to look at more than one thing (subVI diagrams, help pages, online help, this forum discussion(!), etc.) ! I hate staring at code the size of a postcard and having the rest of the screen plain white. Plain tunnel vision!
  • Don't use overlapping controls on the front panel, arrange the buttons in a nice grid and make them all the same size.
  • Why would you change the mechanical action to "switch until released"???? This will give you two events, one on the press and one on the release. Only one event is needed. The correct mechanical action is "latch when released" Make sure you know the difference.
  • Combine all your buttons into a cluster to greatly simplify the code (1 terminal instead of 15! 1 event cases instead of 15! Simplify! Really!)
  • Every single event case writes to the same local variable and you create 15 identical local variables for that purpose. None are needed, simply place the indicator terminal after the event structure to retain the current (wrong!) functionality!
  • You need shift registers. One to build the current entry string and another one to maintain a numeric stack (array) for the calculations.
  • You need an outer while loop to hold the shift register and to be ready for the next button press after each press.
  • In a typical calculator, the operation buttons perform an operation on the current entry and the stack entry, not show their symbol on the display.
  • You are missing a button for the decimal point (or comma) and for the sign. How would you enter a value of -1.54, for example?.
  • Instead of all these scattered string diagram constants, use an array of constants and index into it e.g. by information obtained from the cluster value change.
0 Kudos
Message 5 of 10
(5,294 Views)

i have added a while loop and shift registers 

 

please tell me what should i attach to the shift registers

 

This is my first basic application on labview. 

 

thanks,

 

Regards

Akshay

0 Kudos
Message 6 of 10
(5,261 Views)

You need two shift registers. One (string) for the currently displayed string where new numeric characters are appended when certain buttons are pressed and updated with the result after a calculation has been performed. Another one (DBL) to contains the calculation stack, in the most simple case just the previously entered numeric.

 

It is nor sufficient to "attach" shift registers (whatever that means). You need to understand what they do. Once you understand their purpose, their use will become clear automatically.

0 Kudos
Message 7 of 10
(5,255 Views)

Can i add case structure inside the event structure for the operations?

0 Kudos
Message 8 of 10
(5,238 Views)

Yes.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(5,233 Views)

@akshay321 wrote:

Can i add case structure inside the event structure for the operations?


You could, but generally that is an "inside-out" way of thinking.  Generally, you should have an event for each button because the event structure is the case structure.  (LabVIEW help even refers to "Event Cases".)

 

Of course, there are exceptions to every rule, and your calculator happens to have such an exception.  It's where the numbers (and the decimal point) are concerned.  All have the same expected behavior, which is "when pressed, display it" and probably should be dealt with in one event case.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 10
(5,220 Views)