Shop OBEX P1 Docs P2 Docs Learn Events
What's a good way to convert an 8.2 usec Propeller pulse into a 1 usec pulse? — Parallax Forums

What's a good way to convert an 8.2 usec Propeller pulse into a 1 usec pulse?

ElectricAyeElectricAye Posts: 4,561
edited 2011-06-20 02:00 in Propeller 1
I would like to take the 8.2 usec pulse produced by the Propeller chip (generated by the PWM object) and convert it into a shorter pulse of about 1 usec (or maybe even less) to serve as a trigger for another circuit. My first thought is to differentiate the pulse from the Propeller by placing a capacitor on the line(???) and then feed that to a one-shot, monostable circuit made from a high speed 555 chip.

Does this approach make sense? Or would I need to build it from discrete components?

Also, I would like to be able to vary the short pulse width, even if done manually.

Any way I could get the pulse width down to 100 nsec while I'm at it?

Thanks!

Comments

  • markaericmarkaeric Posts: 282
    edited 2011-06-19 08:43
    Bit banging at 80MHz should give you those 100ns pulses, but you wont be able to do anything else with that cog if those pulses have the be continuous. Bit banging at 1us resolution should be no problem (Dunno about that PWM object).
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-06-19 08:53
    markaeric wrote: »
    Bit banging at 80MHz should give you those 100ns pulses, but you wont be able to do anything else with that cog if those pulses have the be continuous. Bit banging at 1us resolution should be no problem (Dunno about that PWM object).

    I see what you're saying, but in my case I need to space the 100 nsec pulses by time intervals ranging from about 100 msec to about 10 msec. Is that possible by straight bit banging? Or maybe some combination of bit banging and other delays?

    Thanks!
  • idbruceidbruce Posts: 6,197
    edited 2011-06-19 08:59
    ElectricAye

    This should give you 1us pulses. 1us high and 1us low.
    PUB GiveUsMicroSecondPulses(PulsePin) | Counter, OneMicroSecond
     
      CTRA[30..26] := %00100
      CTRA[5..0] := PulsePin
      FRQA := 1
      DIRA[PulsePin]~~
      Counter := CNT
      OneMicroSecond := CLKFREQ / 1_000_000
      REPEAT
        PHSA := OneMicroSecond
        WAITCNT(Counter += OneMicroSecond)
    

    EDIT: That's not what you wanted is it?

    I remember reading somethiong about the counters where you can get some unbelievably high pulse rate. I think it was in PE Fundamentals under counters
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-06-19 09:52
    idbruce wrote: »
    ...
    EDIT: That's not what you wanted is it?...

    Bruce, that's correct. I guess I should have said something about that early on. That irritating need for spacing out the very short pulses is what's confounding me. I basically need a pulse generator with delays that are long relative to the ~100 nsec width of the pulses. Thanks for giving it a shot, though. There are so many ways to skin the cat on the test and I keep churning all of this around in my head trying to figure out a strategy that I, personally, can do. Sorry for not being clear on the requirements. For me, the problem still isn't well define.
  • idbruceidbruce Posts: 6,197
    edited 2011-06-19 10:06
    Where are those 100 nanosecond pulses coming from? Or going?
  • AribaAriba Posts: 2,690
    edited 2011-06-19 10:26
    With a Propeller Counter in DUTY mode you can generate a delay of up to 27 seconds and then one short 12.5 ns pulse if you want.
    With a software delay and a counter in NCO mode you can generate pulses as short as 12.5ns (10ns with 100MHz) or any multiple of that.

    Andy
  • idbruceidbruce Posts: 6,197
    edited 2011-06-19 10:29
    @Andy - I remember seeing something to that affect with counters. I am still not sure just exactly what he is trying to accomplish.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-06-19 10:32
    I'm no counter guru at all almost the opposite. But why shouldn't you be able to do bitbanging combined with waitpeq / waitpne
    and with a second cog doing the longterm timing triggering the waitpeq / waitpne?

    Indeed if you would tell what you want to do in the end more or better solutions can be found.

    keep the questions coming
    best regards

    Stefan
  • idbruceidbruce Posts: 6,197
    edited 2011-06-19 10:34
    Stefan I just got finished finding a discussion where pjv was having problems with that techinique and nanoseconds.

    Bruce

    EDIT: Or something to that effect. I did not read the whole discussion
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-06-19 12:34
    idbruce wrote: »
    Where are those 100 nanosecond pulses coming from? Or going?

    I was guessing that the pulses would be triggered by the Propeller but restricted to a narrow pulse width by probably some other external circuit. But, certainly, if the Prop can output a 12.5 nsec pulse and I can get a long 10msec delay between those pulses, then I think I would be in good shape. The pulses are meant to trigger a mosfet that controls 10 amps or so of DC current, which fires a bank of IR LEDs.

    Ariba wrote: »
    With a Propeller Counter in DUTY mode you can generate a delay of up to 27 seconds and then one short 12.5 ns pulse if you want.
    With a software delay and a counter in NCO mode you can generate pulses as short as 12.5ns (10ns with 100MHz) or any multiple of that.

    Andy, I will have to go back and read all the stuff about what counters can do. I know I rarely use even a fraction of their capability. If you are correct about this, and it's that easy, then we will be erecting stone monuments in your honor. Thanks so much for the suggestion.

    StefanL38 wrote: »
    ...

    Indeed if you would tell what you want to do in the end more or better solutions can be found.
    ...

    Stefan,
    the purpose of this device is to control the output of a bank of IR LEDs. The concept is to keep the average light output per 10 msec time frame the same, but the width of the pulses and their height will change. In other words, as the pulses get shorter, they will get higher, and the total (integrated) area of the (pulse width)x(pulse height)x(total number of pulses per 10 msec) stays the same. So, integrated over time, the same number of photons will hit the target (which is a photosynthetic bacteria) but the behavior of the bacterial photosynthetic complex will be challenged due to the ever-shrinking pulse width. The intensity of the pulses will be governed by a circuit totally separate from the one governing the pulse width.

    You guys have helped me out a lot here. I need to do some homework and explore your suggestions. Thanks again!
  • idbruceidbruce Posts: 6,197
    edited 2011-06-19 15:48
    @ElectricAye
    Andy, I will have to go back and read all the stuff about what counters can do. I know I rarely use even a fraction of their capability. If you are correct about this, and it's that easy, then we will be erecting stone monuments in your honor. Thanks so much for the suggestion.

    I believe I said something very similar before he did, I just did not know how high. I want a stone monument also :(
    I remember reading somethiong about the counters where you can get some unbelievably high pulse rate. I think it was in PE Fundamentals under counters
  • AribaAriba Posts: 2,690
    edited 2011-06-19 18:06
    idbruce wrote: »
    I believe I said something very similar before he did, I just did not know how high. I want a stone monument also :(
    ...but mine must be bigger !

    Reading all about the counters may take too long and you will not have enough time for the monument(s), therefore here a Spin code that shows the use of the counters for short pulses:
    CON  _clkmode  = xtal1 + pll16x
         _xinfreq  = 5_000_000
    
         OUTPIN = 16  'pin number
    
    VAR  long us, pwidth, timer
    
    PUB Main
      us := clkfreq / 1_000_000
      ctra := %00100 << 26 + OUTPIN   'counter in NCO mode
      frqa := 1
      dira[OUTPIN] := 1
      timer := cnt               'init timer
      repeat
        pwidth := 8              '100ns pulsewidth (8*12.5ns)
        timer += 10_000 * us     '10ms delay time
        waitcnt(timer)           'wait the delay time
        phsa := -pwidth          'generate out-pulse
    
    The delay time and pulswidth are hold in variables and are calculated first, so it should be easy to modify it for your needs.

    How the pulse generation works:
    A counter in NCO mode outputs the state of the highest bit of phsX to the output pin. If you set frqX to 1 then phsX is incremented with 80MHz. As long as phsX is positive the pin is Low, when it overflows to negative the pin is High.
    The code above just writes a little negative value (-8) to phsa so the pin gets high, then after 8 clock pulses phsa overflows to a positive value and the pin goes low. The counter still counts, but it takes over 27 seconds until the pin will go high again. More than enough time to write new values in phsa.

    Andy
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-06-19 21:19
    idbruce wrote: »
    ... I want a stone monument also...

    Ariba wrote: »
    ...but mine must be bigger !

    You got it. Carving begins tomorrow, pending Congressional approval. You guys are awesome! You deserve much bigger, I know, but this is the best I could do on such short notice:

    800px-Monumentvalley.jpg
  • markaericmarkaeric Posts: 282
    edited 2011-06-20 00:32
    Very cool info on the counters! Since I don't really understand VCOs and NCOs, I misinterpreted this part about the counters in the prop manual:

    For stable operation, it is recommended that the VCO frequency be kept within 64 MHz to
    128 MHz. This translates to an NCO frequency of 4 MHz to 8 MHz.

    I interpreted that as 8MHz max pin toggling rate. My CTRx world had been turned upside down!
  • idbruceidbruce Posts: 6,197
    edited 2011-06-20 02:00
    ElectricAye

    I don't have any way to test the code, but one thing I learned through the PulseTheStepPin function is that you should keep the loop as small as possible when trying to get small pulses. Andy's code may work perfectly fine, but may I suggest altering it to this, just in case:
    CON  _clkmode  = xtal1 + pll16x
         _xinfreq  = 5_000_000
         OUTPIN = 16  'pin number
    VAR  long us, pwidth, timer
    PUB Main | offset
      us := clkfreq / 1_000_000
      ctra := %00100 << 26 + OUTPIN   'counter in NCO mode
      frqa := 1
      dira[OUTPIN] := 1
      
      timer := cnt                'init timer
      offset := 10_000 * us       '10ms delay time
      pwidth := 8                 '100ns pulsewidth (8*12.5ns)
      
      repeat
        phsa := -pwidth           'generate out-pulse    
        waitcnt(timer += offset)  'wait the delay time
    
Sign In or Register to comment.