Stepper/servo GO TO endstops without microcontroller - Page 1
Forum section: electronics / beginners

author: meikr
author_rank: Newbie
timestamp: April 16, 2025, 11:43:07 am
content: Hi,I've built a rover with pixhawk 4 flightcontroller with ardupilot and want to expand its functionality.Currently would like to make a raising mechanism with a single motor and a hinge.First in it's basic form to be able to go max up and max down. Controlled by two relays. Relay 1 - Go max up, Relay 2 Go max down.Then I'd like it to be able to set specific height. (maybe by controlling how much time the relay is ON?)If possible I'd like to evade using a microcontroller like arduino or raspberry. Research tells me that it's possible but would it complicate things more than with a microcontroller?1) Stepper:My initial plan was to use a stepper motor,TMC2209 driver, threaded rod and nut. The driver has integrated stall detection so hopefully no need for mechanical endstops. It also has an "Integrated Pulse Generator" so this might be of help too to ditch the microcontroller. Unfortunatelly ardupilot does not support controlling stepper motors so they do it with relays and microcontrollers.2) Servo:Ardupilot supports servos. Do you think I could do the same functionality with a 360 servo?What would be a proper way to tackle this problem?Thanks!

author: MrAl
author_rank: Super Contributor
timestamp: April 16, 2025, 12:51:30 pm
content: Quote from: meikr on April 16, 2025, 11:43:07 amHi,I think you'd have to find a way to generate a PWM signal for the servo, with minimum and maximum pulse width. You'd probably need at least a 555 timer IC but there are other ways to generate a PWM signal.Look up driving a servo with a 555 timer.

author: jwet
author_rank: Frequent Contributor
timestamp: April 16, 2025, 03:56:54 pm
content: Stepper motors are very forgiving about running into hard stops- of course your drive train has to be equally stout. Commodore and Apple floppy drives drove the head motor into the stops on every power up- this is that characteristic floppy sound on those vintage machines.Little microcontrollers are so cheap and easy, something like an AT Tiny85 that can be programmed in the Arduino framework would give you a lot of flexibility. It could drive a Stepper through a 2209 etc or generate PWM's for servos.The traditional way to do this is servo- though servos don't generally take well to being driven into stops.

author: xvr
author_rank: Frequent Contributor
timestamp: April 17, 2025, 01:05:30 pm
content: In this application, it is better to use a servo. A servo is an absolute positioning device. It receives a  PWM signal and sets the corresponding angle on its axis.The stepper motor does not track position. You can command it to step forward or backward, but you have to remember its current position and somehow determine the starting angle (when the system is turned on).

author: rachelrowallan
author_rank: Newbie
timestamp: April 18, 2025, 08:30:05 am
content: Hey all,Thanks for the detailed replies — really appreciate the insight!I was originally leaning towards a stepper motor mostly because of the TMC2209’s stall detection, thinking I could skip mechanical endstops altogether. But yeah, the point about needing to track position still stands — once power cycles, it’s all gone unless I implement some sort of homing routine, and without a microcontroller, that gets messy fast. I didn’t realize older tech like floppy drives just slammed into hard stops — wild.The servo route is starting to look more reasonable, especially since Ardupilot supports it natively. I hadn’t considered the 555 timer option for PWM — definitely gonna look into that. Might be a clean solution for basic up/down control without adding a full microcontroller setup. Though like some of you mentioned, servos don’t like hitting hard limits, so I’ll probably need some mechanical cushion or limit switch just in case.Wil je meer halen uit je ervaring bij Lalas Bethttps://lalasbet.com/promotiecode/? Check dan de promotiecodes op lalasbet.com/promotiecode. Hier vind je altijd de nieuwste acties waarmee je bijvoorbeeld gratis speelgeld of extra spins kunt krijgen. De uitleg is kort maar krachtig, zodat je direct weet wat je moet doen. Ideaal voor nieuwe spelers die willen starten met een voordeel of terugkerende gokkers die graag profiteren van aanbiedingen. Vergeet niet je code in te voeren bij registratie of storting!At the end of the day, I might cave and go with something like an ATtiny just to keep it clean and flexible, especially if I go back to steppers later.Appreciate the tips!

author: MrAl
author_rank: Super Contributor
timestamp: April 18, 2025, 03:48:18 pm
content: Hello,Another point I might mention is that I had a servo one time that would get stuck at the end points if there was no limit to the control pulse. There was apparently no way to get it unstuck without physically moving it by hand. You may want to make sure that is not the case with yours.

author: SteveThackery
author_rank: Super Contributor
timestamp: April 18, 2025, 05:20:39 pm
content: Quote from: rachelrowallan on April 18, 2025, 08:30:05 amThat system, whereby you send enough pulses to a stepper motor to drive it into an end stop no matter where it starts from, is used extensively. I remember printers back in the 1980s doing that, and the secondary throttle on one of my motorbikes works the same way.In actual fact it isn't entirely foolproof. Sometimes a stepper motor so driven will "bounce" off the end stop. It isn't literally a bounce, but depending on exactly where the armature stops it can chatter between two adjacent positions until the drive pulses end. At that point it is essentially random as to which of the two positions it stops in. One of the 1980s printers I worked on got round that by driving the motor against the end stop, and then slowly stepping it forwards step-by-step until the attached mechanism broke an optocoupler beam. It was set up such that the resolution was reliably down to an individual motor step.The motorcycle is weirder: for some reason the mechanism appears to bounce several steps, apparently stepping in the wrong direction briefly. I don't understand how that can happen, but sometimes stepper motors can go nuts when driven at their resonant frequency. Perhaps it's that. I cured it on mine by adding a gentle spring to the mechanism to help it stay against the end stop. When driven normally, in the opposite direction, it is easily strong enough to overcome the added spring force.