vb.net barcode scanner programming USING NOT QUITE C (NQC) TO PROGRAM THE RCX in Software

Draw Data Matrix 2d barcode in Software USING NOT QUITE C (NQC) TO PROGRAM THE RCX

USING NOT QUITE C (NQC) TO PROGRAM THE RCX
Scanning Data Matrix ECC200 In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Data Matrix Generator In None
Using Barcode drawer for Software Control to generate, create ECC200 image in Software applications.
if the output of the light sensor is greater than 60, turn the motors on; otherwise turn the motors off
ECC200 Recognizer In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
Printing Data Matrix ECC200 In Visual C#
Using Barcode maker for .NET Control to generate, create ECC200 image in .NET framework applications.
Light sensors on the RCX return a value of 0 to 100, with 0 being absolute darkness and 100 being fairly bright light. The value of 60 was selected as a kind of threshold. If you operate the RCX in dim room light, pointing a flashlight at the sensor will cause the motors to run. Turning the flashlight off will cause the motors to stop.
Painting Data Matrix ECC200 In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create ECC200 image in ASP.NET applications.
Data Matrix Drawer In VS .NET
Using Barcode printer for .NET framework Control to generate, create ECC200 image in VS .NET applications.
DOWNLOADING THE NQC PROGRAM
DataMatrix Generator In Visual Basic .NET
Using Barcode printer for Visual Studio .NET Control to generate, create ECC200 image in Visual Studio .NET applications.
Code128 Printer In None
Using Barcode maker for Software Control to generate, create Code-128 image in Software applications.
Now that the program has been written (and saved), you can download it to the RCX by using the main nqc.exe program. This program does two things: it compiles your text programs into a form that is suitable for the RCX, and it transfers the code to the RCX via the Mindstorms IR tower. NQC is a command-line program. To use it, open a new MS-DOS window by choosing Start, Programs, MS-DOS Prompt. (Note: if you don t have this option, choose Start, select Run, type command.com, and then press OK.) If necessary, switch to the NQC program directory using the CD (change directory) command, such as:
Create ECC200 In None
Using Barcode printer for Software Control to generate, create DataMatrix image in Software applications.
USS-128 Creator In None
Using Barcode drawer for Software Control to generate, create UCC-128 image in Software applications.
cd \nqc
Paint GTIN - 12 In None
Using Barcode maker for Software Control to generate, create UPC Code image in Software applications.
Barcode Encoder In None
Using Barcode encoder for Software Control to generate, create bar code image in Software applications.
This assumes that nqc.exe and your programs are in a directory named NQC. Then compile and download your program with the following command:
Generate MSI Plessey In None
Using Barcode printer for Software Control to generate, create MSI Plessey image in Software applications.
Painting Barcode In Objective-C
Using Barcode encoder for iPad Control to generate, create bar code image in iPad applications.
nqc -d program.nqc
Linear Barcode Creator In C#
Using Barcode printer for Visual Studio .NET Control to generate, create Linear image in Visual Studio .NET applications.
Bar Code Maker In Java
Using Barcode generator for Android Control to generate, create barcode image in Android applications.
where program.nqc is the actual program name you want to use. If you saved the sample program as photophile.nqc, for example, type the following:
Encoding Barcode In None
Using Barcode creation for Microsoft Word Control to generate, create barcode image in Word applications.
Bar Code Printer In Objective-C
Using Barcode creation for iPhone Control to generate, create bar code image in iPhone applications.
nqc -d photophile.nqc
Encode Barcode In Java
Using Barcode creation for Android Control to generate, create barcode image in Android applications.
UPC A Generation In Objective-C
Using Barcode creator for iPhone Control to generate, create UPC A image in iPhone applications.
and press the Enter key. NQC will then compile the program and download it to the RCX. If there are syntax errors in your program, NQC will alert you of them and display the approximate line where the error occurs (usually the actual error is a line or two above). Assuming the program compiles correctly, NQC displays Downloading program and then finally Complete when downloading is finished. Run the downloaded program by pressing the Run button on the RCX. Note: Unless you tell it otherwise, NQC assumes that the IR tower is connected to COM1 of your computer. Use the set command in DOS to set a different communications port, such as:
set RCX_PORT=COM2
184 PROGRAMMING THE LEGO MINDSTORMS RCX
This tells NQC to use COM2 instead. Valid values are COM1, COM2, COM3, and COM4. If you type one of these in the DOS window you have opened for NQC, the value will remain only until you close the window. If you want to make the setting permanent, edit the autoexec.bat file (it s in the root of the C drive) and add the set command there. It will take effect the next time you start your computer.
ALTERING THE BEHAVIOR OF THE ROBOT
It s easy to alter the behavior of your NQC-controlled robot creations. One small change you can make is to have the motors turn the other way when the light shines on the sensor. This has the effect of creating a photophobic robot a robot that appears to run away from the light. The complete code example is shown in Listing 14.3. If you retype this program, name it photophobe.nqc.
Listing 14.3
#define LIGHT #define MOTOR
photophobe.nqc.
SENSOR_1 OUT_A+OUT_C
task main() { SetPower(MOTOR, 7); SetDirection (MOTOR,OUT_FWD); SetSensorType(BUTTON, SENSOR_TYPE_LIGHT); while(true) { if(LIGHT > 60) On(MOTOR); else Off(MOTOR); } }
CREATING A MULTITASKING CONTROL PROGRAM
One of the most important capabilities of the RCX is that it is a multitasking device. You can run up to 10 tasks simultaneously in one program. The microcontroller in the RCX divvies up a little bit of its processing time to each task, so in human terms things appear to happen simultaneously. Of course, in microcontroller terms it s handling one instruction at a time, but at very fast speeds. The following program is a rudimentary but fully functional example of an RCX program with multiple concurrent tasks. The program is based on the photophobe.ncq example in the previous section. We have added separate tasks, one to play a little song (the first notes of something that sounds like Mary Had a Little Lamb ) and another to reverse the motors and spin if a touch sensor is activated. When the program is run, the robot exhibits three events (sometimes called behaviors in modern robot artificial intelligence efforts): Event 1. A song is played every few seconds. This event is free running, and no other event in the program affects it. Event 2. When a strong enough light strikes the light sensor, the robot backs away from the light source (of course, backs away depends on how the motors and light sen-
Copyright © OnBarcode.com . All rights reserved.