Announcement

Collapse
No announcement yet.

turn on output at 10pm and turn off at 5am

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts


  • turn on output at 10pm and turn off at 5am

    Hi,

    I am trying to write a program to turn on each output of my PLC each day. For example,

    Y1 is turned on, on Jan 1st,
    Y2 on Jan 2nd
    Y3 on Jan 3rd
    Y4 on Jan 5th
    Y5 on Jan 6th
    Y6 on Jan 7th

    and the cycle repeats itself for the whole month and similarly for the whole year from Jan to Dec.

    I have made my ladder logic program for the case when I have to turn on and off the output on the same day, for example turn on at 8am and turn off at 4pm.
    But now I am struggling to turn on the output at 11pm at night on (lets say Jan 1) and turn it off at 2am (Jan 2).

    I am not sure on how to include the condition to change the day.

    The on and off times are to be input from the user. So the user can choose any time, for example on_time = 8 , off_time=12 (my code works fine for this) or on_time = 22 , off_time=2.

    In my code , when the RTC conditions are satisfied, C1 is on, which turns on the timer. Timer T1 turns on Y1.

    Thank you

    Attached Files


  • #2
    For this to work you need to implement a clock. Not sure if click plc has a real time clock, but if it doesnt, just use a timer to 1min, then counter for minutes to reset after 60, hourly counter to reset after 24, daily counter to reset weekly. Idea being that three counters are enough to tell which day and which top of the hour is.
    After that, just turn the output on or off depending on the readings of the counters ( which day, which hour).
    Let me know if you need a program snippet.
    Last edited by Alexandru; 08-31-2018, 10:42 AM.

    Comment



    • #3
      Alexandru, OP's posted image shows that OP is using RTC
      santamaria, does it matter if the power is cycled? do the lights that WERE on at power off need to come BACK ON at power ON?

      Comment



      • #4
        So, you're skipping the 4th day of the month, but have C1 true on the 1st and the 7th? I need some clarification. Otherwise, you likely meant to write Y4 to be true on the 4th, Y5 on the 5th, Y6 on the 6th, leaving Y101 to go true on the 7th?
        Why worry? If you've done the best you can, worrying won't make it any better

        - Walt Disney

        Comment

        Working...
        X