Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Rootin Tootin Fast Pulse Shootin

  1. #1
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193

    Rootin Tootin Fast Pulse Shootin

    Playing with the Teensy 3.2 today, I wondered what would be the fastest output pulse that I could generate.

    Using "120 MHz overclock" and initialising with "pinModeFast(23, OUTPUT)", the following code...

    digitalWriteFast(23, 1); //set pin 23 high
    digitalWriteFast(23, 0); //set pin 23 low

    ... produced this scope display on single shot (load = x10 probe only)...

    Click image for larger version. 

Name:	FastestPulse01.jpg 
Views:	27 
Size:	65.9 KB 
ID:	14742

    Can't guarantee the amplitude calibration, but the pulse duration is impressive.

    (for more info on pinModeFast see - https://forum.pjrc.com/threads/28735...ll=1#post75044)

  2. #2
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193
    And in case you were wondering about T3.6 (at 240 MHz overclock)...

    Click image for larger version. 

Name:	FastestPulse02.jpg 
Views:	28 
Size:	66.1 KB 
ID:	14743

    The limit here is my scope leads bandwidth.

  3. #3
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    582
    Pretty impressive! A while back I was playing around with pulses from a Raspberry Pi and only got about 10 nsec pulse width, and I was also not sure about the capability of the scope to fully resolve the edges.
    https://www.raspberrypi.org/forums/v...3a9819#p495574

  4. #4
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193
    To find a comparison, I made the following breadboard circuit and found that it gave a very similar 5 nS pulse shape to T3.6...

    Click image for larger version. 

Name:	Pulse02a.jpg 
Views:	0 
Size:	15.4 KB 
ID:	14751 Click image for larger version. 

Name:	Pulse02b.jpg 
Views:	6 
Size:	62.4 KB 
ID:	14752

    I now suspect that the actual risetime is much faster than shown in the scope pictures (and being limited by the scope itself). Perhaps someone with a faster scope might investigate. The breadboard circuit relies on the avalanche breakdown of the base/collector junction to produce the pulse. The coax cable has a capacitance of about 25 pF.

    Its worth noting that if a beam of light entered your room window at exactly the same time as the rising edge, then the falling edge could occur before the light beam hit the carpet :-) !!

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    130 volts, really?

  6. #6
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by PaulStoffregen View Post
    130 volts, really?
    That was also my first thought
    The datasheet says collector emitter breakdown voltage 40 V.

    curious to see if it is 13V or US mains voltage.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Quote Originally Posted by TelephoneBill View Post
    Perhaps someone with a faster scope might investigate.
    Here's what I see with my 200 MHz bandwidth scope.

    Click image for larger version. 

