Shop OBEX P1 Docs P2 Docs Learn Events
confusing numbers — Parallax Forums

confusing numbers

Jayguy5000Jayguy5000 Posts: 139
edited 2005-10-11 23:04 in BASIC Stamp
in the book, IRremoteBoeBot there is the following paragraph

Inside the DO…LOOP, the program executes the command PULSIN 9, 0, time, which
measures pulses. Whenever a pulse duration is between 975 (1.95 ms) and 1425 (2.85
ms), the IF…THEN…ENDIF code block increments the counter variable and displays the
counter and time variables under the Repetitions and Current Duration headings. <~~~pg 13

how does 975 = 1.95 mS and 1425 = 2.85 mS ???
I cant figure it out to save my life...
~Jeremy

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-10-11 15:23
    If you look at the Help file under PULSOUT you will see that the increment of time for the BS2 is 2 ms.· So if you say

    PULSOUT 1.........

    You are actually send a 2ms pulse.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2005-10-11 15:25
    yea i found the answer slighty after i asked the question it hit me,
    not to be dinky but its 2 uS "units"...
    thanks for the help.
    ~Jeremy
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-10-11 15:38
    Jeremy -

    Different Stamp platforms (BS-2, BS-2SX, BS2p, etc) have different operational speeds. By working with "timer units" in the text, the definitions of all the time related commands can be the same. Tables of timer unit values are always found in the text of the PBASIC command definitions. Then it is up to the programmer/user to determine which Stamp platform they are planning to use, and determine the value of the timer unit and apply it appropriately within the program.

    Additionally, since conditional compilation is now available, the programmer could set up a "timer unit template" to plug-in the appropriate constant, as may be required, based on the '{$STAMP } directive (which see). The '{$STAMP ... } directive tells the PBASIC Stamp Editor which Stamp platfom is being used. The values used would come from the published timer unit tables mentioned above.

    Regards,

    Bruce Bates
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2005-10-11 16:35
    so Bruce, If i purchase a BS2px, then maybe the pulsin command would be able to measure in 1uS units instead of 2uS as mentioned above?
  • NewzedNewzed Posts: 2,503
    edited 2005-10-11 16:37
    The BS2p Stamp have an increment of .8us.· That is as close as you're going to get to 1us.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-10-11 20:06
    Jeremy -

    The Table found with the Pulsin instruction tells you everything that you need to know. Here is a copy of it:

    attachment.php?attachmentid=73741


    The BS-2px·timer unit value is .81 µs, and the maximum pulse width is 53.08 ms.

    Regards,

    Bruce Bates
  • Jayguy5000Jayguy5000 Posts: 139
    edited 2005-10-11 23:01
    now the stupid question must be asked becuase currently the code says
    DEC5 time * 2
    becuase the bs2 measures in increments of 2uS,, so if i get a faster stamp would i have to change the code to a more complex formula?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-11 23:04
    Yes, for the BS2sx, for example, you would do this:

    · DEC5 (time */ $CC)

    The */ operator allows you to multiply by fractional values (resolution is 1/256).· $C0 = 0.8.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.