SlideShare a Scribd company logo
3
Most read
12
Most read
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

What's hot (20)

PPT
Introduction to programming with c,
Hossain Md Shakhawat
 
PPTX
Introduction to C Programming
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
PPTX
COM1407: Introduction to C Programming
Hemantha Kulathilake
 
PPTX
introduction to c language
Rai University
 
PPTX
C basics
thirumalaikumar3
 
PPTX
introduction to c programming language
sanjay joshi
 
PDF
Introduction to c programming
Akshay Ithape
 
PPTX
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
PPT
Introduction to C Programming
MOHAMAD NOH AHMAD
 
PPT
Introduction to c programming
ABHISHEK fulwadhwa
 
PPTX
C_Programming_Notes_ICE
Gilbert NZABONITEGEKA
 
PPTX
Sachin kumar ppt on programming in c
Sachin Kumar
 
PPTX
Std 10 computer chapter 10 introduction to c language (part1)
Nuzhat Memon
 
PPTX
Introduction of c programming
Tarun Sharma
 
PPTX
C programming tutorial for beginners
Thiyagarajan Soundhiran
 
PDF
Programming Fundamentals and basic knowledge
imtiazalijoono
 
PPT
C language introduction
musrath mohammad
 
PDF
Learning the C Language
nTier Custom Solutions
 
PPT
C Language
Aakash Singh
 
PPTX
Introduction to c programming language
sanjay joshi
 
Introduction to programming with c,
Hossain Md Shakhawat
 
COM1407: Introduction to C Programming
Hemantha Kulathilake
 
introduction to c language
Rai University
 
introduction to c programming language
sanjay joshi
 
Introduction to c programming
Akshay Ithape
 
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Introduction to c programming
ABHISHEK fulwadhwa
 
C_Programming_Notes_ICE
Gilbert NZABONITEGEKA
 
Sachin kumar ppt on programming in c
Sachin Kumar
 
Std 10 computer chapter 10 introduction to c language (part1)
Nuzhat Memon
 
Introduction of c programming
Tarun Sharma
 
C programming tutorial for beginners
Thiyagarajan Soundhiran
 
Programming Fundamentals and basic knowledge
imtiazalijoono
 
C language introduction
musrath mohammad
 
Learning the C Language
nTier Custom Solutions
 
C Language
Aakash Singh
 
Introduction to c programming language
sanjay joshi
 

Viewers also liked (20)

PDF
Object-Oriented Programming 2
Warawut
 
PPTX
Object Oriented Programming Basics
Malik Ghulam Murtza
 
PPTX
Programming Basics
Abhishek Pratap Singh
 
PPT
Programming basics
Ladislav Martincik
 
PDF
2013 Programming And Controlling Puma Arms
블로그코디
 
PPT
Programming Robots
Andreas Heil
 
PDF
Live Robot Programming
ESUG
 
PPTX
IESS Lab Final Presentation!!
Nikki V. Schumaker
 
PDF
Spree framework overview
martin_hong91
 
PDF
Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open C...
Spark Solutions
 
PPTX
Basic programming
Jugul Crasta
 
PDF
Spree Commerce Admin Insights
Vinsol
 
PDF
Computer Programing
MohammedAlShawab
 
PDF
Computer programing
JT Taylor
 
PPTX
Programing techniques
Prabhjit Singh
 
PPTX
System software lecture infs429
Edmund Sowah
 
PPTX
Robot Programming
Ahmad Nawaz Alizai
 
PPTX
Introduction to basic programming
Jordan Delacruz
 
PDF
Introduction to Computer and Programing - Lecture 04
hassaanciit
 
PDF
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
Object-Oriented Programming 2
Warawut
 
Object Oriented Programming Basics
Malik Ghulam Murtza
 
Programming Basics
Abhishek Pratap Singh
 
Programming basics
Ladislav Martincik
 
2013 Programming And Controlling Puma Arms
블로그코디
 
Programming Robots
Andreas Heil
 
Live Robot Programming
ESUG
 
IESS Lab Final Presentation!!
Nikki V. Schumaker
 
Spree framework overview
martin_hong91
 
Sean schofield & Richard Lister, Spree Commerce_ Fearless deployment @ Open C...
Spark Solutions
 
Basic programming
Jugul Crasta
 
Spree Commerce Admin Insights
Vinsol
 
Computer Programing
MohammedAlShawab
 
Computer programing
JT Taylor
 
Programing techniques
Prabhjit Singh
 
System software lecture infs429
Edmund Sowah
 
Robot Programming
Ahmad Nawaz Alizai
 
Introduction to basic programming
Jordan Delacruz
 
Introduction to Computer and Programing - Lecture 04
hassaanciit
 
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
Ad

Similar to The Basics of programming (20)

PPTX
Introduction to RobotC
EMJeney
 
PPTX
Programming A Robot Using
Spitiq
 
PDF
Atmega tutorial
Rajan Gautam
 
PPTX
Embedded Application : An Autonomous Robot or Line Follower Bot
Er. Raju Bhardwaj
 
PPT
Intro to RobotC
palmuccijom
 
PPTX
Fabric robots
Endian Neo
 
PPTX
Python and the Raspberry Pi
Rachel Wang
 
PPTX
Robot Programmming VAL-I PART-I-Robot Language .pptx
ashishdesai625
 
PPTX
First fare 2013 basic-labview
Oregon FIRST Robotics
 
