I am new to electronics so any form of advise will be helpful.

While trying to build a line-following robot by studying the circuit schematic(as attached), I wanted to find out what the capacitor C1 and C2 are doing.

1) From my beginner's understanding, I am guessing that C1 and C2 each function as a Bypass Capacitor, responsible for ensuring steady current flow to the LED diode so it doesn't flickers(due to the voltage ripple caused by the motors) as the LED diode is used with the photo-resistor sensor for calibration.

2) Also in the same circuit, there is also no capacitors connected directly to the power source and ground, thus I believe the circuit designer have left out dampening any possible voltage ripple(caused by the inductance of the motor and many other factors) for the whole circuit. Or maybe it's just not significant to regulate the voltage for the whole of this circuit.

Please help verify if my understanding above is correct. it will help me progress big time. Many thanks in advance!

enter image description here

  • \$\begingroup\$ (1) Sounds about right. Whether it's stabilizing the voltage across the LEDs or allowing high-frequency currents to bypass the LEDs and short-circuit to ground through the capacitor (it's low impedance for high frequencies), it's the same thing. Just different perspectives. (2) Your analysis isn't quite right. The capacitors act as a short-circuit for high frequency noise currents and act as a high frequency on-demand charge supply. They are placed close to the loads so the inductance between capacitor and load is smaller which allows it to react faster than the supply. This reduces noise. \$\endgroup\$
    – DKNguyen
    May 3 '19 at 2:52
  • \$\begingroup\$ @Toor, thanks for your speedy reply and explanation. It really helps. For (2), If it should be placed near the loads, then why are capacitors placed so very close to the power source in several circuits over my research. An example of it is here: imgur.com/a/SKgBkWW \$\endgroup\$
    – Jack Oat
    May 3 '19 at 3:26
  • \$\begingroup\$ See my answer for how it works now - it's a "bang bang" full-left or full right only control. That MAY work OK. Or not. I'd expect to get a nicer result if the motors were both on at about half throttle when both sensors were evenly illuminated, and then as it slewed off centre if one motor throttle down and the other throttled up. That needs a new circuit BUT perhaps not too different to this one - using amplifiers instead of comparators would allow the motor drive voltage to change with illumination and thus voltage difference. BUT - odds are it will work well enough as a starting point. \$\endgroup\$
    – Russell McMahon
    May 3 '19 at 12:11
  • \$\begingroup\$ @JackOat I'm sure Russ and Toor will agree , although this design looks conceptually ok, it needs a lot of explanation but easier to make some major improvements. Also the inputs IC1B look inverted but are inverted twice, so it's a simple design flaw that proves it was never tested. \$\endgroup\$ May 3 '19 at 15:14
  • \$\begingroup\$ @SunnyskyguyEE75 Yeah,I would not make the circuit that way. \$\endgroup\$
    – DKNguyen
    May 3 '19 at 15:16

Where did the diagram come from - supplied or traced out by you or others?

S1 connections are incorrectly shown - this raises questions about the accuracy of the rest of the circuit. As shown, S1 operating or releasing creates a short break in the supply voltage while the switch transits between states. It is vanishingly unlikely that this is what is intended. It may just be meant to be an in/off SPST but drawn wrong.

Brief: If noise from the motors modulates the LEDs then the illumination of the white-line(s) will vary and the motors will be influenced. Adding capacitors across the LEDs is an attempt to minimise the noise effect on motor drive - quite possibly the need was empirically determined when the system worked worse with them absent.


R13 and R14 are light controlled resistances.

