















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Course title is Embedded Intelligent Robotics. This course is for Electrical engineering students. Though good thing is everyone can learn about robotics in this course. This lecture includes: Nxc Programming, Firmware, Next Byte Code, Threading Model, Nxc Sample Program, Rotatemotor, Mimicking a Servo Motor, Lcd Display
Typology: Slides
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















NXC ( N ot e X actly 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
Reasonably stable development environment Provides support for all LEGO robotic platforms Free!
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’
#include "NXCDefs.h" task main() { }
#include "NXCDefs.h" task main() { SetSensor( IN_1, SENSOR_TOUCH ); }
To read a sensor use x = Sensor( IN_1 );
Simple motor commands are available OnFwd(), OnRev(), Off(), Float()
To use the built-in rotation sensors, you need to use the new motor commands Easiest to use is RotateMotor()
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 );
The LCD display is useful for Debugging Setting parameters Runtime messages Graphics Games … and more
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
y = 42; TextOut(0, LCD_LINE5, "Answer:" ); NumOut( 8*6, LCD_LINE5, y ); // characters are 6 pixels wide
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
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 } docsity.com