Chain stretch Project.

I've inherited a project at work to long term measure the wear (stretch) of a drive chain over time.
Now I knocked up a simple project using a PLC which works fine but the constraints of the project (cost) requires me to use an arduino, so I've been given an uno to work with.

Basically what my PLC did was monitor a magnet that went around the chain and count the pulses of sensor 1 between hits of the magnet.

This gave me a chain link count ( this can vary as the chain wears (stretches) and we remove lengths of it.

and a second sensor which is exactly 4.5 inches upstream of the first one, this i use to count when both sensors are true together which indicates that, that link is excessively worn. I count these in a cycle ( using the magnet) and when the amount of worn links is = 5% of the total links I fire an output to alarm the Maintenance crew to replace the chain.

Does anyone know of an easy way to do this on an arduino. I'm having difficulty getting my head around C when I'm so used to ladder and STL

You need to explain the algorithm that your plc solution is using. Is it something to do with measuring time between pulses from the two sensors? What kind of sensors are they? You mention magnets being "hit" but I don't know what that means exactly.

So I’ve attached a picture of the chain and the magnet (best paint skills available)

Basically the magnet is mounted onto of the chain and we pick it up using a hall sensor or a reed switch (cant recall which it is)

The sensors are these HERE and as mentioned they are set apart so that when they both return a signal (N/O) that link is over worn (stretched)

I hope this makes more sense

I use the magnet and one sensor to determine how many links are in a revolution.
I think count how many excessively worn ones there is and compare it to the total link count
When the worn amount is grater than 5% of the total amount I fire an output for graphical display

Detecting the passing of a magnet is easy (use a hall effect sensor or reed switch).
Time between two sensors pulses, or between pulses from two sensors, is a little harder but also not that hard.
It sounds like that's the two parameters you're looking for - based on the results of those measurements you can trigger the alarm state.

I'm using the ServeralThingsAtTheSameTime as a base.

so far I think I've everything declared and just need to write int the actions.
Hopefully I can figure it out myself.

// Arduino nobitakun attempt
// Version 1.0
// God bless the Tightness of NMUK

// This project attempts to do the following
// Pickup a magnet moutned onto a moving conveyor chain
// count how many times a sensor changes state between two pulses of the magnet (link detect)
// check using a pair of sensors to detect when a chain link is excessively worn
// count how many links are excessively worn and compare it to the total number of links
// When 5% of the links are detected as excessively worn, fire an output for external use.

// Pins 1&2 are reserved for serial coms
// Pins 3,4,5 are for the two sensors and magnet sensor respectively
// Pin 7 will be used to reset the link count in the event the chain has been modified
// Pin 8 will be used for the relay to supply the signal out

// The signal from sensors 1&2 is 12V and is lowered to 5V using a resistor divider with R1=3.6Kohm and R2-2.2Kohm
// The arduino can power the 5V relay to switch the 110V signal line abck to the master panel


//   ------ Constants (wont change)-----

const int onBoardLedPin =  13;      // the pin numbers for the LED
const int Sesnor1Pin = 3;
const int Sensor2Pin = 4;
const int MagnetSense = 5;
const int LinkReset = 7;

const int RelayPin = 8;

//   ------ Variables (will change) -----

byte LinkNumKnown = LOW;      // used to tell if the total link count is known
byte ChainOverWorn = LOW;     // used to indicate if the chain is over worn

int LinkTotal = 0;            // used to store number of links in revolution
int WornLinks = 0;            // used to store number of worn links in revolution
int LastRevWorn[100];          // used to store number of worn links in last 100 revolutions
int WornLinkLimit = 0;        // used in the 5% of links calc

//==========================================================================================================================

void setup()  {

  Serial.begin(115200);
  Serial.println("Starting to measure chain wear");   // Now we know what is running


    // set the LED pin as output and relay as output:

    pinMode(onBoardLedPin, OUTPUT);
    pinMode(RelayPin, OUTPUT);

    // Set sensors and reset button as inputs

    pinMode(Sensor1Pin, INPUT);
    pinMode(Sensor2Pin, INPUT);
    pinMode(MagnetSense,INPUT);
  
}

//==========================================================================================================================

void loop() {

  // Notice nothing is done in loop() apart from reading the time millis()
  // Loop just calls the functions that will perform the actions

  currentMillis = millis();   //Capture the latest milis() value
}

wvmarle:
Detecting the passing of a magnet is easy (use a hall effect sensor or reed switch).
Time between two sensors pulses, or between pulses from two sensors, is a little harder but also not that hard.
It sounds like that's the two parameters you're looking for - based on the results of those measurements you can trigger the alarm state.

They way I wrote it in PLC is that I didn't time anything.

I had a Boolean condition for if a link was worn or not. and i just counted them and compared them again the total number of links.
So if both sensors came on together that link was worn, if one one sensor blipped it was ok.

The magnet acts as a reference for each revolution and allows me to evaluate the chain as a single defined length

I'm still not too clear on the sensors but it sounds like you can do the exact same as you did on the PLC with the Arduino.
Read the two sensors, if they're triggered at the same time it's worn, otherwise it's OK. Sounds quite trivial, though if the signals are short you may have to connect one to an interrupt, and in the ISR read the second. That way you check both sensors within a few microseconds from one another, for most practical applications that'd qualify as "at the same time".

Katsuki:
// count how many links are excessively worn and compare it to the total number of links

Is there a reason all the links will not wear evenly together?

Is there any kind of idler/slack chain mechanism involved?

dougp:
Is there a reason all the links will not wear evenly together?

Yes, mainly due to how massive the chains are (some are excess of 2Km long) and how well the link pins are lubricated

dougp:
Is there any kind of idler/slack chain mechanism involved?

Yeah, we use big tension tables with weight cages, once the tension table has traveled its full span we'll remove a pitch of chain, hence the requirement to count the links

We used to just hang the removed pitches up on the tension unit wall and when 5% had been removed it was time for a new chain, but we've had a few occurrences where the chain has snapped due to one very badly worn link pin

I don't understand how a magnet will stretch together with a chain link, but this may be a company secret. As already outlined, it's easy to check whether the two sensors are activated at the same time, and how often this happens.

Let me see if I can play this back to you and get it right.

There is only one magnet on the chain, attached to the chain. When that is detected, by either a hall sensor or reed switch, the current measurement cycle ends and a new cycle starts.

Sensor 1 is an optical sensor which counts the links as they pass. This gives the total number of links in the chain.

Sensor 2 is another optical sensor which is triggered at the same time as sensor 1 if a worn/stretched link passes them. If the link is not worn, sensor 2 is either not triggered at all or is triggered at a different time to sensor 1. So when we see sensor 1 triggered, we can then check sensor 2, and if it is also triggered we can count a worn link. Any overlap between sensor 1 and sensor 2 indicates a worn link, so while sensor 1 is activated, we must continually check sensor 2 for this overlap.

At the end of the cycle, the number of worn links is compared to the total number of links, and if this exceeds 5%, an alarm is triggered.

Thanks, now it makes sense :slight_smile:

You have a single magnet which is mounted on the chain.
You have two photoelectric sensors which are configured at a distance of 4.5 inches apart which are triggered when a link pin/roller passes.

Counting the total number of links in the chain is trivial.
If you assume that a simultaneous detection from the two sensors indicates a bad link, then the problem (and program) is also trivial.

However,
Is it safe to assume that a link is OK if it is not 4.5 inches long ? If it is 4.0 inches, then it clearly hasn’t stretched to the limit.
What happens, though, if it has stretched to 5.0 inches ? It passes the simultaneous detection test, but is clealy a bad link. To handle this
case makes the program more difficult because you now consider a timing element. That is say, we have a detection at sensor 1 but have not yet a detection at sensor 2 for the same link.

You can’t use any timing calculations to directly determine the length of a link because that requires a very accurate measure of speed which you don’t have.

Chain.JPG

Why not just measure sag of the chain on the 'return' journey to the driven gear... ?

  • or the displacement of a chain tensioner if there is one...?

lastchancename:
Why not just measure sag of the chain on the 'return' journey to the driven gear... ?

  • or the displacement of a chain tensioner if there is one...?

That would indicate stretch of the whole chain (and that's going to be a lot for a 2 km long chain just due to temperature changes). So that doesn't indicate reliably whether a chain is worn or not. Also it seems OP wants to know which individual links are broken, hence the checking of individual links and counting of them.

6v6gt:
Is it safe to assume that a link is OK if it is not 4.5 inches long ? If it is 4.0 inches, then it clearly hasn't stretched to the limit.
What happens, though, if it has stretched to 5.0 inches ? It passes the simultaneous detection test, but is clealy a bad link. To handle this

I don't expect this to be an issue as metal links won't suddenly stretch a lot (they'd break). It'll take lots of passes for a link to stretch beyond the detection window, and then it's been detected as bad already and presumably replaced.

I do have the feeling that it needs quite careful placement of the detectors as the difference between a good and a bad link is probably in the order of a few mm.

// Arduino nobitakun attempt
// Version 1.0
// God bless the Tightness of NMUK

// This project attempts to do the following
// Pickup a magnet moutned onto a moving conveyor chain
// count how many times a sensor changes state between two pulses of the magnet (link detect)
// check using a pair of sensors to detect when a chain link is excessively worn
// count how many links are excessively worn and compare it to the total number of links
// When 5% of the links are detected as excessively worn, fire an output for external use.

// Pins 1&2 are reserved for serial coms
// Pins 3,4,5 are for the two sensors and magnet sensor respectively
// Pin 7 will be used to reset the link count in the event the chain has been modified
// Pin 8 will be used for the relay to supply the signal out

// The signal from sensors 1&2 is 12V and is lowered to 5V using a resistor divider with R1=3.6Kohm and R2-2.2Kohm
// The arduino can power the 5V relay to switch the 110V signal line abck to the master panel


//   ------ Constants (wont change)-----

const int sensor1Pin = 3;
const int sensor2Pin = 4;
const int magnetPin = 5;
const int relayPin = 8;
const int wornLinksPctLimit = 5;

//   ------ Variables (will change) -----

int totalLinks;            // used to store number of links in revolution
int wornLinks;            // used to store number of worn links in revolution
int lastMagnet;
int lastSensor1;
int lastSensor2;

//==========================================================================================================================

void setup()  {

  Serial.begin(115200);
  Serial.println("Starting to measure chain wear");   // Now we know what is running

  // set the LED pin as output and relay as output:

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(relayPin, OUTPUT);

}

//==========================================================================================================================

void loop() {

  int magnet = digitalRead(magnetPin);
  int sensor1 = digitalRead(sensor1Pin);
  int sensor2 = digitalRead(sensor2Pin);

  if (magnet == HIGH && lastMagnet == LOW) {

    //measurement cycle ends
    int wornLinksPct = 100 * wornLinks / totalLinks;
    int alarm = wornLinksPct > wornLinksPctLimit ? HIGH : LOW;
    digitalWrite(relayPin, alarm);

    char msg[32];
    sprintf(msg, "links: %d, worn: %d (%d%%)", totalLinks, wornLinks, wornLinksPct);
    Serial.println(msg);

    //new measurement cycle begins
    totalLinks = 0;
    wornLinks = 0;
  }

  if (sensor1 == HIGH && lastSensor1 == LOW) totalLinks++;

  if (sensor2 == HIGH && lastSensor2 == LOW && sensor1 == HIGH) wornLinks++;

  lastMagnet = magnet;
  lastSensor1 = sensor1;
  lastSensor2 = sensor2;

}

(untested, of course!)

wvmarle:
That would indicate stretch of the whole chain (and that's going to be a lot for a 2 km long chain just due to temperature changes). So that doesn't indicate reliably whether a chain is worn or not. Also it seems OP wants to know which individual links are broken, hence the checking of individual links and counting of them.

I don't expect this to be an issue as metal links won't suddenly stretch a lot (they'd break). It'll take lots of passes for a link to stretch beyond the detection window, and then it's been detected as bad already and presumably replaced.

I do have the feeling that it needs quite careful placement of the detectors as the difference between a good and a bad link is probably in the order of a few mm.

My understanding was that individual links were not replaced. Sections of chain were removed to maintain its total length because of stretching. They decide to replace the whole chain when 5% of the links are bad.

I am also curious about the sensors and their detection profile in this application and also about the speed of the chain, but the OP says that it all worked with a different processor so the basic concept is, I guess, OK.

My assumption is that it's the bad (excessively worn) links that are being taken out, as they're detected individually so you know which ones (a matter of counting - though that's a lot of counting for a 2 km chain), but OP indeed isn't too clear about it.

ok, how about a short pre-tensioned segment of the chain path (say 20cm of tensioned rollers) - with an optical ‘through-link’ sensor to measure the ink-to-link interval.

Depending n the speed of the chain, you could compare the interval against a known/moving average to identify chain segments which are ‘overlength’.

This would require an index once per complete chain revolution - so the absolute link can be identified.

Hi,
If you have the PLC program working as required, can you post a copy of the PLC program please.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What voltage is the system working at?

Have you written any code, just to check the detection of all the inputs you have?

Thanks.. Tom.. :slight_smile: