Interrupt pins stay triggered when powering on Stepper Controller

hhelmbold
Posts: 7
Joined: Wed May 27, 2020 3:12 pm

Interrupt pins stay triggered when powering on Stepper Controller

Postby hhelmbold » Wed May 27, 2020 3:27 pm

I just started using the ESP32 and having issues using interrupt pins. All of this is working on an Arduino board but I would like to switch over to the ESP32. I have 2 Hall Effect switches connected to pins 32 and 33. The Stepper motor is on pins 16 (DIR), 17 (PUL) and 4 (ENA)

The Stepper motor works when I test it with a simple sketch (Nema 42 using a Microstep Driver DM556S). The Hall Effect Switches works when I test them with a simple sketch, but if I power on the stepper motor's power supply the interrupts immediately gets triggered. As a newby this is really confusing me. Attached is an image of the layout and the code will follow.

With the power to the stepper motor OFF and running the sketch I get "Triggered" when the magnet moves over the Hall Effect Switches. The moment I turn on the power to the stepper motor I just get an endless loop of "Triggered" in the serial monitor.
  1. const byte RightHallPin = 33;
  2. const byte LeftHallPin = 32;
  3.  
  4. void setup() {
  5.   Serial.begin(115200);
  6.   pinMode(LeftHallPin, INPUT_PULLUP);
  7.   pinMode(RightHallPin, INPUT_PULLUP);
  8.   attachInterrupt(digitalPinToInterrupt(LeftHallPin), chgdir, RISING);
  9.   attachInterrupt(digitalPinToInterrupt(RightHallPin), chgdir, RISING);
  10.   Serial.println("Initialised");
  11. }
  12.  
  13. void chgdir() {
  14.   Serial.println("Triggered");
  15. }
  16.  
  17. void loop() {
  18.   delay(1);
  19. }
Attachments
ESP32-uncomplicated_bb.png
ESP32-uncomplicated_bb.png (119.79 KiB) Viewed 4184 times

ESP_Sprite
Posts: 9769
Joined: Thu Nov 26, 2015 4:08 am

Re: Interrupt pins stay triggered when powering on Stepper Controller

Postby ESP_Sprite » Thu May 28, 2020 6:50 am

Do you have an oscilloscope you can connect to the Hall sensor output pins? Sounds like you're getting interference from the steppers on those lines.

hhelmbold
Posts: 7
Joined: Wed May 27, 2020 3:12 pm

Re: Interrupt pins stay triggered when powering on Stepper Controller

Postby hhelmbold » Thu May 28, 2020 10:50 am

Unfortunately not... and doing this as a hobby I admit I don't always know what I am doing. I also think it is interference...

I have also tried a simple digital pin sketch that will display 0 or 1 for the Hall Effect switch, not using interrupts, just using the basic loop function and a delay(200).

The result is that it will display 0 for a while, then display 1, then display 0, then display 1 - all this without a magnet, so it does look like it is interference which I don't get on the Arduino boards. But I also know the Arduino boards has some extra resistors etc built onto the board which the esp32 doesn't have.

I think my question is maybe what can I add to reduce this interference? :D

hhelmbold
Posts: 7
Joined: Wed May 27, 2020 3:12 pm

Re: Interrupt pins stay triggered when powering on Stepper Controller

Postby hhelmbold » Thu May 28, 2020 5:27 pm

UPDATE - I placed a 104 Ceramic capacitor over the Gnd and VIN wires of the Hall Effect Switch and this is giving better results. It seems like it is more stable and I can use the switches for now. Not sure if this is the correct solution, but it's working for now.

Who is online

Users browsing this forum: vritzka and 92 guests