I have a 5 motor rig that i would like to use Dragon Frame with. I have a Megatronics controller that has stepper driver sockets built into it and its based on a Mega 2560.
The DragonFrame DFMoco Sketch uses Port Registers instead of pin numbers for the step and direction pins. Also the pin numbers called to by the DFMoco are different than the Megatronics board I am trying to use.
I need to figure out how to set the Megatronic Pin numbers in the DFMoco Sketch.
This is from a sketch that works with the Megatronics.
#define X_STEP_PIN 26
#define X_DIR_PIN 27
#define X_ENABLE_PIN 25
#define X_MIN_PIN 37
#define X_MAX_PIN 40
#define Y_STEP_PIN 4 // A6
#define Y_DIR_PIN 54 // A0
#define Y_ENABLE_PIN 5
#define Y_MIN_PIN 41
#define Y_MAX_PIN 38 //15
#define Z_STEP_PIN 56 // A2
#define Z_DIR_PIN 60 // A6
#define Z_ENABLE_PIN 55 // A1
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
#define E0_STEP_PIN 35
#define E0_DIR_PIN 36
#define E0_ENABLE_PIN 34
#define E1_STEP_PIN 29
#define E1_DIR_PIN 39
#define E1_ENABLE_PIN 28
#define E2_STEP_PIN 23
#define E2_DIR_PIN 24
#define E2_ENABLE_PIN 22
And this is the DFMoco sketch:
#define MOTOR0_STEP_PORT PORTG
#define MOTOR0_STEP_PIN B00100000
#define MOTOR1_STEP_PORT PORTH
#define MOTOR1_STEP_PIN B00001000
#define MOTOR2_STEP_PORT PORTH
#define MOTOR2_STEP_PIN B00100000
#define MOTOR3_STEP_PORT PORTB
#define MOTOR3_STEP_PIN B00010000
#if ( PINOUT_VERSION == 2 )
#define MOTOR4_STEP_PORT PORTA
#define MOTOR4_STEP_PIN B01000000
#define MOTOR5_STEP_PORT PORTC
#define MOTOR5_STEP_PIN B10000000
#define MOTOR6_STEP_PORT PORTC
#define MOTOR6_STEP_PIN B00100000
#define MOTOR7_STEP_PORT PORTC
#define MOTOR7_STEP_PIN B00001000
#elif ( PINOUT_VERSION == 1 )
#define MOTOR4_STEP_PORT PORTA
#define MOTOR4_STEP_PIN B00000001
#define MOTOR5_STEP_PORT PORTA
#define MOTOR5_STEP_PIN B00000100
#define MOTOR6_STEP_PORT PORTA
#define MOTOR6_STEP_PIN B00010000
#define MOTOR7_STEP_PORT PORTA
#define MOTOR7_STEP_PIN B01000000
#endif
#else
#define MOTOR0_STEP_PORT PORTD
#define MOTOR0_STEP_PIN B00010000
#define MOTOR1_STEP_PORT PORTD
#define MOTOR1_STEP_PIN B01000000
#define MOTOR2_STEP_PORT PORTB
#define MOTOR2_STEP_PIN B00000001
#define MOTOR3_STEP_PORT PORTB
#define MOTOR3_STEP_PIN B00000100
#endif
It looks like the Dragon Frame Sketch uses Port Registers instead of just specifying a port number. This method if faster and takes less code but more problematic if you want to change pins.
So for what I can gather so far it works like this
DragonFrame default sketch. This is Digital Pin 4
#define MOTOR0_STEP_PORT PORTG //PG5 ( OC0B )
#define MOTOR0_STEP_PIN B00100000 //sets 5 to high pin 4
My board uses pin 26 for the step on Motor0. which would be:
#define MOTOR0_STEP_PORT PORTA //PA4 ( AD4 )
#define MOTOR0_STEP_PIN B00010000 // sets 4 to high pin 26
Easy enough I think for the Step. Now for the direction:
// initialize motor structures
for (int i = 0; i < MOTOR_COUNT; i++)
{
// setup motor pins - you can customize/modify these after loop
// default sets step/dir pairs together, with first four motors at 4/5, 6/7, 8/9, 10/11
// then, for the Mega boards, it jumps to 28/29, 30/31, 32/33, 34/35
#if ( PINOUT_VERSION == 2 )
motors[i].stepPin = (i * 2) + ( (i < 4) ? 4 : 20 );
#elif ( PINOUT_VERSION == 1 )
motors[i].stepPin = (i * 2) + ( (i < 4) ? 4 : 14 );
#endif
motors[i].dirPin = motors[i].stepPin + 1;
Little confused here.
My Motor0 Dir pin is 27 so this should work I think. But for other motors I am not sure how to make this work for me. My motor 1 is Pin 4 for Step and 54 for for direction. StepPin+1 does not work for this.
Also I am not sure if I am missing something else. I get a clicking and no motor movement. If I load my own sketch for this shield all the motors run fine. So its just how I have it configured in the DFMoco sketch
Because my motor 0 should work if I set to PortA and Set 4 to high which is Pin 26. I am sure I am missing something about the dir pin setup or maybe need a enable. Not sure.
I tried posting this on the Dragon Frame board a couple weeks ago and received no suggestions. Since this is a Arduino board and code I thought I would try here.
I can make the DFMoco move my motors by just hooking up a 2560 and external steppers but I want the compact size of using the all in one Megatronics board since I have a extra laying around and for portability
Help,
Donny
.