585,604 active members*
3,247 visitors online*
Register for free
Login
IndustryArena Forum > OpenSource CNC Design Center > Arduino > Using Arduino Mega 2560 with Protoneer CNC Shield
Results 1 to 5 of 5
  1. #1

    Using Arduino Mega 2560 with Protoneer CNC Shield

    Project with 2 stepper motors.
    Using Arduino Uno, AccelStepper, Protoneer CNC Shield V 3.0, DRV8825 drivers, 12V to steppers, 5V to Arduino - all works well. Steppers respond Accel/Dec, stop, start, respond to limit stops, etc

    Note: Not using GRBL

    Because Arduino sketch is approaching max for Uno and I need access to analog pins for external sensors, I tried using Arduino Mega 2560. But nothing works.

    To test I have reverted to using basic AccelStepper library example 'constant speed stepper'. Works fine with Uno but with Protoneer shield attached to Mega 2560 it will not upload (times out).
    Without shield the sketch uploads to Mega OK. Then adding shield to Mega results in no motor response

    AccelStepper literature says it is tested with Mega 2560. I have read about different pin maps between Uno and Mega, but it is supposed to work

    DRV8835s are OK (work with Uno)

    Shield does not have any logic, just electrical routing?

    Can anyone suggest what might be my problem?

  2. #2
    Join Date
    Mar 2015
    Posts
    409

    Re: Using Arduino Mega 2560 with Protoneer CNC Shield

    To test I have reverted to using basic AccelStepper library example 'constant speed stepper'. Works fine with Uno but with Protoneer shield attached to Mega 2560 it will not upload (times out).
    Without shield the sketch uploads to Mega OK. Then adding shield to Mega results in no motor response
    Send me the sketch (PM) and I will test it this weekend on my Mega2560. I don't have a protoneer CNC shield but I can test the output signals of the stepper pins. Please remove as much as code as possible to make my life easier.

    If the shield is causing the problems than maybe the pin(s) you are using are connected to other pins on the shield (4 axis?). The way to find the problem by making small test programs (blink) just to test one small function of the whole program. Make a program to just read the analog input pin. If you use inputs, make a program to read just these inputs. In the end, if the final program is working well, you can use these small programs ti identify the problem is something stops working.

  3. #3

    Re: Using Arduino Mega 2560 with Protoneer CNC Shield

    Hello hfjbuis - thank you for your interest

    Sketch below

    // ConstantSpeed.pde
    // -*- mode: C++ -*-
    //
    // Shows how to run AccelStepper in the simplest,
    // fixed speed mode with no accelerations
    /// \author Mike McCauley ([email protected])
    // Copyright (C) 2009 Mike McCauley
    // $Id: ConstantSpeed.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

    #include <AccelStepper.h>

    AccelStepper stepperX(1, 2, 5);

    void setup()
    {
    stepperX.setMaxSpeed(1000);
    stepperX.setSpeed(900);

    #define EN 8
    pinMode(EN, OUTPUT);
    digitalWrite(EN, LOW);


    }

    void loop()
    {
    stepperX.runSpeed();
    }


    I have run this (and other sketches) with AccelStepper OK on Uno but no luck with Mega 2560. Not using GRBL and no micro-stepping

    I have set up Arduino Mega with DRV8825 on a breadboard (ie without the Protoneer shield) and it runs OK. Only connection to Mega is pins 8 Enable and 2 Step and 5 Direction. I have checked pin continuity for these (since the shield is really only a wiring routing device) and all is OK

    Checking pin voltages with the Protoneer indicates the En pin 8 is not being pulled LOW (required to enable steppers) when using Mega. But it is 0V when using Protoneer on Uno? Also when using breadboard with Mega it must be going low to work?

    I have been powering the Arduinos with USB and 12v external supply for steppers. Some of the voltage readings I got with Mega were strange - small voltages on 'Reserved' pins - so I plugged in 12V to Mega power jack and voltage regulator burnt out. So my problem might be a faulty voltage regulator causing some sort of leakage to pins?? I will replace regulator and test Mega diode etc - or buy new Mega - before proceeding any further. I will post result - may be this will fix whole problem?

  4. #4
    Join Date
    Aug 2009
    Posts
    56

    Re: Using Arduino Mega 2560 with Protoneer CNC Shield

    Quote Originally Posted by wandiligong View Post
    Hello hfjbuis - thank you for your interest
    I have been powering the Arduinos with USB and 12v external supply for steppers. Some of the voltage readings I got with Mega were strange - small voltages on 'Reserved' pins - so I plugged in 12V to Mega power jack and voltage regulator burnt out. So my problem might be a faulty voltage regulator causing some sort of leakage to pins?? I will replace regulator and test Mega diode etc - or buy new Mega - before proceeding any further. I will post result - may be this will fix whole problem?
    Suggest to check wiring, it is not uncommon to fry regulator. It can be done simply adding too much accessories or inserting 12V in wrong place. Regulator is rated something like 1.5A but there is no cooling, so sudden death will occur easily, before shutdown circuit can work. Strange voltage readings occurs when power demand is higher than regulator can handle, not saying where I get this info

  5. #5
    Join Date
    Mar 2015
    Posts
    409

    Re: Using Arduino Mega 2560 with Protoneer CNC Shield

    // ConstantSpeed.pde
    // -*- mode: C++ -*-
    //
    // Shows how to run AccelStepper in the simplest,
    // fixed speed mode with no accelerations
    /// \author Mike McCauley ([email protected])
    // Copyright (C) 2009 Mike McCauley
    // $Id: ConstantSpeed.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

    #include <AccelStepper.h>

    AccelStepper stepperX(1, 2, 5);

    void setup()
    {
    stepperX.setMaxSpeed(1000);
    stepperX.setSpeed(900);

    #define EN 8
    pinMode(EN, OUTPUT);
    digitalWrite(EN, LOW);
    }

    void loop()
    {
    stepperX.runSpeed();
    }
    The sketch uses the AccelStepper libray. According to the reference and the signal outputs, it is designed for H-Bridge controllers. The DRV8825 is a Step/Direction controller, that is quite different.

    Measuring on the Atmega2560 there is a 900 Hz pulse on pin 2, Pin 5 is HIGH. This is due to the fact you set the steps per revolution to 1 and probably run in to the limits of the timer hardware. Most steppers are 200 steps/revolution.

    I Changed the line AccelStepper stepperX(1, 2, 5) to AccelStepper stepperX(2, 2, 5) and now there is a 222 Hz pulse on pin 2 and 5. This could drive a H-Bridge controller. There is probably a difference in the arduino uno and Atmega2560 timer that could explain why the sketch runs on the Arduino uno.

    To get this working, you have to use a Step/Dir driver for your sketch. There are probably a lot of them. I found this one https://github.com/laurb9/StepperDriver

Similar Threads

  1. Arduino Mega grbl
    By cilim in forum Arduino
    Replies: 1
    Last Post: 08-10-2016, 02:12 PM
  2. G-Code Interpeter for Arduino Mega?
    By BrendaEM in forum Arduino
    Replies: 20
    Last Post: 01-05-2016, 11:22 AM
  3. Choosing 110V Relays for Mega 2560
    By herring_fish in forum CNC Machine Related Electronics
    Replies: 6
    Last Post: 11-05-2012, 05:10 PM
  4. I'm about to buy a replacement Arduino Mega 2560
    By herring_fish in forum Hobby Discussion
    Replies: 0
    Last Post: 12-22-2011, 03:20 AM
  5. Arduino Mega driving my cnc.
    By aventgps in forum Videos
    Replies: 2
    Last Post: 12-30-2009, 08:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •