ajohns1288 / AzElTracker

Arduino firmware to control https://www.thingiverse.com/thing:4664558
GNU General Public License v3.0
6 stars 2 forks source link

Unable to interface hall effect sensor and erratic behavior #2

Closed keyboarderror closed 2 years ago

keyboarderror commented 2 years ago

Hello, in trying to attach a hall effect sensor I've been unable to get a proper response with a couple of different Arduinos. I chose a fancier sensor (49E Hall Sensor LM393 Linear Hall Effect Sensitivity Detection Module https://www.amazon.com/dp/B09BJC64NM/ref=cm_sw_em_r_mt_dp_HVGCGJ5VT3JEXTQFBMHF?_encoding=UTF8&psc=1) thinking I could get it to connect in analog or digital mode but it doesn't seem to properly detect either.

In trying random hookups I can get an inverted detection with the sensor's digital output connected to the Arduino's analog input. I can confirm the sensor's proper outputs on a scope so it is working. I've tried configuring around various pins.

I actually don't seem to need the sensor if I set a digital input pin but depending on the specific Arduino the expected input may need to need inverted. Perhaps this is an internal pull resistor issue. Is there a mode to bypass it? Also one unit "just works" at startup while another needs a reset button press after power up or the elevation rotor just turns and the program seems stuck. I'm not sure what to attribute this to as the units look nearly identical. They program identically. I'd appreciate any thoughts. The one that just works has been great. I would hope it to be repeatable.

ajohns1288 commented 2 years ago

Two things I had to deal with when I set it up: 1: Magnet direction matters, one side will make the analog go down, one side will make it go up. 2: Fine tuning needed on the potentiometer to trigger the digital out at the right time.

I did account for the different sensor available in rotorParams.c:

define INVERT_DIG_HOME 0 //0: Home switch high when at home, 1: Home switch low when at home

define ANALOG_HOME_VAL 700

You should be able to play with those and it may work better. There should also be an option to assume 0 azimuth 0 elevation at start up if you select NO_HOME but I never actually tested that.

keyboarderror commented 2 years ago

Thanks very much for the reply. With a bit of time to test out your suggestions the sensor does indeed work in both modes. I had to reduce the threshold in ANALOG_HOME_VAL to 500 to get it to detect the output. So analog settings may need to be tuned for each build. It's polarity sensitive to the magnet as you said in both analog and digital. The sensor's LED still lights up the other way but the Arduino doesn't detect it.

I can also confirm sensorless operation with pinMode(NO_HOME, INPUT); in finalRotorPart.h works on both nanos. It's also necessary to set INVERT_DIG_HOME 1 in rotorParams.h. That might be a good default with the explanation of the other details for less experienced users such as myself. It's not really that hard to adjust manually.

That solves all the problems I had with my hardware. Otherwise it works really well. If there was a way to figure out why WispDDE can't connect to it in Windows it would be perfect. Currently I'm using Windows Subsystem for Linux version 1 with Xming to access the Arduino as a serial device and run Gpredict. But it works.

Thanks again for your efforts.