Using logic chips can make the robot’s behavior more interesting and can implement more complex algorithms. In this robot, the gate circuit is used to make the robot no longer worried about the sharp turns. It will only be using one sensor.
Algorithms for this robot motion will be as follows: when the sensor on a black field, then one of the motor will be switched on and off the other. Thus, the robot will change until the sensor is not able to pass on a white field. Then the motor running, and off – on. The robot starts rotating in the opposite direction until the sensor back on the black line. The algorithm will repeat again, and robots, slightly swaying from side to side, begin to move along the border of black and white.
A logical element that we add to the circuit of the robot is an element “NOT” gate, or “inverter”. The inverter has one input and one output. When the input of inverter fed a logical “1” (logical unit – a high signal), the output we will have a logical “0” (logical zero – low signal), and when the input will be submitted to a logical “0”, then output will be present a logical “1”.
In addition to the NOT gate, there are also elements of OR and AND, providing a logical addition and logical conjunction, respectively. In addition, is often used combined elements of NAND and NOR. More information about the logical elements can be read here.
When connecting the phototransistor used pull-up resistor R2, sincethe TTL chips at the entrance when no signal is present a logic high(logic “1”). Resistor, pull-up input to the “land”, will provide a low level(logic “0”) in the absence of a signal from the phototransistor.
The principle of the scheme is based on inversion of the signal from the phototransistor. When the sensor is illuminated (located on a white field), the phototransistor will be opened and the input motor driver L293D INPUT1 a signal is high (logic “1”). Motor M1 rotates. In addition, the signal from the phototransistor will be served at the input of “NO”, which will convert a logical “1” to logical “0” and submit it to the input INPUT4. Motor M2 will stand.
When the robot turns and the sensor is over the white field, the phototransistor will be closed and the input signal INPUT1 be low (logic “0”). M1 motor stops. A logical “0” is inverted by an element “NOT”, and at the entrance INPUT4 appears logical “1”. Motor M2 starts to rotate.
The change from state 1 and state 2 will give the robot to follow along the border of white and black.
In this scheme can be applied to logic chips or SN7404N.
Described by the robot can be implemented without the use of pull-up resistor. In this case, the emitter of the phototransistor can be connected to “earth” and to use two elements of the “NOT” gate.
It should be noted that the gate in addition to its direct purpose, may be a signal amplifier. Therefore, it is a variant of the scheme is often used in creating robots to sports competitions “Racing on the line.”