It is currently Wed Oct 28, 2020 1:14 am




Post new topic Reply to topic  [ 7 posts ] 
 DragonFrame Custom Ardunio Mega 2560 shield Pins config ??? 
Author Message

Joined: Fri Oct 04, 2013 11:44 am
Posts: 10
Post DragonFrame Custom Ardunio Mega 2560 shield Pins config ???
I have a 5 motor rig that i would like to use Dragon Frame with. It uses a Ardunio Mega with a shield so to speak that uses different pins.
The shield has 6 steppers with the following config. How do I set this up in the DFMoco sketch? The Max and Min are for Endstops(limit switches) which I would like to use one set on the slider. Does DFMoco use the Enable? If not I think I might need to add it to make the motors turn. I did not see it in the sketch.
Also this board normally runs at 115200 baud. Can I run at this instead of 57600?

This is from a sketch that works with the Mega 2560 and shield I run.
#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

This is from the DFMoco Sketch. I found step but not direction and it looks like nothing I am used to. Can someone explain what PortG is for example and how do I define the direction. And what Pin B00100000 is. Binary?
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

#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

thanks in advance,
Donny


Fri Oct 04, 2013 11:47 am
Profile

Joined: Fri Oct 04, 2013 11:44 am
Posts: 10
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
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.

http://arduino.cc/en/Hacking/PinMapping2560


Any suggestions??

Donny


Sat Oct 05, 2013 6:36 pm
Profile

Joined: Tue Jan 14, 2014 6:54 pm
Posts: 23
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
Hi Donny,
did you finally get your RAMPS working with dragon frame ?

Ben


Sun Sep 14, 2014 8:21 am
Profile

Joined: Fri Oct 04, 2013 11:44 am
Posts: 10
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
Yes I did. You can se some pics of the rig at http://timelapsemotion.blogspot.com/.

And some video at http://www.youtube.com/playlist?list=PL7oUiq_-Wr-8CSRpmmgPECahqTqxKdE3u

Its a fun project. Now I just have to find the time to use it more.

Donny


Mon Sep 15, 2014 9:20 am
Profile

Joined: Tue Jan 14, 2014 6:54 pm
Posts: 23
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
I've seen it.
It looks really awesome.
How did you end up modifying the DFMoco sketch?
How did you add the Enable pin?
I wonder if I should do it in the motor loop or just in the setup.
I did the port register method for all my step pins and added the direction pins in the "customize " after the loop.
It works, I could with my multimeter, but the motors are not moving.
I tried to add the Enable pin inside the void setup, but it's not working so far. I did it the usual way, not using port register.
Do I miss something ?
Any tip would be appreciate.

Thank you for your help.

Ben


Tue Sep 16, 2014 5:45 am
Profile

Joined: Fri Oct 04, 2013 11:44 am
Posts: 10
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
Hope this helps. This is specific to the Megatronics board. But a 2560 works the same just have to specify the right ports and pins. I have even done it on a Micro for a small 3 axis rig.


Code:
#if ( PINOUT_VERSION == 4 ) 
//Start Megatronics V2 Port Mapping

  #define MOTOR0_STEP_PORT PORTA
  #define MOTOR0_STEP_PIN  B00010000 //Pin 26 PA4
  #define MOTOR0_ENABLE_PIN   25
 
  #define MOTOR1_STEP_PORT PORTG
  #define MOTOR1_STEP_PIN  B00100000//Pin  4 PG5
  #define MOTOR1_ENABLE_PIN   5
 
  #define MOTOR2_STEP_PORT PORTF
  #define MOTOR2_STEP_PIN  B00000100 //Pin 56 PF2
  #define MOTOR2_ENABLE_PIN   55

  #define MOTOR3_STEP_PORT PORTC //Pin 35 PC2
  #define MOTOR3_STEP_PIN  B00000100
  #define MOTOR3_ENABLE_PIN   34
 
  #define MOTOR4_STEP_PORT PORTA //Pin 29 PA7
  #define MOTOR4_STEP_PIN  B10000000
  #define MOTOR4_ENABLE_PIN   28
 
  #define MOTOR5_STEP_PORT PORTA //Pin 23 PA1
  #define MOTOR5_STEP_PIN  B00000010
  #define MOTOR5_ENABLE_PIN   22
 
  //End Megatronics V2 Port Mapping
  #endif



then down in void setup
Code:
// set output pins
  for (int i = 0; i < MOTOR_COUNT; i++)
  {
    pinMode(motors[i].stepPin, OUTPUT);
    pinMode(motors[i].dirPin, OUTPUT);
    pinMode(MOTOR0_ENABLE_PIN, OUTPUT);
    pinMode(MOTOR1_ENABLE_PIN, OUTPUT);
    pinMode(MOTOR2_ENABLE_PIN, OUTPUT);
    pinMode(MOTOR3_ENABLE_PIN, OUTPUT);
    pinMode(MOTOR4_ENABLE_PIN, OUTPUT);
    pinMode(MOTOR5_ENABLE_PIN, OUTPUT);
   // pinMode(MOTOR6_ENABLE_PIN, OUTPUT);
   // pinMode(MOTOR7_ENABLE_PIN, OUTPUT);
            
      
    digitalWrite(MOTOR0_ENABLE_PIN, LOW);
    digitalWrite(MOTOR1_ENABLE_PIN, LOW);
    digitalWrite(MOTOR2_ENABLE_PIN, LOW);
    digitalWrite(MOTOR3_ENABLE_PIN, LOW);
    digitalWrite(MOTOR4_ENABLE_PIN, LOW);
    digitalWrite(MOTOR5_ENABLE_PIN, LOW);


Donny


Tue Sep 16, 2014 12:05 pm
Profile

Joined: Tue Jan 14, 2014 6:54 pm
Posts: 23
Post Re: DragonFrame Custom Ardunio Mega 2560 shield Pins config
Thank you for your help.
I'll try tonight . But I already see what I was doing wrong. I'll turn the enable pin to High instead of Low.
That should be why it didn't work. Stupid me.

thanx again.

Ben


Tue Sep 16, 2014 12:57 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore. pozycjonowanie