Shop OBEX P1 Docs P2 Docs Learn Events
A faster pulsin — Parallax Forums

A faster pulsin

SamTheManSamTheMan Posts: 43
edited 2007-06-05 17:39 in General Discussion
The pulse in command in the SX is slow (the resolution is 10us)
How can I go as fast as 0.8us? just like the BS/SX

Comments

  • JonnyMacJonnyMac Posts: 9,214
    edited 2007-06-05 16:46
    Easy... have a look "under the hood" at the generated assembly code and use it to create a custom function (I've been doing this a lot lately). Remember, the BS2sx has a fixed 50 MHz resonator and SX/B has to generate code that can work down to 4 MHz and lower, hence the decision to use 10 uS for PULSIN resolution.
  • BeanBean Posts: 8,129
    edited 2007-06-05 16:47
    What Jon said... Also initially SX/B only had byte variables, so the pulsin had to have low resolution to avoid overflowing the byte variables when reading servo pulses.
    cnt = 0
    DO ' Wait for pin to go low
    LOOP UNTIL inPin = 0
    DO ' Wait for pin to go high
    LOOP UNTIL inPin = 1
    DO ' count until pin goes low again
      PAUSEUS 0.8 ' You'll have to adjust this value to account for instruction time
      INC cnt
      IF cnt = 0 THEN EXIT
    LOOP UNTIL inPin = 0
    ' cnt now holds the desired value
    

    Bean.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • SamTheManSamTheMan Posts: 43
    edited 2007-06-05 17:39
    it works.
    Thank you very much
Sign In or Register to comment.