Help us with this cable winch counter!

It does look like the pulses may overlap, but I suspect there will be sufficient time between the starts of the two pulses to allow that to be ignored.

I had not realized there would be so many pulses per revolution.

@marengsen, please answer the question I asked back in Reply #4

You need to give us numbers for what you mean by fast or slow. How many pulses per second from the sensor.

And give us all the other information you have about the project so we don't have to prise it from you like a dentist pulling teeth.

...R

It would be easier to visualize the timing relationships from the perspective of a picture looking down on the ends of the Hall switches where they pick up the magnets. Is this possible?

Even better would be an o'scope picture of the two waveforms in action. With time/div included.

Hi,
I suspect the "hall sensors" are industrial inductive pickups.
The thread and shape gives the game away.

Can you tell us if the sensor design was you predecessors design, and did he know what he was doing?
Did he leave any documentation, especially on the sensors, part numbers etc.

Thanks.. Tom.. :slight_smile:
Have you connected an Oscilloscope to the sensors to see how the pulse timing is related?

Hi guys!

Thanks for all your comments yesterday. Really appreciate it, also trying to answer all your questions as good as I can with our currently very bad satellite Internet..

I've searched everywhere for our handheld Fluke Oscilloscope, but it seems one of my colleagues has brougt it to our workshop on land, so sadly I cant show you any pulses :frowning:

@Robin2 - Also I don't have any documentation at all from this project, all I did was take over the hardware which I assembled and some old code that was sort of half done, so I made it all from scratch, as the code I posted on page 1.

Guess we're stranded here. All I can say about the pulses is that when I rotate the wheel manually theres a small pause between the sensors react. How small is small? Well I cant rotate the wheel very fast by hand, but even 30 meters per minute with the hydraulics on isnt very fast and seems the interrupts follows just fine for this application. The counting part works just fine and I haven't noticed any "jumps" or "pauses" between the pulses - the counting seems very steady.

But even if I could post a picture of the two pulses, would that be a solution to differentiate the winch direction?

marengsen:
But even if I could post a picture of the two pulses, would that be a solution to differentiate the winch direction?

Have you tried the code I suggested in Reply #4?

The Arduino system is great for learning-by-doing.

...R

When you first posted the question, I imagined a roller with a single magnet, passing by two sensors. Then it's easy. Every time you see a pulse in a sensor it's one rotation; which of the two sees the pulse first tells you the direction it's moving in. The speed of the winch of course remains the easy one (just time the pulses of one of the sensors).

marengsen:
But even if I could post a picture of the two pulses, would that be a solution to differentiate the winch direction?

Maybe, maybe not. It would anyway be helpful in understanding the signal you get. With the many magnets I don't see clearly how you could see the direction.

What you could do - at the very least to visualise things for yourself - is write a sketch that reads both sensors every millisecond, and writes it out on your serial monitor with the time (the millis()) and the status of the two sensors (1 or 0). That you could then easily turn into a block wave using Excel (MS Office) or Calc (LibreOffice). Rotate a bit in both directions at as much as possible the same speed. Half a rotation will give you plenty of data points.

Compare the two, and see whether you can distinguish them in a meaningful manner - that way you determine the direction.

Something like:

loop() {
  currentmillis = millis();
  if (currentmillis > oldmillis()) {
    sensor1 = read_sensor1();
    sensor2 = read_sensor2()'
    Serial.print(currentmillis);
    Serial.print(", ");
    Serial.print(sensor1);
    Serial.print(", ");
    Serial.println(sensor2);
    oldmills = currentmillis;
  }
}

This assuming read_sensor1() and read_sensor2() are fast and return 1 or 0 depending on the status (magnet or not) within microseconds. Then copy/paste part of the the thousands of lines of output you get, and graph it.

If that doesn't work: maybe you could remove every other magnet or every two out of three, then your distance resolution drops but you get a moment where both sensors will return 0, and then for sure you'll be able to tell the direction.

Hi,
I assume that the sensor assembly has not been used before and this is part of the new construction.

So the concept of overlapping pulses may be behind the design, just not attained due to hardware layout.

To get over lapping pulses and a recognized method of speed and direction detection, the sensor spacing would have to be reduced.

Tom... :slight_smile:

wvmarle:
With the many magnets I don't see clearly how you could see the direction.

If that doesn't work: maybe you could remove every other magnet or every two out of three, then your distance resolution drops but you get a moment where both sensors will return 0, and then for sure you'll be able to tell the direction.

I can see how having so many magnets could cause a problem and it looks like it would be very easy to remove some of them as suggested.

I can't see that there would be any meaningful loss of data. The OP is probably measuring 10s or 100s of metres of cable and must also allow for unpredictable wave effects.

...R

As long as the edges are synchronous 'per magnet' to the sensors, the rules of quadrature still exist. They just occur more times per revolution, so you have to divide the total pulse count by the number of 'teeth'.

The pulse rate from any one sensor tells you how fast the reel is turning, while the continuous relationship between the overlapping pulses of both sensors tells the direction.
OTOH, you can also detect partial revolutions e.g. lash in the transmission - you won't lose resolution of the cable length that is spooled out.
A little logic and persistent variables can catch :
go-stop-go-stop-reverse-stop-go situations.

Hi,
I don't believe they are magnets, they are steel markers and the sensor is an industrial inductive sensor, not a Hall Device.

Tom... :slight_smile:

"Could" be those hall sensors that have a magnet built-in, and switch when the teeth go past - breaking the field.
Either way, OP needs to find out exactly what they are and qualify them against a known movement of the wheel, so he/we know what the impulse train looks like as a pair of sensors in the current mounted positions (if they are fitted correctly)

I think (hope) it's designed so that a single piece of metal passing the sensor pair will tell you which way the wheel is rotating. It looks as though only one at a time will trigger the sensors and if not you could remove every other to ensure that that's so. Given that, whichever sensor sees a signal first tells you direction and then you can just count pulses on it to get speed.

TomGeorge:
I don't believe they are magnets, they are steel markers and the sensor is an industrial inductive sensor, not a Hall Device.

I am inclined to that view also. I bought one of those things years ago to measure engine speed from the teeth on the starter ring on the flywheel with a PIC microcontroller. I lost interest and never finished it.

...R

Exactly.
I've done that in the past as well.
It's a fairly standard flywheel tacho technique.

wildbill:
I think (hope) it's designed so that a single piece of metal passing the sensor pair will tell you which way the wheel is rotating. It looks as though only one at a time will trigger the sensors and if not you could remove every other to ensure that that's so. Given that, whichever sensor sees a signal first tells you direction and then you can just count pulses on it to get speed.

Hi again. How exactly code-wise would you make it so that the sensor who sees the signal first, tells the direction?

I could move the sensors closer in a new box with sensor overlap - would that help?

Hope you can send me an example of knowing direction by sensing first.

Tom's reply #6 shows exactly how it works.
If the wheel turns in the opposite direction, the sensors effectively 'swap' precedence.

Quadrature Encoding
Abouit 2/3 down - it shows the phase relationship of the two sensors for both directions.

marengsen:
Hi again. How exactly code-wise would you make it so that the sensor who sees the signal first, tells the direction?

That's how the code in Reply #4 works!

Maybe I could resolve your doubts if you explain why you are not convinced?

But it does assume the "magnets" are far enough apart so that the time from the last pulse from (say) "magnet" A to the first pulse from "magnet" B is obviously greater than the time between the first and last pulses for "magnet" A. If the "magnets" are too close together that won't be the case - hence the suggestion to remove some of them.

I asked in Reply #24 if you had tried the code in Reply #4. I don't think you are going to make any useful progress without doing some experimentation so that you can see what different pieces of code actually do.

...R

marengsen:
Hi again. How exactly code-wise would you make it so that the sensor who sees the signal first, tells the direction?

It's a matter of using one or the other as a reference. Refer to post #6
Assume #2 is the reference. Now if #2 goes low while #1 is steady at low, that's direction A. If #2 goes low while #1 is steady at high that's direction B.

marengsen:
I could move the sensors closer in a new box with sensor overlap - would that help?

If you can get them close enough to produce the overlapping waveform in post #6, yes. As nearly as possible you have to position them such that one transitions in the middle of the other's steady time. This may not be possible if the gaps between targets are not the same size as the targets themselves. Normally quadrature encoders are made such that sensed on/off times are symmetrical. Additional thoughts - from the photos it appears the targets and gaps are not the same size, however, the signal may be the desired one since the sensors need a certain amount of material in front of them to trip from one state to the other. You may even be able to achieve this by adjusting the sensors slightly in or out toward the target.

If you're going to move one of the sensors I'd mount it in a box of its own and cut a slot in the mount to allow adjusting the sensor closer to/farther from the fixed one. This would give you some adjustment room to get the correct phase relationship.

marengsen:
Hope you can send me an example of knowing direction by sensing first.

Is any kind of FWD/REV signal available from the winch motor drive? If so, you could use something like: If motor in FWD count up on sensor #1 pulses. If motor in REV count down on #1 pulses.

I'm not a big fan of the last idea, but it can work.

Sensing direction with two-phase quadrature sensors is not all that hard to understand. and you'll be looking for other applications once you get it together!

It's not about whether the inputs are high or low, but where the 'other' input is when the first input 'changes' state,

lastchancename:
I'm not a big fan of the last idea, but it can work.

It's not optimum but in the middle of the ocean it may be the best of several not-so-good choices.