Hall sensor interference help

Hi,
I have a project that uses a 55100-3H hall sensor from Hamlin and it has worked great for a year or two and I now have problems with it adding state changes randomly.
I just finished going through my project and changing the unshielded cables for shielded ones, the cable drains all terminate back to the Arduino Due GND. I have 5 of these Hall sensors on my project but the one in question is mounted on a large stepper motor to count revolutions. I have it count 4 revolutions and then everything stops and moves back to a ready position.
The problem is occurring when the motor starts to move it will add an extra count in the middle of the count to 4.
I have a .1uf cap mounted next to the Hall sensor on the Vcc(+5V) and GND and a 220 ohm Pullup Resistor on the the signal wire to the Due.
If I try any larger resistor the Hall sensor activates randomly to the point that it's useless to use, I have tried using the 10K internal resistor and a 4K7 resistor and both caused the random activation.
I have double checked all my connections and even switched out the Hall sensor but nothing changes the erratic behavior.
I'm not sure where to go next and any help is appreciated.
Spec sheet below.
https://www.mouser.com/datasheet/2/240/Littelfuse_Hall_Effect_Sensors_55100_Datasheet.pdf-938874.pdf

Stepper motors are motors so they generate quite a field. Have you tried taking it off the motor and testing it?

You're describing a typical EMI scenario. It's impossible to address without full wiring diagrams and complete close up photographs of your hardware.

Shielding wires by itself is not sufficient, there is an "art" to it, so we need to know exactly how you've done that too.

And, until most people struggle like you are doing, they eventually discover they have grounded both ends of shielded wiring so what used to be a shield is now a conductor of their noise.
Only one end of a shield is connected to the lowest impedance ground in your project. That would be closest to the power supply.
Good luck
Paul

Can you tell us how you are using this hall sensor to count revolutions?
i.e. is there a magnet on the shaft you are counting or are you trying to sense any magnetic leakage from the motor?

I haven't yet, I would have to figure a way to hold it in the air while the motor turns.

Stepper motors are motors so they generate quite a field. Have you tried taking it off the motor and testing it?

I'm having to redo the whole thing so it will take a little time for a diagram.

You're describing a typical EMI scenario. It's impossible to address without full wiring diagrams and complete close up photographs of your hardware.
Shielding wires by itself is not sufficient, there is an "art" to it, so we need to know exactly how you've done that too.

I was sure not to terminate the shielding at the business end of the cable. The only cable in question would be the shielded cable going from the motor to the Driver, I connected the drain line from that cable to the drain line on the cable carrying the step and direction signals to the Driver and the drain goes back to the Arduino GND.

And, until most people struggle like you are doing, they eventually discover they have grounded both ends of shielded wiring so what used to be a shield is now a conductor of their noise.
Only one end of a shield is connected to the lowest impedance ground in your project. That would be closest to the power supply.
Good luck
Paul

I have a magnet on the shaft of the stepper that passes by the Hall sensor.

Can you tell us how you are using this hall sensor to count revolutions?
i.e. is there a magnet on the shaft you are counting or are you trying to sense any magnetic leakage from the motor?

Photo?

And is that shaft made of steel. by any chance?
Paul

What happens if, when counting starts, the switch is already activated (the magnet is over the switch)? Post your code and a diagram of how the switch and magnet are arranged.

Here is a photo of how it is attached and the printed magnet holder that passes by it to activate it.
https://ibb.co/5nZn9m0

Here's the code to count the passes.

int Sensorcounter = 0;
int SensorcurrentState = 0;
int SensorpreviousState = 0;
int Sensor = 47;

void setup() {
  pinMode(Sensor, INPUT);
  Serial.begin(115200);
}

void loop() {
  SensorcurrentState = digitalRead(Sensor);     //used to time all events
  if (SensorcurrentState != SensorpreviousState) {    //check the count and add 1
    if (SensorcurrentState == 1) {
      Sensorcounter = Sensorcounter + 1;
      Serial.println(Sensorcounter);
    }
  }
  SensorpreviousState = SensorcurrentState;
}

So, now you don't have a magnet attached to the shaft of the motor.

Hi,
Have you swapped sensors around to see if the fault moves with the sensor or not?

Tom... :smiley: :+1: :coffee: :australia:

Yes I have, the sensor works fine in any other position I put it in with that same cable or one of the other cables that connect the other Hall sensors I have.

It's attached to the shaft with a 3D printed holder that clamps around the shaft.

Not quite the same, is it?

I have taken the cable that comes off the Hall sensor and crossed it 90 degrees to the motor supply lines and the problem has gotten much better. I ran it this morning for a couple hours and only got 3 or 4 miscounts which brings it back to the nuisance level where before it was about 50 or 60 miscounts before.
I will upload a picture when I get back home.

I don't know what you're trying to convey, does it make a difference whether it's on the shaft?

On the shaft will magnetize the entire shaft. As you have it mounted it will only magnetize the shaft a little bit.

Good to know, Thanks.

Can you not afford a better picture?