Induction Sensor on slow moving shaft to pause a loop

Hello, I've got a carriage that moves backwards and forwards via a hybrid servo motor connected to a ballscrew. This carriage needs to pause when an external shaft stops rotating (max speed of the shaft is 1.2 rmp) and then continue its loop when the shaft starts rotating again.

The loop is running really fast as it's driving the pulse signal to the hybrid servo driver (30micros between pulses/loop) The induction sensor has 12 'pick ups' at 30degrees. How do I compute whether the shaft is turning and allow for the fact that the shaft might stop while giving a 'HIGH' signal as it over one of the 'pick ups'?

Do I need this part of the program to be run by a separate arduino to give a high low signal which I can use in the original program to 'do nothing' while said Pin = HIGH. I've only been writing code for a few months so my knowledge is patchy. The rest of the program deals with 6 buttons (AUTO/MANUAL, START, STOP, HOME, FORWARDS, BACKWARDS) , 2 limit sensors and the outputs to the servo driver which Ive written.
Any help would be greatly appreciated, thanks for your time.

if I understood right you want to the process 1 stop execution if on the process 2 does not interleave a pulses for too long time

one approach is to consider the pulses from these pickup as a heartbeat and stop when the heartbeat stops

the questions is how long should the code recognize when the heartbeat stops? is there a minimum time between those pulses?

yes there will be a lag between when the shaft stops rotating and your servo stops.

or you could tie the servo movement to a pulse for each 30 deg of shaft rotation which might mean the servo tracks the shaft speed

Hi,
Thanks for your input. The shafts maximum speed would be 1.2rpm and the slowest would be 0.48rpm. I like the idea of the 'heartbeat' approach. The lag time between when the shaft stops turning and when my servo stops doesnt matter too much. The project is an automatic belt washing machine. If the slow shaft is turning this means that the belt is moving past the carriage and it (the carriage) needs to continue moving as it is holding the pressure washer nozzles, which in turn are cleaning the belt.
What Im struggling to understand is how to approach writing a program which can 'recognise' whether the heartbeat state is 'true'.

Look at the state change example in the IDE. When your induction sensor input changes, record the time using millis. If it hasn't changed in a while, stop.

a timestamp can be captured every time a pulse occurs.

also within loop() is a check to see if some maximum time since the last timestamp has been exceeded, and to take some action.

that check may be getting close, but then a pulse occurs, the timestamp is updated.

Your code should look something like this:

const int  sensorPin = 2;    // the pin that the pushbutton is attached to

int lastSensorState = 0;     // previous state of the sensor
bool isRunning = false;

cont unsigned long maxInterval = 1000;  // 1 second for demo, adjust to true RPM

void setup() {
  pinMode(buttonPin, INPUT);
  Serial.begin(115200);
}


void loop() {
  int sensorState = digitalRead(sensorPin);

  if (sensorState != lastSensorState) {
    // still moving
    lastMovementTime = millis()
  }
  lastSensorState = sensorState;

  // check if we are rotating
  if ( millis() - lastMovementTime >= maxInterval ) {
    // nothing has changed in too long so stop
    isRunning = false;
  }
  else {
    isRunning = true;
  }

  if ( isRunning == true ) {
    // do appropriate things here
  }
}

I understand how to approach it now. I was overcomplicating things in my head. I really appreciate the help from everyone, Ill give this a whirl this afternoon. :+1:

  • Current sensing of belt motor,
  • optical sensing if belt drum has wheel spokes or the belt itself has holes,
  • on dry surfaces can be used optical mouse sensor,
  • magnets and Hall sensor, like Pedelec pedal assist sensor,
  • etc

What is the maximum speed that is considered "stopped". If 0 RPM is the maximum speed for 'stopped' you will need to wait an infinite amount of time to determine if the shaft is stopped. Please pick a non-zero value.

1.2 RPM = 0.833 minutes per revolution = 4.166 seconds per pulse.

If you allow the shaft to run at 0.5 RPM without counting as 'stopped' you will need to wait at least 10 seconds since the last pulse to determine if it has stopped.

Most people would use one proximity sensor and a toothed wheel rather than one 'tooth' and 12 sensors. Maybe 60 teeth? That would get you a speed value in 1/5th the time.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.