AccelStepper question

Hello

I want to make a camera slider for time-lapse (probably not the first one) and I'm a bit stuck with the flow I'm setting up.

I want a 2-motion slider, where one motor will slide the unit and the other motor will rotate the cam to a certain point over time.

Is it possible to set a begin and endpoint for a stepper by measuring it's current position? I'll try to explain...

The setup now is that the cam will move left to right over a period of time for the time lapse. That's not difficult. I would like that I can set the from-to rotation of the cam somehow.

I thought something like:

  • A +/- button in the startpostion to set the motor2 zero point. So the cam might be rotated from the start.

  • move the dolly to the left side to the point where the rotation should be done (could be the very end)

  • rotate the motor2 again with +/- buttons and save that location

  • return the holy back to start position and start the sequence

Is that possible? So in a way, motor2 has a new zero-point at the start position, and has an endpoint of x° at the end position.

Can I 'record' that end position?
Thanks

Is that possible?

Not even very difficult. It's more of a hardware setup issue than a coding issue.

Can I 'record' that end position?

Yes, EEPROM is useful for that.

It sounds like you are content to move the motors to the start or ZERO position manually (i.e. by pressing a button and watching to see where it moves to) and then pressing a button to tell the Arduino that where the motors are NOW is the zero position.

If you don't want to do it manually you will need some sort of ZERO switches (a microswitch or an optical detector) and when the Arduino starts it can move the motors until they trigger the switches to tell it that the motors are now at the ZERO position.

If neither of those is an option you need to tell us what you want to happen.

...R
Stepper Motor Basics

Thank you both for replying!

I want to move the dolly manually (with the 2 motors) to a start position and to the end positions of both motors.
The steps for each motor is what I need to record/store somehow. So when I start the routine to take pictures, the dolly will start at the start position with both motors set to the start position and stop at the end positions for both motors.

Just for visualization: the track is 1500mm long and motor one will cover that, motor two will cover the rotation of the cam (for instance 20 degrees).

ETA: EEPROM seems to be what I need. Not sure how to set begin and end as they can be set at any position on the track. How can I tell the stepper where the startpoint and endpoint is? Sorry for my questions, Arduino's and steppers are quite new to me. All help is appreciated!

snewpers:
I want to move the dolly manually (with the 2 motors) to a start position and to the end positions of both motors.

Just to clarify ... do you mean that you want to manually set the start and end positions and then have the system move automatically between those positions?

That should be easily doable. Have a button to make the motor move 1 step at a time. Have another button to press when the start position is reached - that tells the Arduino that this location is START. Then move the motor to the end position and press a different button to mark the END. The Arduino records the step number that it has now reached.

Do you want to retain the start and end positions when the Arduino is switched off?

If so you need to save the positions to the EEPROM. HOWEVER, it is not as simple as that. The Arduino will have no way of knowing where the motor is when it starts. The usual way to deal with that is to move the motor until it triggers a limit switch to mark the ZERO position. And that means that the motor will need to have been correctly ZEROed before the manual moves.

...R

Hello Robin, that's exactly what I would like to do. I don't need the values to be stored for later use.

So with the setup you mention this can be done? I'm still confused on how to get these values into the AccelStepper functions... I think I need setCurrentPosition for the start position but I'm not sure where to put the end position since I don't know where to get the number of steps from to use, for instance, targetPosition or Move[to]. I thought I could store the end value with currentPosition but I'm not sure.

Thanks a lot!

snewpers:
I'm still confused on how to get these values into the AccelStepper functions... I think I need setCurrentPosition

First of all write a short program that moves the motor along one step at a time while you have a button pressed. And have a counter that counts the number of steps.

When you get to the start position you will need to save that number to a variable.

Then move the motor some more, still counting the steps and when you get to your end position save the value of the counter to another variable.

At that stage you have a number for the start and a number for the finish. The difference will be the number of steps for the move.

Because you are now at the end position it may be easiest to tell AccelStepper that that is position ZERO and if you move a distance of -difference it should get your motor to the start.

...R