stepper motor control using PWM and non-shield motor driver


i looking best way control nema 34 stepper motor (1.8º angle) http://www.act-motor.com/product/34hs_en.html non-arduino shield.  need send pwm square wave on 1 pin of arduino.

most tutorials , code have come across use 4 pins , either h-bridge or other chip control stepper motor, using arduino generate 4 pulse waves. not need do.

i have stepper motor driver http://www.leadshine.com/productdetail.aspx?type=products&category=stepper-products&producttype=stepper-drives&series=m&model=ma860h

the driver receives 5v+ signal on pul+ , when pul- set low arduino make motor go 1 step. (or seems!)  sketch pul- connected pin 3.

the driver requires minimum 1.5ms pulse, able create pulse using potentiometer connected a0 , oscilloscope until found right pulse width, , wrote out serial monitor hard code delay sketch (310 microseconds)

i tried using second potentiometer connected a1 set frequency or delay between pulses control speed of motor. seems work.

then changed code have first potentiometer control direction (i should use switch potentiometer connected). if pot >= 500 motor spins in 1 direction , <500 spins other.

first problem:
if serial communication severely slows down motor. believe adapting blinkwithoutdelay sketch way implemented in tutorial confusing me.

2nd problem:
i'd able program in ramps changing direction , slowing down stop. , functions.

any appreciated

here have working far, basic, "hello world" stepper motor, , need better.


code: [select]

int dirpin = 2;
int steppin = 3;

int sensorpin1 = a0;        // select input pin direction potentiometer
int sensorpin2 = a1;       // select input pin delay potentiometer

int dirvalue = 0;          // variable store value coming sensor
int sensorvalue2 = 0;      // variable store value coming sensor
int pulsewidth = 310;      // creates aprox 1.5microsceond 2microsecond pulse width
int pulsedelay2 = 0;       // variable pulse frequency speed of motor

void setup()
{
pinmode(dirpin, output);
pinmode(steppin, output);
serial.begin(9600);
 
}
void loop()
{
  dirvalue = analogread(sensorpin1); // read direction pot
  if (dirvalue >= 500){
    digitalwrite(dirpin, low);       // turn cw
    delay(5);                        // delay driver accept direction change
  }
  else {
    digitalwrite(dirpin, high);      // turn ccw
    delay(5);                        // delay driver accept direction change
  }
   
  sensorvalue2 = analogread(sensorpin2);   // read frequency or speed pot
  pulsedelay2 = ((sensorvalue2*10)+300);   // math on analogue reading, add 300 frequency never below pulse width
  //serial.print("width 1 = "); serial.print(pulsewidth); serial.print(" delay 2 = "); serial.println(pulsedelay2);
     
  digitalwrite(steppin, low);            // low high change creates the
  delaymicroseconds(pulsewidth);         
  digitalwrite(steppin, high);           // "rising edge" driver knows when step.
  delaymicroseconds(pulsedelay2);

}

http://www.airspayce.com/mikem/arduino/accelstepper/

mystepper = accelstepper(accelstepper::driver, step_pin, direction_pin);


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > stepper motor control using PWM and non-shield motor driver


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support