NQC: Not Quite C (last updated 9/14/05 2:24pm) Each NQC program has a task main () The program is contained within curly braces { ….. } task main() { SetSensor(SENSOR_1,

Slides:



Advertisements
Similar presentations
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Advertisements

While Loops and If-Else Structures
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
A Review. a review of lessons learned so far… ( 2 steps forward - 1 step back) Software Development Cycle: design, implement, test, debug, document Large.
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Alternative Programming Languages Myles McNally LMICSE Workshop November , 2004 University of Mississippi.
NQC: Control Structures: Loops Last updated 10/5/05 References: NQC Tutorial Baum Chapter 3 Baum Appendix D pg 368.
NQC: Control Structures: Branching Last updated 10/6/05 10:00am References: Baum Chapter 3 pp NQC Tutorial pp Baum Appendix D pg 368.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
Not Quite C: A CS 0 Option LMICSE Workshop June , 2005 Alma College.
2. Textual user interface NQC (Not quite C)  C-like programs translated into CRX-bytecode  Composed of: 1.Global variables 2.Task blocks 3.Inline functions.
LEGO Mindstorms RIS 2.0 Programming: NQC Code B.A. Juliano and R.S. Renner September 2004 California State University, Chico Intelligent Systems Laboratory.
Debugging (updated 9/20/06 12:48pm) It doesn’t work…. What do I do????
Repeating Blocks of Code (updated 9/20/05 7:35pm) Reference NQC Tutorial pp 9-12.
Preprocessor Directives (last modified 9/19/05 2:47pm) Statements beginning with # are directives to the preprocessor. –They DO NOT end with ; –Before.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Testbed: Exercises.
Chapter 3 Getting Started with C++
Nael Alian Introduction to PHP
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Chapter 8: Arrays.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
NXC (and NBC) NXC (Not eXactly C) is a language similar to NQC, which was the most popular way to program the RCX Built on NBC, the Next Byte Code ‘assembler’
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
NQC Brief Introduction – Part 3 David Schilling. NQC – Where is my data? Programs have 32 global variables Tasks have 16 local variables These are always.
Wall Encounter By Made easy by Dwayne Abuel.
THE TOUCH SENSOR The Touch Sensor, shown in the picture, gives the robot the sense of touch. It gives too different signals when the orange part is ether.
NQC / BricxCC Brief Introduction David Schilling.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
Oregon Robotics Tournament and Outreach Program RCX Basics.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
1 ©2006 INSciTE Common Blocks. 2 ©2006 INSciTE Common Blocks Common blocks are full featured actions Like English statements Move Wait for an action Display.
Mindstorm NXT-G Introduction Towson University Robotics.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Week 3 - Friday.  What did we talk about last time?  Preprocessor directives  Other C features  sizeof, const  ASCII table  printf() format strings.
Chapter 2 Creating a C++ Program. Elements of a C++ Program Four basic ways of structuring a program Four basic ways of structuring a program 1.Sequencing.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Introduction to Programming in RobotC
Information and Computer Sciences University of Hawaii, Manoa
Week 3 - Friday CS222.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Loop Control Structure.
Automation and Robotics
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
LRobot Game.
Chapter 2 - Introduction to C Programming
While Loops and If-Else Structures
Chapter 2 - Introduction to C Programming
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Chapter 2 - Introduction to C Programming
Preprocessor Directives
While Loops and If-Else Structures
Oregon Robotics Tournament and Outreach Program
While Loops And If-Else Structures
NQC Program Structure 3 types of code blocks with their own features and limitations 1. Tasks 2. Subroutines 3. Inline Functions.
Presentation transcript:

NQC: Not Quite C (last updated 9/14/05 2:24pm) Each NQC program has a task main () The program is contained within curly braces { ….. } task main() { SetSensor(SENSOR_1, SENSOR_TOUCH); OnFwd(OUT_A); until(SENSOR_1 == 1); Off(OUT_A); }

task main() { SetSensor(SENSOR_1, SENSOR_TOUCH); OnFwd(OUT_A); until(SENSOR_1 == 1); Off(OUT_A); } Statements are separated by ; The language is case sensitive OnFwd(OUT_A) is different from onfwd(OUT_A)

task main() { SetSensor(SENSOR_1, SENSOR_TOUCH); OnFwd(OUT_A); until(SENSOR_1 == 1); Off(OUT_A); } SENSOR_1 refers to the sensor on sensor port 1 SetSensor defines SENSOR_1 to be a touch sensor OUT_A refers to the output port A OnFwd(OUT_A) turns on port A in forward direction OnFwd(OUT_A+OUT_B) turns on port A & port B in forward direction

The until statement until(condition) body ; Executes the body zero or more times until the condition is true. Assignment operator: x=5 assigns the value 5 to the variable x. Relational operator: x==5 has a value true if the value of x is 5 false if the value of x is not 5

until(SENSOR_1 == 1) ; sensor 1 is a touch sensor The output of a touch sensor is binary when the switch is open the output is 0 when the switch is closed the output is 1 When the sensor is open, what statement is executed? The null statement You don’t have to leave any spaces The ; indicates the end of this statement. When the sensor is open, the null statement is executed over and over again. It is like the program holds on this statement until the switch is closed.

Several forms of the until statement until(SENSOR_1 == 1) ; until(SENSOR_1 == 1) OnFwd(OUT_B); until(SENSOR_1 == 1) note: no ; here { On(OUT_A); On(OUT_B); } note: no ; here

Comments task main() { SetSensor(SENSOR_1, SENSOR_TOUCH); // Execution of the following statement turns // on output port A to full value. OnFwd(OUT_A); until(SENSOR_1 == 1); Off(OUT_A); } All characters following // until the end of a line are treated as comment.

What do the following statements do? Float(Out_B); Rev(Out_B); Toggle(Out_A + Out_B); OnFwd(Out_A); // turn on A in forward direction OnRev(Out_A); On(Out_A); Turns A on. If the last state was reverse, it will now be in reverse.

Controlling Timing OnFor(OUT_A, 100); Turns A on for 1 second Note OnFor(outputs, duration); Is different from OnFwd(outputs);

Controlling Power Output SetPower(OUT_A+OUT_B, 0); Sets the power to A & B to it’s lowest value SetPower(OUT_A+OUT_B, 7); Sets the power of A & B to it’s highest value SetPower(OUT_A+OUT_B, OUT_FULL); Same as the preceeding statement How many output levels are there?

Using #define You can name various motors and sensors #define LEFT_TREAD OUT_A note below On(LEFT_TREAD); Allows you to remember what is attached to different ports. Note: Statements which begin with # are directives for the preprocessor they do not have semicolons following them.