Shop OBEX P1 Docs P2 Docs Learn Events
Measure Pulse Width — Parallax Forums

Measure Pulse Width

HumanoidoHumanoido Posts: 5,770
edited 2010-09-10 02:22 in Propeller 1
I have the Parallax Demo Board toggling pin 0 and want to measure the pulse width to determine the execution speed of a program (instructions per second). How to do this without an oscilloscope? Thanks in advance.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2010-09-09 08:00
    Try the jm_freqin object from OBEX.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-09 08:06
    If you're not using all the cogs, you can run a program in one of the cogs to measure the pulse width. How you display the result depends on what other resources you have available. You could use the LEDs on the VGA port or use the TV output ... lots of choices.

    One cog can "watch" the I/O pins used by another cog because the INA register reflects the state of the I/O pin itself. Probably the easiest way would be to use one of the cog's counters to give you the number of system clocks while the specified input pin is high. The program in the cog would set up the counter and wait for the input pin to go from high to low. It would then read and reset the counter's PHS register and use that as the pulse width.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-09-09 11:14
    Heater. wrote: »
    Try the jm_freqin object from OBEX.
    Heater, are you sure this is in the OBEX? I did find _Freq_counter.zip which probably does the same frequency counting on a square wave.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-09-09 11:23
    Mike Green wrote: »
    If you're not using all the cogs, you can run a program in one of the cogs to measure the pulse width. How you display the result depends on what other resources you have available. You could use the LEDs on the VGA port or use the TV output ... lots of choices.

    One cog can "watch" the I/O pins used by another cog because the INA register reflects the state of the I/O pin itself. Probably the easiest way would be to use one of the cog's counters to give you the number of system clocks while the specified input pin is high. The program in the cog would set up the counter and wait for the input pin to go from high to low. It would then read and reset the counter's PHS register and use that as the pulse width.
    Hi Mike, thanks, I like the idea of using a cog's counter and will try this. For output, I have 32 LEDs, one on each pin. The count can be represented by a binary variable output to the LEDs. What is the method to translate the variable number to the binary lights is my next question. I think this should be easy but cannot think of a method.
  • Heater.Heater. Posts: 21,230
    edited 2010-09-09 11:32
    Object 479:

    http://obex.parallax.com/objects/479/

    I used frequency_counter for timing ZiCog execution once, worked well.
  • anhingusanhingus Posts: 10
    edited 2010-09-10 02:22
    if you want to do it in hardware, shape your pulse with a 74LS14 schmitt trigger making a flipflop do its thing. pulse leading edge set, trailing edge reset. measure the time the flipflop is high. maybe 50-cents for the chips.

    if you use the schmitt, make sure you put a .01 mfd cap across the power and ground pins of the chip. tie all unused inputs to ground. measure as you will, but external frequency meter is a good idea. 1/frequency gives you the time period.

    if you are using leds for binary value outputs, use the windows accessory calculator for conversion, scientific mode.
Sign In or Register to comment.