PPTX
Introduction to Arduino and Robotics tech
escoljeff23
 
PPT
13223971.ppt
SuYee13
 
PPTX
Introduction to Arduino & Robotics
Zubayer Al Billal Khan
 
PPT
Controlling Motors for Robot
Varad Manglekar
 
DOC
Weekly Report 5 7
mimi
 
DOC
Weekly Report 5 7
mimi
 
DOCX
Robotics Coursecntnt
Ahamed Satham
 
PDF
arduino
murbz
 
PPTX
Rig nitc [autosaved] (copy)
Aravind E Vijayan
 
PDF
Ardx experimenters-guide-web
Jhonny Wladimir Peñaloza Cabello
 
DOCX
Advanced robotics
sunny00700
 
Introduction to RobotC
EMJeney
 
Programming A Robot Using
Spitiq
 
Atmega tutorial
Rajan Gautam
 
Embedded Application : An Autonomous Robot or Line Follower Bot
Er. Raju Bhardwaj
 
Intro to RobotC
palmuccijom
 
Fabric robots
Endian Neo
 
Python and the Raspberry Pi
Rachel Wang
 
Robot Programmming VAL-I PART-I-Robot Language .pptx
ashishdesai625
 
First fare 2013 basic-labview
Oregon FIRST Robotics
 
Introduction to Arduino and Robotics tech
escoljeff23
 
13223971.ppt
SuYee13
 
Introduction to Arduino & Robotics
Zubayer Al Billal Khan
 
Controlling Motors for Robot
Varad Manglekar
 
Weekly Report 5 7
mimi
 
Weekly Report 5 7
mimi
 
Robotics Coursecntnt
Ahamed Satham
 
arduino
murbz
 
Rig nitc [autosaved] (copy)
Aravind E Vijayan
 
Ardx experimenters-guide-web
Jhonny Wladimir Peñaloza Cabello
 
Advanced robotics
sunny00700
 
Ad

Recently uploaded (20)

PDF
Keppel Investor Day 2025 Presentation Slides GCAT.pdf
KeppelCorporation
 
PDF
Explore Unique Wash Basin Designs: Black, Standing & Colored Options
Mozio
 
PDF
From Legacy to Velocity: how we rebuilt everything in 8 months.
Product-Tech Team
 
PPTX
IP Leaks Can Derail Years Of Innovation In Seconds
Home
 
PDF
Thane Stenner - An Industry Expert
Thane Stenner
 
PDF
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
PPTX
DECODING AI AGENTS AND WORKFLOW AUTOMATION FOR MODERN RECRUITMENT
José Kadlec
 
PDF
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
PDF
Dr. Enrique Segura Ense Group - A Philanthropist And Entrepreneur
Dr. Enrique Segura Ense Group
 
PPTX
Business Trendsjobsand careerr 2025.pptx
sahatanmay391
 
PPTX
Understanding ISO 42001 Standard: AI Governance & Compliance Insights from Ad...
Adeptiv AI
 
PDF
Kirill Klip GEM Royalty TNR Gold Presentation
Kirill Klip
 
PDF
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
PPT
Financial Management - All Slides.ppt.pdf
HeangLaisiv1
 
PDF
Concept topology- Architectural Build Design.pdf
Brij Consulting, LLC
 
PDF
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
PDF
Top Farewell Gifts for Seniors Under.pdf
ThreadVibe Living
 
PDF
Importance of Timely Renewal of Legal Entity Identifiers.pdf
MNS Credit Management Group Pvt. Ltd.
 
DOCX
RECLAIM STOLEN CRYPTO REVIEW WITH RECUVA HACKER SOLUTIONS
camilamichaelj7
 
PDF
Concept Topology in Architectural Build Addendum.pdf
Brij Consulting, LLC
 
Keppel Investor Day 2025 Presentation Slides GCAT.pdf
KeppelCorporation
 
Explore Unique Wash Basin Designs: Black, Standing & Colored Options
Mozio
 
From Legacy to Velocity: how we rebuilt everything in 8 months.
Product-Tech Team
 
IP Leaks Can Derail Years Of Innovation In Seconds
Home
 
Thane Stenner - An Industry Expert
Thane Stenner
 
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
DECODING AI AGENTS AND WORKFLOW AUTOMATION FOR MODERN RECRUITMENT
José Kadlec
 
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
Dr. Enrique Segura Ense Group - A Philanthropist And Entrepreneur
Dr. Enrique Segura Ense Group
 
Business Trendsjobsand careerr 2025.pptx
sahatanmay391
 
Understanding ISO 42001 Standard: AI Governance & Compliance Insights from Ad...
Adeptiv AI
 
Kirill Klip GEM Royalty TNR Gold Presentation
Kirill Klip
 
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
Financial Management - All Slides.ppt.pdf
HeangLaisiv1
 
Concept topology- Architectural Build Design.pdf
Brij Consulting, LLC
 
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
Top Farewell Gifts for Seniors Under.pdf
ThreadVibe Living
 
Importance of Timely Renewal of Legal Entity Identifiers.pdf
MNS Credit Management Group Pvt. Ltd.
 
RECLAIM STOLEN CRYPTO REVIEW WITH RECUVA HACKER SOLUTIONS
camilamichaelj7
 
Concept Topology in Architectural Build Addendum.pdf
Brij Consulting, LLC
 

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.