Shop OBEX P1 Docs P2 Docs Learn Events
Handling Clock Signal That Routes Over Ribbon Cable — Parallax Forums

Handling Clock Signal That Routes Over Ribbon Cable

photomankcphotomankc Posts: 943
edited 2013-12-09 20:35 in Propeller 1
So last night I ran into a neat issue. I have a Propeller that is generating an 8MHz signal on two pins that are fed out to a couple of L6470 stepper drivers as the external clock for them. The idea here is that this allows them to match speeds correctly and I can adjust the actual clock rate to calibrate for mechanical differences in the gearing between the two output wheels that result in drift for my robot. The prop is controlled by an ARM linux system that uses serial to command the clock speed for each channel.

So I tested it out with a quick test rig using a ribbon cable to carry the two clock signals over to the breadboard for the L6470 drivers. I hooked up my scope (60Mhz so it's not a fantastic view of an 8Mhz signal) and ran the program for the drivers and everything worked well. The two motors turned in perfect sync which is much improved from using each L6470's internal clock. Cool beans. So I power down, unhook all the test gear and power up to test some more code on the motor side. Now it's all out of whack. The motors sound bad, the shafts turn at different speeds, and it's clear they are running at much different rates than they should.

It's got to be the clock. I hookup the scope and run the test program again. It's back to running fine. Sounds good, shafts in sync, and speeds are right where they should be and clock freq reads correct in the scope. Unhook the scope and it immediately falls apart again. Connect the scope once more and it runs fine! AAARRRRRHHHHHH!!!! I don't think I can just strap the scope to the robot forever so I need to figure this one out.

Ok.... so I know a couple things, the ribbon cable is about 7 inches long and it's small gauge wire like maybe 28, so that connection is not ideal. The signals are right next to each other and are coupling to some extent. I know probes on a scope act like a small capacitor and thus *can* effect the circuit they measure. So I look at the probe capacitance loading and it says ~16pf. Now I don't have that value in caps but I did have 7pf and 33pf. I tried 7pf between each clock line and ground and it improved but did not solve the issue. I tried 33pf and it immediately improved and appeared to have both drives operating at the correct frequency and speed were well matched. I tried 66pf just to see and that caused everything to fall apart again and go way out of sync. Ok, so immediate issue solved.... 33pf it is.

The thing is that I have no idea why that works or what it's really doing since using the probe is sure to alter the signal and the display of an 8Mhz signal on that scope is kinda poor anyway. It did look like there may be reflections coming into play since I saw some some dips in the rising and falling edges on the signal trace on one channel of the clocks. My best guess is that the caps slow the edges a bit and that cleans things up enough that the device is not seeing ringing or reflections as clocks.

I doubt that's a reasonable strategy to build the final board with these caps included since I bet the value is dependent on several variables I don't grasp yet. I know that I would want to keep the traces short in the final product but the signal will have to traverse some ribbon cable to the driver board.



Questions:
- Is there any type of general termination I should do?

- Should I route it on a PCB as CLK | GND | CLK | GND?

- I can tell that if one carries a 7.8MHz signal and the other an 8.0MHz signal then they are interfering a bit since the wave shape changes as one of the clocks frequency is changed. Would GND between them help with that?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-05 20:21
    Add a termination resistor to the end of the clock line. A 1K or 2.2K pull-up or pull-down resistor should work fine.

    -Phil
  • jmgjmg Posts: 15,173
    edited 2013-12-05 21:01
    photomankc wrote: »
    I don't think I can just strap the scope to the robot forever so I

    hehe There are a lot of things that work better with a scope attached... :)

    Yes, GND between CLK lines helps, and if you can manage it, differential clk drive can help too, as that gives local balance of the edge currents.

    Next, a moderate series R, 50-150 Ohms, can reduce the higher harmonics, and somewhat match the cable.
    In extreme cases, I've used end of line terminators too, of a series R-C
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-05 21:12
    ams recommends caps on some of their SPI lines.

    They have an apnote about SPI over long distances. Here's a link to the pdf.

    (Note, I don't know enough about the parts you're using to know if the apnote applies to your application.)
  • photomankcphotomankc Posts: 943
    edited 2013-12-06 05:17
    Thanks for the tips. I'll try out some of these and see what helps most. I know a breadboard and ribbon cable are about as dirty as you can get for routing a clock line but it was good to run into this now rather than on a PCB with no help for it.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-12-06 12:34
    To add to what Phil said ...

    "...Add a termination resistor to the end of the clock line..."


    ...Place a resistor on both ends. This will create a transmission line and help minimize reflections and attenuate any antenna effects.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2013-12-06 17:14
    Hi Beau;
    To add to what Phil said ...
    "...Add a termination resistor to the end of the clock line..."
    ...Place a resistor on both ends. This will create a transmission line and help minimize reflections and attenuate any antenna effects.
    I read the ApNote Duane provided.
    They are recommending an RC launching circuit to reduce the signal rise and fall time. This prevent or greatly reduces crosstalk.

    Clearly their network is not related to transmission termination resistors which are designed to allow the fastest of rise times. But fast rise times must be used in constant impedance stripline or coax cables which limit crosstalk.

    They even say resistors on the end of each line do nothing.

    Duane J
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-12-06 17:56
    Duane,

    The app note is "adding" C? ... that's usually a parasitic effect of wire length against a shield and/or parallel wire you don't necessarily want. .... The line itself also has parasitic resistance (R) and inductance (L). By adding a terminating resistance on both ends (G) you affect the conductance or Z. You can get away with placing it on one end, but to attenuate reflections and Antenna effects, forming a "Pi" transmission line terminating at both ends is better than just a single end. To claim it does nothing is wrong though.


    Reference: (See Telegrapher's equations)
    http://en.wikipedia.org/wiki/Transmission_line
  • Mark_TMark_T Posts: 1,981
    edited 2013-12-07 04:13
    Are the 8MHz signal(s) routed between two ground wires on the ribbon? That would help if not.

    Also a 50 ohm resistor in series with the line at each end will damp down reflections substantially,
    remember the Prop generates fast edges, a lot faster than many chips, and they will tend to ring
    when sent down a wire to a capacitive load - adding resistance lowers the Q of the system (wire's
    inductance + load capacitance). The scope probe adds more capacitance at a different place
    which slows down the edge seen further down.

    Ideally you'd just use a transmission line, but for 8 inches that's overkill really.

    These are phenomena beyond the capability of a 60MHz scope to see...
  • photomankcphotomankc Posts: 943
    edited 2013-12-07 20:36
    So far just the 1K resistors to GND have tamed the issue and allow the system to run as desired. I can even add the scope now and not cause failure like it did with the caps to GND. I have not yet tried 50ohm resisters at the ends but that's probably a good idea too so I want to test it out. The two clocks are carried right next to each other. Nature of how it's being done makes it hard to fit GND between them on the test rig here.

    I know the scope is too slow to see the details on these signals. I wish I had a 100 or better yet a 200Mhz scope. About all I can tell with mine is the frequency and duty cycle are what they are supposed to be. I have plans to upgrade my scope this year. This one has helped me a great deal the last 5 years but my logic analyzer works for a lot of things I used to use it for and the other analog phenomena that the LA can't show this one often can't either.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-07 20:58
    Place a resistor on both ends. This will create a transmission line and help minimize reflections and attenuate any antenna effects.

    Are you sure resistors are needed at both ends? At the driving end, the impedance will be whatever the driver output provides, i.e. very low. Adding a resistor at that end to ground (i.e. in parallel with the driver output) would seem to have little effect. Now, if it were a bidirectional bus, I could understand...

    -Phil
  • Mark_TMark_T Posts: 1,981
    edited 2013-12-08 02:41
    Are you sure resistors are needed at both ends? At the driving end, the impedance will be whatever the driver output provides, i.e. very low. Adding a resistor at that end to ground (i.e. in parallel with the driver output) would seem to have little effect. Now, if it were a bidirectional bus, I could understand...

    -Phil

    Well it can't hurt to reduce reflection at both ends!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-08 09:03
    Mark_T wrote:
    Well it can't hurt to reduce reflection at both ends!
    True. But for the stated reason, I do not see how adding parallel resistance at the driving end achieves that objective. Reflections at the dirving end are typically damped with a series resistor, but that requires a signal of twice the amplitude.

    -Phil
  • jmgjmg Posts: 15,173
    edited 2013-12-08 18:18
    True. But for the stated reason, I do not see how adding parallel resistance at the driving end achieves that objective. Reflections at the dirving end are typically damped with a series resistor, but that requires a signal of twice the amplitude.

    I think they mean series R, not parallel.
    Series R only needs 2x when you shunt terminate at the line impedance, - classic Video does this.

    For Logic Clock signals, Series R can help, even with no far-end termination, as it lowers the harmonics on what is not quite an ideal transmission line.

    There is a sweet spot however, too much aggression on R+ shunt C, solves the ringing and overshoot, but slows the clock slew rates, and some SPI slaves have fast CLK-MISO times, and if the MISO line pulses whilst the clock line is still very close to the threshold, you can now have double clocking.

    For this reason, a series R at the FAR end, on MISO can help, and certainly separate CLK from all data lines with GND/PWR.

    In extreme cases, (tens of inches) we have also added series R+C 'snubber' at the far end of CLK lines too, with 100R/100pF type values. This is mainly to lower the over-shoot effects, which can start to hit protection diodes (best avoided).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-08 19:01
    Right, jmg! The only time parallel resistance at both ends is helpful is in the case of a bidirectional data bus.

    Here's an example of an ideal bidirectional situation where the transmit and receive signals can be separated at each end:

    attachment.php?attachmentid=105484&d=1386558918

    During receive at its end, the transmit driver pulls the resistor low. Both transmit drivers must output a 2x voltage level.

    -Phil
    460 x 153 - 2K
  • photomankcphotomankc Posts: 943
    edited 2013-12-09 20:35
    Just to follow up with my results:

    1K to GND - This seemed to be enough to make things work but the scope picture was still ugly even with limited BW. Prior to this there was a pronounced fish-hook in one clock's rising edge and that drive was the one that seemed to have the most issue. The resistor to GND reduced that a bit and the drive would operate properly. The second clock line had what I would describe as a cowboy hat appearance with a heavy dip in the center of the low and high levels. The resistor slightly reduced this but not by much.

    100 Ohm inline - This seemed to produce the best result. The scope representation showed the fish-hook now as a brief shelf and the other spikes seemed to be reduced greatly by this as well. The cowboy hat appearance of the 2nd clock line was greatly reduced as well. The two drives operated very well. I now need to spend some time understanding the nature of how to distribute these signals and the reasons behind this. I have not to this point worked with many MHz signals and so this is somewhat new to me.

    Oh, and I talked myself into a purchase. My new Rigol DS2202 arrives on Wednesday :) Early Xmas, Birthday, Valentines, ect present for me.

    ETA: Found this video that helped explain this nicely http://www.youtube.com/watch?v=zrDxSM91Jcg

    ETA-2: R/C termination was not much use here. Tried that and got little result. I tried 150 Ohms inline and that cleaned things up even more. One of the clocks even looked almost like a square-wave. It's definitely clear though how hard that is on rise time. If you superimpose the source and the end against each other the rounded edge and flatter slope are clear.

    Thanks for all the help and info. Despite this being a horrible way to route a digital clock it's working well enough to test everything now.

    Prior To Termination:
    attachment.php?attachmentid=105524&d=1386737563

    After 150 Ohm Series:
    attachment.php?attachmentid=105525&d=1386737564
    320 x 240 - 43K
    320 x 240 - 42K
Sign In or Register to comment.