Counters?!?!

DustyC

Member
Join Date
Nov 2023
Location
Tx
Posts
20
Hey guys, thanks for reading. I am trying to use a micrologix(1000 or1500) to control 3 hydraulic pumps. I have a time clock to give a signal to the plc and a rotary switch to set schedules. At 6am pump A or B will turn till 7pm then pump C turns on. A and B need to alternate days. Then I need 3 schedules 4day, 5day, and 6day. I am thinking a counter to reset every 7 days. Time clock on 6am-7pm will give one count per day. XIO, XIC the same input to turn pumps on or off but how to alternate pumps A/B with counter? Examine accumulated number? Don't know how to do that. Then set a rotary switch to set schedule.

Example schedule 1= 4days.Timeclock turns on Count 1 turns on pump A. Loose time clock signal Pump A off Pump C on. Next day time clock on, count 2 pump B on. Loose time clock signal pump C on. Rinse repeat 4 days.3 days pump C on. Cycle starts over. Is this doable?
 
Is this for school or are you using an obsolete PLC with no real time clock for the purpose of making things hard on yourself?

Actually, the ML1500 does have an optional RTC module.

Welcome to the forum, by the way!
 
day is Integer e.g. N7:0.

assuming first bit is day 0, second is day 1, etc. Increment day on any one-shot scan cycle when RTC:0.HOUR decreases (typically from 23 to 0). E.g.
LES RTC:0.HOUR last_hour CTU C5:0 sched_length 0
XIC C5:0/DN RES C5:0
MOV RTC:0.HOUR last_hour

day of schedule is then Integer C5:0.ACC; sched_length is Integer controlled by rotary switch.

A will be used when value of bit (boolean) day/0 is 0 (i.e. day is 0, 2, 4); B will be used when value of bit day/0 is 1 (i.e. day is 1, 3, 5).

Also look for "alternator methods" under [DOWNLOADS] above (under Allen-Bradley).

Welcome to the forum.
 
Is this for school or are you using an obsolete PLC with no real time clock for the purpose of making things hard on yourself?

Actually, the ML1500 does have an optional RTC module.

Welcome to the forum, by the way!

No, not for school. I work for chepos that buy stuff at auction and then expect maintenance to work miracles. Like a box of old ML. Also why I am using a Digital time clock instead of an RTC module. Time clock is on the shelf, RTC cost several hundred.
 
Drbitboy, the solution you posted almost makes sense to me but text is my weakest plc skill. I'm not sure how to draw the text into a ladder logic. I am just getting into plc programming, have been an electrician for 25 years but this is a little different. Thanks for the help and I will try to apply your solution.
 
Learn how to use the counter's .ACC word with the comparison functions (EQU, NEQ, LES, LEQ, GRT, GEQ). Also bit zero of the counter's .ACC word is off for an even number, on for an odd number.

Hey Steve, I was trying to use EQU for ACC 1-7 but didn't know what to compare to? Last week I thought I was doing good understanding XIC, XIO but now my brain is smoking
 
Drbitboy, the solution you posted almost makes sense to me but text is my weakest plc skill. I'm not sure how to draw the text into a ladder logic. I am just getting into plc programming, have been an electrician for 25 years but this is a little different. Thanks for the help and I will try to apply your solution.

I don't know what your digital clock is doing or how you will get time-of-day into the MicroLogix 1000, but the attached image and PDF might give you some ideas. It basically does what @Steve Bailey is suggesting. Feel free to ask questions.
Untitled.png
 
Hey guys, thanks for reading. I am trying to use a micrologix(1000 or1500) to control 3 hydraulic pumps. I have a time clock to give a signal to the plc and a rotary switch to set schedules. At 6am pump A or B will turn till 7pm then pump C turns on. A and B need to alternate days. Then I need 3 schedules 4day, 5day, and 6day. I am thinking a counter to reset every 7 days. Time clock on 6am-7pm will give one count per day. XIO, XIC the same input to turn pumps on or off but how to alternate pumps A/B with counter? Examine accumulated number? Don't know how to do that. Then set a rotary switch to set schedule.

Example schedule 1= 4days.Timeclock turns on Count 1 turns on pump A. Loose time clock signal Pump A off Pump C on. Next day time clock on, count 2 pump B on. Loose time clock signal pump C on. Rinse repeat 4 days.3 days pump C on. Cycle starts over. Is this doable?

Easily doable....but your description is a little unclear. On the schedule, are you saying the remaining days are just solid pump C on until end of day 7 and then schedule starts over? What happens if the schedule is changed from 4 to 5 on day 3? What if it's changed from 4 to 6 on day 5? What happens on a new week if odd or even day schedules were selected because that determines if you ended on Pump A or Pump B. In otherwords does day 1 always start on A or does it start opposite of last week's end? Don't have enough detail to fully help, but the logic is simple. Your clock input, increment the counter. The counter.ACC will contain the current day. Counter has preset of 7, use .DN to reset and start over. If you always start on A, the A runs on all odd days as long as ACC is less than schedule and clock signal is on. B runs on even days with clock signal on. C runs when clock signal is off or ACC is greater than schedule.
 
C5:1.ACC, the day-of-schedule counter, will run from 0 to 5 for a six-day schedule before resetting. Note the correlation between the last two columns:

  • bit 0 of the day-of-schedule C5:1 accumulator (C5:1.ACC/0), and
  • the active pump of A and B

