How to use Stepper Motor with ARDBOX Analog

How to use Stepper Motor with ARDBOX Analog

This post is showed how to control a steeper motor with an Ardbox analog.

Example requirements:

Important: our equipment’s are prepared for work with common ground !!!

Once we have all the requirements we proceed to connect Ardbox, Driver and Stepper motor.

Usually the Stepper Drivers has at least 3 Inputs (Enable, Direction y Pulses). On our Ardbox we will connect the GND and the 5V from the SPI side between the GNDCom and 24Vcom from the Output side (Q’s). With that we will fix outputs at 5V. We will connect GNDCom with GND of the Stepper Driver. And we will use two outputs to control Enable and Direction. In this example we have used Q0_0 for Direction and Q0_1 for Enable. At last we will connect PIN 3 to PULL (Pulses).

Important: to generate a PWM enough fast to control a stepper motor we must use PIN 3 (Ardbox) and PIN 3 and PIN2 (M-Duino). The normal digital outputs of our equipment’s (Q’s) are limited over 500Hz!!!

Once inputs driver are connected we proceed to connect the stepper motor. Each phase has to be connected with its respective driver output. And connect power supply of the Driver. In our example it is used a stepper motor of 12V and 1,8º angle for each phase.

Next is showed an example code controlling the stepper motor for turn on the same side:

#define stp 3  //PIN3
#define dir Q0_0 
#define EN  Q0_1 

void setup() {
  pinMode(stp, OUTPUT); //set pins as a OUTPUTS
  pinMode(dir, OUTPUT);
  pinMode(EN, OUTPUT);
  
  digitalWrite(dir, HIGH); //Pull direction pin HIGH to move "forward", change to LOW to move reverse
  digitalWrite(EN, LOW); // Enable the Driver, change to HIGH to disable.
}

void loop() {
  //analogWrite(stp, 127); // Also it is posible to make the step with the function analogWrite(stp, x)
  
  digitalWrite(stp,LOW); //Trigger one step forward
  delayMicroseconds(500);    
  digitalWrite(stp,HIGH); //Pull step pin low so it can be triggered again
  delayMicroseconds(500);
}

 

And other example function code of how to control a one turn of our stepper motor:

void OneTurnMode()
{
  Serial.println("One turn mode.");
  for(x= 1; x<200; x++)  //Loop the forward stepping enough times for one turn
  {                      //In this example we need 360/1,8 = 200 rev
    digitalWrite(stp,HIGH); //Trigger one step forward
    delayMicroseconds(500);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delayMicroseconds(500);
  }
}

 

See also:

HOW TO TOUCH UP DATA FROM THE EEPROMHOW TO CONNECT AND CONFIGURE A LOAD CELL USING HX711 TRANSMITTER WITH OUR EQUIPMENT’SHOW TO GENERATE A DIFFERENT PWM’S SIGNALS WITH OURS EQUIPMENT’SHOW TO USE THE WATCHDOGRS-485 COMMUNICATION EXAMPLE USING OUR LIBRARIESHOW TO CREATE A WEB SERVER TO READ A SD CARD WITH OUR PLC’SHOW TO CONNECT A SD CARD TO A PLCHOW TO UPLOAD A BOOTLOADER ON A ARDBOX/M-DUINO PLC

Comments are closed.