Shop OBEX P1 Docs P2 Docs Learn Events
SW21-EX17-Freq_Measure-Adv.BS2 - Math & Code — Parallax Forums

SW21-EX17-Freq_Measure-Adv.BS2 - Math & Code

MichelBMichelB Posts: 154
edited 2009-11-30 08:59 in BASIC Stamp
Hi, in this program the constant Scale is $200 (512) for "2.0 µs per unit".
How this value (512) has been found? I tried with 65535 / ?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-11-29 05:39
    How about ATTACHING the program to your next post so we can all see?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • MichelBMichelB Posts: 154
    edited 2009-11-29 08:47
    Please find attached program.

    P.S.: In BSManual-v2.2 page 345, Demo Program (PULSIN.bs2) we can find:

    Scale· CON· $200 (512)· ' 2.0 µs per unit

    Where and how they found the value 512?

    Post Edited (MichelB) : 11/29/2009 1:18:12 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2009-11-29 17:22
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    #SELECT $STAMP
      #CASE BS2, BS2E, BS2PE
        Scale       CON     $200                    ' 2.0 us per unit
      #CASE BS2SX, BS2P, BS2PX
        Scale       CON     $0CC                    ' 0.8 us per unit
    #ENDSELECT
    
    

    If you read the manual the frequency used by the BS2 depends on the type you are using the two frequencies are 2us and .8us and will affect the timing of commands like PULSOUT, baud rate and other timing dependent commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-11-29 17:54
    Bonjour Michel,

    That scale factor is for use with the */ operator.

    $200: 512/256 = 2
    useconds = RCvalue */ scale ' multiplies RCvalue times 2 for BS2, E, or PE

    $CC: 204/256 = 0.796875, call it 0.8
    useconds = RCvalue */ scale ' multiplies RCvalue times 0.8 for BS2SX, P or PX

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MichelBMichelB Posts: 154
    edited 2009-11-30 08:59
    Well understood, merci beaucoup Tracy.
Sign In or Register to comment.