Shop OBEX P1 Docs P2 Docs Learn Events
Request help for generation of short pulses on P2 — Parallax Forums

Request help for generation of short pulses on P2

Hello everyone,
any suggestions to generate the shortest possible pulses on P2 ?
many thanks in advance

FX

Comments

  • The obvious code

    drvh #pin_n
    drvl #pin_n
    

    gives a 2 cycle pulse, which is plenty short.

    Then of course there's the appropriately named P_PULSE smart pin mode, which can create pulses of any length. So to create a 1 cycle pulse:

    '' (note: I just scribbled this down without testing it, there may be a mistake)
    ' setup pin
    fltl #pin_n
    wrpin ##P_PULSE,#pin_n
    wxpin #1,#pin_n
    drvl #pin_n
    ' start pulse
    wypin #1,#pin_n
    

    The pulse length is Y*X[15:0] and another pulse can be created by doing another WYPIN

  • RaymanRayman Posts: 14,632

    Is there a way to create a sub cycle pulse? Seems like maybe some trickery with clocked and unclocked pins and some of the smart modes might allow this?

  • A C and a R might do the trick?

  • roglohrogloh Posts: 5,786
    edited 2024-04-22 00:12

    @Rayman said:
    Is there a way to create a sub cycle pulse? Seems like maybe some trickery with clocked and unclocked pins and some of the smart modes might allow this?

    Sounds more like a glitch if it's sub cycle. I vaguely remember a fix put in where there was once some race condition in the P2 between changing the pin's direction control and the pin state at the same time. It might have been during the respin.
    UPDATE: found it... https://forums.parallax.com/discussion/comment/1448595/#Comment_1448595

  • Thanks Wuerfel_21 and everyone for the suggestions,

    at the moment I used code below obtaining pulses of about 5-6 ns with a repetition frequency of about 11.25 MHz,

    It would be interesting to apply the tricks for shorter pulses, so I ask further help and example codes

  • edited 2024-04-22 12:38

    DEBUG

    relaunching the code after an EVAL P2 off, it doesn't work,
    so I made this fix:

    and now repetition frequency increase at 45 MHz

  • RaymanRayman Posts: 14,632

    Yes, definitely want the #
    Surprised it worked without it…

    I think FlexProp will give you a warning if you make that mistake but prop tool does not

  • Wuerfel_21Wuerfel_21 Posts: 5,051
    edited 2024-04-22 12:45

    if you want the fastest repeating pulse, try this (in Spin): pinstart(1, P_NCO_DUTY|P_OE, 1, 1<<31)

  • Wuerfel_21

    YES! 180 MHz

  • @Rayman said:
    Yes, definitely want the #
    Surprised it worked without it…

    in fact it is not clear,
    I was testing variuos code in Spin2 and PASM, probably Propeller Tool had changed some registers that made the code work without the #

  • Notes

    in all measurements I used a 10x attenuated probe, I only just noticed that I set correctly the probe only on the
    first two oscillograms, so the vertical signals amplitudes of the last two oscillograms shown must be multiplied by 10

  • At theese frequencies the quality of the probe, cable and analog frontend of the scope becomes important. Most scopes even with 500MS/s do not display the waveform of a 5ns pulse correctly. To distinguish between a 5ns square pulse and something like a sine half-wave you need at least a true bandwidth of the 5th overtone = 100MHz * 5 = 500MHz.

    You can always make the pulse narrower by a high pass filter followed by a schmitt trigger. But you need a high driver strength, a good layout and matched cable impedances.

    What is the application?

  • @ManAtWork said:
    At theese frequencies the quality of the probe,
    cable and analog frontend of the scope becomes important. Most scopes even with 500MS/s do not display the waveform of a 5ns pulse correctly. To distinguish between a 5ns square pulse and something like a sine half-wave you need at least a true bandwidth of the 5th overtone = 100MHz * 5 = 500MHz.

    certainly, at the moment I am using an oscilloscope with a bandwidth of 200 MHz 500 MS/s, probes have a bandwidth of 250 MHz (in the 10x position) and rise time of 1.4 ns

    You can always make the pulse narrower by a high pass filter followed by a schmitt trigger.

    I agree, I know well because and already I used this tecnique

    But you need a high driver strength, a good layout and matched cable impedances.

    Sure, respecting the transmission line impedance and load is highly recommended

    What is the application?

    Various research

    • Local optical / wire / wireless / data transfer
    • High frequency PWM for power conversion
    • Time domain reflectometer
    • Etc.
Sign In or Register to comment.