Technical Informations
How BarCodeReader work |
|
BarcodeReader block use the rotation sensor inside the motor connected to B NXT output port in this manner: when the light sensor reach a dark area, the rotation sensor is resetted, next when a white area is found, the counter value is read and stored in a variable as candidate for the logical one value. The counter is resetted for the white space detection and, in the same manner, if the rotation value read is approximately1/2 of the value read for the first black bar, the process go on. White spaces and black bars used for the logical zero value have the same width: 1/2 of the width of the first bar read. Starting from the second black bar, its value (0 or 1) is multiplied for a power of two: 0 for the second bar, 1 for the third 2 fort the quarter4 for the for the fifth and so on. The sum of this numbers do the final value. Every time the width of a bar have an unexpected dimension, the whole process restarts, so in output from the block can be obtained only a correct value. |
Using BarCodeReader in your project | |
BarcodeReader has two plug: one for input the number of bars of the code and one for the output of the result code read. The number of bars corresponding to the number of black bars minus 1 for the synchronization bar. Place the block in a infinite loop and connect its output plug to an "if " block. Place in every branch of the "if" instruction for the task you want the robot perform when a certain value is read. When you use BarCodeReader in your project to control motors, please make attention to drive each motor in the same unique process. (See startup project for a sample of this). |
Rules to make your own code | |
BarcodeReader works fine also with different code. For example, if
you want perform a larger number of different tasks you need a larger
number of black bar. To make your own code, simply observe these simple
rules: -the code must start and end with a large bar, the same used for the one logic value; -the width of a zero bar must be half of the width of the one bar; -the width of a white separation bar must be the same of the width of the zero bar; -if you want the robot perform different actions according the direction it cover the barcode, please make an asymmetric code. |
Some Consideration | |
Depending on the velocity of your robot, you may need of different barcode format. Greater it is the speed that you want to catch up, greater will be the width of the bars. First start with very low velocity and then gradually increase it. When the robot stops to read the correct value, you need of a more large print of the same barcode. |