Author Topic: Displaying time on display  (Read 5399 times)

mjb123

  • Newbie
  • Posts: 3
    • View Profile
Displaying time on display
« on: June 07, 2006, 12:42:38 PM »
When I display the time on the display, I get unusual hours, minutes and seconds appearing. (hour = 94).  

H=TIME[1]+1
if h>24 then h=0
endif
SETLCD 4,1,"HE: " + STR$(H)

overflow?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Displaying time on display
« Reply #1 on: June 07, 2006, 01:30:12 PM »
It is because it has previously displayed two digits and later on display only one digit and the old digit did not get erased. There are two ways of doing it. One is to use the STR$(H,2) to change the number to only two digits. Another way is to add some white spaces behind the current display string so that it wipes out old characters.

E.g. SETLCD 4,1,"HE: "+STR$(H)+"    "

Third method is to clear the line first using SETLCD 4,1, "                             " . You can put this inside a function to be called as a subroutine. That way old data will not be present that lead to confusion.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

mjb123

  • Newbie
  • Posts: 3
    • View Profile
Re:Displaying time on display
« Reply #2 on: June 08, 2006, 09:52:41 AM »
Thanks for the quick reply. :D