Author Topic: Real Time Clock  (Read 13723 times)

speedyfox

  • Newbie
  • Posts: 4
    • View Profile
Real Time Clock
« on: August 11, 2008, 07:08:42 PM »
I have the T100MD+ PLC and I understand that you can use the real time clock to trigger events?

The book talks about this a little bit on page 10-4 however I can't find any reference on
how to do write the code so I can do the following:

I am needing to set a timed event.  I want to trigger a digital output to activate once a
week for a duration of 30seconds.  Can any one please give me some guidence on how to go about
this?

I learned how to program PLC's about 10 years ago in school but haven't messed with them again until now.

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Real Time Clock
« Reply #1 on: August 11, 2008, 09:42:44 PM »
The real time clock data are accessible to TBASIC as variables:

DATE[1]: Year
DATE[2]: Month
DATE[3]: Date
DATE[4]: Day of the Week.
TIME[1]: hour
TIME[2]: minute
TIME[3]: second

What you need to do is to monitor the real time clock periodically. Since you are only triggering your output once a week, you can check it very irregularly e.g. once a minute. So you can use the 1 minute clock pulse "CLK:1min" to trigger your custom function and you can check the variable to see if it match your criteria. E.g. if every Monday, that means DATE[4] = 1 and at 12:00pm that means TIME[1]=12 and TIME[2]=0 and you will trigger the output.  The custom function will be called every 1 minute and only when the DATE[1] and TIME[1] and TIME[2] match the condition would the output be turned ON. You can do the same to turn OFF the output.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

speedyfox

  • Newbie
  • Posts: 4
    • View Profile
Re:Real Time Clock
« Reply #2 on: August 13, 2008, 08:15:58 PM »
Thanks for the feedback.  I also managed to find an example in the book (Page A1-9) however when I ran the script with my settings it didn't turn on output 5 per the code.

Maybe I am doing something obviously wrong...not sure.  Below is what I coded.

If DATE[3]=3
   If TIME[1]=21 AND TIME[2]=55 SetBIT OUTPUT[1],4:ENDIF
   If TIME[1]=22 AND TIME[2]=0 SetBIT OUTPUT[1],4:ENDIF
   ENDIF
ENDIF

The latter logic was the following...
   Tim30s                        Fn_1
----I I---------------------{dCusF}

   Tim30s                       Tim30s
----I I------------------------(TIM)


speedyfox

  • Newbie
  • Posts: 4
    • View Profile
Re:Real Time Clock
« Reply #3 on: August 14, 2008, 02:30:39 PM »
Any Idea's anyone?  This code should run in simulation correct?  Just making sure I don't have to download it to ??? the PLC to test.

ryandsm

  • Newbie
  • *
  • Posts: 4
  • I'm a llama!
    • View Profile
Re:Real Time Clock
« Reply #4 on: August 14, 2008, 02:56:39 PM »
this is what i would do
you woundt have to transfer the program to the PLC to simulate.
click on the "simulate" tab at the top of the window then click on "run( all i/o reset)"


 time1sec                          
--||--------------------------[dCusF]

 relay
---||-------------------------[out1]
 turn_on

if date[3] = 3 and time[1] = 21 and time[2] = 55 and time[3] = 30
   setio turn_on
else
   if date[3] = 3 and time[1] = 21 and time[2] = 56
      clrio turn_on
   endif
endif
« Last Edit: August 14, 2008, 02:59:07 PM by ryandsm »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Real Time Clock
« Reply #5 on: August 14, 2008, 04:02:42 PM »
Make sure that your output #5 is not already controlled by some other parts of your ladder logic. Otherwise your function may turn it ON when the function runs but the same bit is turned OFF by another part of the ladder logic immediately. You can tell by right-clicking on output #5 and if it doesn't stay lit that means it has been controlled somewhere else.

For debugging you can also add an additional statement such as "C = C + 1" as the first statement in this custom function so that you can see if this custom function has been executed every 30 seconds if you see C is being incremented every time the custom function runs.

« Last Edit: August 14, 2008, 04:04:35 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

speedyfox

  • Newbie
  • Posts: 4
    • View Profile
Re:Real Time Clock
« Reply #6 on: August 14, 2008, 09:58:13 PM »
Thanks all for your help.  I had it right from the start.  Apparently TriLOGI software had faulted.  I noticed that the TRI software clock was skipping minutes and running faster than the PC clock.  So I closed & restarted the program.  After that the custom function worked just fine....go figure.   Talk soon!