Presentation is loading. Please wait.

Presentation is loading. Please wait.

FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.

Similar presentations


Presentation on theme: "FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics."— Presentation transcript:

1 FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics

2 FRC Project Browse to find your last code (or open new) Navigate to the Robot Main block diagram Then select Begin Go to Block Diagram

3 Where We Left Off: Read Gyro And PID Control Of Steering Correction In Autonomous  Get Gyro Refnum, Get Gyro Angle  Set Timer of loop (30ms used here)  Add PID function block 1.Setpoint – set to 0 to drive straight forward 2.Connect Gyro output as Process variable input to PID 3.Limit output range 4.Set PID gains 5.Connect output to X input to arcade drive (Steering)

4 The PID Function Block  Set-point  Desired value to get to  Process variable  Actual value as measured by a sensor  Output determined by magnitude of difference (error) between setpoint and process variable  PID Gains adjust sensitivity

5 Suggested method for determining PID gains Method for Setting Values Start with CP small and CI, CD both zero. Raise CP until the robot is oscillating consistently around the target. (or one bounce?) Once this is accomplished, start increasing CD until the robot stops oscillating. Then add CI until the robot stops within a desired range of the target. Often we have only used the P, or PD

6 Tuning the PID Hands on example of trial and error

7 Downloading Vs. Deploying Code When developing code it is convenient to run the code right from the lap top by pressing the single arrow in the top left of the Robot Main Front Panel VI and “downloading” it from the laptop. You must first be connected to the robot through the driver station (Prior session) f you get a ‘Conflict Resolution” message – it is ok – it only means that you will be overriding the code previously deployed to run at the start-up of the robot. Sometimes you get another warning that will require you to reboot the robot and try again.

8 Once code is developed it is then desirable to Deploy it to the cRio to run onboard the robot. This is required for competition. To Deploy: 1.On Project Explorer, right click on: “Build specifications” and select: New / Real Time Application 2.On source selection screen, Select Source Files, Then select Robot Main, and by clicking arrow add it to the “Startup.Vi’s”, then press “Build” 3.Once Build is complete – right click on this latest “Real Time Application” and select “Run at Start-up” 1.This deploys the compiled code onto the cRio, The robot should be connected by Ethernet cable for this step. 2.If you get a “Conflict Resolution” message – it is ok it means you will be replacing the existing code loaded on the cR io. 3.If you get a message that you cannot say ok to - you probably need to reboot the robot and try again. 4.Once deployed it will ask to reboot the robot – say yes. 1.Once rebooted it will be running your code on the cRio. Deploying the Code to the Robot

9 Homework Challenge Slides Learn how to modify the Dashboard Make an autonomous Drive Sequence Drive a square pattern Learn to use the “examples” and be able to code a variety of sensors – including encoder

10 Modifying the Dashboard – Gyro Indicator a)Open Dashboard Project, Modify to display Gyro angle on a gage (follow Labview tutorial number 7) b)Modify Robot code Tele-op to send data to dashboard (also part of Labview tutorial) DashboardMain.vi Front Panel:

11 Incorporating Sensors – Gyro:: a)Open Dashboard Project, Modify to display Gyro angle on a gage (follow Labview tutorial) b)Modify Robot code Tele-op to send data to dashboard (also part of Labview tutorial) Follow Tutorials 4-7 Adds Gyro Opens Dashboard Project (7)

12 Homework / Challenge # 2 Update the Autonomous code Add multiple sequential While loops (like in default disabled structure) Have robot go straight, turn 90 degrees, Repeat 4-5 times to drive in a square.

