Go to Post when all else fails, try making the bot go slower - KenWittlief [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 13-02-2013, 01:53
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Shooter Lifting Code

I don't believe your code will work correctly as designed right now.

You actually have quite a few problems.

1st, in BLUE. The In Range / Coerce function is very useful and is exactly what you want for this logic, but... what about numbers between say 15 and 16, 24 and 25, 38 and 39, or 44 and 45? The way you have it setup is almost perfect because of the solid diamond on the bottom (include the value and all values above) and the hollow diamond at the top (include all values below, but not the value). So you need to decide on one of the two numbers. So instead of 15 and 16, you need to either have just 15 or just 16 for both of them. Otherwise you have a gap in your logic.

2nd, in PINK. The red dot in the code means you're doing a coercion, or that you are converting from one data type to another without explicitly meaning to. This may be fine for your use, as long as the number is EXACTLY what you specify. If it's somewhere between say 4 and 5... which one should it pick? If there's no need for decimal points (floating point arithmetic), then take it out. It only slows down the code, uses more memory, and complicates your code.

3rd, in GREEN. Two problems here. You have an unthrottled while loop... while it's waiting on your DIO to return a value, it will just sit there in a loop, waiting, going as fast as it can, using all available CPU time. But that doesn't matter because you CANNOT place an undeterministic 'while' loop in the Teleop VI. This is a HUGE no no. This will cause all other functions in teleop to become unresponsive while the lift motor is running. Still... even with all of this, you have an even bigger problem...

4th, in ORANGE. This loop will never terminate because the DIO input will never be updated within the loop. Once the while loop begins, it gets stuck there, forever. Hence why it's such a HUGE no no to have a while loop in teleop. In this case, your robot would cease to function because it would get stuck in this while loop. If (and I strongly discourage it) you stuck with this while loop in teleop, you need to have the DIO Get function inside of the while loop. That way, it can update and terminate the while loop once the motor is done moving.

5th, in RED... what are you trying to do here? Are you trying to selectively get the reference to your DIO input? Don't you already know what desired level you want because of the case structure that was partically circled in PINK a moment ago? Why complicate your code like this?
Click image for larger version

Name:	LiftCode.png
Views:	59
Size:	73.0 KB
ID:	13964
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote
 


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 22:49.

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