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’

Slides:



Advertisements
Similar presentations
1chung 5 th Annual Robofest 2004 Informational Meeting Mar. 20, 2004 Chan Jin Chung Ali Khazaal Jason Lo Computer Science Lawrence Technological University.
Advertisements

08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
LabView Basics.
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Navigating the BOE-BOT
Computer Science 1000 LOGO I. LOGO a computer programming language, typically used for education an old language (1967) the basics are simple: move a.
Microsoft ® Office Word 2007 Training Bullets, Numbers, and Lists ICT Staff Development presents:
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.
EIGHTH GRADE ROBOTICS KITTATINNY REGIONAL HIGH SCHOOL MR. SHEA Introduction to Programming
Alternative Programming Languages Myles McNally LMICSE Workshop November , 2004 University of Mississippi.
Motor control drive in circles Pragmas configure motors Turning right in function of time Turning left in function of time Main program starts from here.
LEGO Robotics Lecture 1: Getting acquainted with your robotic environment.
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,
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
Not Quite C: A CS 0 Option LMICSE Workshop June , 2005 Alma College.
LEGO Mindstorms RIS 2.0 Programming: NQC Code B.A. Juliano and R.S. Renner September 2004 California State University, Chico Intelligent Systems Laboratory.
Preprocessor Directives (last modified 9/19/05 2:47pm) Statements beginning with # are directives to the preprocessor. –They DO NOT end with ; –Before.
Topic 4 – Programmer- Defined Functions. CISC 105 – Topic 4 Functions So far, we have only seen programs with one function, main. These programs begin.
Using the LEGO NXT March 2007 David Schilling Gus Jansson.
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.
Python Programming Fundamentals
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber.
[Low-level] Programming of NXT Robots Pavel Petrovič Department of Applied Informatics, Faculty of Mathematics, Physics and Informatics
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? simplicity,
Programming the CheapBot-14. Start the Editor Set the Mode.
CSCI 394© 2007 JW Ryder1 NXC Information  Not eXactly C  very similar to NQC  Currently has more NXT API supported than LeJOS NXJ   Uses.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
A tiny turtle robot DEI The University of Padova.
Recursion Recursion Chapter 12. Outline n What is recursion n Recursive algorithms with simple variables n Recursion and the run-time stack n Recursion.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 2 Graphics Programming with C++ and the Dark GDK Library Starting.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
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.
How to link the robot and the computer (Bluetooth) How to turn on and off How to connect the adaptor Fluke card connection Sec Getting Started How.
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.
1 Original Source : and Problem and Problem Solving.ppt.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Title Slide Progress Report Name. Goal Goal Statement – ex. design/create/fabricate … - should be clear and short Needs/Problems – clear and short Space.
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
NQC / BricxCC Brief Introduction David Schilling.
Minds and Computers 2.1 The RCX l Hitachi H8/3297 series processor l 3 inputs/sensors (1, 2, 3) l 3 outputs/motors (A, B, C) l 32k RAM/ 16k ROM ä 12 kB.
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Using Sensor Data and Port View.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
NQC Brief Introduction – Part 2 David Schilling. NQC – Where to put code? Programs Tasks Functions Subroutines.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
ROBOTC Software EV3 Robot Workshop
ROBOTC Software EV3 Robot Workshop Lawrence Technological University.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
NXC: Making Music BricxCC has a built-in utility to convert .wav files into .rso files accessible via menu Tools, Sound conversion. Then you can store.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Python Programming Module 3 Functions Python Programming, 2/e1.
Presentation Outline I. Background Information II. Design Project
Introduction to Programming in RobotC
ARM from NXT NXC Programming
BEGINNER EV3 PROGRAMMING Lesson
Functions and Procedures
Introduction to Gobbit Programming
Introduction To Programming with LEGO NXT 2
Introduction to Robots and the Mind - Methods -
An Introduction to VEX IQ Programming with Modkit
Chapter 2 Graphics Programming with C++ and the Dark GDK Library
C Programming Getting started Variables Basic C operators Conditionals
ICT Gaming Lesson 3.
Glossary NXT-G – the graphical thing for wimps
Getting the software Install Fantom driver
LEGO Mindstorms Robot and Java
NQC Program Structure 3 types of code blocks with their own features and limitations 1. Tasks 2. Subroutines 3. Inline Functions.
Presentation transcript:

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’ Uses the built in firmware, and p-code system

