![]() |
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?
|
Re: Scaling motor speed in LabVIEW
1 Attachment(s)
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. |
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.
|
Re: Scaling motor speed in LabVIEW
Quote:
Code:
if (buttonIsNotPressed) {cmd=0; setMotor(cmd)} |
Re: Scaling motor speed in LabVIEW
1 Attachment(s)
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 |
Re: Scaling motor speed in LabVIEW
Quote:
|
Re: Scaling motor speed in LabVIEW
Quote:
|
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 |
| All times are GMT -5. The time now is 10:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi