ARRAY TO CONTROL 3 STEPPER MOTORS

Hello,

I am rather new to the Arduino. I currently am attempting to control 3 stepper motors using an array to store coordinates. Does any body have any ideas or suggestion on this.

Thank you, any help is greatly appreciated!!!

Does any body have any ideas or suggestion on this.

Sure do. Post your code.

int xDirection = 8;
int xStep = 7;
int yDirection = 5;
int yStep = 4;
int zDirection = 3;
int zStep = 2;
int motor_array[6][3][3]=//{x,y,z}
{{1,0,0},
{0,1,0},
{0,0,1},
{0,1,0},
{0,0,-1},
{1,0,1}};

void setup() 
{
  pinMode(xDirection, OUTPUT);
  pinMode(xStep, OUTPUT);
  pinMode(yDirection, OUTPUT);
  pinMode(yStep, OUTPUT);
  pinMode(zDirection, OUTPUT);
  pinMode(zStep, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
for(int x=0; x<5; x++)
tone(7,500,x*.001*10000);
digitalWrite(8, HIGH);
{
for(int x=0; x=0 ;x++)
{
for(int x=0; x<0 ; x++)
tone(7,500,x*.001*10000);
digitalWrite(8, LOW);
}
}
}

What does that code do exactly? There are so many things wrong with that code to even know where to begin. But, in general, using the same variable for the index for the inner loop as the outer loop really is NOT a good idea.

The middle clause is a while clause. The loop runs while the middle clause is true. WTF is the purpose of the outer loop? Exactly how many times will it iterate?

Sorry about that, is just something I started with. I am trying to create an array that is filled with motor controls ie (x,y,z). Based on if the number is positive or negative the stepper motor will go left or right. I want it to just go through all the rows and perform the proper movements until the last row is reached, then the program will stop.

I can't see any relationship between your code and stepper motors - apart from an array. What is the data in the array supposed to be. What is the rest of the code supposed to do?

PLEASE go back and edit your post to put your code inside code tags so it looks like this - it is explained in How To Use This Forum.

...R

Numbers in array are meant to be the distance that a carriage needs to go, later to be converted into time that the motor will be driven for.

Numbers in array are meant to be the distance that a carriage needs to go, later to be converted into time that the motor will be driven for.

You don't understand what a stepper motor does, do you?

don't understand what a stepper motor does, do you?

I am well aware :slight_smile:

I am well aware

Then, why are you talking about distances and times? You need to be talking about number of steps.

How are you driving the stepper motors? Where is the code to create an instance of the Stepper class, for each motor? Where is the code to step anything?

I am using the tone function. {tone(pin, frequency, duration)}

I am using the tone function. {tone(pin, frequency, duration)}

For what ? Why ? What does that have to do with stepper motors or the title of you post ? Why is that not in the title ?

I am generating step and directions on PWM pins which are connected to a parallel breakout board.
This (http://probotix.com/ready_to_run_driver_options/ ) is what powers the stepper motors. So I only need to generate a tone and direction signal to operate the motors. I am having trouble seeing where the confusion lies. I have done this in the past. All this post was inquiring about as if I could control motors using an array. I do not need help operating the motors. What I do need help with is if I can set up and array that has x,y,z columns with some amount of rows to control "something", lets take the motors out of the topic. For example

Lets say that I have a 4 x 4 LED matrix in which I would like to flash row by row, controlled by an array . Lets say the array is like this
{0,0,0,1},
{0,0,1,0},
{0,1,0,0},
{1,0,0,0}

where the 1 is on and zero is off. How do I iterate through each row to only turn on the desired LED?

googlie:
I am generating step and directions on PWM pins which are connected to a parallel breakout board.
This (http://probotix.com/ready_to_run_driver_options/ ) is what powers the stepper motors. So I only need to generate a tone and direction signal to operate the motors. I am having trouble seeing where the confusion lies. I have done this in the past. All this post was inquiring about as if I could control motors using an array.

Either that is a new way to drive stepper motors that people here are not familiar with or you are failing to give us some necessary information.

Most people use one of the Arduino libraries to create the signals for a stepper motor. In the case of a stepper driver that only needs step and direction inputs it is trivial to generate them with a digitalWrite() to the relevant pins. I am not aware of anyone using PWM to generate the step signals - how would you control the speed or the precise number of steps that way?

Without understanding how you are driving your motors it's difficult to understand how you plan to use the data in the arrays.

Iterating through an array is the easy part. For example ...

for (byte n = 0; n < 3; n++) {
   byte xx = array[n];
   if (xx == 1) {
     // do something
   }
}

Use nested FOR loops to iterate through a multi-dimensional array.

...R

You haven't explained how an AC audio TONE (TONE is a word used to describe an audio sound) has anything whatsoever to do with a PWM 0 to 5V DC SWITCHING signal (not AC, NOT AUDIO) . Does that explain the confusion ? How does the link to the stepper driver explain the TONE part ?

FYI-I know that it is possible to convert an audio tone to a PWM duty cycle through various methods but it is up to you to state that you are doing this. Simply saying all you have to do is generate a tone without stating "I have a tone to pwm circuit to generate my stepper PWM" is not enough.. I didn't see that, and we therefore have to ask why you would say that. Without knowing your background we have no idea if you have any idea what it means to say that.

Also- You never identified this:

to a parallel breakout board

What breakout bd ? Vendor link ?
Datasheet ?