View Single Post
  #13   Spotlight this post!  
Unread 13-02-2013, 18:11
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

Next, let's go to periodic tasks. Create a new while loop, place a timer inside of it, and set your execution to never stop.

Click image for larger version

Name:	PT1.PNG
Views:	10
Size:	3.7 KB
ID:	13987

This code will start running as soon as your code begins running, and it will never stop. Having loops in periodic tasks is fine because they execute outside the scope of teleop. Basically what you're doing is multitasking. Your robot can run simultaneous loops at the same time.

Now let's just get your hardware setup... for this we have the potentiometer and the lift motor. Let's also get in that global variable. To do this, just drag and drop the Robot Global Data into the Periodic Tasks VI. Right click on the global variable, and select "Change to Read" You also need to select the DesiredLevel variable. You can do this also by right clicking, and going to "Select Item".

Click image for larger version

Name:	PT2.PNG
Views:	19
Size:	9.2 KB
ID:	13988

Now we have everything we need to do a closed loop controller. By far, my favorite is PID.

To implement a PID controller, right click in the Block Diagram, go to PID, and select PID.vi.

Hook it up as you would expect. Your setpoint is the desired level, your process variable is the voltage from the potentiometer, and the output goes directly to the motor.

You'll want to be extremely careful the first time you run it. You have to tune the PID controller for your system.

You need to specify the output range (-1 to 1 for our motors), and the PID gains, which are what controls the response of the system.

Here's the block diagram for the finished control loop.

Click image for larger version

Name:	PT3.PNG
Views:	27
Size:	13.1 KB
ID:	13990

Here's what will be on your front panel.

Click image for larger version

Name:	PTFP.PNG
Views:	12
Size:	16.3 KB
ID:	13991

Once the system is tuned, you'll want to save those values. To do this, right click on the cluster, go to Data Operations, and select Make Current Values Default.

Click image for larger version

Name:	Screen Shot 2013-02-13 at 5.10.51 PM.png
Views:	9
Size:	39.2 KB
ID:	13992
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

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