SlideShare a Scribd company logo
The Basics of Programming! By Christine Luu 11/28/06
Agenda What is programming? Overview What you need before you program Familiarizing yourself with MPLAB Programming in C The Code Associating things in the programming with things on the robot controller and the operator interface Other programming features Back up
What is programming? Creating a set of codes to control robot behavior. The program will take the input from the operator interface (or the sensors, camera) and tell the robot to do what it’s supposed to do.
What you need before you program Robot Controller & RC Master Code (Processor Firmware) Operator Interface & Joysticks Software  MPLAB IDE v.7.0+ (download from http://www.microchip.com/MPLAB) IFI Loader v.1.0.10+ (download from www.ifirobotics.com/rc.shtml) MPLAB C18 Compiler (available during build season at  www.usfirst.org ) Latest Default Code Computer with a serial port An assembled, working electronics board Other components (i.e. CMUcam, sensors)
Overview Operator Interface Robot controller Electronics board camera
Familiarizing yourself with MPLAB Workspace – where you edit your files Build All – compiles your code into machine language Get to know all the files you will use Critical files:  user_routines.c user_routines_fast.c main.c ifi_aliases.h
Programming in C C is a high-level programming language Common commands: if, else, case,  while, loop <=, >=, !=, ==, &&, || Syntax: Semicolons  – end of any command Comments - /* blahblah */ Brackets  { } – used in commands
Programming in C Variables – a name that you assign to a certain part of the electronics so you can control its value Example: pwm01 >= 240 Functions  a small piece of code that performs a specific task can be called from the main program Include – tells the program what files to use to control the different components of the hardware Example: #include “ifi_aliases.h”
Example! if (pwm01>=240) { pwm01=240; } else if (pwm01<=14) { pwm01=14; } else { pwm01=pwm01; } This piece of code will limit the maximum speed of the wheels. Stopped = 127 Forward = above 127 up to 255 Reverse = below 127 down to 0 So this code is limiting the max forward speed of the wheel to 240, and the max reverse speed to 14. Otherwise, it will maintain the speed that is given by the joystick.
The Code The Default FRC Code gives you everything you need to get started. The main files main.c – extremely important, but don’t mess with it. user_routines.c – this is where you modify the code to make the robot do what you want it to do. user_routines_fast.c – this is where you edit the autonomous mode (where the robot moves by itself). ifi_aliases.h – defines all the names of the variables
Associating things in programming w/ things on the robot controller 0-1024 10-bit Analog sensors Rc_ana_in01 - rc_ana_in18 Rc_ana_in## 0 or 1 Bit Digital sensors Rc_dig_in01 - rc_dig_in18 Rc_dig_in## 0 or 1 Bit SPIKE relays Relay1_fwd – relay8_fwd Relay1_rev – relay8_rev relay#_fwd relay#_rev 0-255 Unsigned char Victors  (controls motors) Pwm01-pwm16 pwm## Poss. Values Data Type Object on Board Variables available of this type Variable
On Operator Interface 0 or 1 Bit Lights next to “Switch 1-3” Switch1_LED – Switch3_LED Switch#_LED 0-255 Unsigned char Joystick Wheel p1_wheel – p4_wheel p#_wheel 0-255 Unsigned char X and Y axis of joysticks p1_y – p4_y p1_x – p4_x p#_y p#_x 0 or 1 Bit Joystick top button p1_sw_top - p4_sw_top p#_sw_top 0 or 1 Bit Joystick Trigger p1_sw_trig – p4_sw_trig p#_sw_trig 0 or 1 Bit Lights next to “Relay 1” and “Relay 2” Relay1_red – relay2_red Relay1_green – relay8_green relay#_red relay#_green 0 or 1 Bit Lights next to “PWM 1” and “PWM 2” Pwm1_red – pwm2_red Pwn#_red Poss. Values Data Type Object on Board Variables available of this type Variable
Other Programming Features Autonomous CMUcam Sensors
Things to Keep in Mind Always make copies of the original code before making any modifications. Anything you do to the code, no matter how minute it may seem, will have an effect on what the robot does. Always know the data type you are manipulating (i.e. unsigned char, bit, etc.) Remember the semicolons! Never download the program to the robot if there is an error.
Let’s take a look at last year’s code!
HELFUL DOCUMENTS Helpful site :  http://www.kevin.org/frc/ CMUcam2_workbook.pdf CMUcam2_workbook.zip Everything you need to know about the care and feeding of your nifty CMUcam2 camera sensor is in this document. CMUcam2_mount_assembly.pdf CMUcam2_mount_assembly.zip CMUcam2 pan and tilt mechanism assembly instructions. This information is also included in the workbook.  CMUcam2_commands.pdf   CMUcam2 command dictionary. CMUcam2_data_packets.pdf   CMUcam2 data packet documentation. OV7620_ds.pdf OV7620_ds.zip Data sheet for the OV7620 camera module used with the CMUcam2.

More Related Content

PPSX
C programming basics
PPT
Why C is Called Structured Programming Language
PPT
introduction to C programming (C)
PPTX
Introduction to C Language (By: Shujaat Abbas)
PPT
Brief introduction to the c programming language
PPTX
Introduction to c programming
PPT
Programming in c
PPT
C PROGRAMMING
C programming basics
Why C is Called Structured Programming Language
introduction to C programming (C)
Introduction to C Language (By: Shujaat Abbas)
Brief introduction to the c programming language
Introduction to c programming
Programming in c
C PROGRAMMING

What's hot (20)

PPT
Introduction to programming with c,
PPTX
PPTX
COM1407: Introduction to C Programming
PPTX
introduction to c language
PPTX
PPTX
introduction to c programming language
PDF
Introduction to c programming
PPTX
C Programming Language Tutorial for beginners - JavaTpoint
PPT
Introduction to C Programming
PPT
Introduction to c programming
PPTX
C_Programming_Notes_ICE
PPTX
Sachin kumar ppt on programming in c
PPTX
Std 10 computer chapter 10 introduction to c language (part1)
PPTX
Introduction of c programming
PPTX
C programming tutorial for beginners
PDF
Programming Fundamentals and basic knowledge
PPT
C language introduction
PDF
Learning the C Language
PPT
C Language
PPTX
Introduction to c programming language
Introduction to programming with c,
COM1407: Introduction to C Programming
introduction to c language
introduction to c programming language
Introduction to c programming
C Programming Language Tutorial for beginners - JavaTpoint
Introduction to C Programming
Introduction to c programming
C_Programming_Notes_ICE
Sachin kumar ppt on programming in c
Std 10 computer chapter 10 introduction to c language (part1)
Introduction of c programming
C programming tutorial for beginners
Programming Fundamentals and basic knowledge
C language introduction
Learning the C Language
C Language
Introduction to c programming language
Ad

Viewers also liked (20)

PDF
Object-Oriented Programming 2
PPTX
Object Oriented Programming Basics
PPTX
Programming Basics
PPT
Programming basics
PDF
2013 Programming And Controlling Puma Arms
PPT
Programming Robots
PDF
Live Robot Programming
PPTX
IESS Lab Final Presentation!!
PDF
Spree framework overview
PDF
Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open C...
PPTX
Basic programming
PDF
Spree Commerce Admin Insights
PDF
Computer Programing
PDF
Computer programing
PPTX
Programing techniques
PPTX
System software lecture infs429
PPTX
Robot Programming
PPTX
Introduction to basic programming
PDF
Introduction to Computer and Programing - Lecture 04
PDF
Introduction to the c programming language (amazing and easy book for beginners)
Object-Oriented Programming 2
Object Oriented Programming Basics
Programming Basics
Programming basics
2013 Programming And Controlling Puma Arms
Programming Robots
Live Robot Programming
IESS Lab Final Presentation!!
Spree framework overview
Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open C...
Basic programming
Spree Commerce Admin Insights
Computer Programing
Computer programing
Programing techniques
System software lecture infs429
Robot Programming
Introduction to basic programming
Introduction to Computer and Programing - Lecture 04
Introduction to the c programming language (amazing and easy book for beginners)
Ad

Similar to The Basics of programming (20)

PPTX
Introduction to RobotC
PPTX
Programming A Robot Using
PDF
Atmega tutorial
PPTX
Embedded Application : An Autonomous Robot or Line Follower Bot
PPT
Intro to RobotC
PPTX
Fabric robots
PPTX
Python and the Raspberry Pi
PPTX
Robot Programmming VAL-I PART-I-Robot Language .pptx
PPTX
First fare 2013 basic-labview
PPTX
Introduction to Arduino and Robotics tech
PPT
13223971.ppt
PPTX
Introduction to Arduino & Robotics
PPT
Controlling Motors for Robot
DOC
Weekly Report 5 7
DOC
Weekly Report 5 7
DOCX
Robotics Coursecntnt
PDF
arduino
PPTX
Rig nitc [autosaved] (copy)
PDF
Ardx experimenters-guide-web
DOCX
Advanced robotics
Introduction to RobotC
Programming A Robot Using
Atmega tutorial
Embedded Application : An Autonomous Robot or Line Follower Bot
Intro to RobotC
Fabric robots
Python and the Raspberry Pi
Robot Programmming VAL-I PART-I-Robot Language .pptx
First fare 2013 basic-labview
Introduction to Arduino and Robotics tech
13223971.ppt
Introduction to Arduino & Robotics
Controlling Motors for Robot
Weekly Report 5 7
Weekly Report 5 7
Robotics Coursecntnt
arduino
Rig nitc [autosaved] (copy)
Ardx experimenters-guide-web
Advanced robotics

Recently uploaded (20)

PDF
Nidhal Samdaie CV - International Business Consultant
PDF
Roadmap Map-digital Banking feature MB,IB,AB
PDF
DOC-20250806-WA0002._20250806_112011_0000.pdf
DOCX
unit 2 cost accounting- Tender and Quotation & Reconciliation Statement
PPTX
Belch_12e_PPT_Ch18_Accessible_university.pptx
PDF
Unit 1 Cost Accounting - Cost sheet
PDF
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
PDF
WRN_Investor_Presentation_August 2025.pdf
PPTX
Amazon (Business Studies) management studies
PDF
Business model innovation report 2022.pdf
PDF
Reconciliation AND MEMORANDUM RECONCILATION
PPTX
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
PPTX
Principles of Marketing, Industrial, Consumers,
PDF
MSPs in 10 Words - Created by US MSP Network
PDF
Laughter Yoga Basic Learning Workshop Manual
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PPTX
5 Stages of group development guide.pptx
PDF
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
PPTX
HR Introduction Slide (1).pptx on hr intro
PPT
340036916-American-Literature-Literary-Period-Overview.ppt
Nidhal Samdaie CV - International Business Consultant
Roadmap Map-digital Banking feature MB,IB,AB
DOC-20250806-WA0002._20250806_112011_0000.pdf
unit 2 cost accounting- Tender and Quotation & Reconciliation Statement
Belch_12e_PPT_Ch18_Accessible_university.pptx
Unit 1 Cost Accounting - Cost sheet
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
WRN_Investor_Presentation_August 2025.pdf
Amazon (Business Studies) management studies
Business model innovation report 2022.pdf
Reconciliation AND MEMORANDUM RECONCILATION
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
Principles of Marketing, Industrial, Consumers,
MSPs in 10 Words - Created by US MSP Network
Laughter Yoga Basic Learning Workshop Manual
Power and position in leadershipDOC-20250808-WA0011..pdf
5 Stages of group development guide.pptx
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
HR Introduction Slide (1).pptx on hr intro
340036916-American-Literature-Literary-Period-Overview.ppt

The Basics of programming

  • 1. The Basics of Programming! By Christine Luu 11/28/06
  • 2. Agenda What is programming? Overview What you need before you program Familiarizing yourself with MPLAB Programming in C The Code Associating things in the programming with things on the robot controller and the operator interface Other programming features Back up
  • 3. What is programming? Creating a set of codes to control robot behavior. The program will take the input from the operator interface (or the sensors, camera) and tell the robot to do what it’s supposed to do.
  • 4. What you need before you program Robot Controller & RC Master Code (Processor Firmware) Operator Interface & Joysticks Software MPLAB IDE v.7.0+ (download from http://www.microchip.com/MPLAB) IFI Loader v.1.0.10+ (download from www.ifirobotics.com/rc.shtml) MPLAB C18 Compiler (available during build season at www.usfirst.org ) Latest Default Code Computer with a serial port An assembled, working electronics board Other components (i.e. CMUcam, sensors)
  • 5. Overview Operator Interface Robot controller Electronics board camera
  • 6. Familiarizing yourself with MPLAB Workspace – where you edit your files Build All – compiles your code into machine language Get to know all the files you will use Critical files: user_routines.c user_routines_fast.c main.c ifi_aliases.h
  • 7. Programming in C C is a high-level programming language Common commands: if, else, case, while, loop <=, >=, !=, ==, &&, || Syntax: Semicolons – end of any command Comments - /* blahblah */ Brackets { } – used in commands
  • 8. Programming in C Variables – a name that you assign to a certain part of the electronics so you can control its value Example: pwm01 >= 240 Functions a small piece of code that performs a specific task can be called from the main program Include – tells the program what files to use to control the different components of the hardware Example: #include “ifi_aliases.h”
  • 9. Example! if (pwm01>=240) { pwm01=240; } else if (pwm01<=14) { pwm01=14; } else { pwm01=pwm01; } This piece of code will limit the maximum speed of the wheels. Stopped = 127 Forward = above 127 up to 255 Reverse = below 127 down to 0 So this code is limiting the max forward speed of the wheel to 240, and the max reverse speed to 14. Otherwise, it will maintain the speed that is given by the joystick.
  • 10. The Code The Default FRC Code gives you everything you need to get started. The main files main.c – extremely important, but don’t mess with it. user_routines.c – this is where you modify the code to make the robot do what you want it to do. user_routines_fast.c – this is where you edit the autonomous mode (where the robot moves by itself). ifi_aliases.h – defines all the names of the variables
  • 11. Associating things in programming w/ things on the robot controller 0-1024 10-bit Analog sensors Rc_ana_in01 - rc_ana_in18 Rc_ana_in## 0 or 1 Bit Digital sensors Rc_dig_in01 - rc_dig_in18 Rc_dig_in## 0 or 1 Bit SPIKE relays Relay1_fwd – relay8_fwd Relay1_rev – relay8_rev relay#_fwd relay#_rev 0-255 Unsigned char Victors (controls motors) Pwm01-pwm16 pwm## Poss. Values Data Type Object on Board Variables available of this type Variable
  • 12. On Operator Interface 0 or 1 Bit Lights next to “Switch 1-3” Switch1_LED – Switch3_LED Switch#_LED 0-255 Unsigned char Joystick Wheel p1_wheel – p4_wheel p#_wheel 0-255 Unsigned char X and Y axis of joysticks p1_y – p4_y p1_x – p4_x p#_y p#_x 0 or 1 Bit Joystick top button p1_sw_top - p4_sw_top p#_sw_top 0 or 1 Bit Joystick Trigger p1_sw_trig – p4_sw_trig p#_sw_trig 0 or 1 Bit Lights next to “Relay 1” and “Relay 2” Relay1_red – relay2_red Relay1_green – relay8_green relay#_red relay#_green 0 or 1 Bit Lights next to “PWM 1” and “PWM 2” Pwm1_red – pwm2_red Pwn#_red Poss. Values Data Type Object on Board Variables available of this type Variable
  • 13. Other Programming Features Autonomous CMUcam Sensors
  • 14. Things to Keep in Mind Always make copies of the original code before making any modifications. Anything you do to the code, no matter how minute it may seem, will have an effect on what the robot does. Always know the data type you are manipulating (i.e. unsigned char, bit, etc.) Remember the semicolons! Never download the program to the robot if there is an error.
  • 15. Let’s take a look at last year’s code!
  • 16. HELFUL DOCUMENTS Helpful site : http://www.kevin.org/frc/ CMUcam2_workbook.pdf CMUcam2_workbook.zip Everything you need to know about the care and feeding of your nifty CMUcam2 camera sensor is in this document. CMUcam2_mount_assembly.pdf CMUcam2_mount_assembly.zip CMUcam2 pan and tilt mechanism assembly instructions. This information is also included in the workbook. CMUcam2_commands.pdf CMUcam2 command dictionary. CMUcam2_data_packets.pdf CMUcam2 data packet documentation. OV7620_ds.pdf OV7620_ds.zip Data sheet for the OV7620 camera module used with the CMUcam2.