Macro focusing rail control

Hi all

I am a 71 year old just newly addicted to the arduino and with severe brain fade.

I have the hardware for a focusing rail, a CNC Z axis, which I can just about get to backwards and forwards with very simple coding.

What I would like to do is be able to control it via either a LCD shield with buttons or via the serial monitor, the latter being the easier for the moment I am thinking.

I am looking to be able to say fast forward and backwards to find the total distance I need to focus over. I would then like to be able to input that distance and the size of each step and have the Arduino work out the number of steps to do this.

Once this is done step forward, pause for a shutter release, repeat until the total distance has been travelled.

I would be most grateful if you could help out with the coding by either pointing be in the right direction or giving me a framework I could work from.

Thanking you in anticipation... Colin

I would get a stepper motor controller, and the software for it, and try to hook it up to your motor. What kind of motor is it, then we can recommend a controller.

poynder:
I have the hardware for a focusing rail, a CNC Z axis, which I can just about get to backwards and forwards with very simple coding.

That sounds like you already have a stepper motor and a stepper driver and a program.

Post links to the motor and driver datasheets
Post your program code

And please use the code button </> so your code looks like this and is easy to copy to a text editor

…R
Stepper Motor Basics
Simple Stepper Code

Thanks for quick reply.
Sorry forgot all about the details of what I have got so far.

I am using a adafruit motor shield with my stepper motor. As I said I can get the motor to go backwards and forwards and crudely input a value for the number of steps.

I would post the code but not sure what you mean with use the code button </>
I have copied for forum from within the ide, do I attach this or just paste it here.

In the meantime I will check out the two links you provided.

If it will fit (less than 9000 bytes) the best thing is to post it here. Press the code button </> and paste the code between the code tags.

Alternatively add your .ino file as an attachment.

I think all this in How to use the Forum

Also, post a link to the datasheet for the stepper motor and for the motor shield. The more information you provide the esier it is to give useful advice.

…R

poynder:
I would post the code but not sure what you mean with use the code button </>

You can also manually add the code tags. I’m going to spell “CODE” with a zero instead of an “O” so the forum software doesn’t parse the tags.

You need to start with a the tag “[C0DE]” and end with the tag “[/C0DE]”.

[C0DE]

Arduino code goes between the tags.

[/C0DE]

When I spell “CODE” correctly the above text becomes a block of code.

  Arduino code goes between the tags.

You don’t have to use uppercase text in the tags. I used uppercase text so the zero would look like an “O”.

If you quote a post with a block of code, you should be able to see the code tags used by the author of the post.

URL tags will make links clickable. By using URL tags other forum members will be able to easily visit the page of interest. Here are two ways of using URL tags.

Using the URL as the text:

Or a hyperlink can be added to text.

Again, quoting a post will allow you to see the tags. You don’t have to really make a post after clicking “Quote”.

Edit: I don’t know why there’s so much empty space in the code block. The extra space was added after I edited a typo in the post. Apparently code tags behave differently in an edited post than in an unedited post. The forum software changed my URL tag example so the two sets of URL tags look the same. The tag was changed to [url=https://www.adafruit.com/products/1438} (but with a square closing bracket) so my suggestion of quoting the post, to see the difference in the text used, won’t work.

Welcome to the forum poynder.

I am a 71 year old just newly addicted to the arduino and with severe brain fade.

Sorry forgot all about the details of what I have got so far.

Well just think, if you get excited about something you learn today, you can get excited about it all over again when you learn the same thing tomorrow. ;) .

DuaneDegn:
Edit: I don’t know why there’s so much empty space in the code block. The extra space was added after I edited a typo in the post. Apparently code tags behave differently in an edited post than in an unedited post.

After you’ve saved the edit, refresh the page and the extra space disappears.

Thanks guys.

After reading more of the links and posts I have come to conclusion it would be best if I stand back and take stock of what I am trying to achieve. I think I got a bit carried away with what I wanted to do, time to start with the basics.

You have given me some food for thought.

Thanks once again, nice to meet you all.

Keep up with your new hobby.

.