Using 3 prox sensors to monitor two Chain that needs to stay at equal length.

I have 3 prox sensors to monitor a chain stretch. Each chain has 47 pins which are going to trigger my sensors as they pass by. I also have 1 extra pin which i’m using as a zero flag( this pin is not in the way of the other 47 pins). 2 of the prox sensors are placed across from each other and I want my program to run in a way that , the program does not start to run until the zero flag prox is triggered. I also want the program to give me the times between 1 zero flag trigger and the next so I can know the chain revolution. I also want the program to record the times between the triggers of the two other prox sensors for the 47 pins simultaneous and restart from 1 whenever the zero flag sensor is triggered. This way, with time, the time differences between the two prox will tell me which of the two chains is stretching. I used pulseIn and I could not get good results. any help is very much appreciated.
Thanks in Advance.
I have attached my code below and the results I got for the first test but the pulse1 and pulse2 which are the time differences for triggers between prox1 and prox 2 are weird numbers at some places. Also the serial monitor does not stop displaying data when the chain stops running.

slatskewtest_int_and_pulsein.ino (2.48 KB)

test for slat skew.txt (311 KB)

The green bolt head is what the sensors are looking at.pdf (89 KB)

I want my program to run in a way that , the program does not start to run until the zero flag prox is triggered.

That is not going to happen. The program must be running in order to poll the proximity sensor(s). You can make the program start doing something different when the polling detects that the zero sensor has detected something..

I also want the program to give me the times between 1 zero flag trigger and the next

That''s easy enough to manage. That's what millis() is for.

I used pulseIn

For what?

So are you saying that there's no way the zero flag sensor can act as a switch to initiate the rest of the program?

if you look at my code then you can see what I'm trying to do with pulseIn. To basically act as a timer for the two other prox sensors. it would take about 17 seconds for the zero flag prox to be triggered again but the two other prox have to be triggered by 47pins within one revolution of the zero flag. I need to be able to measure the times between one trigger and the next for 47 pins using two prox sensors.

dohdesmond: So are you saying that there's no way the zero flag sensor can act as a switch to initiate the rest of the program?

No. I said it could be used to trigger executing a different section of the program. What you SAID you wanted was for it to START the program. And THAT can't happen.

I need to be able to measure the times between one trigger and the next for 47 pins using two prox sensors.

Suppose you have a watch and a stopwatch, and I have a two-by-four. I'm going to whack you on the head 47 times. I want you to record when each time I whack you. Are you going to use the watch (millis()) or the stopwatch (pulseIn())?

PaulS: I want you to record when each time I whack you. Are you going to use the watch (millis()) or the stopwatch (pulseIn())?

That's exactly my question. I used the stop watch but the results were inconsistent as you can see from the data I attached to the original post.

dohdesmond: That's exactly my question. I used the stop watch but the results were inconsistent as you can see from the data I attached to the original post.

No, I can't see that.

The stop watch is NOT the correct tool to use, to know WHEN something happened.

PaulS:
No, I can’t see that.

The stop watch is NOT the correct tool to use, to know WHEN something happened.

So how can I record times between whacks for 3 sensors where one of them is used to initiate the other two to start recording and restarts from 1 again when the zero flag sensor is whacked again. Any example code or flow I can work from?

I'm not clear on your description. Does each chain have a prox to sense its 47 pins or, only one chain has two proxes? Apparently, the time for one revolution of the chain which has the 'zero' pin is to act as a reference for the other chain. Yes?

dougp: I'm not clear on your description. Does each chain have a prox to sense its 47 pins or, only one chain has two proxes? Apparently, the time for one revolution of the chain which has the 'zero' pin is to act as a reference for the other chain. Yes?

Each chain has it's own prox to monitor it's 47pins and yes the zero is to act as the reference.

I'm not seeing how this will get you what you want.

Imagine an analog clock face. Make a mark on the second hand where it crosses the bottom of the '2' in the '12'. Make another mark on the second hand at the top of the '2'. Let the second mark represent the stretched chain. No matter how far out you extend the marks each will still take sixty seconds to return to some arbitrary point.

I notice your .txt file name. Could this be for a shoe sorter conveyor?

So how can I record times between whacks

You don’t. THAT is the point. You record the times OF the whacks and COMPUTE the intervals.

To record the times OF the whacks:

for(byte sensorNumber=0; sensorNumber<3; sensorNumber++)
{
   if(whacked(sensorNumber))
   {
      whackTime[whackCount++][sensorNumber] = millis();
   }
}

dougp: I'm not seeing how this will get you what you want.

Imagine an analog clock face. Make a mark on the second hand where it crosses the bottom of the '2' in the '12'. Make another mark on the second hand at the top of the '2'. Let the second mark represent the stretched chain. No matter how far out you extend the marks each will still take sixty seconds to return to some arbitrary point.

I notice your .txt file name. Could this be for a shoe sorter conveyor?

I did not understand your correlation of the analog clock face to what i'm trying to do and Yes it's for a shoe sorter conveyor.

Yes it's for a shoe sorter conveyor.

So, post some pictures showing the chains/sprockets/sensors, so we can get some idea whether you are trying to measure the right thing.

PaulS: You don't. THAT is the point. You record the times OF the whacks and COMPUTE the intervals.

Oh this makes sense now. I thought there was a way to measure times between whacks

dohdesmond: Oh this makes sense now. I thought there was a way to measure times between whacks

Can you measure the time between now and when I got up this morning? Or do you need to calculate that?

PaulS: So, post some pictures showing the chains/sprockets/sensors, so we can get some idea whether you are trying to measure the right thing.

I just attached a pdf file that has a picture of what i'm trying to do.

PaulS:
You don’t. THAT is the point. You record the times OF the whacks and COMPUTE the intervals.

To record the times OF the whacks:

for(byte sensorNumber=0; sensorNumber<3; sensorNumber++)

{
  if(whacked(sensorNumber))
  {
      whackTime[whackCount++][sensorNumber] = millis();
  }
}

This example code is for the 2 prox sensors monitoring the 47 pins right? and if that’s the case how do you get the zero flag sensor involved to act as a flag after 47 recordings from the 2 prox ?

dohdesmond: I just attached a pdf file that has a picture of what i'm trying to do.

Don't do that. If you add attachments, add them to a reply. Don't modify the original post.

I’m afraid the pictures don’t help a lot. The drawing shows two sensors “looking at green bolts”. Your post talks about 3 sensors, two of check are counting 47 pins.

It isn’t clear how knowing the interval between pins is going to tell you anything about chain stretch.