Encoder signal through a very long wire

AnalogKid

Joined Aug 1, 2013
11,041
You might have said this already - max frequency of either signal line?

Also, I think the idea of moving the XOR function out to the encoder was that there already is power out there to run the encoder chip, so there is no net increase in wire count as long as there is sufficient current available. Or something like that.

ak
 
There is no reason whatsoever to do an XOR. Use mode 2, step output. It's direct, simple and has less to fail.

But why are you using this bizarre magnetic rotation encoder? Is there some special application that requires rotation? And what are you going to do with multiple pulses in the MCU?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
There is no reason whatsoever to do an XOR. Use mode 2, step output. It's direct, simple and has less to fail.

But why are you using this bizarre magnetic rotation encoder? Is there some special application that requires rotation? And what are you going to do with multiple pulses in the MCU?
There are several reasons, actually:
  • With an XOR gate at the encoder side, I reduce by one the number of wires needed to transmit the signal back to the MCU (in this case two, because I'll be using a differential twisted pair), since my application does not need to detect direction of rotation. Also so a single input pin into the MCU does not only simplify things electronically speaking, but makes the code far easier to write as well.
  • You're right about mode 2, but that requires extra work in programming and complicates the circuit design a bit, since a 7.5V source is needed to program the part
  • As for the use of a magnetic encoder, I've used them before, and are extremely reliable. In fact, they're much sturdier than optical ones since they are very robust and resistant to vibrations and dirt, and the circuit can remain completely isolated from the source of rotation. Also, they can tolerate a small misalignment. My application does not require this, but this sort of encoder has the capability of working underwater (even saltwater) if you place the magnet under the chip (under the PCB), just as I'm planning to do myself. That allows you to encapsulate the circuitry in a perfectly sealed enclosure, making no physical contact with the rotating magnet.
 
There are several reasons, actually:
  • With an XOR gate at the encoder side, I reduce by one the number of wires needed to transmit the signal back to the MCU (in this case two, because I'll be using a differential twisted pair), since my application does not need to detect direction of rotation. Also so a single input pin into the MCU does not only simplify things electronically speaking, but makes the code far easier to write as well.

  • You're right about mode 2, but that requires extra work in programming and complicates the circuit design a bit, since a 7.5V source is needed to program the part
But why do an XOR at all? If you're averse to the programming, then just use one quadrature output, since you don't care about direction. It's a clean and simple square wave:




  • As for the use of a magnetic encoder, I've used them before, and are extremely reliable. In fact, they're much sturdier than optical ones since they are very robust and resistant to vibrations and dirt, and the circuit can remain completely isolated from the source of rotation. Also, they can tolerate a small misalignment. My application does not require this, but this sort of encoder has the capability of working underwater (even saltwater) if you place the magnet under the chip (under the PCB), just as I'm planning to do myself. That allows you to encapsulate the circuitry in a perfectly sealed enclosure, making no physical contact with the rotating magnet.
OK so those are the benefits of magnetic encoders. But why are you using an encoder at all? I haven't seen any mention of what it's for.
 

WBahn

Joined Mar 31, 2012
30,055
There are several reasons, actually:
  • With an XOR gate at the encoder side, I reduce by one the number of wires needed to transmit the signal back to the MCU (in this case two, because I'll be using a differential twisted pair), since my application does not need to detect direction of rotation. Also so a single input pin into the MCU does not only simplify things electronically speaking, but makes the code far easier to write as well.
But the quadrature output isn't there just so that you can detect direction of rotation. It is there so that you don't have to debounce the signals If you XOR them together then you will present a bouncy signal to your MCU. You've indicated that you don't want to use one of the modes because of the additional code that you would need to write. So why suffer the additional code needed to debounce the signals when the quadrature nature of the signals will do that automatically for you?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
But why do an XOR at all?
Because if I don't XOR the outputs, and use a single output (channel) instead, I'd lose resolution. 50% to be precise.

why are you using an encoder at all?
I want to measure and keep track of a flat strip of stainless steel (about 1.5" wide) being dispensed from a coil. For that purpose, I'll be using a couple of free-spinning heat-treated rollers pressing against each other with the stainless steel strip sandwiched between them.
 
Last edited:
Because if I don't XOR the outputs, and use a single output (channel) instead, I'd lose resolution. 50% to be precise.


I want to measure and keep track of a flat strip of stainless steel (about 1.5" wide) being dispensed from a coil, for that purpose, I'll be using a couple of free-spinning heat-treated rollers pressing against each other with the stainless steel strip sandwiched between them.
Thank you. It makes perfect sense now.

I was confused by the other related thread.

How are you getting power out to the encoder chip? If it has to go along the long wire, I would use two twisted pairs -- one for signal and ground and one for power and ground so whatever magnetic field noise they encounter they'll all cancel out.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
But the quadrature output isn't there just so that you can detect direction of rotation. It is there so that you don't have to debounce the signals If you XOR them together then you will present a bouncy signal to your MCU. You've indicated that you don't want to use one of the modes because of the additional code that you would need to write. So why suffer the additional code needed to debounce the signals when the quadrature nature of the signals will do that automatically for you?
Thanks for your comments, W, they're always welcome and thoroughly appreciated. I don't think I need to debounce the signals, since the encoder chip already has an hysteresis of 0.704 degrees in it. You can check, page 7 of its datasheet for this spec.
Unless you mean that my arrangement would be susceptible to noise... But as I mentioned before, the XOR gate would be attached to the encoder's output, and its output will then be transmitted to the faraway MCU deferentially using an RS485 chip using twisted-pair cabling.
 
But the quadrature output isn't there just so that you can detect direction of rotation. It is there so that you don't have to debounce the signals If you XOR them together then you will present a bouncy signal to your MCU. You've indicated that you don't want to use one of the modes because of the additional code that you would need to write. So why suffer the additional code needed to debounce the signals when the quadrature nature of the signals will do that automatically for you?
How does quadrature eliminate the signal debouncing need?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Or, one twisted pair that takes power out, brings data back, cancels noise, and is only 140 years old. POTS has been doing this a loooong time, the great-grandfather of the 4-20 mA current loop. What is the max. pulse rate of the output?

ak
I'm expecting less than 10 kHz... mind elaborating over this POTS thing you've mentioned?
 

WBahn

Joined Mar 31, 2012
30,055
How does quadrature eliminate the signal debouncing need?
Because you can just let your step counter respond to all the bounces. For instance, if A is HI and B is LO and then it moves CW until B goes HI (I'm using an arbitrarily assigned sequence) you add 1 to the step counter (I'm assuming the step counter increases for CW rotation). Now if B bounces LO you subtract the 1 back off. If it bounces HI and LO a thousand times you are simply adding and subtracting the same step from the total and once it settles down in the HI condition you will be left with a count value that has incremented exactly once. All the is necessary is for the bounces in one phase to end before the first transition of the other phase, and that is pretty much guaranteed by the design of the encoder.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Because you can just let your step counter respond to all the bounces. For instance, if A is HI and B is LO and then it moves CW until B goes HI (I'm using an arbitrarily assigned sequence) you add 1 to the step counter (I'm assuming the step counter increases for CW rotation). Now if B bounces LO you subtract the 1 back off. If it bounces HI and LO a thousand times you are simply adding and subtracting the same step from the total and once it settles down in the HI condition you will be left with a count value that has incremented exactly once. All the is necessary is for the bounces in one phase to end before the first transition of the other phase, and that is pretty much guaranteed by the design of the encoder.
I understand your concern now. Yes, that's a problem I've encountered in previous situations, and of course I've had to use both channels and extra code to make sure that bouncing is looked after and cancelled accordingly. Suffice it to say that the machine's design does not allow for play or vibration back and forth anywhere near the encoder's inherent hysteresis. That's why I'm not worried about that issue.
 

WBahn

Joined Mar 31, 2012
30,055
If you're satisfied that it's not an issue in your application, then certainly go for it. Worst that happens is that it turns out that it actually is an issue and you have to go back and deal with it.
 

AnalogKid

Joined Aug 1, 2013
11,041
POTS - Plain Old Telephone Service. Yes, that's really the name. https://en.wikipedia.org/wiki/Plain_old_telephone_service

In general terms, POTS is a two-wire balanced system that is biased with DC from a medium-output-impedance voltage source or a current source. For example, 48 Vdc, 900 ohms, wire out, device, wire back, 900 ohms, GND. Modulation of the DC source can be picked up by the device, and the device can modulate its output impedance to impress information on the loop that can be picked up back at the source. Your application is one-way only, much more simple than a phone. The phone company moves 4 kHz low-level audio and megabit ISDN data for *miles* with this over unshielded twisted pairs. If you've ever worked with 4-20 mA instrumentation, that is a variation of the original. https://en.wikipedia.org/wiki/Current_loop

There are specialized 4-20 mA chips, data protocols, etc. But your application is restricted and tightly bounded, so I think a complete system would be pretty simple. 21 mA at 5 V is not a lot of power.

ak
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
If you're satisfied that it's not an issue in your application, then certainly go for it. Worst that happens is that it turns out that it actually is an issue and you have to go back and deal with it.
Good point... I'll leave the PCB's prepared for that worst case scenario, then. Also, I can always add another shielded twisted pair cable if necessary.
Thanks for the advice.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
POTS - Plain Old Telephone Service. Yes, that's really the name. https://en.wikipedia.org/wiki/Plain_old_telephone_service

In general terms, POTS is a two-wire balanced system that is biased with DC from a medium-output-impedance voltage source or a current source. For example, 48 Vdc, 900 ohms, wire out, device, wire back, 900 ohms, GND. Modulation of the DC source can be picked up by the device, and the device can modulate its output impedance to impress information on the loop that can be picked up back at the source. Your application is one-way only, much more simple than a phone. The phone company moves 4 kHz low-level audio and megabit ISDN data for *miles* with this over unshielded twisted pairs. If you've ever worked with 4-20 mA instrumentation, that is a variation of the original. https://en.wikipedia.org/wiki/Current_loop

There are specialized 4-20 mA chips, data protocols, etc. But your application is restricted and tightly bounded, so I think a complete system would be pretty simple. 21 mA at 5 V is not a lot of power.

ak
I like it... but the equipment is not so far off that I'd be willing to spend all that extra work and design hours just to save on a little cabling. It's good to have learned something new, though. Thanks a lot.
 

kubeek

Joined Sep 20, 2005
5,795
Good point... I'll leave the PCB's prepared for that worst case scenario, then. Also, I can always add another shielded twisted pair cable if necessary.
Thanks for the advice.
If you simply use a CAT6 cable you should have the pairs already in.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Just thought I'd let you all know how things worked out in the end... and that's PERFECTLY :)

I used the following circuit to feed the encoder's signal to my MCU:

Capture.JPG


The filtering section is optimized to work at 60 Khz, and the XOR gate is performing flawlessly. I am now able to measure and cut an SS tape up to 6m long, at a speed of 1.5m per second, with an accuracy better than ±0.2mm :eek: !

As a recap: the reason I used an XOR gate is because the SS tape is fed in only one direction, with no backslash, so no direction of motion analysis is necessary.

Thank you all who helped me out in this thread.
 

Attachments

Top