D1 and D5 provide illumination for a white line (possible one each side or two lines or with a middle position shield, and vehicle steering is controlled by varying the illumination of R13 and R14.

ICA1 & B are comparators which are both fed with signals proportional to the illumination of the two sensors BUT with opposite sense.

In an ideal and unachievable state, When the vehicle is running 'straight and true' both sensors are equally illuminated. This state would result in indeterminate comparator switching and the vehicle would "jitter" around the mid point.

When R13 is more illuminated than R14 IC1A-3 will be of lower voltage than IC1A-2, IC1A comparator will be off, IC1A-1 will be low, Q1 will be turned on and M1 (left hand motor) will be powered. Conversely IC1B-7 will be high and motor M2 will not be powered. When R14 is more illuminated than R13 M2 will operate and M1 will not be powered.

SO - what are the capacitors for?:

The Robot is battery powered and can be expected to produce a significant amount of noise on the supply rail. It will benefit from the addition of significant capacitance on the rail - 100 uF minimum and 1000 uF+ would not go astray.

Steering operation is critically dependant on R13 and R14 providing accurate estimates of the relative illumination of the track that they are monitoring. When running at close to equal, small signal variations in one direction will swing them across the threshold and toggle the motor drive outputs.
If noise from the motors modulates the LEDs then the illumination of the white-line(s) will vary and the motors will be influenced. Adding capacitors across the LEDs is an attempt to minimise the noise effect on motor drive - quite possibly the need was empirically determined when the system worked worse with them absent.

Hysteresis: An improvement in operation (or not) MAY be obtained by providing a small amount of positive feedback to the sensing circuit. Adding two resistors (try 1 MOhm each to start) from IC1-1 to IC1-3, and the other from IC1-7 to IC1-5 will add positive feedback to the comparators. Whether this improves operation is left as an exercise for the student.

  • \$\begingroup\$ I agree, the caps were most likely a band-aid. Warning to the OP: since the original designer had issues with motor noise coupling to the LED/sensors, poor wiring techniques and/or poor decoupling could cause your system to be worse. \$\endgroup\$
    – Mattman944
    May 3 '19 at 8:28
  • \$\begingroup\$ SW-DPTP means ON-OFF-ON works, but redundant, useless, except may have been used to switch in added battery voltage not shown for turbo mode. \$\endgroup\$ May 3 '19 at 14:56
  • \$\begingroup\$ @SunnyskyguyEE75 I missed that it said DPTP by the switch. || I'd have thought that it should say "DPDT" if they mean 3 position, centre off. || I imagine that it's a draughting typo - DPTP may be used to mean that BUT I've not seen it. Thoughts? \$\endgroup\$
    – Russell McMahon
    May 3 '19 at 23:35
  • \$\begingroup\$ The diagram came from where I bought the line-following robot kit, here: bit.ly/2H16YRW \$\endgroup\$
    – Jack Oat
    May 4 '19 at 4:33
  • \$\begingroup\$ Yes, I believe the switch is drawn and labeled wrongly. \$\endgroup\$
    – Jack Oat
    May 4 '19 at 4:34

It functions like a low pass filter, with a time constant of 100uF*51=tau=0.00051s So it will filter out most noise with that is faster than roughly half a millisecond.

Bypass filters are mainly to solve a problem with line impedance to the load. The battery is a relatively low impedance source, so you may not see much noise. If the cables from the battery are short (and low resistance/inductance) then filter caps may not be needed. As a precaution most people include bypass capacitors without doing a load analysis (because properly analyzing a switching load can take more time=money than the capacitors are worth)

  • \$\begingroup\$ Elcos are ineffective for filtering for frequencies > 100 kHz. So, it is likely not effective for filtering motor noise. \$\endgroup\$
    – Huisman
    May 3 '19 at 6:00
  • \$\begingroup\$ The resistors (R5, R6) are 51 ohms, not 51k. In any case, these may be a band-aid. It wasn't working well, so they were added. \$\endgroup\$
    – Mattman944
    May 3 '19 at 8:13
  • \$\begingroup\$ I agree with your general comments but for Red or more likely IR LED's the Rs is < 12 Ohms which shunts the 51R or 100 us step response time. regardless , LDR's bulk C response time is 10 to 30ms .. too many unknowns \$\endgroup\$ May 3 '19 at 15:55
  • \$\begingroup\$ @Mattman944 or could R5 and R6 be "protective" resistors to avoid the LED diode below them from burning? Thus explaining the small 51 ohms resistor. \$\endgroup\$
    – Jack Oat
    May 4 '19 at 3:44
  • \$\begingroup\$ @SunnyskyguyEE75 The LED diode is just a normal and very common LED. The LED is tasked to illuminate so that the photo-resistors R13 and R14 can "read" the brightness and provide input to the LM393(voltage comparator) chip. \$\endgroup\$
    – Jack Oat
    May 4 '19 at 3:49

I wonder if the capacitors are being used to reduce noise. Nor as protection against voltage dips.

R13 and R14 seem to be a LDR or another light sensor.
If there was a need to filter noise, those sensors should have a (ceramic) capacitor parallel to them to shunt high frequent noise rather then the LED's. Now, the R13 and R14 are still susceptible to noise (high frequent motor noise, voltage dips, external light sources, etc).
Moreover, elco's are not effective against high frequent noise due to their ESL.

If they were to smooth voltage dips due to initial stall currents of the motors, the elcos should have been placed between the motor and the voltage block (maybe with a resistor to form a RC filter).

If R13 and R14 are indeed LDR's, I think the elco's are being used to generate some kind of initial time out/settling time. Maybe to compensate for the response time (which is several ms) of the LDR's??

  • \$\begingroup\$ I agree, if they were trying to reduce noise they'd have a ceramic across R13 and R14, but in this case it's probably unnecessary since the motor and inertia of the vehicle act as pretty good low pass filters on their own. As another answer stated, the time constant of those elcos is really high, high enough that at the point your filtering out the signal along with noise. It seems more likely that your suggestion of them being used as a initial time out is more likely because the motors might not even move without an initial pulse of current. \$\endgroup\$
    – c10yas
    May 3 '19 at 6:14
  • \$\begingroup\$ A large capacitor like that directly across the LED wouldn't really make much sense for filtering since as soon as the capacitor reached the forward voltage of the LED all the current would flow through the LED, and as soon as the capacitor discharged a little bit, the LED would turn off and prevent further discharge. To reduce noise in the LED output, the capacitor would have to be in parallel with the LED AND a resistor imo \$\endgroup\$
    – c10yas
    May 3 '19 at 6:17
  • \$\begingroup\$ Yes, R13 and R14 is a LDR. \$\endgroup\$
    – Jack Oat
    May 4 '19 at 4:12
  • \$\begingroup\$ Appreciate your replies and also suggesting a different possibility of C1 and C2. However, if they are used to compensate for the response time and to give the motor the initial pulse of current, then why is it placed in that position? What has it got to do with the LED diode connected in parallel. For context, I am leaving the link to the cheap DC brush motor here: bit.ly/2Y65TxX \$\endgroup\$
    – Jack Oat
    May 4 '19 at 4:18
  • \$\begingroup\$ As for the type of capacitors to use(electrolytic for lower frequency and ceramic for higher frequency), it largely depends on the frequency produced in the circuit, or at least till the point where the capacitor is placed(I think). But I am still wondering how is the frequency derived/calculated? I think if someone could assist with this, we will be very close to resolving the matter. \$\endgroup\$
    – Jack Oat
    May 4 '19 at 4:30

I figured I should spend more time improving the design than criticizing it. I did not realize until my own investigation that this was for a 2 wheel racer robot.

The optics under-body are spaced at least the width of the track being followed, such that each emitter-detector gets only 1/2 the maximum amplitude on the middle of the track. Test this separately. Thus only half the light is reflected on each edge as the optics track each edge for steering error.

When both pots are too high in value, the optics are too sensitive and the FETs are both ON too much, causing slack in the steering, resulting in unstable driving left-right.

If the pots are too small in value reducing sensitivity may cause only 1 motor being on at a time with a dead spot in between with neither motor on. So the optics design and pot settings are critical. Whereas the Arduino based one can calibrate itself going in a circle at first to adjust the gain which is like adjust both pots at the same time and offset which is the difference.

I chose 2 Yellow LEDs since these would be around 2.1V with good LEDs e.g. 5 Cd 60deg intensity pointed to refect into sensors.

3.1V Blue might look nice but when the battery drops in voltage so does the optical Gain and it may result in a deadspot with low gain. So I though an improvement would be regulate the current.

The CC sink can be reduced in current by raising the Current sense = 15 R if the LED intensity is too bright.

The power FET's will reduce transistor losses but must be rated for at least 10x the motor current to have low RdsOn. A reasonable value would be 10% of the motor DCR (resistance.) THe Vgs(th) is just the threshold of the FET (Vt) turning on < 0.5mA so it must be a "3V compatible logic Level FET". This usually means about Vgs(th)=1/3 of Vbat min. A clamp diode is necessary to prevent negative spikes when the FET's turn off and will also tend to coast more around corners depending on diode size. (T=L/R)

If the motor goes too fast with the gear ratio used, then a half bridge FET array works better as instead of coasting like Formula 1 it goes from full power to full brake for the duration needed to get a faster corner response. But if you have a slow motor wheel ratio, then coasting is better without the diode ( or LED) across the motor and use the avalanche Zener inside the FET to absorb the losses at lower current.

enter image description here

  • \$\begingroup\$ Thank you and appreciate your time to come up with the above input. I am still learning thus there are quite a few jargons and concept that are not familiar to me. However, I make a summary for immediate and future use(once I understand these better). \$\endgroup\$
    – Jack Oat
    May 5 '19 at 3:40
  • \$\begingroup\$ Summary: 1) Use good LEDs and take note/measure the LED's rating as it may affect the sensitivity. 2) I take that the capacitors are replaced with another pot, but am unsure why? 3) The original transistors are replaced with another kind of transistor, but am unsure why? 4) Totally get the addition of the clamp diode to prevent inductive kickback, especially when the motor is going through on/off state so often in the original design, thanks for the reminder. \$\endgroup\$
    – Jack Oat
    May 5 '19 at 3:40
  • \$\begingroup\$ Reply:1) LED intensity is critical for performance and regulated intensity is critical for stability on nulling hysteresis or deadspot 2) The constant current (CC) circuit design replaces the need for the big caps and reduces current variation from 50% to 5% . No. The Pots were always there to adjust line edge threshold levels 3) The Pch MOSFETS are capable of lower voltage drop than PNP's using the specs on dwg, with "no gate current"., just 3x threshold voltage required pulled down from V+ to turn on. 4) good. \$\endgroup\$ May 5 '19 at 3:59
  • \$\begingroup\$ Thanks again for your explanation. Will dive more into (2) and (3). :) \$\endgroup\$
    – Jack Oat
    May 6 '19 at 3:53
  • \$\begingroup\$ The idea of constant current(CC) circuit design is kinda cool, eliminating the use of caps. However, is this technique applicable to most if not all circuit design? I would think that caps is an easy-and-quick way to deal with voltage ripple caused by inductance and others. \$\endgroup\$
    – Jack Oat
    May 6 '19 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.