Go to Post The point of FIRST is not to create pretty robots. It's to teach kids about science, technology, and engineering. - Cory [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 26-01-2014, 11:40
iggy_gim's Avatar
iggy_gim iggy_gim is offline
Registered User
AKA: Theodore Kim
FRC #5123 (Mechadogs)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Yonkers, NY
Posts: 79
iggy_gim is on a distinguished road
Timing Motor Functions in Teleop

Hi,

I'm new to Labview as my team recently switched over from Java. I was wondering how to time a motor turning function so that when I press a button on the joystick, the motor turns for 5 seconds then stops. I have everything but the timing part. Any help would be appreciated.

Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 26-01-2014, 11:48
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Timing Motor Functions in Teleop

Two common methods:

1) In Teleop, set a time and keep checking to see if it's expired. (is it done yet?...Is it done yet?...)


2) In Periodic Tasks, just set a timer.



Some other examples are found here.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 26-01-2014 at 12:04.
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2014, 11:56
Captain Planet Captain Planet is offline
Apprentice Programmer
FRC #2500 (Herobotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Minneapolis, MN
Posts: 7
Captain Planet is an unknown quantity at this point
Re: Timing Motor Functions in Teleop

First of all, Teleop is not the place to put this. Teleop is called around every 20 ms, if I recall correctly, so anything slower than that will "freeze" up teleop and make your controls unresponsive. So, instead you should place timed sequences like this in Periodic Tasks. As to how you would actually make the motor run for 5 seconds, there are a couple ways. You could do something like this, or just make a while loop with a 5000 ms delay in it that only runs once, and then put that inside a case structure to control it.
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2014, 11:56
iggy_gim's Avatar
iggy_gim iggy_gim is offline
Registered User
AKA: Theodore Kim
FRC #5123 (Mechadogs)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Yonkers, NY
Posts: 79
iggy_gim is on a distinguished road
Re: Timing Motor Functions in Teleop

Thank you so much for your response.

As I said, I am new to Labview and programming it for FRC. When you said keep checking if a time expires, what do you mean by that?

I'm sorry if this question seems really dumb, but I would appreciate any answer you could give me. Thank you so much!
Reply With Quote
  #5   Spotlight this post!  
Unread 26-01-2014, 12:01
iggy_gim's Avatar
iggy_gim iggy_gim is offline
Registered User
AKA: Theodore Kim
FRC #5123 (Mechadogs)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Yonkers, NY
Posts: 79
iggy_gim is on a distinguished road
Re: Timing Motor Functions in Teleop

Quote:
Originally Posted by Captain Planet View Post
First of all, Teleop is not the place to put this. Teleop is called around every 20 ms, if I recall correctly, so anything slower than that will "freeze" up teleop and make your controls unresponsive. So, instead you should place timed sequences like this in Periodic Tasks. As to how you would actually make the motor run for 5 seconds, there are a couple ways. You could do something like this, or just make a while loop with a 5000 ms delay in it that only runs once, and then put that inside a case structure to control it.
Thank you the second method solved my problem.
Reply With Quote
  #6   Spotlight this post!  
Unread 26-01-2014, 12:15
iggy_gim's Avatar
iggy_gim iggy_gim is offline
Registered User
AKA: Theodore Kim
FRC #5123 (Mechadogs)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Yonkers, NY
Posts: 79
iggy_gim is on a distinguished road
Re: Timing Motor Functions in Teleop

One last question...

what is the name of the green arrow function block and what does it do?

Thanks.
Reply With Quote
  #7   Spotlight this post!  
Unread 26-01-2014, 12:18
Captain Planet Captain Planet is offline
Apprentice Programmer
FRC #2500 (Herobotics)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Minneapolis, MN
Posts: 7
Captain Planet is an unknown quantity at this point
Re: Timing Motor Functions in Teleop

It's a way of making something only trigger once on a button press. There should be some explanation of it on this page, which is where the example was taken from.
Reply With Quote
  #8   Spotlight this post!  
Unread 26-01-2014, 12:24
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Timing Motor Functions in Teleop

That arrow thingy is called a feedback node and is found on the Programming -> Structures palette.
Basically it remembers what the previous value of the data line was.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #9   Spotlight this post!  
Unread 26-01-2014, 12:33
iggy_gim's Avatar
iggy_gim iggy_gim is offline
Registered User
AKA: Theodore Kim
FRC #5123 (Mechadogs)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Yonkers, NY
Posts: 79
iggy_gim is on a distinguished road
Re: Timing Motor Functions in Teleop

Thanks.
Reply With Quote
  #10   Spotlight this post!  
Unread 26-01-2014, 13:29
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: Timing Motor Functions in Teleop

Quote:
Originally Posted by Captain Planet View Post
First of all, Teleop is not the place to put this. Teleop is called around every 20 ms, if I recall correctly, so anything slower than that will "freeze" up teleop and make your controls unresponsive.
For the sake of other rookies who may be reading, it's perfectly fine to put this in TeleOp if you use a "state machine" approach like Mark showed.

Quote:
Originally Posted by iggy_gim View Post
When you said keep checking if a time expires, what do you mean by that?
When the button is first pressed, read the system clock and set a "target value" equal to the system clock plus 5 seconds (5000ms).

On every subsequent execution of TeleOp, check to see if the system clock has reached (or passed) that target value. If it has not, just finish the rest of your TeleOp and get out before your allotted 20ms; otherwise execute whatever code you wanted to run, and wait for the next button press to start the process again.


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:00.

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