Estudiante
i
Robotics Programming in C
Robotics Programming in C
ii
COLLABORATORS TITLE : Robotics Programming in C ACTION NAME DATE SIGNATURE
WRITTEN BY
August 25, 2012
REVISION HISTORY NUMBER DATE DESCRIPTION NAME
Robotics Programming in C
iii
Contents
1 2
Goals of this Tutorial Why C? 2.1 2.2 2.3 2.4 C is an open standard . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C is an all-purpose language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C is fast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C can do anything . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . .
1 2 2 2 2 3 4 4 4 4 5 6 6 6 6 7 8 9 9 9
3
Vex Programming Options 3.1 3.2 3.3 3.4 MCC18 and MPLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . easyC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RobotC . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SDCC and OpenVex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
Getting Started with Vex Programming 4.1 4.2 4.3 4.4 Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programming Computer .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programming Tool Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Programming Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 6
The Compilation Process The Basics 6.1 6.2 6.3 Unix Basics . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Vex Beginner Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Editing the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 15 16
7 8
Basics of Embedded C ProgrammingStreams 8.1 8.2
What is a Stream? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Standard Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Robotics Programming in C
iv
9
Standard stream I/O functions
18 20 22 24
10 Data types, Variables, and Expressions 11Functions and Macros 12 Programming Exercises
12.1 Attaining Wisdom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 12.2 Maximizing Available Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 12.3 Basic Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . 25 12.4 Basic Sensor Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Robotics Programming in C
v
List of Tables
2.1 9.1
Language Speed Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
printf() place-holders . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
10.1 C Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Robotics Programming in C
1 / 26
Chapter 1
Goals of this Tutorial
This tutorial is meant as a quick-start guide to robotics programming in C, using the Vex robotics kit and SDCC. It assumes...
Regístrate para leer el documento completo.