|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Scaling motor speed in LabVIEW
How would you layout the code used to program a motor to gradually speed up as you hold down a button?
|
|
#2
|
||||
|
||||
|
Re: Scaling motor speed in LabVIEW
I have attached code that should do what you want. The while loop is obviously unnecessary if you have this in Teleop or Period Tasks. This code will save the elapsed time of the program to a local variable while a button (the Boolean input) is not pressed. When the button is pressed, it will find the difference between the time at the moment the button was pressed and the current time. This is then divided by a constant to give an output your motor can use.
Let me know if you have any questions. |
|
#3
|
|||
|
|||
|
Re: Scaling motor speed in LabVIEW
So what I'm asking is when I'm not pressing we'll say button A, the motors aren't spinning. However, when I press A, the motors will slowl speed up until they reach their max RPM possible and will sustain the max speed until I release the button.
|
|
#4
|
||||
|
||||
|
Re: Scaling motor speed in LabVIEW
Quote:
Code:
if (buttonIsNotPressed) {cmd=0; setMotor(cmd)}
else {cmd+=epsilon; if (cmd>1) cmd=1; setMotor(cmd)}
|
|
#5
|
|||
|
|||
|
Re: Scaling motor speed in LabVIEW
The attached image shows how to do it using a feedback node.
A feedback node is a very local variable that keeps the value from the last iteration. This allows execution N be based on the values of execution N-1. Replace the button with the one you want to read, replace the 0.1 with the delta you want to add, and don't forget to connect the refnum to the joystick and motor VIs. Ask questions if some portion of it doesn't make sense. Greg McKaskle |
|
#6
|
||||
|
||||
|
Re: Scaling motor speed in LabVIEW
Ah, there is always an easier way!
|
|
#7
|
|||
|
|||
|
Re: Scaling motor speed in LabVIEW
When you say this, what exactly do you mean? Sort've a noob at LabVIEW still, but I understand some of it. When you say connect the refnum to the joystick and motor VIs, do you mean connect the button portion with the current joystick running our drive motors?
|
|
#8
|
|||
|
|||
|
Re: Scaling motor speed in LabVIEW
Quote:
The refnum is created by the Open block and can be stored and retrieved by name. Take a look at Begin to see some being opened and saved, and Teleop to see them being retrieved and used for RobotDrive and Joystick. Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|