Shop OBEX P1 Docs P2 Docs Learn Events
PINK status register — Parallax Forums

PINK status register

John JenkinsJohn Jenkins Posts: 12
edited 2008-06-24 20:54 in BASIC Stamp
I am using a PINK in a project and need to know if a user has updated a variable via the web interface. According to the doc, bit 1 of the PINK status register is set in that event. But if I check the status register in a loop, and while it's running I modify a PINK Variable via the web, the status doesn't change. Does anyone have any suggestions as to how I can make this work?

Thanks!

Comments

  • skylightskylight Posts: 1,915
    edited 2008-06-23 11:53
    As far as i understand the status bit is reset when read, ready for the next time its set
  • John JenkinsJohn Jenkins Posts: 12
    edited 2008-06-23 20:11
    I understand that, but when I read it, it never changes, even if the variables are changed via the web interface.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-23 20:21
    John,

    Are you taking some action when the bit is set or just displaying the value? If you’re just displaying the value it will be cleared and that value will be displayed too fast for your eye to see. Can you post the code you are using to check the register?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • John JenkinsJohn Jenkins Posts: 12
    edited 2008-06-24 00:40
    Thanks, Chris. Here is the code I'm using. When I run this,·update_flag·is true through every iteration of the loop, - i.e·bit1 of the status register never seems to reset. I tried testing Pink_updated directly also, but that didn't work either.

    I'm sure I'm doing something dumb, thanks for your help!

    ·- John

    '
    [noparse][[/noparse] I/O Definitions ]

    RX············· PIN···· 14············· ' Serial Receieve Pin --> PINK.TX
    TX············· PIN···· 15············· ' Serial Transmit Pin --> PINK.RX


    '
    [noparse][[/noparse] Constants ]

    Baud··········· CON···· 396············ ' 2400 bps (BS2)


    '
    [noparse][[/noparse] Variables ]

    nbvar············ ·VAR···· Byte······· ' PINK Data Variable Array
    Pink_status····· VAR···· Byte
    update_flag····· VAR···· Bit
    Pink_updated··· VAR···· Pink_Status.BIT1
    '
    [noparse][[/noparse] Program Code ]

    Main:
    DEBUG CLS

    DO
    · update_flag=0
    · Pink_status=0
    · SEROUT TX, Baud, [noparse][[/noparse]"!NB0RST"]··················· ' Send Command To Read Variable 01
    · SERIN· RX, Baud, 100, Timeout, [noparse][[/noparse]DEC Pink_status]' Get Data With Timeout
    · Update_flag = Pink_updated

    · IF update_flag <>0· THEN DEBUG "Something changed!",CR
    LOOP

    Timeout:
    · DEBUG "Communication Timeout!"······· ' Serial Timeout
    · END
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-24 15:04
    John,

    You're reading in the status register as if it were formatted as an ASCII stream. Do not use the DEC modifier...Just read the byte and look at the one bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-24 17:50
    John,

    ·· I went ahead and whipped up a test program for the status register. This program sits in a loop and reads the status register. As soon as bit 1 or bit 5 is set the program handles the displaying of the change.

    ·· For Variables the variable number is shown along with the contents of the variable (up to 20 characters) are displayed. For UDP messages the incoming IP Address, Port and Message (up to 20 characters) are displayed.

    ·· The program will continue to display message events as they happen in real time. It is important to note that when a variable is updated the PINK is busy for longer than usual. When this happens it can delay return of the status variable and cause a timeout. Because of this a higher timeout value is set on the SERIN reading the status register. A screenshot is attached below as well that shows a sample of my testing. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • John JenkinsJohn Jenkins Posts: 12
    edited 2008-06-24 20:36
    Perfect! Thanks, Chris, for you your help!

    John Jenkins
    www.sparkmuseum.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-24 20:54
    John,

    Please let us know if this helps. I have been slowly trying to address the more common questions on the PINK and a few other products and come up with code examples that kind of cover a range of application examples. Hopefully this one does that. As a note, I will revise the source code examples for the PINK very soon and post a message on here so customers can get some more examples and hopefully AppNotes.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.