Go to Post Sometimes the team really needs the kid, and sometimes the kid really needs the team. - Taylor [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-2014, 16:06
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Coding in a sequence.

So in the below picture, I want to make the Restraint Solenoid to retract when I press Button 3(I'll use a Select block). I want the Winch motor to then run a for a set amount after the Restraint is retracted. I assume I need one more frame in the Flat sequence and a Wait command for a few seconds, but I don't know where to go from here. Pictures to go with explanations would be appreciated. Thank you guys.
Attached Thumbnails
Click image for larger version

Name:	Sequential Code.jpg
Views:	93
Size:	128.8 KB
ID:	16053  
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2014, 20:33
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: Coding in a sequence.

I wouldn't put the sequence you describe into Teleop.
It'd be easier on you to put a sequence like you describe into Periodic Tasks.

So, your sequence can be thought of as these discrete frames:
  1. Retract solenoid; Wait 500ms (half a second to give the retraction time to complete)
  2. Set Winch motor to speed (1.0); Wait 3000ms (or however long it takes the winch to do it's work)
  3. Set Winch Motor to 0 speed
  4. When does the solenoid get extended to complete the cycle?
Here's an example of something similar:
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #3   Spotlight this post!  
Unread 02-02-2014, 13:43
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Re: Coding in a sequence.

I plan for the solenoid to re-extend after the winch brings the catapult back down.

Initially, the solenoid is holding back a catapult. When it retracts(the button is pressed), the catapult will launch. Then, the winch will start after the catapult launches, to pull the catapult back to starting position. Once it is back to the starting position, the solenoid will re-extend to hold back the catapult again until the driver hits the fire button again.

Why wouldn't it work in TeleOp?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2014, 14:02
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: Coding in a sequence.

Quote:
Originally Posted by DarthMaulCIS View Post
Why wouldn't it work in TeleOp?
Teleop is called by Robot Main each time the Driver Station sends a packet of data, 50 times per second. It's supposed to quickly do its job and be done. If it doesn't run to completion before the next DS packet arrives, it'll start tripping the system communication watchdog and your ability to control the robot will suffer.

Using a long-running loop, or waiting for an event to occur, should not be done in Teleop.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2014, 14:11
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: Coding in a sequence.

Teleop MUST execute and complete/exit in less than 20ms, otherwise you will lose driver control.
It has to do this to keep up with the driver commands flooding in from your drivers.

If you call a sub vi that delays or add a delay of any kind into Teleop that is more than that 20 ms limit, then your driver's will begin to lose control as their command packets start to get dropped while the robot continues to do what Teleop was last told what to do.
For small time skips the drivers will start to notice slow or jerky robot reaction.
If you use the default Safety Config on the drive motors, then your robot will jerk to a halt after only a tenth of a second. Manipulators that are in motion will continue in motion and not be able to be stopped until your delay in Teleop finishes and Teleop is allowed to process the driver control commands again.
If you delay for really significant amount of time (seconds) and the Safety Config is not used, then the robot will continue driving on it's own according to what it last heard before you hit the button that started the sequence.
With no driver control that probably means crashing into a wall or your alliance partners.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #6   Spotlight this post!  
Unread 02-02-2014, 14:45
matthewdenny's Avatar
matthewdenny matthewdenny is offline
Registered User
FRC #6054 (Dukes)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 310
matthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant futurematthewdenny has a brilliant future
Does the periodic in java need to execute in 20ms. If so is there a Periodic tasks in Java?
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2014, 15:19
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Re: Coding in a sequence.

oh ok. thank you guys!
Reply With Quote
  #8   Spotlight this post!  
Unread 02-02-2014, 16:28
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Re: Coding in a sequence.

So the command will still execute correctly in Periodic Tasks, right?
Reply With Quote
  #9   Spotlight this post!  
Unread 02-02-2014, 17:02
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: Coding in a sequence.

Yes.
You just need to enclose your code in a While loop that runs forever (and a little delay to keep from hogging the CPU).

You can pretty much do anything that you'd do in Teleop.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #10   Spotlight this post!  
Unread 04-02-2014, 09:35
Invictus3593's Avatar
Invictus3593 Invictus3593 is offline
time you like wasting is not wasted
FRC #3593 (Team Invictus)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Tulsa, OK
Posts: 318
Invictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really niceInvictus3593 is just really nice
Re: Coding in a sequence.

Quote:
Originally Posted by matthewdenny View Post
Does the periodic in java need to execute in 20ms. If so is there a Periodic tasks in Java?
There is an entire Forum for FRC Java here on CD! Better to post there as you will get some good answers from FRC Java veterans!
__________________
Per Audacia Ad Astra
Reply With Quote
  #11   Spotlight this post!  
Unread 04-02-2014, 20:21
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Coding in a sequence.

Quote:
Originally Posted by matthewdenny View Post
Does the periodic in java need to execute in 20ms. If so is there a Periodic tasks in Java?
Yes, the telopPeriodic method in java in the IterativeRobot template must execute within 20ms.

There are a few things you can do to work around this.
1) Use the Simple Robot template
2) Use a state machine.
2a) Switch to the command framework (which uses a state machine). See http://wpilib.screenstepslive.com/s/...nomous-program
3) Run the code in a new Task. This would be equivalent to Periodic Tasks in LabVIEW.
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2014, 18:38
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Re: Coding in a sequence.

Quote:
Originally Posted by Mark McLeod View Post
I wouldn't put the sequence you describe into Teleop.
It'd be easier on you to put a sequence like you describe into Periodic Tasks.

So, your sequence can be thought of as these discrete frames:
  1. Retract solenoid; Wait 500ms (half a second to give the retraction time to complete)
  2. Set Winch motor to speed (1.0); Wait 3000ms (or however long it takes the winch to do it's work)
  3. Set Winch Motor to 0 speed
  4. When does the solenoid get extended to complete the cycle?
Here's an example of something similar:
If I put this in my code (adjusting for time and the parts i want to call) would it work?
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2014, 18:44
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: Coding in a sequence.

That will work as is in Periodic Tasks.
Just drop it by itself onto the Block Diagram.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2014, 19:11
DarthMaulCIS DarthMaulCIS is offline
Registered User
FRC #4607
 
Join Date: Jan 2014
Location: Becker, Minnesota
Posts: 24
DarthMaulCIS is an unknown quantity at this point
Re: Coding in a sequence.

Quote:
Originally Posted by Mark McLeod View Post
That will work as is in Periodic Tasks.
Just drop it by itself onto the Block Diagram.
Sweet. I added solenoids in with the motor. In Begin, the solenoid starts in Forward, then in Periodic, the solenoid is retracted when Button 1 is pressed, then 1 sec later, the motor starts, then after X seconds, the motor stops and then the solenoid goes back to Forward. Does that describe the pic I have?
Attached Thumbnails
Click image for larger version

Name:	periodic.png
Views:	27
Size:	24.6 KB
ID:	16202  
Reply With Quote
  #15   Spotlight this post!  
Unread 10-02-2014, 19:23
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: Coding in a sequence.

Looks good.

The only change I'd make is to the very first 2 sec. timer directly under "Button 1"
I'd change that to "20"

That's just because new driver commands arrive every 20ms and you really don't want the driver to have to wait 2 seconds to find out if he/she pushed the button correctly. That might annoy the drivers a little.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 11-02-2014 at 16:10.
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:05.

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