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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating buttons that have numeric value to run a motor.

I'm trying to create two buttons with values (-1, 1). These values have to do with my motor I'm trying to run. -1 means to move up and 1 means to move down. I've attached my VI. I'm refering to the Revolution loop in my VI. How could I make a two buttons that have the value of -1 and 1 that will replace the Num Rev control? 

0 Kudos
Message 1 of 22
(2,629 Views)

Radio buttons.  Enumerated control. Ring Control. Slider. Data entry limits on any numeric control. Boolean plus a bit of math.

 

I am not sure exactly what you want but I think there are probably several ways to get it.

 

Your block diagram is way too large. It is recommended to keep the diagram to one screen. Yours is about 3x4 (large) screens.  Sequence structures and local variables should also be avoided.

 

Lynn

0 Kudos
Message 2 of 22
(2,615 Views)

I'm trying to have two buttons with -1 and 1 values. I can't replace the Num Rev but have an additional two buttons. I try using a Enum, but it doesn't have negative values. How would I create two buttons with true being 1 and false being -1 and i could rename as Up and Down and also be wired together to replace the Num Rev? Doesn't have to be true or false, just need two buttons with two seperate values could be link together and replace my Num Rev.

0 Kudos
Message 3 of 22
(2,587 Views)

@iinWill wrote:

I'm trying to have two buttons with -1 and 1 values. I can't replace the Num Rev but have an additional two buttons. I try using a Enum, but it doesn't have negative values.


Create a lookup array diagram constant and index into it using the enum.

0 Kudos
Message 4 of 22
(2,576 Views)

@altenbach wrote:

@iinWill wrote:

I'm trying to have two buttons with -1 and 1 values. I can't replace the Num Rev but have an additional two buttons. I try using a Enum, but it doesn't have negative values.


Create a lookup array diagram constant and index into it using the enum.


Would you be able to help me out on this? I am not able to remove Num Rev, as it is used throughout my VI, but  could I create two different buttons with numeric values that could act similar to the Num Rev? I am not sure how to setup an array to enum. 

0 Kudos
Message 5 of 22
(2,556 Views)

@iinWill wrote:

@altenbach wrote:

@iinWill wrote:

I'm trying to have two buttons with -1 and 1 values. I can't replace the Num Rev but have an additional two buttons. I try using a Enum, but it doesn't have negative values.


Create a lookup array diagram constant and index into it using the enum.


I agree with Altenbach, I just used a lookup array and a case structure. See attached.

0 Kudos
Message 6 of 22
(2,546 Views)

@LukeTEI wrote:

@iinWill wrote:

@altenbach wrote:

@iinWill wrote:

I'm trying to have two buttons with -1 and 1 values. I can't replace the Num Rev but have an additional two buttons. I try using a Enum, but it doesn't have negative values.


Create a lookup array diagram constant and index into it using the enum.


I agree with Altenbach, I just used a lookup array and a case structure. See attached.


Could you attach as 2010 labview instead of 2012? Can't open it. 

0 Kudos
Message 7 of 22
(2,538 Views)

@LukeTEI wrote:
See attached.

 That seems a bit convoluted. 😮

 

  • Your "select" constructs should be replaced by boolean to 0,1
  • A 2D LUT is not scaleable. What if the next program requires five buttons, would you do a 5D array diagram constant?
  • There should NOT be anything orange when dealing with integers (look at all the coercion dots!)
  • Your VI uses 100% CPU of one core when no button is pressed.

 

Here's one possible solution (since the buttons are latch action, only zero or one can be TRUE at any given time).

 

 

Message 8 of 22
(2,534 Views)

@altenbach wrote:

@LukeTEI wrote:
See attached.

 That seems a bit convoluted. 😮

 

  • Your "select" constructs should be replaced by boolean to 0,1
  • A 2D LUT is not scaleable. What if the next program requires five buttons, would you do a 5D array diagram constant?
  • There should NOT be anything orange when dealing with integers (look at all the coercion dots!)
  • Your VI uses 100% CPU of one core when no button is pressed.

 

Here's one possible solution (since the buttons are latch action, only zero or one can be TRUE at any given time).

 

 


I will agree, it was not the best solution and I should have used a wait constant at the very least. I'm also fairly new to Labview and its good to learn some new tricks.

0 Kudos
Message 9 of 22
(2,511 Views)

Here is the picture of my block diagram so iinWill can see what altenbach was talking about. I did add the wait constant, although I'm not certain this fixes the processor issue.

Motor Control.png 

0 Kudos
Message 10 of 22
(2,509 Views)