Beginner Programming Workshop Simona Doboli Assistant Professor Computer Science Department Hosftra University November.

Slides:



Advertisements
Similar presentations
Teacher/Mentor Institute Using the Cortex Chuck Powell.
Advertisements

Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Lab7: Introduction to Arduino
Add and Use a Sensor & Autonomous For FIRST Robotics
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
2008 KOP IR Sensor Workshop January 12, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
Automation and Robotics
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
Bread Boarding and Operating The IFI Robotic Control System.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Overview of New System Beta Team from Wilsonville 1425 Wilsonville Robotics – Code Xero 2550 Oregon City Robotics.
FRC LabVIEW Software Overview Joe Hershberger Staff Software Engineer National Instruments.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
Learning C really fast A power point for Jay. RobotC vs C RobotC is slightly different than C We will cover standard C Then RobotC differences.
Erik A. Cokeley Programming Workshop FIRST 2007.
Old control system ( ) MVRT. Main Circuit Breaker Connected to the red wire (power) of the battery When turned off, all power is cut off and robot.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Testbed: Exercises.
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
FIRST Robotics Team 1619 Programming Workshop Programming the Control System Mark Dotterweich Team 1619 Mentor Presentation available at:
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Driver Station MVRT 2009 – 2010 Season. Add information Breadboard Classmate PC USB Hub Joysticks Stop Button.
ENGG1100 Introduction to Engineering Design Digital Logic (Part 2) Prof. Kin Hong Wong Department of Computer Science and Engineering.
LabView Basics The Fighting Pi Controls Group. About LabView LabView is a highly adaptable programming GUI (Graphic User Interface) LabView compiles the.
Introduction to VEX Programming with EasyC
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Mentors Workshop Control System Sub-System Mark McLeod Team 358 Festo/Hauppauge H.S. F For I Inspiration and R Recognition of S Science and T Technology.
ROBOTC for VEX On-Site Professional Development
Coding for the FIRST Tech Challenge: RobotC
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
Programming and Controls for FIRST – The Basics Tom Barch, Scott VanBrocklin and Kayla Peltier February 5 th, 2008.
LabVIEW Workshop September 26, 2009 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
Programming and Controls Workshop – The Basics Tom Barch.
Advanced Programming Workshop Simona Doboli Assistant Professor Computer Science Department Hosftra University November 18, 2006.
The New FTC Platform (Connecting your legacy hardware)
Teacher/Mentor Institute Using easyC Joel Kirkland July 30-31, 2015.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
TU STORM 2007 High School Autonomous Robotics Competition Introduction.
Mentors Workshop Programming Sub-System Mark McLeod Team 358 Festo/Hauppauge H.S. F For I Inspiration and R Recognition of S Science and T Technology.
ROBOTC Training Session 1 Timothy Friez 1/10/08 Revision 1.
How to Program the 2004 Robot Controller from Innovation First For new C programmers and non- technical types.
EasyC Programming Workshop January 30, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
2010 LabVIEW Beginner Workshop October 9, 2010 Hauppauge High School SPBLI – LI FIRST Mark McLeod Hauppauge Team 358 Northrop Grumman Corp.
Mechanics of LabVIEW Workshop January 10, 2009 Farmingdale State College SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.
Default_Routine(); - PWM Mapping /******************************************************************** * FUNCTION NAME: Default_Routine * PURPOSE: Performs.
Example Design Programming controls for an imaginary robot. The robot has to drive around, use a camera to track a green light, aim using a turret, and.
FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.
AUTOMATION WITH ROBOTC Starting to write and troubleshoot computer code.
2008 SBPLI/FIRST Programming Workshop Tom Boehm Patchogue Medford High School, Team 329 Motorola Inc. Mark McLeod Hauppauge High School Team 358 Northrop.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
Understanding The 2008 FRC Robot Controller Chris Gregory FRC1089 – Team Mercury
Session 11 Intro to FRC API.
Teacher/Mentor Institute Using easyC David Dominguez June 2, 2015 Update Version.
Microcontrollers, Microcomputers, and Microprocessors
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Innovation First Hardware & Default Program The 5¢ Tour... Dr. Joe January 5, 2002.
Mechanical Components and Programming Ken Youssefi Introduction to Engineering – E10 1.
Programming Design ROBOTC Software. Behavior-Based Programming A behavior is anything your robot does –Turning on a single motor or servo Three main types.
Programming Applied Sensors in FIRST Robots Chris Elston – Team Download sample code:
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
INTRODUCTION TO JAVA PROGRAMMING FOR THE FIRST ROBOTICS COMPETITION JONATHAN DANIEL HEAD PROGRAMMER FERNBANK LINKS.
Val Manes Department of Math & Computer Science
ROBOTC for VEX On-Site Professional Development
Introduction to Team 294 Programming Concepts
2010 LabVIEW Intermediate Workshop
Automation and Robotics
Programming the BASIC Stamp
Introduction to Arduinos
Introduction to Programing the Cortex for BEST
Presentation transcript:

Beginner Programming Workshop Simona Doboli Assistant Professor Computer Science Department Hosftra University November 17, 2007 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.

Agenda FIRST Control System FIRST Control System MPLAB Environment MPLAB Environment C Basics C Basics FRC Default Code FRC Default Code –Robot Driver Control Demonstration of Basic OI Controls Demonstration of Basic OI Controls –Robot Autonomous Control Demonstration of Dead Reckoning Demonstration of Dead Reckoning Hands-On Hands-On

FIRST Control System solenoidmotor

FIRST Control Elements Hardware Hardware –Robot Controller (RC) User Processor vs. Master Processor User Processor vs. Master Processor PWM, Relay, Digital I/O, Analog, Misc. PWM, Relay, Digital I/O, Analog, Misc. –Operator Interface (OI) –Tether cable / Programming cable –Laptop Programming Programming –C Language –MPLAB/mcc18 (write & compile your program) –IFI_Loader (download to robot controller) –Dashboard (optional) –FIRST Default Code

Robot Controller Architecture User Processor User Processor –What we download to –Runs our code –Reads the digital/analog I/O directly Master Processor Master Processor –Controls Disable/Autonomous/Driver modes –Disables OI inputs & most RC outputs –Must hear from User periodically or shuts it down –Master Code Software is updated each year

Robot Controller I/O Banner Sensor Touch Sensor Switch Gyroscope Camera Limit Switch Analog Rangefinder Encoder Potentiometer Pressure Sensor Servo SolenoidCompressor Analog Digital Motors Relays Team LEDs TTL

Getting Started Create/Open an MPLAB Project Create/Open an MPLAB Project Edit a File Edit a File Build/Compile Build/Compile Download Download

MPLAB IFI_Loader.hex file Robot Controller Operator Interface Dashboard (optional)

C Basics Structure (#include, functions) Structure (#include, functions) IF, THEN, ELSE IF, THEN, ELSE WHILE WHILE FOR FOR =, ! =, ! >=,, =,, <, != &&, || &&, || Operators Operators Prototype declarations Prototype declarations

C Basics – Structure Program #include // C header file – standard library function // prototypes #include “myHeader.h” // User header file – user function prototypes int globalVar = 10; // definition global variable – can be used anywhere // in this file // in this file void main(void) { // What your program does int result; // local variable – can be used only in main() function int result; // local variable – can be used only in main() function result = max(1, 10); // call function max: 1, 10 – actual parameters result = max(1, 10); // call function max: 1, 10 – actual parameters} int max(int i, int j) // int i, int j = formal parameters { // a function definition // a function definition}

C Basics – Data Types TypeSizeMinMax char 8 bits unsigned char 8 bits 0255 int 16 bits -32,76832,767 unsigned int 16 bits 0 65, 535 short long 24 bits -2^232^23-1 unsigned short long 24 bits 02^24-1 long 32 bits -2^312^31-1 unsigned long 32 bits 02^32-1

C Basics – A simple program #include #pragma config WDT = OFF int max(int i, int j); // function declaration void main(void) { int m, n, bigger; m = 10; n = 20; bigger = max(m,n); printf("m= %d, n = %d, bigger = %d”, m, n, bigger); while(1); } //############### // Function definition //############### int max(int i, int j) { int result; if (j > i) result = i; else result = j; return result; }

C Basics – if statement if (touch == 1 && light != 0 ) goStraight = 1; else goStraight = -1; !!! NOTE: if (touch =1) vs. if (touch == 1) ASSIGNMENT CONDITION ASSIGNMENT CONDITION AND Logic OR Logic (||)

C Basics – while loop while (touch == 0) while (touch == 0) { leftMotor = 5; rightMotor = 5; read(touch); // need to change touch inside // the loop // the loop } // use { } if more than one statement in a loop // use { } if more than one statement in a loop

C Basics - Exercise Write a program that computes the first n numbers in the Fibonnacci series: Write a program that computes the first n numbers in the Fibonnacci series: 0, 1, 1, 2, 3, 5, 8, 13. n is an integer number between 0 and 30. n is an integer number between 0 and 30.

C Basics - Algorithm int first = 0, second = 1, third; while (n > 0){ third = first + second; output third first = second; second = third; n --; }

FRC Default Code Flow Main() Main() –User_Initialization() –Do as long as we’re on New radio packet (slow loop) New radio packet (slow loop) –Process_Data_From_Master_uP() Default_Routine() Default_Routine() –As long as we’re in auto mode do this User_Autonomous_Code() User_Autonomous_Code() Fast loop stuff Fast loop stuff User Initialization Radio packet ? Driver Routine Auto Mode ? User Autonomous NO YES

FRC Default Code Files to change Files to change –user_routines.c (to add switches & change controls) Default_Routine() Default_Routine() User_Initialization() User_Initialization() –user_routines_fast.c User_Autonomous() (to add autonomous movement) User_Autonomous() (to add autonomous movement) –user_routines.h (to share variables between files)

Input / Output OI OI –Inputs Joysticks x & y (0-254) Joysticks x & y (0-254) Buttons (0 or 1) Buttons (0 or 1) Unused inputs Unused inputs –Outputs LEDs – lights or 3-digit readout LEDs – lights or 3-digit readout RC RC –Outputs Digital I/O for sensors and devices (0 or 1) Digital I/O for sensors and devices (0 or 1) PWM for motors (0=reverse, 127=stop, 254=forward) Don’t use PWM for motors (0=reverse, 127=stop, 254=forward) Don’t use Relay for on/off, e.g., pneumatics (forward, reverse, stop) Relay for on/off, e.g., pneumatics (forward, reverse, stop) –Inputs Analog for sensors, e.g., potentiometers (0 to 1023) Analog for sensors, e.g., potentiometers (0 to 1023) –Both TTL for devices, e.g., camera or LCD screen TTL for devices, e.g., camera or LCD screen

Sample OI Controls (note: OI switches =0 when off and =1 when on) Sample uses: Drive Control arm Control turret // motor controlled by switch pwm03 = 127; if (p1_sw_trig == 1) { pwm03 = 254; } // arm joystick pwm03 = p3_y; // 2-Joystick drive pwm01 = p1_y; pwm02 = 255-p2_y; // 1-Joystick drive pwm01 = Limit_Mix(p1_y + p1_x - 127); pwm02 = Limit_Mix(p1_y - p1_x + 127); // Limit_Mix keeps pwm between 0 & 254

Sample OI Input/Output Changing the OI LED/digital display Changing the OI LED/digital display // LED display on the OI if (user_display_mode == 0) // OI lights are in use (select switch on OI) { Pwm1_green = 1; Pwm1_red = 1; } else // OI digital display is in use { User_Mode_byte = 123; } Sample uses: Trim joysticks Display auto selected Display backup battery voltage

Sample RC Digital Input Switches on the Robot Controller (RC Digital Inputs) Switches on the Robot Controller (RC Digital Inputs) (note: RC switches =1 when off and =0 when on) Sample uses: Limit switches Autonomous selection Field starting position Pressure sensor // Autonomous selection if (rc_dig_in01 == 1) { Autonomous_1(); } else { Autonomous_2(); } // Limit Switch on arm pwm03 = p3_y; if ((rc_dig_in01 == 1) && (pwm03 > 127)) { pwm03 = 127; }

Sample RC Analog Input Analog Inputs on the RC (e.g., a potentiometer) Analog Inputs on the RC (e.g., a potentiometer) // Use of arm position sensor (potentiometer) to limit arm movement int armpot; pwm01 = p3_y; armpot = Get_Analog_Value(rc_ana_in03); // value will be if ( (armpot > 900) && (pwm01 > 127) ) { pwm01 = 127; // Neutral } else if (armpot < 100) && (pwm01 < 127) ) { pwm01 = 127; // Neutral } Sample uses: Position sensors Gyroscope Analog rangefinder

Sample RC Relay Output Forward / Reverse / Neutral Forward / Reverse / Neutral relay8_fwd = 1; relay8_rev = 0; relay8_fwd = 0; relay8_rev = 1; relay8_fwd = 0; relay8_rev = 0; // Single pneumatic solenoid (valve) relay8_fwd = p1_sw_trig; relay8_rev = 0; // Double pneumatic solenoid (valve) relay8_fwd = p1_sw_trig; relay8_rev = !p1_sw_trig; // Turn on Compressor when Pressure Switch on digital input 18 says so relay8_fwd = !rc_dig_in18; relay8_rev = 0; Sample uses: Pneumatic valves Compressor on/off On/off motors

Robot Autonomous Control Must be developed under identical environment as in competition Must be developed under identical environment as in competition Training the robot must be repeated over & over to get right Training the robot must be repeated over & over to get right Develop code using old robots or prototypes Develop code using old robots or prototypes Plan on multiple autonomous options Plan on multiple autonomous options Use as few distinct movements as possible Use as few distinct movements as possible

Sample Autonomous // Drive forward and stop Sample_Auto_1() { static int counter=0; if (counter<100) { counter++; pwm01 = 200; pwm02 = 54; //motor is reversed } else // Make sure it always stops { pwm01 = 127; pwm02 = 127; } May need function prototype: void Sample_Auto_1(void);

Common Issues Syntax and typos Syntax and typos Program & Data Space Program & Data Space Code Too Slow trying to do too much Code Too Slow trying to do too much Joystick trim Joystick trim Embedded math (variable overflow) Embedded math (variable overflow) Infinite or too large loops Infinite or too large loops Variables keep values until you change them Variables keep values until you change them Unfortunately, it does exactly what you tell it to do Unfortunately, it does exactly what you tell it to do

Hands-On Vex Robots Vex Robots Timed Autonomous Timed Autonomous Sensors for Advanced Students Sensors for Advanced Students 1.Vex w/encoder, turret, gyro 2.Vex w/camera 3.Vex w/pot controlled arm 4.Vex w/rangefinders (IR, sonic) 5.Vex w/swerve drive 6.Edu w/bumper sensor

References Programming Quick Start Programming Quick Start FIRST RC Reference Guide FIRST RC Reference Guide FIRST OI Reference Guide FIRST OI Reference Guide Programming forum Programming forum

Reference Books C For Dummies, Volume One C For Dummies, Volume One C For Dummies, Volume Two C For Dummies, Volume Two C Programming - A Modern Approach - K N King “The C Programming Language” - Kernighan & Ritchie “The C Programming Language” - Kernighan & Ritchie “The C Answer Book” - Kernighan & Ritchie “The C Answer Book” - Kernighan & Ritchie

Presentation slides at: Presentation slides at: orTeam358.org Questions/Help please us. Questions/Help please us.