1 / 59

Programming and Controls for FIRST – The Basics

Programming and Controls for FIRST – The Basics. Tom Barch, Scott VanBrocklin and Kayla Peltier February 5 th , 2008. Agenda. System Overview How the systems works – Controls Block Diagram Robot Controller Operator Interface Controls Overview of the controls used and how they work

lore
Télécharger la présentation

Programming and Controls for FIRST – The Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming and Controls for FIRST – The Basics Tom Barch, Scott VanBrocklin and Kayla Peltier February 5th, 2008

  2. Agenda • System Overview • How the systems works – Controls Block Diagram • Robot Controller • Operator Interface • Controls • Overview of the controls used and how they work • Programming • How to get started with the EasyC Program Software • Default Code Reference Guide – How and why to use • MPLAB and IFE Loader – How to install and use • Default Code – An overview • Downloading the Code to the Robot Controller • Pneumatic Controls • Overview of the pneumatics system – Block Diagram • Controlling the pneumatics – Understanding the controls

  3. Robot Controller or RC

  4. Robot ControllerSystem Block Diagram

  5. Operator Interface or OI

  6. Operator InterfaceSystem Block Diagram

  7. Tether Communications

  8. Radio vs. Tether communication • If the controllers ‘see’ a tether cable connection, then they will communicate via the tether port. • If no tether connection exists, then they will attempt to use the radio signal. • Note: Connecting via radio at the competition other than during a match is not allowed and can be dangerous if another teams operator interface controls your robot.

  9. Controls • Understanding the controls will help to understand the software variables and how the software is modifying and outputting them to get the Robot to move. • The joystick is read by the Operator Interface and is transmitted to the Robot Controller. It usually drives a pwm output which controls a Victor 883 or 884 speed controller. The speed controller maybe wired to a drill motor. • By pressing the joystick, we hope to control the speed and direction of the motor to get the Robot to move. • Lets start with the Joystick.

  10. Joystick • The joystick consists of two potentiometers mounted to a stick that vary as the stick is moved along its axis. • One potentiometer is mounted in the x axis or left – right direction and the other is mounted in the y axis or forward – backward direction. • As the potentiometer moves from one extreme to the other, the operator interface reads the voltage from 0 to 5 volts. • This voltage is broken into an 8 byte variable that ranges from 0 (0 volts) to 254 (5 volts).

  11. Joystick - continued • Full forward in the y axis will result in p1_y = 254. • When the joystick is in the center, it reads 127. • Full backward would read 0

  12. Victor Speed Controller • The input to the speed controller is a pwm signal that varies from software value of 0 to 254. • Battery and ground is supplied to two input terminals and the two output terminals can be wired to an electrical load like a drill motor. • At an input of 127, the two outputs which we will call m+ and m- are at 0 volt difference • As the pwm increases from 127 toward 254, the voltage varies from a positive difference of 0 to 12 volts. • As the pwm decreases from 127 towards 0, the voltage varies from a negative difference of 0 to 12 volts.

  13. Victor 884 speed controller

  14. Joystick to Motor • The joystick variable read by the Operator Interface is the same as the variable outputted to the pwm output to drive the motors forward and reverse. • In the default software, port one y axis is output directly to pwm01 port: pwm01 = p1_y; • In the default software, port two y axis is output directly to pwm02 port: pwm02 = p2_y; • The two of these make up the tank drive (two joystick). • The software also outputs joystick one x and y axis to pwm ports 13 and 15 to get one joystick drive.

  15. Joystick Switches • Located on the joysticks are four switches that are read by the computer as 0 or a 1. When the switch is closed, then the variable is read as a one. • These switch inputs are mapped to the relay outputs. relay1_fwd = p1_sw_trig; relay1_rev = p1_sw_top; relay_5_fwd = p1_sw_aux1; relay_5_rev = p1_sw_aux2;

  16. Spike Controller • The spike controller is a relay or electronic switch that will drive two outputs based on the inputs. • The reason for two input and two outputs are to enable the output to be driven positively or negatively to drive a small motor forward or reverse. • When the inputs to the relay are driven both as 0, then the outputs are both at 0 volts. One input is called Fwd and one is called Rev. One output is m+ the other is m-. • If the Fwd input is a 1 and the Rev input is a zero, then the m+ output will be 12volts and the m- output will be 0 volts. • The spike can be used to drive small motors, lights, air compressor, or any other 12 volt electrical load. The concern is the current draw which is much lower then the speed controllers.

  17. Spike Blue Controller

  18. Spike Truth Table • The truth table for the input to output is as follows:

  19. Spike alternative circuit • The spike can also be used to drive two different outputs in a on/off sequence. • An example would be two solenoid valves.

  20. Programming the Robot Controller

  21. Using EasyC • “EasyC” is very useful for people who do not have much experience with programming. • It’s a much simpler version of the “C” language • Teams may choose to program with either “EasyC” or the standard “C” with MPLAB

  22. Getting Started With EasyC

  23. Begin by setting up your robot controller by selecting “Robot Controller Setup” in the Options toolbar.

  24. Select the “FRC Robot Controller” and the “FRC 2006-2008 (PIC18F8722)” device…and click “ok”.

  25. Loader Setup • Go to the “Build and Download” toolbar and click “Loader Setup” • Make sure the settings are as follows…

  26. Downloading Default Code Using EasyC You can either: • Write your own default code or • Use the one provided by the EasyC Software.

  27. To download the default code provided by EasyC go to the “Build and Download” toolbar and click “Download Default Code”

  28. It will ask you if you’re sure you want to download the program…click “yes” The computer will then erase the memory on the robot controller and download the default code.

  29. Robot Controller Code • MPLAB IDE v6.30 is the C programming editor and complier from PC Microchips used to edit and compile the code. • IFE Loader is a program that will download the complied code into the robot. • None of this is necessary if the default code is used. • If modifications are necessary (custom functions are needed/variables need to change slightly), the code will only need modifications instead of a complete re-write.

  30. Default Code Reference Guide • Available from Innovation First website http://www.ifirobotics.com/ (in the Robot Controller section at the bottom) • Shows OI wiring/variables to RC variables/output for the default code functions. • Contains the variable listing for modification of default code. FRC 2004 RC Default Code Reference Guide.pdf

  31. Table of Contents

  32. Joystick Function RC PWM1 is the port that the left side victor should be plugged into to make port 1 the left joystick for tank style drive Joystick plugged into port 1 Y-Axis is forward – backwards (tank drive) P1_y is the variable used in the software to read this function

  33. Single Joystick Drive • Missing from default guide – It is on the front cover but hard to read. • Connect the right drive motors to PWM13 and/or PWM14 on the RC. • Connect the left drive motors to PWM15 and/or PWM16 on the RC.

  34. MPLAB Install • Adobe PDF document exists on CD • Has the defaults and instructions for installing MPLAB as well as the IFE loader. • C-BOT_Install_1-29-2004.pdf

  35. MPLAB and Default code • After downloading the default code, place the unzipped files in a directory, preferable in c:\code\frccode. • MPLAB and First recommends a simple directory. My Documents is a complex directory in Windows 2000 and Windows XP. • Saving an old revision and creating a new one is done by copying the folder and pasting to new director (i.e. copy c:\code\frccode into a new directory c:\code\frccode1 and so on).

  36. Opening the default workspace • Do not use the file open command. Use the open workspace command.

  37. User_routine.c • Most of the code changes will be made in the user_routine.c file • Custom code should be placed in Process_Data_From_Master_uP function at /* Add your own code here */. • The specific functions for most of the inputs/outputs are in the Default_Routine which is at the bottom of User_routine.c • The variables can be modified in the default routine, but make sure to use new revision directories here so that changes can be reversed.

  38. Modifying a variable • Lets say that the right side joystick is backwards. When the joystick is pressed forward the robot moves backward. • There would be two options. Change the M+ and M- terminals on the Victor (this is actually the recommended fix) • The software could also be changed to reverse the direction on the motor. • Locate the default statement for the right controller • pwm02 = p2_y; • The code could be modified as follows: • pwm02 = 254 – p2_y;

More Related