Go to Post Backwards PWMs happen to the best of us. - Woolly [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-03-2014, 00:07
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Periodic Tasks Help

I need some help with putting my teleop code into periodic tasks. I have never worked with doing that. The loop that I have in teleop is casing things to lockup when it is running. Any help would be great.
Attached Files
File Type: vi Teleop.vi (48.6 KB, 14 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 21-03-2014, 01:10
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Periodic Tasks Help

OK. Your stuff triggered by button 5 and 6 need to move over to periodic tasks. Teleop has to finish in 20 ms or less, and you have waits in both.

Set a global variable when the button is pressed, and read the variable to trigger those actions in a timed loop in periodic.

Global variables are specified in Robot Global Data.vi.

Last edited by Levansic : 21-03-2014 at 01:14.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-03-2014, 02:19
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Re: Periodic Tasks Help

ok i think I got it, never worked with global variables either

http://prntscr.com/32pged
http://prntscr.com/32pgg2
Reply With Quote
  #4   Spotlight this post!  
Unread 21-03-2014, 02:28
Levansic's Avatar
Levansic Levansic is offline
Registered User
AKA: Len Evansic
FRC #0585 (Cyber Penguins)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Tehachapi, CA
Posts: 185
Levansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud ofLevansic has much to be proud of
Re: Periodic Tasks Help

Almost. Those parts that you moved to periodic tasks need to be in a while loop with a delay. There are two of those in your screenshot. All of the code you moved needs to be in one of those loops (I suggest the 100 ms one). You can keep the refnums outside the loop.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-03-2014, 02:37
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Re: Periodic Tasks Help

http://prntscr.com/32pini should I remove the while loop that is in the case structure for button 5 since it is in the 100ms one now?
Reply With Quote
  #6   Spotlight this post!  
Unread 21-03-2014, 15:35
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Periodic Tasks Help

Yes remove that while loop, but before that can you explain what does your digital input do? I see that it stops the while loop, but what is its intention?

Last edited by Kevin Phan : 21-03-2014 at 15:38.
Reply With Quote
  #7   Spotlight this post!  
Unread 21-03-2014, 22:05
ChrisArmour ChrisArmour is offline
Registered User
FRC #3133
 
Join Date: Feb 2010
Location: scottsdale
Posts: 14
ChrisArmour is an unknown quantity at this point
Re: Periodic Tasks Help

it actually worked perfectly today at regional with out taking it out thank you so much. the DIO is to stop the turning of our shooters cam right before its release point. we are running a chain driven choo-choo style cam for our shooter.
Reply With Quote
  #8   Spotlight this post!  
Unread 21-03-2014, 22:12
Kevin Phan's Avatar
Kevin Phan Kevin Phan is offline
College Student
FRC #0357 (Royal Assault)
Team Role: Alumni
 
Join Date: Apr 2013
Rookie Year: 2010
Location: PA, United States
Posts: 95
Kevin Phan will become famous soon enoughKevin Phan will become famous soon enough
Re: Periodic Tasks Help

Well the reason why I thought you needed to remove that while loop is to save on processing time. Since you have a condition wired to it, that probably allows it to work correctly. I'm just confused about a 10 ms task in a 100 ms task, since it will only execute every 100 ms in the outer loop.
Reply With Quote
  #9   Spotlight this post!  
Unread 22-03-2014, 10:16
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: Periodic Tasks Help

A delay is just a node that takes zero CPU to execute but doesn't finish executing until a deadline takes place. It does not prevent the loop from doing other things in parallel.

So, since the outer loop contains a wait of 100ms, it will not execute more than 10 times per second. If the other contents take longer than 100ms, then it will execute even slower.

The inner loop has a delay of 10ms. That means that it will check no more than 100 times per second to see if the digital switch has closed.

To document that portion code with an English sentence, I'd describe it as ...

About 10 times per second, check button 5 on the joystick. If pressed, set the motor to 75% and start checking the switch. Check 100 times per second. The motor will be turned off in other code unless button 6 is pressed at the time.

I'm glad to hear it worked. A couple things that would make it easier to understand and more robust ...
1. Loops that check for things like switches should probably have a limit on how long they will check and enter an error state after you have waited long enough for the mechanism. Not doing this, and having a HW or electrical issue may cause other code to stop working, may leave motors stalled, or may cause a mechanism to rip themselves apart. So, it is useful to identify all the conditions which should cause the motor to stop. I'd also suggest moving the motor stop so that it is more obvious.

2. The rate that you want to check the switch should be based on how fast the mechanism moves and how long it will press the switch before going beyond. I'm not saying 10ms is good or bad, but SW values like this can be converted to "check every 1/4 inch, which is 10ms", and those comments in the code really help later if anything is changed such as the motor gearing, the speed of the motor, friction, springs, weight reduction, etc.

There are others, but that is a good start, and congrats on figuring out that it didn't belong in teleop and successfully getting it to work in periodic.

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 20:07.

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