Shop OBEX P1 Docs P2 Docs Learn Events
Why does pulsout double the period — Parallax Forums

Why does pulsout double the period

ArchiverArchiver Posts: 46,084
edited 2003-06-16 00:14 in General Discussion
The period you specify is multiplied by an actual time constant that varies
according to the Stamp you have. See Page 243 of the 2.0c Stamp manual for
more info.

Since you say it appears to double the value, its safe to assume you have a
BS2 or BS2E. The constant for a BS2 / BS2E is 2 us (microseconds) --
multiply this by the period you specified, 210, and this gives you a 420 us
pulse duration.

Original Message

> Ok I already posted and I didn't really get the answer I was looking for.
> I understand that you use pulsout like this:
>
> pulsout 0,210
>
> which would invert p0 for period and then change it back. The time it
> stays inverted is period yes? Ok thats fine but why does it double what
> you give the routine?

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-04-04 22:06
    Because you are specifying the 'Period' (ie the 210 below)
    in 2 uS 'ticks'. That is, a value of '1' gives you a
    2 uS pulse. The value is really how long you want it
    to stay high, in 2 uS units.

    --- In basicstamps@yahoogroups.com, Hudson T Clark
    <dark_archon1@j...> wrote:
    > Ok I already posted and I didn't really get the answer I was
    looking for.
    > I understand that you use pulsout like this:
    >
    > pulsout 0,210
    >
    > which would invert p0 for period and then change it back. The time
    it
    > stays inverted is period yes? Ok thats fine but why does it double
    what
    > you give the routine?
  • ArchiverArchiver Posts: 46,084
    edited 2003-04-05 04:57
    A BS2's PIC platform can't crank instructions fast enough to change
    the output status of a pin, increment a 16-bit timer, check for timer
    expiration, loop if necessary or alternatively reverse the output
    state on a pin all within 1 usec. Doing all the above with 2 usec
    resolution is no mean feat.

    Another nice thing about the PULSOUT implementation is that it allows
    you to specify a 17-bit value (albeit always even) with a 16-bit
    argument. So even though PBASIC doesn't deal with numbers greater
    than 65,535, you can indirectly specify a 131,070 usec pulse.

    Steve

    On 15 Jun 03 at 15:16, Hudson T Clark wrote:

    > Ok I already posted and I didn't really get the answer I was looking
    > for. I understand that you use pulsout like this:
    >
    > pulsout 0,210
    >
    > which would invert p0 for period and then change it back. The time
    > it stays inverted is period yes? Ok thats fine but why does it
    > double what you give the routine?
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 23:16
    Ok I already posted and I didn't really get the answer I was looking for.
    I understand that you use pulsout like this:

    pulsout 0,210

    which would invert p0 for period and then change it back. The time it
    stays inverted is period yes? Ok thats fine but why does it double what
    you give the routine?
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-15 23:49
    Makes it very clear thanks.
  • ArchiverArchiver Posts: 46,084
    edited 2003-06-16 00:14
    Yeah I read the documentation and it makes more sense now... you aren't
    really even giving it a time you are giving it how many units of the
    specific stamps time unit is. =)

    In my case I'm using the bs2 so yeah... hehehe... one unit is 2us.
Sign In or Register to comment.