Connecting one leg of the capacitor to the input of the first inverter (pin 1 of ic2) and the other leg to the output of the second inverter (pin 4) provides positive feedback to reset the capacitor when the delay times out.
Here's a rough timing diagram:
At time t0, the input (pin1) is high and so is the output (pin4).
At time t1, the sensor is triggered and pin 1 is pulled low by the comparator's output. Pin 4 goes low as well. The voltage at pin 1 now starts to rise as the capacitor is charged via the 100k resistor.
At time t2, the capacitor voltage rises to the upper threshold of the 74HC14's input which sends pin 4 high again.
Pin 4 is capacitively coupled to pin 1 and, as it goes high, it drives pin 1 high as well. The charge on the capacitor is clamped and dumped on the positive rail via the internal input protection diodes of the 74HC14.
Without the positive feedback of pin 4, the voltage at pin 1 (especially when using the 1 Meg resistor, it seems) can just hang around the switching voltage of the input, reacting to motor and switching noise, and refusing to rise any higher. This leads to a sort of chaotic oscillation of the motor drive, and the poor old motor blurps and farts away unable to decide which way to go.
With the cap attached as it is in the schematic, clean switching occurs between forward and reverse.
Hooray!! Congratulations, aidzmana! Best wishes to you. :D
Kampai: 1. A toast, the Japanese equivalent for "Cheers!".
2. To celebrate, or to have a party.
Yes, that's right.
Adding in the indicator LEDs really helps to set the potentiometer.
edit: I've put some photos on a blog page, if that helps:
I used these motors from Altronics:
The phototransistors I used are from Jaycar:
I can't remember where I got the IR LEDs, but I'm sure most would be fine.
I need the 74HC14 to drive the transistor h-bridge, but I will try the other circuit I posted, where I attached the sensor directly to an L293D. With the reduced delay resistor. Should cut out half the wires I've had to use!
You could still go ahead and use some 38kHz sensors to drive some relays, but I imagine you'll still have to introduce some sort of small delay to the sensor output, to extend the motor response. Shouldn't be too hard, I suppose.
Or spend a bit more money and go for some Sharp distance sensors. Still use the comparator to set the threshold, just change the inputs as the Sharp sensor output rises as an object comes closer.
BTW, I only used one potentiometer in my mockup to set both sensor thresholds. Consequently, the 'bot 'sees' quite well out of its left eye, but is almost blind in its right eye. Sort of like my old uncle Fred!
For anyone casually following this topic:
I've done a really quick mock-up of the circuit I posted earlier, and it works fine, 'cept for one thing!
The sensor works well, until you add the motors to the mix. (How often have you heard that?)
It took me about half an hour to do a quick lash-up, using CD's, doublesided tape, and a breadboard. I then spent about an hour troubleshooting.
It appears the trouble is the 1Meg resistor in the delay components. Works fine, until you start the motors. Then a mysterious voltage appears across it, as it did in the 2nd circuit with the L293D. I should have realised then. Another reminder of the hazards of high value resistors in noisy environments. Any small currents generated by the motor noise get transformed into large voltages by the large resistor.
Dropping it to 100k, and upping the capacitor value did the trick. So maybe the second circuit would work as well. I'll check later this week.
The amended circuit:
I used this h-bridge:
Link to video of dodgy lash-up!:
Things to watch for in video: Funky desk fan, cat food, cornflakes, sensor indicator lights, ugly carpet, cute puppy.
This is an brainless easy to build robot.