



















































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: Nqc Programming, Global Variables, Inline Functions, Subroutines, Tasks, Motors, Control Structures, Functions, Variables, Sensor Modes
Typology: Slides
1 / 59
This page cannot be seen from the preview
Don't miss anything!




















































1. Youāll be programming your robot in NQC (Not **Quite C).
Youāll get this. You should also get another window
If you donāt, press F9 once or twice until you do
Copy and paste the text file ātrustyā from your email
And save it locally as trusty (a .nqc file)
1. You will get helpful error messages below the **program
task name ( ) { // the task 's code is placed here }
1. name : any legal identifier.
In robotC #pragma config(Motor, motorA, RightMotor, tmotorNormal, PIDControl, ) #pragma config(Motor, motorB, LeftMotor, tmotorNormal, PIDControl, ) //!!Code automatically generated by 'ROBOTC' configuration wizard !!// void rightTurn(int turnTime) { motor[RightMotor] = - 100; motor[LeftMotor] = 100; wait10Msec(turnTime); } void leftTurn(int turnTime) { motor[RightMotor] = 100; motor[LeftMotor] = - 100; wait10Msec(turnTime); } sub turn_around() { OnRev(OUT_C); Wait(400); OnFwd( OUT_A + OUT_C ); } This in NQC
In robotC #pragma config(Motor, motorA, RightMotor, tmotorNormal, PIDControl, ) #pragma config(Motor, motorB, LeftMotor, tmotorNormal, PIDControl, ) //!!Code automatically generated by 'ROBOTC' configuration wizard !!// void rightTurn(int turnTime) { motor[RightMotor] = - 100; motor[LeftMotor] = 100; wait10Msec(turnTime); } void leftTurn(int turnTime) { motor[RightMotor] = 100; motor[LeftMotor] = - 100; wait10Msec(turnTime); } task main() { motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100); rightTurn(20); motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100); leftTurn(20); motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100); StopAllTasks(); }
Subroutines sub turn_around() { OnRev(OUT_C); Wait(400); OnFwd(OUT_A+OUT_C); } task main() { OnFwd(OUT_A+OUT_C); Wait(100); turn_around(); Wait(200); turn_around(); Wait(100); turn_around(); Off(OUT_A+OUT_C);}c
Subroutines
Control structures
Inline function, call by reference void turn_around(int turntime) { OnRev(OUT_C); Wait(turntime); OnFwd(OUT_A+OUT_C); } task main() { OnFwd(OUT_A+OUT_C); Wait(100); turn_around(200); Wait(200); turn_around(50); Wait(100); turn_around(300); Off(OUT_A+OUT_C); } task main() { int count=0; while (count<=5) { PlaySound(SOUND_CLICK) ; Wait(count*20); increment(count); } } void increment(int& n) { n++; }