Shop OBEX P1 Docs P2 Docs Learn Events
Just not getting it... — Parallax Forums

Just not getting it...

WolfbrotherWolfbrother Posts: 129
edited 2011-01-09 09:58 in Propeller 1
So I am trying to understand the RFID/RFID test module available in the OBEX. I'm going through the manual and using serial debug to output, but I don't understand something and I think it's probably so obvious to most. In the code snippet below, I understand that time:= cnt is to make the repeat occur on entry, but I don't understand how this doesn't make the debug lines come out repeated since there looks like at least one second that the repeat should, well, repeat. But it only prints out on the screen once. How does this work?

Then I'm a bit lost on how the time += clkfreq * 2 at the end works is that adding two seconds, so when you subtract it from cnt you again have a second of repeating like before?

Sorry to be obtuse, I'm just not getting it.

Thanks in advance,

Dave
  time := cnt
  REPEAT
    REPEAT WHILE (cnt - time < clkfreq)  ' this should get figured out....
      IF (output)
        DEBUG.bin(output, 2)          ' output shows whether a key was a match or not
        DEBUG.str(string(" - "))
        DEBUG.dec(tag_ret)            ' this is the match id, what you will pass to the main program
        DEBUG.tx($D)                  ' Carriage return for neatness        
        
        REPEAT i FROM 1 TO 10         ' this little section here outputs the actual tag id
          IF (outtag[i] > 31)        
            DEBUG.tx(outtag[i])       
          
        DEBUG.tx($D)                  ' Carriage return for neatness
        output := 0                      ' clear output so we know when a new key has arrived
    time += clkfreq * 2               ' this means time = time + clkfreq*2
    RFID.disable
    
    waitcnt(clkfreq + cnt)            ' wait a second
    RFID.enable

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-01-08 20:31
    When you post code, please place the code between code tags.

    They look like this except remove all the spaces I placed inside the brackets.

    [ CODE ]

    [ / CODE ]
    That way
       your indentation 
          is preserved
    
    
  • WolfbrotherWolfbrother Posts: 129
    edited 2011-01-08 20:34
    Thanks. It looks much better.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-01-08 20:48
    It seems a little weird to me, too.

    Would it help to see the REPEAT WHILE statement looking like this:

    REPEAT WHILE (cnt < (clkfreq + time))
  • WolfbrotherWolfbrother Posts: 129
    edited 2011-01-08 20:57
    Either way, it seems to me that there would be more than enough time for repeated debugs, but there isn't. I just don't get it.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-08 22:09
    Do you have a link to the code?

    Bruce
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-01-08 22:14
    Does setting output := 0 lower in the code cause the IF(output) statement to get skipped for a while?
  • idbruceidbruce Posts: 6,197
    edited 2011-01-08 22:23
    Wolfbrother

    You may have plenty of time, but you have conditions going on there. It will only repeat if

    cnt - time less than clkfreq

    And it will only debug if there is output

    IF (output)

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-01-08 22:29
    time := cnt Value is set

    time += clkfreq * 2 time gets added to clkfreq *2 and then that value goes back into the time variable

    But yes 2 secs is getting added to the time variable


    Bruce
  • WolfbrotherWolfbrother Posts: 129
    edited 2011-01-09 09:58
    Thanks everyone, I knew it was something simple. I was all hung up on the timing and missed that output changes in the program called. I commented out output in this program and it did run away like I thought it would. Now I can figure out how to merge this program with Chip's singing program and put out different notes based on which RFID tag is scanned and my project will be complete. I imagine there will be a few more questions I post in the next day or two, it helps so much to have this forum.

    Thanks again,

    Dave
Sign In or Register to comment.