Go to Post If all else fails - bring cookies in the shape of FIRST shapes. Cookies are always good. - Eugenia Gabrielov [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 01-02-2011, 12:17
3p1c w1n 3p1c w1n is offline
Registered User
FRC #1529
 
Join Date: Jan 2010
Location: Indianapiolis
Posts: 53
3p1c w1n is an unknown quantity at this point
How do you use timer properly?

There is a peg on our robot that I would like to actuate by pressing a button. I would like to press button X and have the peg lower at X speed for X time, then travel the opposite direction to it's starting configuration.

Here's a pretty picture of our robot on our team blog: http://frc1529.wordpress.com/




Should this code work? cRIO went to the Techyard in the sky over the weekend. our new one ships in 2 weeks!! I need to get as much programming as I can without a bot to test with. =[
__________________
~Team 1529 Cybercards~
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2011, 12:22
bladetech932's Avatar
bladetech932 bladetech932 is offline
Programmer of awesome
AKA: Jon
FRC #0932 (Circuit Chargers)
Team Role: College Student
 
Join Date: May 2009
Rookie Year: 2009
Location: Tulsa
Posts: 242
bladetech932 is on a distinguished road
Re: How do you use timer properly?

the easiest way is to use a flat or stacked sequence structure with two frames. The first frame with the set speed at x power and a delay set to x milliseconds then the next frame with the return by doing the same thing in reverse
__________________
Expect the best, Prepare for the worst
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2011, 13:15
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How do you use timer properly?

Quote:
Originally Posted by 3p1c w1n View Post
Should this code work?
I don't think it will work. It seems like it's properly written to do what you want, but what you want is not compatible with the robot communication framework. Any delays like that in your Teleop code will prevent everything else from running and cause the safety watchpuppies to shut down all the robot outputs.

What you should do is learn how to implement a state machine. Your needs call for a case block with three cases: Idle, Lowering, and Raising. You will need to use shift registers or feedback nodes to hold the current state and remember an event time. In the Idle state, keep the motor off and use the button to change the state to Lowering. In the Lowering state, run the motor down and use a simple comparison to detect when X time has elapsed and change the state to Raising. In the Raising state, run the motor up and use a simple comparison to detect when X time has elapsed and change the state back to Idle.

Does this sound like something you can work with? If not, we can probably point you to a solid tutorial on state machines in LabVIEW. I'd rather not just give you working code until you've tried to understand the concepts on your own.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-02-2011, 13:30
3p1c w1n 3p1c w1n is offline
Registered User
FRC #1529
 
Join Date: Jan 2010
Location: Indianapiolis
Posts: 53
3p1c w1n is an unknown quantity at this point
Re: How do you use timer properly?

Thanks for pointing me to state machines. I've found a video tutorial from lvmastery.com on the subject. I'll post back with my results.
__________________
~Team 1529 Cybercards~
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2011, 13:43
IisMathwizard's Avatar
IisMathwizard IisMathwizard is offline
Programming Mentor
AKA: Mathwizard
FRC #1248 (Titanium Allies)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Berea-Midpark High school
Posts: 60
IisMathwizard is an unknown quantity at this point
Re: How do you use timer properly?

Just as a thought....
In your code, why didn't you make the nested case structure hold .25 for true and -.25 for false and hook that up to set motor?
__________________

jRIO 2013 Project
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2011, 19:22
3p1c w1n 3p1c w1n is offline
Registered User
FRC #1529
 
Join Date: Jan 2010
Location: Indianapiolis
Posts: 53
3p1c w1n is an unknown quantity at this point
Re: How do you use timer properly?

I've watched this video all the way through once and I understand how it works except how/where to paste the info from the DIO's to the main robot typedef. After watching the video I think I may want to put limit switches onto the manipulator. one is pressed at the top, when in idle state, and one at the bottom, to end the lowering state.
The video tutorial is from 2009 and the code is a little different in the main.vi.
Sorry if i didn't explain too well the question i'm having, it's ~7:45 into the tutorial. http://www.lvmastery.com/TipJar2009-02-08_1
__________________
~Team 1529 Cybercards~
Reply With Quote
  #7   Spotlight this post!  
Unread 01-02-2011, 19:25
3p1c w1n 3p1c w1n is offline
Registered User
FRC #1529
 
Join Date: Jan 2010
Location: Indianapiolis
Posts: 53
3p1c w1n is an unknown quantity at this point
Re: How do you use timer properly?

..
__________________
~Team 1529 Cybercards~

Last edited by 3p1c w1n : 01-02-2011 at 19:28. Reason: I'm silly and tired. Pay no attention if you saw the original post
Reply With Quote
  #8   Spotlight this post!  
Unread 01-02-2011, 20:45
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How do you use timer properly?

Quote:
Originally Posted by 3p1c w1n View Post
I've watched this video all the way through once and I understand how it works except how/where to paste the info from the DIO's to the main robot typedef.
You don't have to use the typedef if you don't understand it. You can just get the DIO values and use them directly.
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:16.

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