PINK status register
John Jenkins
Posts: 12
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!
Thanks!
Comments
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
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
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
·· 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 Jenkins
www.sparkmuseum.com
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