NXC uses BricxCC Reasonably stable development environment Provides support for all LEGO robotic platforms Free!

Programming with NXC Assuming you are comfortable with C… How to use the motors How to read the sensors Threading model

NXC Programs NXC is based on C Restrictions because it’s based on the built-in P-Code system There’s no stack Limited memory Limited number of tasks (256) And subroutines, which are also ‘tasks’

NXC program skeleton #include "NXCDefs.h" task main() { }

NXC Sensors #include "NXCDefs.h" task main() { SetSensorType( IN_1, SENSOR_TYPE_TOUCH ); SetSensorMode( IN_1, SENSOR_MODE_BOOL ); }

NXC Sensors #include "NXCDefs.h" task main() { SetSensor( IN_1, SENSOR_TOUCH ); }

NXC Sensors To read a sensor use x = Sensor( IN_1 );

NXC Sample program #include "NXCDefs.h“ task main() { SetSensor( IN_1, SENSOR_TOUCH ); while( true ) { if( Sensor( IN_1 ) ) { PlayToneEx(440, 100, 3, false); TextOut( 0, LCD_LINE1, "TOUCHING!"); while( Sensor( IN_1 ) ) ; } TextOut( 0, LCD_LINE1, "---------"); while( !Sensor( IN_1 ) )

NXC Motors Simple motor commands are available OnFwd(), OnRev(), Off(), Float()

NXC Motors To use the built-in rotation sensors, you need to use the new motor commands Easiest to use is RotateMotor()

RotateMotor RotateMotor( port, speed, angle ); port is OUT_A, OUT_B, OUT_C, or combinations such as OUT_AB, OUT_ABC speed is a number -100 to 100 angle is the number of degrees you want the motor to turn (positive or negative)

Mimicking a Servo Motor Read the current motor angle Current = MotorRotationCount( OUT_A ); Calculate how far you need to turn Delta = Target – Current; Turn that amount RotateMotor( OUT_A, speed, Delta );

Displaying Text The LCD display is useful for Debugging Setting parameters Runtime messages Graphics Games … and more

Displaying Text TextOut( x, y, text ); NumOut( x, y, number );

LCD display The origin is the bottom left So TextOut( 0,0, “hi” ) will display in the bottom left corner Use the LCD_LINEn macros if you like to make it easier

Text Example y = 42; TextOut(0, LCD_LINE5, "Answer:" ); NumOut( 8*6, LCD_LINE5, y ); // characters are 6 pixels wide

Graphics There are also commands to draw lines, circles, rectangles, and set points You can display bitmaps from a file RIC files – contain drawing commands One problem is there isn’t an easy way to clear areas of the screen It’s easy to clear the whole screen You can display a 1x1 blank bitmap

Tasks and Subroutines Multiple tasks are possible, but don’t work like you might expect Scheduling is different – tasks start when a ‘dependant’ task finishes There is no easy way of stopping a task Use Precedes() or Follows() in a task to define task dependencies

Tasks task FooTask() { // will start executing when main() finishes } task main() { // program starts here Precedes( FooTask ); task BarTask() { Follows( main ); // will also start executing when main() finishes

Subroutines Essentially a task that can be called It suspends the calling task until it returns Don’t use task keyword to define these Can pass in parameters or return a value

Subroutine Example void TestSub( int x, int y, short i ) { x = y + i; } task main() TestSub( 1, 2, 3 );

NXC Help Preliminary help file is a PDF There are many samples and a tutorial online