Name:	file.png 
Views:	14 
Size:	24.6 KB 
ID:	14753

  8. #8
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    582
    3.8 ns pulse width, that's pretty fast!
    It looks like Table 2.3.2 General switching specifications on p.18 of https://www.pjrc.com/teensy/K66P144M180SF5V2.pdf says the shortest guaranteed valid INPUT pulse on a GPIO pin is more than 10x longer, at 50 nsec.
    Although maybe I'm misreading that, as it would imply you can't receive data faster than 10 MHz at 50% duty cycle and I don't think that's true.

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,466
    Try this with 240MHz (Optimize "Faster") and be amazed ..
    Code:
    void pinModeFast(uint8_t pin, uint8_t mode)
    {
      volatile uint32_t *config;
    
      if (pin >= CORE_NUM_DIGITAL) return;
      config = portConfigRegister(pin);
    
      if (mode == OUTPUT) {
    #ifdef KINETISK
        *portModeRegister(pin) = 1;
    #else
        *portModeRegister(pin) |= digitalPinToBitMask(pin); // TODO: atomic
    #endif
        *config = PORT_PCR_DSE | PORT_PCR_MUX(1); // SRE bit = 0 for fast slew rate
      } else {
    #ifdef KINETISK
        *portModeRegister(pin) = 0;
    #else
        *portModeRegister(pin) &= ~digitalPinToBitMask(pin);
    #endif
        if (mode == INPUT) {
          *config = PORT_PCR_MUX(1);
        } else {
          *config = PORT_PCR_MUX(1) | PORT_PCR_PE | PORT_PCR_PS; // pullup
        }
      }
    }
    
    void setup() {
    
    pinModeFast(23, OUTPUT);
    
    }
    
    void loop() {
    
    digitalWriteFast(23, 1); //set pin 23 high
    digitalWriteFast(23, 0); //set pin 23 low
    // asm volatile ("nop");
    int x = digitalReadFast(23); // <- be amazed!
    Serial.println(x);
    delay(200);
    }
    Output is :
    Code:
    0
    1
    1
    1
    1
    0
    0
    0
    1
    1
    1
    1
    1
    0
    1
    1
    0
    0
    1
    0
    0
    1
    1
    0
    0
    1
    0
    1
    1
    0
    0
    0
    0
    0
    0
    0
    0
    0
    1
    0
    0
    0
    0
    1
    0
    0
    0
    1
    0
    0
    1
    1
    1
    0
    0
    1
    1
    0
    0
    0
    0
    1
    1
    0
    0
    1
    0
    1
    1
    1
    0
    1
    0
    0
    1
    1
    0
    0
    1
    0
    0
    1
    0
    1
    0
    1
    1
    0
    1
    0
    1
    0
    1
    1
    0
    1
    0
    0
    1
    1
    0
    0
    0
    1
    0
    1
    0
    1
    1
    1
    0
    1
    1
    0
    1
    1
    0
    0
    1
    1
    1
    1
    0
    1
    1
    1
    1
    0
    1
    0
    1
    0
    1
    0
    0
    1
    0
    1
    0
    1
    1
    0
    0
    Edit: use (Optimize "Faster")

    Edit: Due to this effect, I've had a problem when trying to read very fast 4-bit parallel from a flash-chip (toggled a pin als "clk"-signal in assembler - I had to insert some "nop", which slowed down it drastically)
    Attached Files Attached Files
    Last edited by Frank B; 09-19-2018 at 07:09 PM. Reason: added hexfile

  10. #10
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193
    Quote Originally Posted by PaulStoffregen View Post
    130 volts, really?
    Yes, you read that correctly - "+130 volts". It doesn't work with a lower rail at +120 volts (at least with my transistor).

    What the circuit relies on is stripping an electron out of the valence band (into the conduction band) which then crashes into another atom and knocking out two. Two becomes four. Four becomes eight... and... you get the idea of the "avalanche". Its a bit like a photomultiplier without the photon. The saving grace is the fact that the discharge then lowers the voltage pretty quickly.

    This avalanche is one of the fastest ways of creating a "switch" with a BJT. Once the cascade is over, then the collector/base junction goes back into normal depletion mode, until the voltage rises again to start another avalanche several microsecs later. Its why I am convinced that the T3.6 signal is being limited by my scope (and your later snapshot confirms - your signal has a square-ish look).

  11. #11
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by TelephoneBill View Post
    The breadboard circuit relies on the avalanche breakdown of the base/collector junction to produce the pulse.
    this statement hinted that 130V is correct, thanks for confirming
    BTW what is the pulse repetition rate?

  12. #12
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193
    The pulse interval is around 5.3 uSec (189 KHz) but a little shaky because the trigger level depends on ambient temperature (thermal energy of an atom being stripped to start the cascade)...

    Click image for larger version. 

Name:	Pulse02c.jpg 
Views:	8 
Size:	65.6 KB 
ID:	14763

    The circuit is interesting. The transistor base is normally switched off (does it ever actually turn on?). The emitter voltage rises because the avalanche drags current up through the emitter/base junction. And you can control the size of the pulse via the emitter resistance.

    When first powered on, the capacitance of the coax inner is not charged (so is zero volts - and the collector too). This capacitance charges on the traditional exponential curve through the 100K resistor, until the electric stress across collector/base is sufficient to start the avalanche. Then the capacitance is rapidly discharged and you get the pulse in the emitter resistor. I guess this is on the faster C x 56R time constant (1.4 nS). If the R was smaller, then we would be talking picoSecs.

    An idea has just occurred to me. The base could be controlled by a Teensy output pin. If switched on (default), then the transistor collector would saturate, drawing about 1.3 uA through 100K (and be in the voltage safe region). When the Teensy pin went low, then the transistor base would turn off and allow the pulse to happen some uSecs later. It may be prudent to protect the pin via a 3v3 zener. But this could generate an even faster pulse than one clock cycle - useful for experiments.

    BTW, Paul's rise time is about 1.3 nS. The bandwidth is normally calculated by B.W. = 0.4 / T (where T is 10/90 edge timing). This gives Paul's scope a B.W. of about 307 MHz actual I conclude.

  13. #13
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    582
    Theoretically speaking, can you make an accurate measure of risetime when you have only a very short pulse, rather than a step? I think it might require additional assumptions like single-pole rolloff behavior. At the frequency limit of the scope, with the probe assembly and the scope internals as well, there might not be a dominant single pole (?)

  14. #14
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    193
    I see your point. Interestingly, I connected the Teensy output directly to the scope BNC (with about 4cm of direct wire), thereby removing the scope probe and leads from the setup. I got a seemingly identical response in the trace (which surprised me).

    Here is a good reference on the topic and puts Pauls's BW slightly lower around 270 MHz - https://www.edn.com/electronics-blog...-its-rise-time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •