Shop OBEX P1 Docs P2 Docs Learn Events
SX/B pulsin command — Parallax Forums

SX/B pulsin command

RsadeikaRsadeika Posts: 3,837
edited 2005-12-02 02:09 in General Discussion
Not sure how to ask this question.

Example:
· pulsin irpin, 0, irpulse
· if irpulse > 240
····· ' do something
· endif

In this case, at SX28 freq 4_000_000, the 240 value is 2.4 ms (?). Now, will this be affected by a freq change, and if so, does anybody have a handy-dandy formula for comming up with the correct numbers when the freq is changed.

Thanks

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-25 18:00
    No, it will not be affected by a FREQ dirctive change. When you recompile at the new setting the timing of PULSIN is adjusted accordingly (use Ctrl-L to look at the compiled output for both settings, you'll see the difference). No matter the FREQ setting, the output resolution of PUSLIN is 10 uS units (so you can fit the result into a byte).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • RsadeikaRsadeika Posts: 3,837
    edited 2005-11-30 22:46
    A revisit of this commnd.

    In the code below, what I am expecting is, goes to pulsin command sub, times out, turns the LED on and off, and keeps repeating. Now, what is ocurring is that the LED does not turn on, means it never got out of the pulsin sub? I tried it with temp1 = 0, that did not do anything for me. So, I tried pushing a button on the remote, and the LED did turn on. My question is, when the program gets to a pulsin, does the program just hang there until it times itself out, or does it just wait until something occurs on the pin (IR demodulator in this case). I thought I read that their is supposed to be a 50 ms time out.·In my program did I insert something weird.

    I just tried it in a stand-alone, and the program works as expected. As soon as I give it power the LED starts to go on and off. Something weird is going on, in stand-alone it works as expected, with SX-key it just hangs there (I hope I did not mess up my board).

    Any comments will be appreciated.

    Thanks

    ******code
    ' =========================================================================
    '
    '·· File...... Test4.sxb
    '·· Purpose... SX/B Programming Template
    '·· Author....· Ray Sadeika
    '·· E-mail....·
    '·· Started...
    '·· Updated...
    '
    ' =========================================================================

    '
    ' Program Description
    '

    '
    ' Device Settings
    '
    DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX
    FREQ··········· 4_000_000

    '
    ' IO Pins
    '
    · irpin var rc.0
    · led1 var rb.0
    '
    ' Constants
    '

    '
    ' Variables
    '
    ·· temp1 var byte

    ' =========================================================================
    · PROGRAM Start
    ' =========================================================================
    '
    ' Subroutine declarations
    '
    ·ledon sub
    ·getsome sub
    '
    ' Program Code
    '
    Start:
    ·' PLP_A = %0000
    · 'PLP_b = %00000000
    · 'PLP_c = %00000000
    ·' temp1 = 0

    Main:
    ·do
    ·getsome·· 'Get a pulse reading
    ·ledon···· 'Turn the LED on/off
    ·loop
    END

    GetSome:
    ·pulsin irpin, 0, temp1
    return

    ledon:
    ·TRIS_b = 0
    ·led1 = 0
    ·pause 1000
    ·led1 = 1
    ·pause 1000
    return
  • RsadeikaRsadeika Posts: 3,837
    edited 2005-12-01 22:43
    Maybe I am reading something incorrectly in the manual. For the pulsin command, it states, "PULSIN will wait for the desired pulse, ... If it sees the start of the pulse, or the pulse is too long ... PULSIN 'times out' ... This operation keeps your program from locking up should the desired pulse never occur." Now, in my short program in the previous post, I think that the PULSIN command is doing just that, locking up. Is their a bug in the PULSIN command or am I using the·programming structure·incorrectly.

    The way I have my program setup, the PULSIN command is supposed to time out and move on to the next step, which it does not. Anybody else run into a problem like this.

    Any comments will be appreciated.

    Thanks
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-02 02:09
    Nope, Ray, you found a problem -- we're working on a fix now.

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