Trying to set up rotary encoder for RPM monitor for an emergency stop

Hi all. I had a question about rotary encoders and the looking for the best way to proceed. I built this arduino radial arm saw, here's a video of it working. Arduino powered DIY radial arm sliding saw for thick metal plate pt. 1 - YouTube

Last night i was testing it and came across a problem. Somehow the feed screw holding up the saw fell off the plate and the saw dug in the metal and locked up the saw and stopped the lead screw, but luckily the only damage done was a bent feed screw, which i already fixed. But after that i decided that i really need an auto emergency stop in case the saw ever binds up again.

What i was thinking about was using a rotary encoder to monitor the RPM of my leadscrew that pushes the saw back and forth and if the RPM drops below of where it should be at it will turn off the saw and the leadscrew to avoid any damage. Right now the RPM is variable and is adjustable by a pot i'm using. Most times, it's running at full speed, but there are times it may be running between 25-75%.

I've checked out a couple videos and some info about the encoders, and most examples i've found is using the encoder for inputs or RPM and direction monitoring, but really haven't found any info regarding using the encoder as a RPM monitor that is compared to another signal. and am unsure how i should code it.

Below is the section of code that the rotary encoder would need to be apart of.

any help would be appreciated

void frontStep(){                                     // front cutting

  if (switch1State == LOW){                      // if front_Switch button activated


  int feedReading = analogRead(A1);                               // feed screw analog
  int feedStep = map(feedReading, 0, 1023, 75, 600);      //  feed screw map and steps
  
    stepper2.setSpeed(20);
    stepper2.step(feedStep);
    
   while(digitalRead(back_Switch)) {


  int sensorReading= analogRead(A0);                                    // lead screw analog
  int stepSpeed = map(sensorReading, 0, 1023, 20, 1500);      // lead screw map and speeds
   
   if (stepSpeed > 0) {
    stepper1.setSpeed(stepSpeed);
   }

     digitalWrite(relay, HIGH);                                          //  turn on saw
     stepper1.step(20);
     delayMicroseconds(20);
   }   
  }
 }

[\code]

You will be using the encoder for inputs just like all those examples. You basically want to set up your encoders to use interrupts and then inside your function, you just have to check the current encoder count and compare it to the previous encoder count to see if the saw is moving or not. If you care about the actual vs. predicted RPM of the saw, you will have to figure that out empirically based on your sensor input. If you only care about if the saw is stalled or not, then you only need to detect encoder changes.

Thanks for the replies. I'll get it all set up and reading the RPM's and then go from there. I imagine i'll have other questions once i get it installed since it's the first time working with an encoder.

But i'm only concerned about a stalled saw

Well, after doing some reading, and checking specs, it doesn't look like i'm going to be able to use these rotary encoders the way i wanted too because of their RPM limitations, which is they say is 60rpm. They are just the normal HW-040 pcb encoder, and it looks like i'm running about 75-80 rpm at the leadscrew, but what i'm gonna do is test the encoder in my electric drill and see how it reacts at the higher rpms. And then to go from there. I also have some hall sensors and other magnetic sensors laying around i could maybe use. in regards to the encoder, the direction of travel doesn't matter in my case so i may be able to do it another way.

They are just the normal HW-040 pcb encoder

If you mean that the encoders you have are the mechanical KY-040 encoders, I'd avoid them, as they are pretty cheaply made and are not likely to last in a non manually operated application.

I also have some hall sensors and other magnetic sensors laying around i could maybe use. in regards to the encoder, the direction of travel doesn't matter in my case so i may be able to do it another way.

If the direction does not matter, it is more simple to not use a quadrature encoder.

Yeah, i thought about gearing it down as an option. I was just hoping for someway that's less bulky. but i'll check it out tonight.

and yes, i have the mechanical ky-040 encoder and didn't think they would last very long at higher rpms.

How about a simple magnet/hall/*occluder to identify the shaft is rotating?
If the sensor isn’t triggered within a period (stopped), or is firing too fast (the lead screw is running / too fast) - then perform some action.

Optical is probably more inclined to get contaminated in this environment, hall can work with relatively large gaps and is easily ‘blown’ clear.

  • read up on the many type of hall-effect sensors (@Allegro)