Welcome to Our Community

Unlock hidden features. Sign Up for Free Today!

NEMA 17 - DQ542MA - Arduino Stepper Setup

Discussion in 'Controller Boards' started by nbuckles, Oct 2, 2016.

  1. nbuckles

    nbuckles New
    Builder

    Joined:
    Sep 9, 2016
    Messages:
    3
    Likes Received:
    0
    Hey all,

    Total stepper newb so looking for some help here. Having trouble with my stepper motor project.

    I'm using:

    Wanta DQ542MA 2H Microstep driver
    NEMA 17 stepper motor from open builds store
    Arduino Uno
    24V DC power supply

    I have PUL+, DIR+, and ENBL+ wired to pins 5,6,7 on the arduino, and PUL-, DIR-, ENBL-, DC-, and Arduino's GND all wired together.

    The DIP pins I have are set to 1 - OFF, 2- ON, 3 - ON, 4 - OFF, 5- OFF, 6 - OFF, 7 - ON, 8 - ON
    This should give 1.46A Peak and 1.04A RMS on the motor which is rated at 1.68A/phase
    Also set at 1600 pulse/rev for 1/8 microstepping (200 steps/rev)

    When I first turned it on, I forgot to set the DIP pins so it was at the max current of 4.2A peak / 3.00A RMS. I didn't have the arduino connected, and connected the DC power supply and the A- wire started smoking and melted the insulation. I removed the power as soon as possible.

    Now only the red PWR/ALM light turns on, which per the spec sheet means "ERR: red, failure light, the motor with phase short-circuit, overvoltage and under-voltage protection"

    What's going on here? What am I missing? Did I just fry the driver?

    Thanks for the help!
     
  2. Kyo

    Kyo Master
    Staff Member Resident Builder Builder

    Joined:
    Feb 27, 2014
    Messages:
    486
    Likes Received:
    381
    Hello @nbuckles

    Let see if I can be of some help. :thumbsup:

    The Uno should be powered by the usb connection. The drivers receive power from the 24v power supply. The power supply should not share a connection with the Uno or pul-, dir-, enbl- terminals.

    24v dc power supply
    ----------------------------------------
    24v + output to Driver DC+ input
    24v - output to Driver DC- input


    Driver to Uno (Uno pins assume GRBL if not running grbl let me know )
    ------------------------------------------------
    Pul+ from driver to Uno pin 4
    Dir+ from driver to Uno pin 7
    Enbl+ from driver to Uno pin 8

    Pul- from driver jump to Dir- on driver
    Dir- from driver to Uno GND pin
    Enbl- leave unconnected.

    Your dip switch and micro step settings look correct for your required output.

    [​IMG]

    I was just playing around with a Nema 17 and a Arduino using a 24v power supply for a video I did. It may be of help to you.
     
    #2 Kyo, Oct 2, 2016
    Last edited: Oct 2, 2016
  3. nbuckles

    nbuckles New
    Builder

    Joined:
    Sep 9, 2016
    Messages:
    3
    Likes Received:
    0
    Hey Kyo - thanks for the info!

    I redid the wiring of the signal ports and that has helped - the PWR/ALM led is now green, and the motor is holding torque - where before the motor was spinning when turned by hand.

    Okay, next thing - the motor does not turn. Also, I'm not using GRBL. I'm developing an automation machine for a product assembly and the motor will run preprogrammed paths, so right now i'm just trying to get the motor to turn a specified number of revolutions, pause, then come back to origin.

    My arduino code:

    int pulsePin = 5;
    int dirPin = 6;
    int enblPin = 7;

    void setup() {
    pinMode (pulsePin, OUTPUT);
    pinMode (dirPin, OUTPUT);
    pinMode (enblPin, OUTPUT);
    digitalWrite(pulsePin, LOW);
    digitalWrite(dirPin, HIGH);
    digitalWrite(enblPin, HIGH);
    }

    void loop() {
    for(int x=0; x<400; x++){
    digitalWrite(pulsePin, HIGH);
    delay(50);
    digitalWrite(pulsePin, LOW);
    delay(50);
    }
    delay(1000);
    }
     
  4. Kyo

    Kyo Master
    Staff Member Resident Builder Builder

    Joined:
    Feb 27, 2014
    Messages:
    486
    Likes Received:
    381
    Give me a min or two and I will grab my driver , uno , nema 17 and see what I get on my end. be right back.
     
  5. Kyo

    Kyo Master
    Staff Member Resident Builder Builder

    Joined:
    Feb 27, 2014
    Messages:
    486
    Likes Received:
    381
    I am still new to Arduino coding so please work with me and anyone more experienced then I am here please step in. But I was able to get it to work :thumbsup:

    Edit: updated next post with what I did.
     
    #5 Kyo, Oct 2, 2016
    Last edited: Oct 3, 2016
  6. Kyo

    Kyo Master
    Staff Member Resident Builder Builder

    Joined:
    Feb 27, 2014
    Messages:
    486
    Likes Received:
    381
    Here we go I cleaned it up a bit and reverted back to your original pin out on 5,6,7. This results in one full rotation then stopping at start point and repeats when reset button is pressed. To make two full revolutions before stopping update "1600" to "3200", "6400" for four revolutions ect.

    Using 1.8 200 step Nema 17 using 1/8 Micro stepping..

    Code:
    int stepPin = 5;
    int dirPin = 6;
    int enblPin = 7;
    
    void setup() {
    pinMode (stepPin, OUTPUT);
    pinMode (dirPin, OUTPUT);
    pinMode (enblPin, OUTPUT);
    digitalWrite(stepPin, LOW);
    digitalWrite(dirPin, LOW);
    digitalWrite(enblPin, HIGH);
    }
    
    void loop() {
    for(int x=0; x<1600; x++){
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(100);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(100);
    }
    digitalWrite(enblPin, LOW);
    exit(0);
    }
    

    Uno Wiring.png
     
    #6 Kyo, Oct 3, 2016
    Last edited: Oct 3, 2016
  7. nbuckles

    nbuckles New
    Builder

    Joined:
    Sep 9, 2016
    Messages:
    3
    Likes Received:
    0
    Wow! Thank you so much!

    It would've taken me forever to figure out that proper wiring of the signal inputs.

    Can you help me understand what's going on here? We're pulling the PUL- and DIR- pins to LOW, and the PUL+, DIR+, and ENBL+ pins to HIGH.

    So, across each pairing - setup is:

    PUL(+/-): HIGH/LOW
    DIR(+/-): HIGH/LOW
    ENBL(+/-): HIGH/(?)

    Then, as the program runs, it switches PUL- to HIGH then back to LOW.

    So during the program across the PUL pair we get HIGH/HIGH then HIGH/LOW...? I feel like how I was conceptualizing the signals here is upside down. I assumed a +5V measured against a common ground would be read as a pulse, but this approach seems like a -5V is a pulse.

    Also - not sure if you tested this but switching the dirPin to HIGH does switch the direction of the motor - so that's taken care of.

    And finally - two questions, which I hope you care to answer, but if not no worries you've been more than helpful!

    1) Why is ENBL- left empty?
    2) Know of any easy way(s) to smooth the acceleration of the stepper?
     
  8. Kyo

    Kyo Master
    Staff Member Resident Builder Builder

    Joined:
    Feb 27, 2014
    Messages:
    486
    Likes Received:
    381
    No Problem, I am just diving into coding myself so I can only answer a few of the questions but i will give it my best.

    This driver wants to see a active high signal on it's enable+ line. We can do this by setting a pin High like we are doing above on pin 7 or by directly connecting it to 5v. The driver is happy either way. The benefit to using a dedicated pin and making it active high is the fact we are now taking some form of control over when and how that signal is sent.

    We are sending the motor the pulses it needs by switching the Pul- High and Low and controlling the motor speed with the delay. ( probably not the best for smoothness ) ( try changing both " delayMicroseconds(100); " to " delay(10); ' it will move much slower.

    Enbl- is left disconnected due to the driver not needing a connection. I find when I connect this pin the driver faults ( red led )

    Another way to change Direction of rotation is with " If " and " else " using Distance in our code. Depending on pulleys , belts, gears, ect. You can work out the exact math to move "X" distance one way then return and repeat.

    This code will have the motor travel four rotations one direction pause two seconds and return to the start point in the opposite direction.

    Code:
    int stepPin = 5;
    int dirPin = 6;
    int enblPin = 7;
    int Distance = 0;
    
    void setup() {
    pinMode (stepPin, OUTPUT);
    pinMode (dirPin, OUTPUT);
    pinMode (enblPin, OUTPUT);
    digitalWrite(stepPin, LOW);
    digitalWrite(dirPin, LOW);
    digitalWrite(enblPin, HIGH);
    }
    
    void loop() {
    for(int x=0; x<1600; x++){
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(100);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(100);
    Distance = Distance + 1;
    }
    
    if (Distance == 6400)
    {
    if (digitalRead(dirPin) == LOW)
    {
    digitalWrite(dirPin, HIGH);
    }
    else
    {
    digitalWrite(dirPin, LOW);
    }
    Distance = 0;
    delay(2000);
    }
    }
    To change the set distance traveled change the value for the if distance == line. Currently set to 6400 in the above example.

    A good page of Arduino and steppers when not concerning cnc I have found is this page by Brian.
    Easy Driver Examples

    This looks like another good page.
    Stepper Motor Basics
     
    Synths and Rick 2.0 like this.

Share This Page

  • About Us

    The OpenBuilds Team is dedicated helping you to Dream it - Build it - Share it! Collaborate on our forums and be sure to visit the Part Store for all your Building needs!
  • Like us on Facebook

  • Support Open Source FairShare Program!

    OpenBuilds FairShare Give Back Program provide resources to Open Source projects, developers and schools around the world. Invest in your future by helping others develop theirs!

    Donate to FairShare!