Go to Post Right now that dream is sealed behind a few milimeters of plastic for most teams. - AllenGregoryIV [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-01-2013, 11:57
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 21-01-2013, 13:02
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
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.
Attached Files
File Type: vi Incremental Motor Speed.vi (8.3 KB, 35 views)
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2013, 14:00
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2013, 14:08
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Scaling motor speed in LabVIEW

Quote:
Originally Posted by Team3763 Adam View Post
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.
Do the LabVIEW equivalent of something like this:

Code:
if (buttonIsNotPressed) {cmd=0; setMotor(cmd)}
else {cmd+=epsilon; if (cmd>1) cmd=1; setMotor(cmd)}
... where "epsilon" is a small constant value that establishes the ramp-up rate.


Reply With Quote
  #5   Spotlight this post!  
Unread 21-01-2013, 18:52
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
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
Attached Thumbnails
Click image for larger version

Name:	Clipboard 1.png
Views:	58
Size:	25.3 KB
ID:	13612  
Reply With Quote
  #6   Spotlight this post!  
Unread 21-01-2013, 22:43
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Scaling motor speed in LabVIEW

Quote:
Originally Posted by Greg McKaskle View Post
The attached image shows how to do it using a feedback node.

Greg McKaskle
Ah, there is always an easier way!
Reply With Quote
  #7   Spotlight this post!  
Unread 23-01-2013, 14:41
Team3763 Adam Team3763 Adam is offline
Lead Programmer
FRC #3763 (4H WildCards)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: North Carolina
Posts: 157
Team3763 Adam can only hope to improve
Re: Scaling motor speed in LabVIEW

Quote:
Originally Posted by Greg McKaskle View Post
...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
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?
Reply With Quote
  #8   Spotlight this post!  
Unread 23-01-2013, 15:00
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Scaling motor speed in LabVIEW

Quote:
don't forget to connect the refnum
One of the inputs to the Joystick and Motor blocks, the one on the top left, is called a refnum. Refnum is shorthand for Reference Number. It tells the block which joystick or motor to operate on.

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
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:51.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi