Arduino UNO with a digital hall effect switch to control relay question

Thread Starter

John4ll4

Joined Apr 9, 2016
6
I have an Arduino UNO set up with a potentiometer to adjust the amount of time(up to 10 seconds at present) a relay closes a pair of contacts when a magnet slides by a hall effect switch. The problem the setup is having is when the magnet is stationary over the hall effect switch, then the relay contacts stay closed until the magnet is moved away. I need the relay to stay on for the set time and then turn off until the magnet passes by again. Is it possible to program this function into the UNO and if so, would someone point me to a tutorial to help me figure this out. This is my first project with a microcontroller and programming anything other then a VCR. I have searched the forums for similar issues without any success. Sure would appreciate any advice you can give me. Thanks, John
 

BR-549

Joined Sep 22, 2013
4,928
It's gonna depend on your hall switch output and your control strategy.

"magnet slides by a hall effect switch" Is it a switch or sensor?

Do you need to know the position of magnet, or just if it's moving or not?

For position, you will need to compare magnitude of flux with a reference.

For movement, compare magnitude with itself over short time.
 

Thread Starter

John4ll4

Joined Apr 9, 2016
6
It's gonna depend on your hall switch output and your control strategy.

"magnet slides by a hall effect switch" Is it a switch or sensor?

Do you need to know the position of magnet, or just if it's moving or not?

For position, you will need to compare magnitude of flux with a reference.

For movement, compare magnitude with itself over short time.
It is a switch that outputs low when the magnet is moved across its face. If the magnet stops on the switch it will output low until the magnet
moves away. That is where the problem resides. If the magnet stops on the switch I need the arduino to read the low once and then ignore the continuous low until the magnet moves away from the switch and the cycle repeats. I am guessing that the sketch will need to run an interrupt to monitor this low condition, but I haven't been able to grasp just how to do this. I appreciate any help you can offer to get me moving in the right direction.
 

Thread Starter

John4ll4

Joined Apr 9, 2016
6
I just figured it out using StateChange Detection. It is working well now. Thank you for leading me in the right path. Now it's onto adding more functionality to the project.
 
Top