Hi all,
I am newbe Bert.
Inspite of a lot of searching I am not able to find a solution.
Issue: For a turntable I use the most common stepper 28byj48 with ULN driver & Accelstepper to control it.
The turntable has various stopping positions, I use resistors and switches for inputting a DC value. So far no issues.
As an example I have stopping positions 1000-2000-3000-4000
The table turns clockwise from 1000 to 2000, 3000, 4000. And goes counterclockwise to go back from 2000 to 1000. I have implemented no code to do so, it seems AccelStepper knows the direction to go to
What I would like him to do is going clockwise from 4000 to 1000 since that is the shortest distance.
I have an idea to put something like this in the sketch to decide CW or CCW:
if newTrack - currentTrack >3000
go CW
else go
CCW
Any hints to solve this?
sounds like you're controlling a railroad turntable. if so ...
the some number of steps, N, turns the table one complete revolution. since AccelStepper operates with an absolute number of steps you may need to specify position 1000 as N+1000.
presumably the table has a calibration point which when passed can "reset" the position referenced by AccelStepper to zero.
Thanks for the quick reply.
Indeed its a railroad turntable. After switch on the zero position is detected. From then on the turntable runs very smoothly to the desired positions.
I do not understand "the some number of steps"?
Can you give an example in how the code would look like?
I have made a test setup, the table is just a design. I am waiting for a 10 leads slipring from China but will be pleased to keep you updated
The setup:
The design: