Motorized Slide Arduino Code Help

Hi Arduino experts,

I desperately need help with a basic code to move a motorized slider for a measurement system.

I am using Arduino Uno with DM542 and a slide that has lead screw pitch of 5mm with NEMA 23

Can someone write a basic code to move the slide 100 mm or so let’s say at 1/5 microstep?
I want it to go 100 mm forward at full speed and then back all the way after certain delay to original position (manual homing in end of code instead of switches).

I will appreciate you forever if you help me or I will be majorly screwed :(((

Welcome to the forum

This forum mainly exists to provide help and advice on projects where members have encountered problems. It does not exist to write code for others unless someone is feeling generous or you are willing to pay for it

So, what experience do you have with the Arduino, what code have you tried so far to meet your needs ?

Have you got any code, however basic, and what problems have you encountered ?

Hi amardu,

you are not yet an arduino-man.
I want to write about an anlogon what you are asking for

At the moment you have no idea how to drive such an excavator

And indeed it will need more than five minutes of explaining and practising to understand which lever does what

You are asking for: can a excavator-expert please digout such a excavation?

You may find somebody who says OK I will do it for free.

I am 100% sure after finishing this excavation shape there will be the need to change something.
Oh I'm so sorry can you please come again with your excavator and modify the excavation that it looks like that?

As long as you know nothing about how to drive the excavator you will be

totally dependend

on the expert.

As soon as you start learning how to drive the excavator

yourself

you will become more and more

independend of experts.

you may think oh no I don't want to. I will be satisfied with the basic motion 100mm forth and back at max speed.

I am 1000% sure. There will be modifications:
what the maximum speed will be depends on

  • the steppermotor
  • the inertia of you mechanical system
  • some more factors

If you really would find somebody that writes you a dozen again and again modficated code-versions.
What is your contribution to the world beyond posting ten times the words "thank you! and adding 200 clap-hands smilies? I mean something substantial?

If you look through the posting list of any subforum. You will find threads with 3 to 5 postings a lot of wih dozens of postings. Some with 100, 200, 300 postings.
There is a neverending continiuosly stream of support for all people that show

own effort

To rise them from beeing a total newbee to an expert in arduino-programming

As a starting point I recommend that you read at least the first five chapters of this tutorial
Take a look into this tutorial:

Arduino Programming Course

It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.

It is crucial to have a basic understanding of what is function

void setup() for
and
function
void loop() for

best regards Stefan

I like the choice of words… but your problem is that you “WONT be screwed”.

My friend warned me most people on this forum are trash and will never say anything actually helpful. Just iterating cliche. Imagine asking for money over a 3 line simple code. What I asked for couldn’t have been simpler. Here’s a sample for slide motion:

// defines pins numbers
const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;
void setup() {

// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);

pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);

}
void loop() {

digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 800; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000); // One second delay

digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 800; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);

}

Imagine asking for help over a 3 line simple code.

a7

You were asked straight away in the first response

I'm pretty sure you will not like this answer. Well I'm free to write what I want as long as it is not against the forum-rules.

If it is a three line short code with a specific question
the question would be have been answered straight away.

Your question is unspecific.

If you would have posted the source-code of post #5 in your first posting combined with a specific question like:

"This code says
// Makes 200 pulses for making one full cycle rotation
// Makes 400 pulses for making one full cycle rotation
but my motor does just a quarter rotation

What do I have to change in the code to make my stepper-motor a full rotation?"

Or if your question would have been

"I have a lead-screw with 5 mm pitch I want a move of 100 mm at 1/5-step"
what do I have to change in this code to do that?"

You would have shown at least some

own effort

that makes

all the difference

and I would have answered very practical with technical information and calculations, with hints to libraries that make it easier to create the steps.

But you made it even worse by writing

that is a bad rating about persons.

If you have a specific question related to sourcecode that you have posted I will answer your question.

best regards Stefan

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