C5:1.ACC
Decimal C5:1.ACC/2 C5:1.ACC/1 C5:1.ACC/0 A/B
Value C5:1.ACC Bit 2 state Bit 1 state Bit 0 state Active
(Day) Sum (value = 4) (value = 2) (value = 1) Pump
======== ======== =========== =========== =========== ======
0 0+0+0 0 0 0 A
1 0+0+1 0 0 1 B
2 0+2+0 0 1 0 A
3 0+2+1 0 1 1 B
4 4+0+0 1 0 0 A
5 4+0+1 1 0 1 B

 
Last edited:
Robertmee, thanks for the reply. I was thinking that a 3 pos switch would determine the schedule. Pump A can start on day one always. And pump C runs whenever AorB are off. If the schedule is changed mid week that shouldn't affect the counter so the cycle would start at whatever point in the week the dominant schedule was at. Example, schedule is on 4day, it is the fifth day of the week. Everything is off, then schedule setting changes to 6 day so the cycle starts on day 5 of 6day schedule. Day 7 pump C runs until time for Pump A to start.
 
Robertmee, thanks for the reply. I was thinking that a 3 pos switch would determine the schedule. Pump A can start on day one always. And pump C runs whenever AorB are off. If the schedule is changed mid week that shouldn't affect the counter so the cycle would start at whatever point in the week the dominant schedule was at. Example, schedule is on 4day, it is the fifth day of the week. Everything is off, then schedule setting changes to 6 day so the cycle starts on day 5 of 6day schedule. Day 7 pump C runs until time for Pump A to start.

If the master schedule is always 7 days pretty easy.

4 day schedule: A/C, B/C, A/C, B/C, C, C, C
5 day schedule: A/C, B/C, A/C, B/C, A/C, C, C
6 day schedule: A/C, B/C, A/C, B/C, A/C, B/C, C

is that correct? If so then Counter that counts to 7 by your clock input. Then several compares:

Pump A = XIC clock and Counter.ACC EQU 1 or EQU 3 or EQU (5 & schedule 5 or 6)
Pump B = XIC clock and Counter.ACC EQU 2 or EQU 4 or EQU (6 & schedule 6)
Pump C = XIO Pump A and XIO Pump B

If you are using a counter CTU, note it would cycle from 0 to 6, not 1 to 7, so adjust accordingly. Me personally, I wouldn't use a counter...just an interger that counts from 1 to 7, and resets to 1...would make the logic easier to read. Each clock input would add 1. Something like:

XIC clock One-shot Add N7:1 1 N7:1. If N7:1 GRT 7 OR LES 1, MOV 1 N7:1.

As for schedules, just a 3 pos selector switch...3 inputs:

Xic input1 OTE schedule 4 (B3:0/0)
Xic input2 OTE schedule 5 (B3:0/1)
Xic input3 OTE schedule 6 (B3:0/2)

No input would be a means to turn all pumps off if you wanted. You could use 2 inputs and let none default to schedule 4, but then it would always run. I'd prefer to have 3 inputs and use none to disable the entire cycling.
 
Last edited:
C5:1.ACC, the day-of-schedule counter, will run from 0 to 5 for a six-day schedule before resetting. Note the correlation between the last two columns:

  • bit 0 of the day-of-schedule C5:1 accumulator (C5:1.ACC/0), and
  • the active pump of A and B

C5:1.ACC
Decimal C5:1.ACC/2 C5:1.ACC/1 C5:1.ACC/0 A/B
Value C5:1.ACC Bit 2 state Bit 1 state Bit 0 state Active
(Day) Sum (value = 4) (value = 2) (value = 1) Pump
======== ======== =========== =========== =========== ======
0 0+0+0 0 0 0 A
1 0+0+1 0 0 1 B
2 0+2+0 0 1 0 A
3 0+2+1 0 1 1 B
4 4+0+0 1 0 0 A
5 4+0+1 1 0 1 B


Unless im missing something, the schedule always runs 7 days....the 4, 5 and 6 day selection just selects how many days A and B runs in those 7 days. The non scheduled days, Pump C runs all day It's really just as easy with EQU statements...A always runs odd days, B always runs even days, C runs when A and B arent. Your use of binary bits of an INT is creative for even/odd, but it would be more intuitive to me to just compare the INT value of the Counter to day #'s
 
Last edited:

Similar Topics

Hi Hope you all are doing well. Iam working on a project with some AOI. I also hate no online edits... lol. My problem occurs when I use a UDT...
Replies
2
Views
157
iFIX 5.5. We have alarm count database tags with SIM driver and I/O address = "C:AREA-SD:ACK" which is suppose to count the acknowledged alarms in...
Replies
16
Views
1,406
https://www.youtube.com/watch?v=zTOOYWMJg9M . Specifically see 1:46 to 2:11. 3. The Cell PLC is in constant communication with two other field...
Replies
14
Views
3,159
Does the 1100 only have 1 high speed counter, but it can have multiple inputs? And so then the 1400 has 6 HSC and you have a choice of multiple...
Replies
1
Views
1,716
I have a questions on counters and accumulators and how do the accumulators work as a preset? I have a program that uses the accumulators as the...
Replies
26
Views
8,609
Back
Top Bottom