Shop OBEX P1 Docs P2 Docs Learn Events
How to measure time between signal going high, and propeller detecting it ? — Parallax Forums

How to measure time between signal going high, and propeller detecting it ?

BeanBean Posts: 8,129
edited 2013-04-14 16:14 in Propeller 1
I need to measure the time between when an input signal goes high, and the time that the Propeller detects it.
This could possible be from 0 to 12.5nSec. I want to measure it to 1pSec resolution (I know I don't ask for much). But 10pSec would be okay.

The only thing I can think of is to use a counter in the feedback mode. So that when the propeller detects the signal another pin will change one propeller clock later.
This will give a pulse between 12.5nSec and 25.0nSec.
Then I could use this pulse to charge a cap through a low resistor value (220 Ohms), then measure how long it takes the cap to discharge through a high resistor value (220K).
This kind of works, but the values are log not linear, in other words short pulses are stretched more than long pulses since the cap charging/discharging is a log function.
Also the measurements are rather jittery too.

So I was just wondering if anyone had any slick ways to measure this ?
I'm open to pretty much any ideas...

Bean

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-04-08 10:36
    Bean,

    At that time scale, you need to define what you mean by "detect." In your scenario, which uses an output, there's an added uncertainty due to signal propagation within the Prop itself, as well as rise time on the output line. At that point, I doubt that a direct measurment would be very meaningful.

    OTOH, I suppose you could use a large sample of random inputs to create a histogram and characterize the internal delays that way. One of the smaller readings could then become a bias factor which you subtract from subsequent readings.

    -Phil
  • LawsonLawson Posts: 870
    edited 2013-04-08 17:08
    Bean wrote: »
    I need to measure the time between when an input signal goes high, and the time that the Propeller detects it.
    This could possible be from 0 to 12.5nSec. I want to measure it to 1pSec resolution (I know I don't ask for much). But 10pSec would be okay.

    The only thing I can think of is to use a counter in the feedback mode. So that when the propeller detects the signal another pin will change one propeller clock later.
    This will give a pulse between 12.5nSec and 25.0nSec.
    Then I could use this pulse to charge a cap through a low resistor value (220 Ohms), then measure how long it takes the cap to discharge through a high resistor value (220K).
    This kind of works, but the values are log not linear, in other words short pulses are stretched more than long pulses since the cap charging/discharging is a log function.
    Also the measurements are rather jittery too.

    So I was just wondering if anyone had any slick ways to measure this ?
    I'm open to pretty much any ideas...

    Bean

    Not asking for much :P I assume you don't have access to a 1GHz oscilloscope? Because it should be able to get close to 10pS timing resolution. I'd say you'd need a fast/stable XOR gate to generate the pulse. Stability wise this is getting into Micrel AnyGate territory but I'd try over-volting a fast 1.8v CMOS logic gate before messing with CML logic.

    To get around the log function of a RC charge/discharge you could replace it with an op-amp integrator. I don't think single nano-second response is needed on the integrator, but it wouldn't hurt. (200-400MHz bandwidth is likely enough) I'd also use an "ideal diode" circuit to define the idle voltage of the capacitor/integrator. The added precision will let you measure short pulses better. Ideally you'd then use an analog switch to switch between a charge and discharge resistor on the integrator. But all the ones I've seen are marginal speed wise. I.e. something like a ts3a4741 (might be able to abuse a single gate inverter to fill in for a switch) In the end, it may be simpler to throw a lot of bias voltage at the charge and discharge resistors so that the charge level of the timing capacitor has less effect.

    Anyway, you're only going to approach that level of timing precision with relative measurements. Even bending cables is likely to make 1pS delay changes and I'll guarantee that this circuit will be a good thermometer. A stable temperature will be required to get the precision you want.

    Lawson
  • BeanBean Posts: 8,129
    edited 2013-04-08 17:35
    Lawson,
    Thanks for the ideas.
    I'll have to try the "AnyGate" devices.

    Bean
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2013-04-08 18:09
    Hi Bean;

    What exactly are you trying to do?
    The Propeller can't possibly be stable enough to do this?

    Duane J
  • jmgjmg Posts: 15,173
    edited 2013-04-08 18:58
    Bean wrote: »
    This kind of works, but the values are log not linear, in other words short pulses are stretched more than long pulses since the cap charging/discharging is a log function.
    Also the measurements are rather jittery too.

    Is this single short, or repetitive ?

    You can solve the linearity, by using scaled current sources, in the simplest form PNP and NPN devices, as current mirrors.
    I see Intersil have HFA3096BZ, which is UHF array : PNP and NPN at ft 5.5GHz and 8GHz.

    I'd try a couple of fast. tinylogic (schmitt) as the Timing element, & Fast XOR gate, like a 74AUP1T57/58/97/98 - as you want no other GND/VCC noise sources.


    I've also seen RF Diodes (schottky) used for current steering, (HSMS-2865?) so that might give some cost trade off on UHF transistors.
    You need lowest possible stray C, and these RF parts all need 'ESD paranoid' handling.
    You might want a 3-state design : Charge, discharge and a hold until next charge.
    A resistor in series with the integrate cap, will ensure the high drive charge phase, gets over the Schmitt threshold.

    Might need a couple of test PCBs made, to determine your noise floor LSBs.


    You can also buy delay lines, OnSemi & Micrel have 1024 tap models, with 10ps taps
  • jmgjmg Posts: 15,173
    edited 2013-04-08 19:49
    I've found the data brief of a part I remembered could be good for this sort of problem...
    It is a TI part, a TPL7200, but I suspect it is vaporware... ?

    1FEATURES
    • Supply Voltage: 2.0V to 3.7V TSSOP - PW PACKAGE
    (TOP VIEW) • Time Sensing
    – LSB 52ps (typ)
    – Accuracy 200ps (max)
    • SPI Host Interface for Configuration and
    Register Access
    • Measurement Range:
    – Mode 1: 10ns to 167μs
    – Mode 2: Power Save Mode
    250ns to 8.2ms With CLOCK = 8MHz
    • Low Quiescent Current
    – TDC running: 1.2 mA (typ)
    – TDC off, Clock Counter on: 200 μA (typ)


    The figures given suggest it has a 15 bit counter, and maybe a /100 prescaler option.
    Something like this could be given a CAL pulse, to check its actual delay quanta.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-09 02:29
    We discussed the internal gate delays at one point a year or so ago. Kuroneko and I were part of that discussion with Chip. It is in one of the threads.
    IIRC Chip said that there is about 3-3.5ns delay depending on which pin and which cog. I don't think you can expect the accuracy you are requiring. There will no doubt be variation in chips from different parts of the wafer as well. BTW This is just a quick reply without totally reading/understanding what you require.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-09 03:04
    1pS, whoa.

    In 1pS a signal will travel about 3mm.
  • BeanBean Posts: 8,129
    edited 2013-04-09 05:15
    It is a single event that I need to measure.

    Here is what I am using so far:
    ' Pulse Expander
    '  Use on a modified Propeller Demo board
    '  Modify microphone circuit by:
    '   Remove microphone (it is socketed)
    '   Remove 10K pullup next to microphone
    '   Install a short for the 0.1uF cap
    '   Connect bottom microphone pin to PIN 0 with a 100 ohm resistor
    '
    DEVICE P8X32A, XTAL1, PLL16X
    FREQ 80_000_000
    
    Baud         CON "T115200"
    
    PulsePin     PIN 0 HIGH
    SensePin     PIN 8 INPUT
    DrivePin     PIN 9 OUTPUT
    PCTX         PIN 30
    
    time         VAR LONG
    value        VAR LONG
    lastValue    VAR LONG
    ascii        HUB STRING(15)
    
    PROGRAM Start
    
    Start:
      INPUT PulsePin
      time = CNT + 80_000_000
      COUNTERA 72, SensePin, DrivePin, 1, 0 ' Keep cap at threshold voltage (1.65V)
    
      DO
        WAITCNT time, 80_000_000 ' Get reading 1 time a second
        
        OUTPUT PulsePin ' Create a quick pulse
        ' NOP ' Add NOPs to lengthen pulse by 50nSec
        INPUT PulsePin
        
        lastValue = CNT ' Get count
        WAITPNE sensePin, sensePin ' Wait until sense pin goes low
        value = CNT ' Get count
        
        value = value - lastValue  ' Compute time elapsed
        
        ascii = STR value, 10, 3 ' Convert to ascii
        ascii = ascii + 13 ' Add a carrage return
        SEROUT PCTX, Baud, ascii ' Send to serial terminal
        
      LOOP ' Forever
    END
    
    

    Here is the values I get:
    Input          
    nSec            Count         pSec Resolution
    -------         ---------     --------
    500             12345         40.50
    450             12027         37.42
    400             11632         34.39
    350             11146         31.40
    300             10540         28.46
    250              9768         25.59
    200              8782         22.77
    150              7503         19.99
    100              5793         17.26
    50               3440         14.53
    
    The value are pretty stable but do move around about +/- 4.

    Bean
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-09 06:52
    don,t know if this is what you want, but you might get an idea....


    the software logic analyzer in propforth may do what you want. it can trigger off any pin or pins, rising edge falling edge, hi or lo


    time period and scale are user controled.


    ranges are 1 to 40 clcok cycles (one cycle needs 4 cogs, 40 cycles uses 1 cog) using cog memory; 41 cycle and greater uses hub memory

    The instructions are in PROPFORTH.HTM included in te download. I have a silly kids oriented walkthrough on the wiki pages

    http://code.google.com/p/propforth/wiki/LogicAnalyzerLAC

    If you application is too big to fit LAC , you can try having a secnd prop chip running LAC and physically piggy backing on your application prop. Sal does this, but I haven't.
  • BeanBean Posts: 8,129
    edited 2013-04-09 11:35
    prof_braino, The goal is to time a pulse much better than 1 cycle.

    I've been experimenting and it looks like measuring a single pulse width to within 10pSec may be doable without getting too complicated.

    Bean
  • Mark_TMark_T Posts: 1,981
    edited 2013-04-09 13:38
    Heater. wrote: »
    1pS, whoa.

    In 1pS a signal will travel about 3mm.

    No, about 150um to 200um - given realistic dielectrics.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-09 13:50
    Did I misplace an order of magnitude there? It's even worse than I thought.
  • jmgjmg Posts: 15,173
    edited 2013-04-09 15:23
    Bean wrote: »
    It is a single event that I need to measure.

    This is an interesting problem - expanding time, by charge difference, so I ran up a linear version in Spice.


    Expanding time, by charge difference :
    This works by charge of a Cap with a high (known) current, in a short but unknown time, and then discharges with a known much lower current, and times how long that needs.
    If the currents have a 1000:1 ratio, you get 1000:1 time expansion. and a 12.5ns LSB can 'magnify' to represent a 12.5ps LSB.

    The waveforms show charge(zoomed), and discharge phases.

    R2 ensures the schmitt hyst is overcome. Q1 & Q2 are in the same package/matched, lowest Ccb/rf devices, used in Common Base.
    Q2+U3 are there simply to track Q1, and give a precise, linear discharge current.
    Q1.re is gated via the Schmitt Comparator, so the discharge ceases on 'time up', and holds the value, for the next Charge (user injected)
    This auto zeros on the threshold point. The C value is not part of the equation, but it will be chosen to give the largest practical dV.
    D1 reduces the swing on Vee, and C2 compensates for Cd and Cbe, to give a clean start to current.

    A M-LVDS Comparator might also work, but is more expensive.


    Q1 enables during the charge time, but the current ratios are very large, and if Q1 enable is inside the minimum time, it is a fixed and small error.
    Charge UP, for now is a pulsed current source, but it would typically be a fast low C PNP device drive by the time window.
    A known pulse width could be used to calibrate out skews in tplh, tphl
  • BeanBean Posts: 8,129
    edited 2013-04-09 18:33
    jmg, That looks really cool.
    I'm lucky because in my application the pulse will always be between 12.5nSec and 25nSec. So I have a much simpler idea.

    I will just use a series resistor and let the PC handle the log to linear math. I also plan to use a propeller generated pulse to calibrate.

    Bean
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-10 06:58
    jmg wrote: »
    This is an interesting problem - expanding time, by charge difference

    This is really interesting. This sounds similar to what laserdeveloper did with his laser rangefinder last year. The phrase "expanding time" drew a lots of calls of "BS". It came out to be accurate to a couple centimetres up to a half mile.

    But he said there was a problem with noise, so he had to take multiple readings and average them. I think he did ten per second. Displaying the reading on the second every second was the slowest part, as I recall.

    So how fancy does the circuit have to be to make this work with a single pulse? Is this in the realm of something a hobbyist n00b can do? What if I enlist the aid of the local hackerspace, who can design their own circuits and etch custom surface mount boards?

    Should this be a separate thread?
  • jmgjmg Posts: 15,173
    edited 2013-04-10 14:09
    This is really interesting. This sounds similar to what laserdeveloper did with his laser rangefinder last year. The phrase "expanding time" drew a lots of calls of "BS". It came out to be accurate to a couple centimetres up to a half mile.

    But he said there was a problem with noise, so he had to take multiple readings and average them. I think he did ten per second. Displaying the reading on the second every second was the slowest part, as I recall.

    Of course, you are pushing down into the noise floor, and jitters and skews all work against you.
    If you can average, you certainly should do that.
    Also on any sort of echo system, the echo itself is going to be low level, and very noisy.
    So how fancy does the circuit have to be to make this work with a single pulse? Is this in the realm of something a hobbyist n00b can do? What if I enlist the aid of the local hackerspace, who can design their own circuits and etch custom surface mount boards?

    The simplest possible expand-by-charge-balance is two resistors(maybe 1000:1), and a cap, and some form of analog gate (Diode/analog SW/Open Drain/open collector).
    That is non linear, but as Bean is doing, that can be 'fixed-later' - it does gain points for simplicity.


    The issues are the same as for classic Dual Slope voltmeters, and if you wanted true single shot, you need to add an Auto-zero state, so you know the Cap is starting from exactly the end-of-charge threshold (ie zero point).
    In the circuit above, the circuit tristates when it hits the threshold, but you cannot wait too long floating without adding errors.

    In a Prop, you could add the Auto zero state in SW, and use the pin threshold as the comparator, for all modes.

    It would help to choose the 'quietest pin', and maybe even GND the lead frame either side, and shut down as much as possible during the measure cycle.

    Injection devices ? - perhaps '3357 Analog Switch (this uses 2 select pins to do Edge and On/Off in one package), or

    I am favouring a 74AUP2G38 - 2 IP pins and open drain (2.3ns, 0.9pF), and the Dual Gate nature opens the door to doing current control via Vdd.
    You would use one half always on, and DC regulate Vcc to give a reference current, and expect the other half to track that,
    or you could just use a load resistor, applying KISS.

    Another benefit of the 2Gate, is you can use one to inject a CAL signal, so do not need to add multiplexers to the critical signal path.
    The 74AUP2G38 includes schmitt IPs & wide Vcc tolerance, so you could use this to create fine delays for testing.
    Plenty of scope for tests, using a cheap and simple part.
  • LawsonLawson Posts: 870
    edited 2013-04-11 16:39
    Cool circuit Jmg. Making current mirrors with RF transistors nicely avoids needing a fast op-amp integrator to get linear charge and discharge. The 74AUP2G38 also looks like an excellent fast input gate with an open collector output. It'd be nice if someone made a similar XOR gate. Though I think that a SN74AUP1G99DCTR configurable gate could be configured to act as a Schmidt triggered open collector XOR gate.

    Bean: please keep the forum up to date on your progress. I've made several boards that measure the buildup time of a Q-switched laser and I'd love to have 100pS to 1nS resolution. I'd also look at correcting the output of the sub-clock measurement circuit on the Prop. It shouldn't be too hard to generate a 50-100 entry look up table and interpolate the true delay from that.

    Lawson
  • jmgjmg Posts: 15,173
    edited 2013-04-11 17:54
    Lawson wrote: »
    The 74AUP2G38 also looks like an excellent fast input gate with an open collector output. It'd be nice if someone made a similar XOR gate. Though I think that a SN74AUP1G99DCTR configurable gate could be configured to act as a Schmidt triggered open collector XOR gate.

    Yes, but you would need two, one for XOR (or almost any 2 pin logic operation) and one using /OE as an Open Drain buffer.
    A benefit of such a gate, is you can try various combinations quite easily.

    However, an important detail of using a Twin Gate (2Gxx Open Drain, is you can use one channel as the reference in a current mirror, and should get same-die tracking performance.

    Spice says an LM317 style regulator as a current injector, works quite well on a Pair of N-FETS Current Mirror.
  • jmgjmg Posts: 15,173
    edited 2013-04-14 16:14
    On the Topic of universal gates and Open Drain, I see Fairchild have just added some new Universal gates with Open Drain :

    1G56/1G59/1G95/1G96

    only minus, is the package is leadless MicroPak, so not practical for low volume use.
Sign In or Register to comment.