No announcement yet.

Help with clock setting from the web ... nettime

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with clock setting from the web ... nettime

    OK ... a while back I asked how to set the time in the PLC from the web.

    You guys gave me an example and I used it ... worked great.

    Problem ... I don't know why it works!

    I have attached a screen shot of what I did ...

    I understand the NETTIME command ... makes sense.

    The last time is STRPRINT ... I see in my notes that I don't actually use this for anything except to see "last time updated"

    This leaves MEMCOPY. I have $NOW ... source SDT0 ... elements 1 ... Destination UDT0

    Is $NOW the time in the machine or SDT0 or UDT0 or ????????

    What is $NOW, SDT0 and UDT0 ???

    I just to know what I did !!!!!

    Why do I even need the memcopy ... does nettime not just automatically update the plc clock?

    Just FYI, I then did a "copy data" and took all the time variables ($now.hour, $now.minute, ....) and saved them to V1, V2, V3 .... then used this in the C-more touch panel to sync the time ... works great also .. even got the daylight savings time working.

    Thanks .... Mike
    Attached Files

  • #2
    SDT is System Date Time block of date/time structures. SDT0 is the PLC realtime clock (local time), with a nickname/tag called $Now. Hence, when you reference $Now, that is the same as SDT0.

    UDT is a User Date Time block with nothing predefined for any of the date/time structures. They let you take snapshots or set your own date/time values. Hence, your logic has an event for C90, such that when it goes from OFF to ON, you want to take a snapshot $Now and store it in UDT0. So $Now will continue updating (because it IS the local PLC clock), but UDT0 will maintain its value because it only gets updated on the PLC event when C90 goes from OFF to ON (edge triggered).

    The STRPRINT is just a way to generate a text string from that "snapshot" value. The script inside the STRPRINT specifies that it formats the snapshot date in U.S. format (i.e. month/day/year), and formats the snapshot time in 24 hour format (vs. am/pm format), e.g. 23:59:59 is 1 second before midnight, which is 00:00::00
    There are 10 kinds of people in this world, those who know binary, and those who do not.


    • #3
      Think I got it .... so NETTIME does in update the PLC clock (SDT0).

      Since I am not using the clock in my program I don't need to do the MEMCOPY (SDT0 to UDT0).

      As I am just using the STRPRINT to see when the time was last updated, I could have used FmtDate(SDT0,us) FmtTime(SDT0,24h) rather then FmtDate(UDT0,us) FmtTime(UDT0,24h) .... ist his correct?

      Thanks so much!


      • #4
        You are technically correct, HOWEVER...

        It doesn't hurt to record the time snapshot of when that occurred IN UDT0.
        1. You may want an HMI to report when it occurred
        2. To diagnose why the time isn't right, from Designer you may want to know, "when was the last time the RTC was updated?". Already in the PLC - look at UDT0.
        3. You may want to calculate the amount of time between actual NETTIME updates
        4. ? ? ?
        There are 10 kinds of people in this world, those who know binary, and those who do not.


        • #5
          Got it ... makes sense.

          In fact, I think you answered a different problem I have been having!

          I show on the c-more screen yesterdays total flow ... plus the total flow from the day before. I have been trying to figure out how to put the date down for "the day before". I am thinking I can just take a snapshot of the time (say UDT0 ) when I transfer the total from yesterday (say R1) to the day before (say R@) .... I can transfer the date (say UDT0) to say UDT1

          Does this make sense?

          Thanks so very much for all the help !!!!!!!!!!



          • #6
            You mean SDT0 to UDT1 (not UDT0 to UDT1). UDT0 is already used as the snapshot of the NETTIME update.

            So on some event, you save off the total to R1 AND MOVE SDT0($Now) to UDT1, then you know R1 value was updated @UDT1 - exactly!
            There are 10 kinds of people in this world, those who know binary, and those who do not.


            • #7
              Yes ... exactly!

              Thanks so much for the help!



              • #8
                I have saved the time/date from SDT0 to UDT0 (yesterdays date) and UDT1 ( the 2 is 2 days ago).

                Problem .... can't figure out how to display them on a C-more touch panel.

                What I am trying to do is display yesterdays flow (no problem doing this) and having it display the date beside it.

                I keep looking and just don't see any way of displaying a date xx:xx:xx or ## SEPT ## or any way ... I just keep getting junk displayed.

                Thanks again!



                • #9
                  I'm not a C-more guy, but a Do-more guy, so someone else may know better...

                  I think you have to create a NickName for UDT1, then from Designer, do File->Export Element Documentation, then select C-more WITH Struct Fields (this is for the C-more Do-more Symbolic Driver, not the Do-more Built-in driver), then IMPORT that file into a C-more project on the Do-more Symbolic driver device. This may or may not work, there may or may not be other ways to do this (I told you I'm not a C-more guy). If this doesn't work, you may have to reference the individual fields in UDT1 .
                  There are 10 kinds of people in this world, those who know binary, and those who do not.


                  • #10
                    If the date fields are separate, (or if the domore driver provides casted values for date fields to cmore tags [i.e. UDT.Year] ) then the Multistate Text object can do it.
                    Embed the MONTH as the message trigger
                    embed the DAY and YEAR in messages 1 -12
                    finally embed add the abbreviated month name in the corresponding month message.
                    Kinda kludgey but if it gets what you need on the screen....
                    Last edited by kewakl; 09-27-2019, 08:36 AM.


                    • #11
                      There's always STRPRINT to SS, (FmtDate, FmtTime script functions can get you the format you want), or just write your own STRPRINT using the individual UDT1 fields, then display the string in C-more (both the Built-In and Symbolic drivers understands Do-more strings)
                      There are 10 kinds of people in this world, those who know binary, and those who do not.


                      • #12
                        As always, you guys are awesome!

                        I will give these a try.

                        Everything works great now I just need to display the information correctly.

                        Thanks again!