I am having trouble getting Hall sensors working with an ESP32. I am using the Sensor test script for the examples. I am setting it up with external pullup resistors.
The sensors working voltage is 4.5 -24 VDC. I am running the sensor from 5V and using a potential divider the step the signal voltage down to the 3.3V level suitable for the ESP32. I am getting changes in the angle value but is not correct or consistent.
I have tried the motor on an Ardunio Mega and it all seems to be working fine. Although not with the potential divider as the ardunio is of course 5V.
Any ideas what is wrong?
Do you have access to an oscilloscope? In this case I think it would be useful to see the signals arriving at the ESP32.
Yes I do. Here is an pic of two traces from the hall sensors that is being recorded at the ESP input pins.
The motor is being run in open loop control at 6.28 rad/s. I would say they are appearing with a far bit of noise.
What do think?
I must admit I never use the Hall sensors, so I am just not sure what the issue might be.
I would be worried about the 1.5V downwards spike that the blue trace seems to have for every high period. That looks possibly low enough to trigger a low reading on the MCU. Looking at the patterns I’d say there is a fair amount of crosstalk too, look how the blue signals react to the rising flank of the red ones.
Maybe a small RC filter to help suppress these spikes would be good?
But perhaps there is someone on this forum who actually uses Hall sensors and could give you better advice than I can…
I have had a tidy-up on the breadboard and in seems to have cleaned up the signals. I think you were right there was a bit of cross-talk causing that spike which I guess was triggering the interrupt. I had thought about adding an RC low pass filter that might clean the signal but didn’t if any delay it might cause would cause further problems.
Anyway for now I have the motor running in closed loop voltage mode and getting some good rpm’s