Interference Triggering Interrupts on Arduino Nano

Hi,

I am having a problem where I am trying to read a rotary encoder, using pin change interrupts. The encoder is coupled to a Nema23 stepper motor driven by a completely separate board. The problem is that when I try to count the pulses from the rotary encoder (at about one pulse every 50 milliseconds) I actually generate interrupts at the motor pulse frequency of about 1000 Hz. This happens even when the Nano has NO connections to anything other than the 4 wires to the rotary encoder (+5volts, Channel A, Channel B and Ground) and the miniUSB that provides power to the Nano and produces the serial output.

When I measure the voltage on the Nano 5 volt pin it is 4.61 volts - this I assume is the voltage from the USB port on the computer. This voltage is the same when it is applied to the Nano before it is plugged into my board.

Doing more investigations I found that if I disconnected the wires that run from my board to the Rotary Encoder - a length of about 500 mm of unshielded four way ribbon cable - the spurious interrupts stopped when the wires were still attached to my board but now as far away as possible from the stepper motor.

Even then, when I touched the ribbon cable when the motor was running, the interrupts started again.

It seems to me that my problem is some sort of RF interference and my question is what steps I can take to remove it as much as possible. Any suggestions would be very helpful as I know very little about electronics and I am now at the stage of tearing my hair out.

Thanks, Hugh

Do you have 5v pullups on the A/B outputs from the encoder?

How long is the cable to the encoder and what sort is it? Have you connected the ground wire to
anything other than the encoder ground at the motor (you mustn't, it must be separate from
the motor frame or any metalwork associated from the motor).

Hi,

Cattledog - no, no 5volt pull-ups. The encoder is a Bourne optical encoder and - as far as I know - doesn't need pull-ups. I would be happy to add them if they help.

Mark-T - the cable to the encoder is about 500 mm long and is unshielded ribbon cable. The encoder ground is connected to the same ground that the motor uses. For clarity - the encoder is not part of the motor, it is a completely separate component and the motor shaft is coupled to the encoder shaft using a flexible coupling.

Regards, Hugh

The encoder is a Bourne optical encoder and - as far as I know - doesn't need pull-ups.

Do you have the exact part number or Data sheet?

It's quite possible that the encoder has push-pull outputs instead of open collector and does not require the pull ups.

Hi Cattledog,

The encoder is a Bourns ENA1J-B28-L00064L. From the Data Sheet

Electrical Characteristics
Output .............. 2-bit quadrature code, Channel A leads Channel B by 90 º (electrical) with clockwise rotation
Resolution.......... 25 to 256 cycles per revolution
Insulation Resistance (500 VDC) ........ 1,000 megohms
Electrical Travel ...Continuous
Supply Voltage.....5.0 VDC ±0.25 VDC
Supply Current.... 26 mA maximum
Output Voltage
Low Output ........0.8 V maximum
High Output........4 V minimum
Output Current
Low Output ....... 25 mA minimum
Rise/Fall Time .....200 ns (typical)
Shaft RPM (Ball Bearing) ...... 3,000 rpm maximum
Power Consumption ..............136 mW maximum
Pulse Width (Electrical Degrees, Each Channel) .....180 º ±45 º typ.
Pulse Width (Index Channel) ............................. 360 º ±90 º
Phase (Electrical Degrees, Channel A to Channel ...90 º ±45 º typ.

I don't understand most of this but perhaps the 'Low Output..........25mA Minimum' means it can sink this much current? If so, would I be OK to use say 1k pull-up resistors to minimise the effects of RF interference?

Regards, Hugh

Output Voltage
 Low Output ........0.8 V maximum
 High Output........4 V minimum

This indicates a "push-pull" design, and there is indeed active voltage from the encoder at both high and low so pull ups or pull downs should not be required.

I don't think that adding the pull ups/pull downs at >1K can hurt. I'm not sure which you would use. Perhaps both?

Hi Cattledog,

Thanks for that. I will try a sequence

say 2.2k pull-downs first

then try adding 0.1uF as well

then add 2.2k pull-ups too

I will also change the wiring from the stepper driver (Leadshine M542) to the stepper motor - at present this is just plain 4-core cable but I think I've got some 3 x 2 twisted pair stuff with shielding round each pair.

I will try everything tomorrow and report back.

Thanks again, Hugh