Turning off an output to a motor when it reaches the end

So I am working on a project that uses a DC motor controller and a mega 2560 (amongst other parts) and I am using 2 of the 2560 analog outputs as the forward and reverse buttons. So I am literally cutting the wires off at each of the buttons and connecting one wire to to coordinating analog out (say forward is 5, reverse is 6), and the other to GND, and then when I want the motor to go forward I just write output 5 to high. Now the thing is, this motor runs a linear actuator and when I connect the 2 motor wires (in either polarity), the motor runs in the proper direction but when it hits the end of its travel it just clicks off and stops, despite having it still connected. So if that were on the Mega 2560 I could keep that pin high all day, once it reaches its limit, that's it. But I don't want to keep it high all day. In fact, I want it to read when the limit has been reached and then go low. Without installing any additional hardware, is there a way that I can do this?

Here is all the info on the motor/actuator that I have

It sounds like the actuator has an internal limit switches. If so, it is OK for power to the actuator to be maintained as the motor will not be powered once it reaches the end

If there are no external connections to the limit switches then you could just run the motor for a fixed time longer than the maximum travel time before cutting the power

I did not understand your explanation of how the Mega, buttons and the actuator are connected. Please post a schematic of your circuit and the code that you are using

More information on the actuator


It does have internal limit switches

If there is no feeback from the actuator there is no way the Mega can know the actuator has reached the limit.

If you monitor current from the power supply you can know if any motor is running.

Assuming you are driving a motor and the current goes to 0 you can assume it reached the limit

That's pretty much what I figured. The internal limit switch was the only explanation for the system behaving the way that it does. I wish my brother hadn't bought that particular unit. Either way, creating a timed switch to low command or monitoring the current draw on the output of the DC motor controller are the only ways to make this puppy bark. Thanks guys. I'm going to see if I can dig up a simple pre-fabricated current monitoring pcb.

So can anyone help me out with a current monitor please? I have been reading up on the ASC712. I'm not sure if that's really what I want or not but I can't find anything else that fits better. I just want to be able to flip that DC motor controller input off.


I’m still looking for some help with the current sensor. My situation is very time sensitive so if anyone can help me, I would very greatly appreciate it. From all of the research that I have done I would say that the ASC712 is mostly intended to read and record the current draw on a circuit. A relevant tidbit is that although the circuit is not polarity sensitive, but the value measured is. I want to use this sensor only to monitor whether or not there is any draw on the circuit. The purpose being that once the internal limit switch on the actuator trips, opens the circuit, and causes the motor to stop drawing current my mega 2560 can then send the appropriate pin low, deactivating the relay and turning off power to the motor. That condition should be when the current sensor output sends 2.5V (VCC/2) into the associated pin on the Mega. Another kink is that the 2.5V will sometimes be positive, and sometimes negative.

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