2 axis stepper controll, Need help

can anyone help me make this work for dual axis/ 2 stepper motors. :slight_smile: ?

/* Include the library */
#include "HCMotor.h"

/* Pins used to drive the motors */
#define DIR_PIN 8 //Connect to drive modules 'direction' input.
#define CLK_PIN 9 //Connect to drive modules 'step' or 'CLK' input.

/* Set the analogue pin the potentiometer will be connected to. */
#define POT_PIN A0

/* Set a dead area at the centre of the pot where it crosses from forward to reverse */
#define DEADZONE 20

/* The analogue pin will return values between 0 and 1024 so divide this up between
forward and reverse */
#define POT_REV_MIN 0
#define POT_REV_MAX (512 - DEADZONE)
#define POT_FWD_MIN (512 + DEADZONE)
#define POT_FWD_MAX 1024

/* Create an instance of the library */
HCMotor HCMotor;

void setup()
{
//Serial.begin(9600);
/* Initialise the library */
HCMotor.Init();

/* Attach motor 0 to digital pins 8 & 9. The first parameter specifies the
motor number, the second is the motor type, and the third and forth are the
digital pins that will control the motor */
HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);

/* Set the number of steps to continuous so the the motor is always turning whilst
not int he dead zone*/
HCMotor.Steps(0,CONTINUOUS);
}

void loop()
{
int Speed, Pot;

/* Read the analogue pin to determine the position of the pot. */
Pot = analogRead(POT_PIN);

/* Is the pot in the reverse position ? */
if (Pot >= POT_REV_MIN && Pot <= POT_REV_MAX)
{
HCMotor.Direction(0, REVERSE);
Speed = map(Pot, POT_REV_MIN, POT_REV_MAX, 10, 1024);

/* Is the pot in the forward position ? */
}else if (Pot >= POT_FWD_MIN && Pot <= POT_FWD_MAX)
{
HCMotor.Direction(0, FORWARD);
Speed = map(Pot, POT_FWD_MIN, POT_FWD_MAX, 1024, 10);

/* Is the pot in the dead zone ? */
}else
{
Speed = 0;
}

/* Set the duty cycle of the clock signal in 100uS increments */
HCMotor.DutyCycle(0, Speed);

}

What have you tried ?

I have tried the above sects, an I have no ide on how to make it dual axis

How about using arrays to hold the similar variables and looping through the 2 entries ?

First of all, pls read the forum rules and use code tags for your sketch.

I don't know your stepper library as I always use AccelStepper library for dealing with more than one stepper. If your library supports multiple motors (check it in thr description of the library) then you have to declare a second stepper with a different name.

In AccelStepper I normally use motor1, motor2 ... or more descriptive: transport_motor, cutter_motor ...

Try changing:

int Speed, Pot;

To

static int Speed, Pot;

And change all those 1024s to 1023, I don't see any mention of motor 1.

outsider:
Try changing:

int Speed, Pot;

To

static int Speed, Pot;

And change all those 1024s to 1023, I don't see any mention of motor 1.

What would be the point in making Pot static, when the first thing that happens in loop() is that it gets assigned a new value?

What would be the point in making Speed static, when it gets a new value on every pass through loop()?