Limit Switches with DC Motor

Hi everyone,

I am controlling a 12V DC motor forwards and backwards using the DC Motor Featherwing from Adafruit. I have the motor rotating a drive shaft which moves a slide horizontally. I purchased some limit switches so that when the slide hits the limit on either side, I would like for the motor to stop in that direction and send a control signal to the Arduino.

I want the motor to be stopped by hardware without the uC controlling it, but I do want the uC to get notified. Turning the motor in the other direction is the only way to move the motor. In code, I would just poll the A1 and A2 for a HIGH control signal.

I put together a schematic (attached) that I think may work. Does anyone see any issues with it? I'm new to motors, and I wasn't sure if current would still flow through to the Arduino from the 12V battery with this schematic.

You should NOT send 12v to an Arduino input. Negative 12V even more so!

I think the limit switches will stop the motor. You may be able to make the voltage safe for the Arduino input with a diode (to prevent negative voltages) and a voltage divider to reduce the voltage to between 4.5 and 5V.

So I can get by without connecting a ground pin from the 3.3V Arduino to the limit switch?

Hi,
Applying 12V to any pin on an Arduino would fry it instantly. :fire: Try this circuit: Screen Shot 2021-04-22 at 10.12.48 AM It uses MOSFETs to switch the Analog pins. When the a motor pin is high, the Arduino will read 0V. When a motor pin is low, the Arduino will read 3V. Any transistor would work instead of a MOSFET. Just make sure the gate voltage is fine up to the motor voltage (12V).

Is the motor to reverse direction under program control only or will there be manual intervention?

Is the motor to reverse direction under program control only or will there be manual intervention?

The motor will be reversed under program control using the DC Motor Featherwing. The code will still need to cut the motor off when limits are hit, but I was concerned about software hangs. I wanted to make sure the motor was turned off regardless of software (via the supply to the limit switch), but also get notified to turn off the motor at the Featherwing. Maybe it's over-engineered?

Thank you! Would a voltage divider work too? I attached a schematic.Screen Shot 2021-04-22 at 9.17.19 AM

Hi,
Yes. A voltage divider could work also. You would need R4 to be 3KΩ or lower though, seeing that your voltage divider would output 3.4V right now. Voltage Divider tool.

Hi,
How big is your 12V battery?
What type is it?
Have you got a fuse in the positive wire incase you have a short?

If you are using SLA or Lipo then they can supply 100's of amps into your project if there is a short, this would basically burn every track and component in its way.

Tom.. :grinning: :+1: :coffee: :australia:

Then I don't believe @kgray9's circuit will do what you want.  Once either switch is hit and stops operation the motor circuit is broken.  How can reversing direction now run the motor?

I think you'll need more hardware.

1 Like

Thank you all for the fast responses!

So, I think I'm going to stick with using the uC to switch off the motor via the featherwing when the limit switch is open. The 12V supply will only be connected between the featherwing and battery. I just don't quite have the knowledge nor expertise for hardware controlled.

How can reversing direction now run the motor?

I thought using a diode between the C and NC pins on both switches (but opposite direction) from the 12V supply would handle that. It should allow current to still flow through the other switch when one is broken. I just wanted the switch to send a signal to the Arduino when open (see my first schematic).

Hi,
You could attach the limit switches from +3V to the Arduino. That way when the limit switch is pressed, in your code you can tell the motor to stop with a relay or something.

Hi,
Yes, you are correct. The diode should do just that, but I forgot to add them in my schematic.

Yes, that's what I plan on doing now. Ideally, I wanted that to be done via hardware without the uC, but I just don't have the knowledge. Too many unknowns for me when dealing with a larger supply.

Hi,
If you are worried about the motor going out of control, fit an E-Stop switch within reach to disconnect power to your project.
Standard industrial practice.

Tom... :grinning: :+1: :coffee: :australia:

Thank you. I will definitely do that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.