LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating buttons that have numeric value to run a motor.


@LukeTEI wrote:

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 


 

 

Would I place the while loop into the revolution case structure or outside, then connect to the Num Rev? I tried Altenbach's program and place a numeric indicator to see if it would return a 1 or -1 if i press up/down. It stayed zero. I'm not sure if I am understanding correctly how the program works. I never dealt with arrays before. 

 

 

test.png

0 Kudos
Message 11 of 22
(543 Views)

iinWill wrote:

 

I tried Altenbach's program and place a numeric indicator to see if it would return a 1 or -1 if i press up/down. It stayed zero. I'm not sure if I am understanding correctly how the program works. I never dealt with arrays before. 

 

 

test.png


It will turn -1 or 1 for about a nanosecond, because there is no wait statement in the loop. You'll never see it!

Place a 500ms wait inside the loop.

 

You could also change the mechanical action of the buttons to "switch until released" (will act like a car horn: ON as long as the button is pressed. Now you'll see the result as long as you hold the button down. (You still want a small wait (e.g. 10ms) to avoid using 100% CPU)

Message 12 of 22
(539 Views)

@altenbach wrote:

iinWill wrote:

 

I tried Altenbach's program and place a numeric indicator to see if it would return a 1 or -1 if i press up/down. It stayed zero. I'm not sure if I am understanding correctly how the program works. I never dealt with arrays before. 

 

 

test.png


It will turn -1 or 1 for about a nanosecond, because there is no wait statement in the loop. You'll never see it!

Place a 500ms wait inside the loop.


Haha a simple mistake 😛 I still don't know where to place the while loop into my program. I know I won't wire with the Num Rev, or am I seeing this incorrectly. Thanks for the fast responce. 

0 Kudos
Message 13 of 22
(534 Views)

@iinWill wrote:

@altenbach wrote:

iinWill wrote:

 

I tried Altenbach's program and place a numeric indicator to see if it would return a 1 or -1 if i press up/down. It stayed zero. I'm not sure if I am understanding correctly how the program works. I never dealt with arrays before. 

 

 

test.png


It will turn -1 or 1 for about a nanosecond, because there is no wait statement in the loop. You'll never see it!

Place a 500ms wait inside the loop.


Haha a simple mistake 😛 I still don't know where to place the while loop into my program. I know I won't wire with the Num Rev, or am I seeing this incorrectly. Thanks for the fast responce. 


Nevermind I got it to work by replacing the Num Rev with the array. How would I create a loop that will run either up then down or down and up, so a full cycle? 

0 Kudos
Message 14 of 22
(519 Views)

@iinWill wrote:

@iinWill wrote:

@altenbach wrote:

iinWill wrote:

 

I tried Altenbach's program and place a numeric indicator to see if it would return a 1 or -1 if i press up/down. It stayed zero. I'm not sure if I am understanding correctly how the program works. I never dealt with arrays before. 

 

 

test.png


It will turn -1 or 1 for about a nanosecond, because there is no wait statement in the loop. You'll never see it!

Place a 500ms wait inside the loop.


Haha a simple mistake 😛 I still don't know where to place the while loop into my program. I know I won't wire with the Num Rev, or am I seeing this incorrectly. Thanks for the fast responce. 


Nevermind I got it to work by replacing the Num Rev with the array. How would I create a loop that will run either up then down or down and up, so a full cycle? 


Would I create a case structure in the while loop and add multiple time delays so it would run like this:

Press Up -> Returns a value -1 -> motor runs -> figure out how long it takes for the motor to run till it finishes > add some sort of time sequence so that after, for example 30 seconds it would run to the case structure and it will return 1 which will make the motor run down. Would this be possible or would there be another simple way? How about adding a relay or some sort of switch? I'm not how to approach it. Or could I use a timed loop, but I'm not sure how I would I set that up. 

0 Kudos
Message 15 of 22
(500 Views)

Try a state machine. Create a state for running the motor in each direction then directed the program from one state to the other. http://www.ni.com/white-paper/3024/en

0 Kudos
Message 16 of 22
(492 Views)

@LukeTEI wrote:

Try a state machine. Create a state for running the motor in each direction then directed the program from one state to the other. http://www.ni.com/white-paper/3024/en


To demonstrate would it be: 1) create a while loop and a case structure inside. 2) Inside would be the attached program, but instead seperate the Up and Down into two seperate case structures. Then I'm not sure afterwards, would I create a program that would run up and down? How would the the program know if Up is finish before running Down? Thanks for your input.                       

 

 

Motor.png

0 Kudos
Message 17 of 22
(487 Views)

I'm not sure your exact application so finding out where the motor is and how far it needs to move in each directions really depends on the sensors and information you have access to. I assumed in my example that you can tell the motors initial position and based on this if you select up it will move the motor to its upper stopping limit, then back to its initial position. Vice versa for the down button. You can use a timer if you have no other way to tell the motor position. (the attached is version 10).

Download All
0 Kudos
Message 18 of 22
(472 Views)

This discussion really pains me to read...a switch by definition has atleast 2 states(active/non-active, true/false,1/0...) and could possibly be multi-stated(3-way, rotary...). The OP wants a 1/-1 in 2 buttons respectfully, but never talks about the quiet/non active /non operable state of a switch ? As this discussion drags on....one must address the quiescent state of the switch or normally( whatever) open/closed.. just my humble opinion

0 Kudos
Message 19 of 22
(467 Views)

@LukeTEI wrote:

I'm not sure your exact application so finding out where the motor is and how far it needs to move in each directions really depends on the sensors and information you have access to. I assumed in my example that you can tell the motors initial position and based on this if you select up it will move the motor to its upper stopping limit, then back to its initial position. Vice versa for the down button. You can use a timer if you have no other way to tell the motor position. (the attached is version 10).


Thanks for the responce. For my application the inital position for the motor is 0. The maximum rotation for my application is 52.For my application I figured that my motor 418,000 counts/rev. which i convert to revolutions by dividing by 8000 counts (This I figured out from my motor). That outputs 52 Revs, meaning from initial to all the way up is 52 revs and from up to down is 0.  I attached pictures of both the Motor Test and how I calculate the position. How would I setup the program so that when it reaches 52 it will pause for 1 seconds then go back to initial (0)? 

Download All
0 Kudos
Message 20 of 22
(466 Views)