13 Sequence While Loops After Each Other Set Time (= # Iterations) For Each Step In this case each is 100 iterations or 3 seconds.

14 Homework / Challenge # 3 Add variety of sensors to Begin and Tele-op Use “Examples” as source to copy correct formats

15 Begin.VI - Open and name sensors

16 Tele-op.VI - Get values and display

17 Program a Robot From its Functional Spec Start with a list of components and how connected Apple Pi Robot: Mantis 2012 Robot Control System Data Connection Spreadsheet I/O Type Actuator/Sensor AIO DIO PWM Relay Pneumatic I/O Port If Actuator, controlled by : If Sensor, used to control: Left rear drive motorPWM1Joy1 axes 1&2 Right rear drive motorPWM2Joy1 axes 1&2 Right Front drive motorPWM1Joy1 axes 1&2 Left Front drive motorPWM2Joy1 axes 1&2 Lower Harvester MotorPWM3Joy2 button 7 Upper Harvester MotorPWM4Joy2 button 8 Shooter Motor1PWM5Joy2 button 1 Shooter Motor2PWM5Joy2 button 1 Ramp Knockdown Device MotorPWM6Joy2 Axes 2 Encoder Left drive 1DIO1Auton Drive Encoder Left drive 2DIO2Auton Drive Encoder Right drive 1DIO3Auton Drive Encoder Right drive 2DIO4Auton Drive Upper Limit switchDIO5Knockdown Device Lower Limit switchDIO6Knockdown Device Upper Harvester IR SensorAIO1Harvester motors Middle Harvester IR SensorAIO2Harvester motors Lower Harvester IR SensorAIO3Harvester motors Tech Tigers Robot: Tiogar 2012 Robot Control System Data Connection Spreadsheet I/O Type Actuator/Sensor AIO DIO PWM Relay Pneumatic I/O Port If Actuator, controlled by : If Sensor, used to control: Left rear drive motorPWM1Joy1 axes 1&2 Right rear drive motorPWM2Joy1 axes 1&2 Right Front drive motorPWM1Joy1 axes 1&2 Left Front drive motorPWM2Joy1 axes 1&2 Accessory Motor 1PWM3Joy2 button ? Accessory Motor 2PWM4Joy2 button ? Upper Limit switchDIO1 Lower Limit switchDIO2 Pressure SwitchDIO3 Compressor SpikeRelay1 Solenoid 1Pneum1 Solenoid 2Pneum2 Solenoid 3Pneum3

18 Program a Robot From its Functional Spec Start with Drive Functionality Base code may have most of this – may need to replace 2 motor with 4 motor In Begin Open 2w Drive or 4w Drive, set Refnum, set correct PWM #’s Open Joystick, Set Refnum In Tele-op Get Refnum, Get Joystick Axes Get Refnum, Set Arcade Drive Connect X & Y axes to the Arcade drive inputs Test & Debug this portion

19 Program a Robot From Its Functional Spec Next what do the other motors do, and how are they controlled? In Begin Open motors, set Refnum, set correct PWM #’s Open 2 nd Joystick (?), set refnum In Tele-op Get Refnum, Get Joystick2 Axes and/or Buttons Get Refnum, Set motor If using Buttons, need to add a case structure changing motor input from 0 if False to “Value” if On Test & Debug this portion

20 Program a Robot From Its Functional Spec Next Incorporate the Limit switches to their functions.? In Begin Open DIO(s), set Refnum, set correct PWM #’s In Tele-op Get Refnum, Get DIOs: read true (on) or False (off) Set up case structure(s) to set motor(s) to zero if limit switch is true Test & Debug this portion

21 Program a Robot From Its Functional Spec Look for Pneumatic Examples

22 Program a Robot From Its Functional Spec Automate the Harvester: 1.Two harvester rollers – can be independently turned on and off 2.3 IR Sensors can detect if ball is in front of them (On or Off = True or False) Set up a “truth table” Determine what you want the rollers to do based on what the sensors see. Three IR sensors used to detect presence of Ball 1 2 3

23 Automation Truth Table sets up a “State Machine” Truth Table for Mantis Auto Harvester Desired behavior is that when Auto harvester engaged - it will collect 3 balls and have them ready for shooting. Lower IR SensorMiddle IR SensorUpper IR SensorLower Harvester MotorUpper Harvester Motor 000 100 010 001 110 101 011 111 This table tells us how we want the harvester to behave in response to the sensor readings.


Download ppt "FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics."

Similar presentations


Ads by Google