Calculating Motor Starts per hour

Hi,
I am trying to develop a prototype for a crane controller using arduino uno and some very basic wiring such as relays, contactors etc. In this i have 1 input which activates 1 output for activating a relay to switch on a motor. Now the motor has Starts per hour rating of 300 Starts per hour. Which means that in any 1 hour duration, the motor can be switched on 300 times. If the motor is started (output went from LOW to HIGH) for more than 300 times in any 1 hr duration, i have to activate an alarm.

Now, i am unable to figure out the programming technique for this. Anyone has done this before? Any ideas?

This sounds like a commercial project.
What's the budget?

Look at the StateChangeDetection example in the IDE which shows how to detect when an input becomes HIGH (or LOW) rather than when it is HIGH (or LOW) and illustrates how to count those state transitions

Juts curious - is there anything more to this specification?

If there were 300 starts in 10 minutes would that be undesirable? Even if 50 minutes went by before another start?

That kind of thing. Now that you are using an Arduino or any microprocessor, there is the possibility of hewing to a more precise set of alarm conditions.

a7

Need actual data.
AC or DC motor?

My first quess would be to put on a clamp on current sensor and do some tests.

300 starts in ANY 60 minute period?

Yes it has a potential to become a commercial project, but first I would need to use something more robust than an arduino uno

The issue is not on how to detect the low to high input. Problem is that I am unable to figure out how to program the logic that if the number of starts in any one hr exceeds 300, then an alarm should go off( one output pin becomes HIGH). How do I calculate the no of starts in any one hr. If at time T0 we start the motor and then stops. Then for next 10 mins we start the motor 50 times, then in the next 50 mins, we start the motor 240 times, so in 1 hr it would be 290 times which is OK, but if in the next 10 mins we start the motor 70 times then it will give an alarm since 240 +70 is 310. That sort of thing. I know it might be a little confusing as I am unable to find the right words to explain properly.

Yes that would definitely be undesirable. Basically motor should start and stop but consecutive starts should not accumulate to more than 300 in any period of 1 hr

Yes

Use a circular buffer of 300 entries, each holding the time of a motor start. Each time you record a new time check the interval between the oldest and most recent entries. If it greater than 1 hour then activate the alarm

1 Like

Thanks. That sounds like an excellent idea. I wasnt aware of circular buffers. I just googled them and It seems like a very simple logic. I will apply it using CircularBuffer library at CircularBuffer - Arduino Reference and will update if the results are as expected, but i think this should work. Thanks again. Really appreciate it!

Be careful of the memory needed to hold 300 time entries

I was thinking of using millis value instead of timestamp. Each millis value is unsigned long int which is 4 bytes. So a total of 1200 bytes will be used up out of 2kB Uno memory. I think i might have to start testing on an Atmega2560 which has 8 kB SRAM. What do you think?

Whether or not you will get away with using a Uno depends on how much memory the sketch uses, but a Mega will, of course, give you more headroom

Yes, but you probably don't need millisecond accuracy.

Using an unsigned int gives > 1000 hours before you'd even have to think about anything weird.

Half the storage.

EDIT: a little more awake - this is like 45 days, a bit short of millis() ~49 day period, so you'll either have to think about that or not, independent of how you store the time.

Do you need to worry about power failure?

a7

No reason not to add
Lifetime starts
RTC to get hrs per day and starts per day
Hours per shift and starts per shift.
Most starts in an hour.
A daily log to the memory chip on most RTC modules should have enough memory to last the life of the machine.

Yes i will try and see it causes any issue or not. I have both UNO and industrial Atmega2560. Will try and see.

Well, to be honest, i use millis since i dont know about any other function which can give me seconds without stopping the program such as delay(). Otherwise i can use any timer function also, eventually it will give an int only. Isnt it. Do you have any better function in mind which can be used.

Regarding, power failure, its not a big issue.

Good point. I will add an RTC module later and try this as well.