2
\$\begingroup\$

As shown in the block diagram below. I generate a 128KHz clock and a stream of known number of pulses in 10msec (the 10msec timer is implemented in the pulse counter by dividing the 128KHz by 1280) and send them to the pulse counter in the system under test.

System block

The problem is that when I send say 1000 pulses in the 10msec, the counter doesn't count exactly 1000. I keep getting lower counts (982 ~ 998). When I just probe the 128KHz at the shown test point (or touch it with my finger!), the counted number decreases a lot reaching ~400 counts despite the probed 128KHz is clean and had no issues!

Any ideas what's happening here?!

Problem Solved!

The pull up resistor at the optocoupler output is 4K, so the max current from the optocoupler is ~1.2mA which is so small to drive the FPGA input. Replacing the resistor by 400 Ohms solved this issue and counting is now stable when i probe or touch with my finger!

Thank you all for your contribution.

\$\endgroup\$
3
  • \$\begingroup\$ Are the opto-couplers just switches on the output side, as apposed to real gates? If so, I'm guessing you forgot the pullup. \$\endgroup\$ Commented Nov 4, 2013 at 15:12
  • \$\begingroup\$ @OlinLathrop , I checked the pull up and measured it from the test point to the 5V rail and it reads 4k ohm. So not a pull up problem. \$\endgroup\$
    – Abdella
    Commented Nov 4, 2013 at 15:39
  • \$\begingroup\$ If the signal looked clean, then it WAS driving the fpga inputs. By changing R you really changed timing (delay and dv/dt). If a 4k pull up were not enough, good luck implementing simple pushbutton and keypad circuits... \$\endgroup\$ Commented Nov 5, 2013 at 17:44

5 Answers 5

2
\$\begingroup\$

It sounds as though the drive from the optocoupler is marginal for the FPGA.

The fact that the scope probe loads it enough to make things much worse seems to confirm it. This is probably capacitance rather than resistance. For example, a Tek P2200 1x/10x passive probe in the 1x position can put 80 pF on the circuit being probed. At 100 kHz, that's -j 20K ohms, which MAY be OK. At 1 MHz (100 kHz x 10), that's -j 2K ohms, which probably isn't.

You really don't want to know why I can quote those numbers for that probe right now. I didn't take a hatchet to the dam' thing, but I was sorely tempted.

Take a look at the current drive specs for the optocouplers. Consider using buffers. If the optocouplers are open drain (open collector) devices, you NEED pull-up resistors, and the smaller the resistance you can get away with, the crisper your rising edges will be.

\$\endgroup\$
1
  • \$\begingroup\$ That's it! The pull up resistor is 4K, so the max current from the optocoupler is ~1.2mA which is so small to drive the FPGA input. Replacing the resistor by 400 Ohms solved this issue and counting is now stable when i probe or touch with my finger! Thank you so much. \$\endgroup\$
    – Abdella
    Commented Nov 5, 2013 at 14:37
2
\$\begingroup\$

Here, probably the optocouplers does not transmit 128Khz signal with good quality (what is very easy with wrong designed schematic). So, the pulse counter (what is the input?) simply misses some of the pulses.

In addition, when you connect the probe capacitance in the circuit, the quality of the signal becomes even worse and the counter misses more pulses.

Try to put Schmitt trigger on the other counter input and see what happens. Also revise the optocoupler part. Try to model it in order to check the frequency characteristics.

Adendum1: If you state that the signals are perfect (and if they really are), then your counter probably does not count properly. I can't see any other reason for such weird behavior.

BTW, some time diagrams might greatly help the analysis.

\$\endgroup\$
3
  • \$\begingroup\$ The 128KHz is very clean and has no problems when I probe it. This signal is connected to the Dedicated clock pin of the pulse counter FPGA. I tried to assign an output 128KHz pin on the pulse counter FPGA which simply takes the input 128KHz and bypasses it. This output is also clean even if I touch the test point with my finger. \$\endgroup\$
    – Abdella
    Commented Nov 4, 2013 at 15:46
  • \$\begingroup\$ Does touching with your finger change the pulse counter behavior? What are the specs on the pulse counter, bandwidth, pulse width minimum, etc? You're mentioning FPGA -- is the pulse counter an implementation in an FPGA? If so, are you configuring the input pins correctly for the part in question? \$\endgroup\$
    – Jon Watte
    Commented Nov 4, 2013 at 16:37
  • \$\begingroup\$ @JonWatte , yes touching with my finger causes an error in the pulse counting. The pulse counter is implemented on the FPGA and the 128KHz clock is input to a dedicated clock pin. The unused pins are configured as "output driving ground" to minimize noise as possible. The pulse stream is input to a normal IO pin. \$\endgroup\$
    – Abdella
    Commented Nov 4, 2013 at 16:43
2
\$\begingroup\$

It could be something to do with the input on the FPGA requiring a certain dv/dt. I note that the input that seems to be affected does not have Schmitt trigger inputs on it.

One way to look at this is to use a passive probe that is made from a piece of coax and a series resistor (you have to crank up your gain on the channel to compensate) but it gives you a very fast probe that loads the signal only by 1 pF or so.

Howard Johnson calls it a "shop built 21:1 probe" using a 1K resitor.

\$\endgroup\$
1
\$\begingroup\$

Another idea is clock-pulse synchronization. If the pulses are "source-synchronous" and the pulses occur with the rising edge of the clock, and your fpga circuit also uses the rising edge of the clock to count, you may have a problem.

The probe will delay the rising edges but not the falling edges (as much), because of the pullup's RC constant.

Do the pulses have exactly one clock period duration, or are they shorter?

Try coding your counter to use the falling edges of the clock (you could simply invert the clock), in the attempt of making sure that the pulse has been there for a while (setup) and will stay there for another while (hold) and see if there is any difference in your results.

\$\endgroup\$
0
\$\begingroup\$

You may also want to check your electrical ground. This can happen when some parts are not grounded properly.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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