Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1] 2 3
Author Topic: Arduino MEGA 2560R3 with RAMPS 1.4?
vdrome
Beginner
Posts: 36
Permalink
Post Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 14, 2014, 16:34
Quote

Hi there!

I recently built a polargraph using an Arduino UNO and an L293D Motor Shield without a hitch. However I have an extra Arduino Mega 2560R3 and a Ramps 1.4 (3d printer motor shield). I was curious if I could drive the polargraph using both the Arduino Mega and the Ramps 1.4 shield. The Ramps 1.4 shield has X, Y, and Z axis motor terminals, with that being said, could I just hook up the two motors to the X and Y terminals to run the polargraph, or would I need a totally different motor shield all together?

Here are links to exactly what I have:

http://www.reprapdiscount.com/electronics/11-taurino-power.html
http://www.reprapdiscount.com/electronics/12-ramps-14.html

The RAMPS 1.4 board I have has A4988 driver chips installed.

Anyway, besides extra room for firmware, would running the polargraph on this have any noticeable effect on the resolution, say an increased resolution for working with highly intricate vector graphics?

Long story short, would I be able to run the polargraph on the boards/chips I have listed, or do I need some extra parts to run it on an Arduino Mega?

Any help would be great!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 15, 2014, 14:12
Quote

Hello, yes the polargraphSD is based on RAMPS, so it should be straightforward. A bit of hacking in the PolargraphSD firmware should do it for you, some pin reassignments. The specs for the control pins are all in the schematics in github (https://github.com/euphy/polarshield_hardware), but I'll try to dig them out later and summarise the changes.

The main difference between the Polarshield and RAMPS is that the polarshield has a big collection of pins dedicated to reading and writing the touchscreen. Now it'll work fine without having the screen attached, it's not strictly necessary for anything.

I'd be interested to see how you get on. You could also have a look at the new version of Dan Royer's drawbot (http://www.marginallyclever.com/shop/drawing-robots/makelangelo-3-control-box) - it is based on the RUMBA board, which is loosely based on RAMPS too (I believe). I haven't looked at his firmware, but his code is usually of a pretty high standard, so you might get something from it.

sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 18, 2014, 16:26
Quote

Thanks for the heads up.

Unfortunately I'm not the savviest of coders - I know a thing or two, I've adjusted a few pin assignments before on my 3d printers. But once I get the PG Firmware uploaded to RAMPS I'll see what pins I need to change. 3 or 4 off the top of my head - would be the power, USB connection, and X / Y axis motor assignments. To find these on my RAMPS board I suppose I would need some sort of Data sheet / schematic.

I'm also curious if I would be able to run a servo motor off RAMPS as well?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 18, 2014, 22:21
Quote

RAMPS has a couple of headers for servo motors, so I don't see why not.

motor pin name    RAMPS pin    Polarshield pin
------------------------------------------------------------
Motor A enable    D36    D3
Motor A step    A0    D4
Motor A dir    A1    D5
Motor B enable    A2    D6
Motor B step    A6    D7
Motor B dir    A7    D8
Servo 1    D7    D9

So if you're using polargraph_server_polarshield, you should open up the configuration.ino tab, and update the values as so:

const byte motoraEnablePin = 36;
const byte motoraStepPin = A0;
const byte motoraDirPin = A1;

const byte motorbEnablePin = A2;
const byte motorbStepPin = A6;
const byte motorbDirPin = A7;

And in the main file (polargraph_server_polarshield.ino), update the servo pin:

int const PEN_HEIGHT_SERVO_PIN = 7;

Now, I _think_ that's all you should need to do to switch over... The polarshield has a load of pins used up by the screen, and there's one line which is configured as an interrupt for the touchscreen. That's D2, which, on RAMPS is set to the X endstop. I don't know what it'l do if it isn't pulled high or low (because it's not really fastened to a screen) - whether it'll trigger touches randomly, or what.

So it might be worth taking these lines out too:

  pinMode(2, INPUT_PULLUP);
  attachInterrupt(INTERRUPT_TOUCH_PIN, lcd_touchInput, LOW);

They're in configuration.ino too - they just enable the interrupt-ability of that pin.

Good luck!

sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 22, 2014, 15:16
Quote

Hey thanks, that was painless! I made those changes in the firmware yesterday, I'll give it a go soon.

=)

donald
Newbie
Posts: 5
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 24, 2014, 18:34
Quote

so is it working?

can you post here the changes you made?

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: April 28, 2014, 19:04
Quote

So far Donald I've only changed the pin assignments in the Polargraph_Polarshield firmware, I can confirm that it did verify the changes without any problems. Hopefully by using Mega + Ramps 1.4 I can get smoother and faster micro-stepping when rendering vector graphics. Alternatively I'm also looking into getting Sandy's Polarshield and installing it on top of the Mega I have at hand.

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 2, 2014, 03:58
Quote

I've been attempting to compile on Ramps 1.4 - I keep getting the,following error when verifying the firmware before uploading. Any ideas?

Class 'AccelStepper' has no member named 'SetEnablePin'

"configuration.ino: In function 'void configuration_motorSetup()':
configuration:80: error: 'class AccelStepper' has no member named 'setEnablePin'
configuration:81: error: 'class AccelStepper' has no member named 'setPinsInverted'
configuration:82: error: 'class AccelStepper' has no member named 'setEnablePin'
configuration:83: error: 'class AccelStepper' has no member named 'setPinsInverted'
/**
*  Polargraph Server. - CORE
*  Written by Sandy Noble
*  Released under GNU License version 3.
*  http://www.polargraph.co.uk
*  http://code.google.com/p/polargraph/

Configuration.

This is one of the core files for the polargraph server program.  
It sets up the motor objects (AccelSteppers), and has default
values for the motor, sprocket and microstepping combinations used
by polargraphs so far.

Comment out the blocks of code you don't need.

*/
// motor configurations for the various electrical schemes

// =================================================================
// 1. Adafruit motorshield

//#include <AFMotor.h>
//const int stepType = INTERLEAVE;
//
//AF_Stepper afMotorA(motorStepsPerRev, 1);
//AF_Stepper afMotorB(motorStepsPerRev, 2);
//
//void forwarda() { afMotorA.onestep(FORWARD, stepType); }
//void backwarda() { afMotorA.onestep(BACKWARD, stepType); }
//AccelStepper motorA(forwarda, backwarda);
//
//void forwardb() { afMotorB.onestep(FORWARD, stepType); }
//void backwardb() { afMotorB.onestep(BACKWARD, stepType); }
//AccelStepper motorB(forwardb, backwardb);
//
//void configuration_motorSetup()
//{
//  // no initial setup for these kinds of motor drivers
//}
//void configuration_setup()
//{
//  defaultMachineWidth = 650;
//  defaultMachineHeight = 650;
//  defaultMmPerRev = 95;
//  defaultStepsPerRev = 400;
//  defaultStepMultiplier = 1;
//  delay(500);
//}
// end of Adafruit motorshield definition
// =================================================================


// =================================================================
// 2. Polarshield motor driver board
// This uses stepstick-format stepper drivers on arduino pins 3 to 8.

const byte motoraEnablePin = 36;
const byte motoraStepPin = A1;
const byte motoraDirPin = A0;

const byte motorbEnablePin = A2;
const byte motorbStepPin = A6;
const byte motorbDirPin = A7;

//const byte motorcEnablePin = 30;
//const byte motorcStepPin = 31;
//const byte motorcDirPin = 32;

AccelStepper motorA(1,motoraStepPin, motoraDirPin); 
AccelStepper motorB(1,motorbStepPin, motorbDirPin); 
//AccelStepper motorC(1,motorcStepPin, motorcDirPin); 

void configuration_motorSetup()
{
  pinMode(motoraEnablePin, OUTPUT);
  digitalWrite(motoraEnablePin, HIGH);
  pinMode(motorbEnablePin, OUTPUT);
  digitalWrite(motorbEnablePin, HIGH);
  motorA.setEnablePin(motoraEnablePin);
  motorA.setPinsInverted(false, false, true);
  motorB.setEnablePin(motorbEnablePin);
  motorB.setPinsInverted(true, false, true); // this one turns the opposite direction to A, hence inverted.
}

void configuration_setup()
{
  defaultMachineWidth = 650;
  defaultMachineHeight = 650;
  defaultMmPerRev = 95;
  defaultStepsPerRev = 400;
  defaultStepMultiplier = 8;

  // init SD card
  sd_initSD();
  lcd_initLCD();
  lcd_showSummary();
  delay(1000);
  //pinMode(2, INPUT_PULLUP);
  //attachInterrupt(INTERRUPT_TOUCH_PIN, lcd_touchInput, LOW);
  
  
  // calibration pins
  pinMode(ENDSTOP_X_MIN, INPUT);
  pinMode(ENDSTOP_Y_MIN, INPUT);
  pinMode(ENDSTOP_X_MAX, INPUT);
  pinMode(ENDSTOP_Y_MAX, INPUT);
  // do a write to turn on the internal pull up resistors
  digitalWrite(ENDSTOP_X_MIN, HIGH);
  digitalWrite(ENDSTOP_Y_MIN, HIGH);
  digitalWrite(ENDSTOP_X_MAX, HIGH);
  digitalWrite(ENDSTOP_Y_MAX, HIGH);
  
  lcd_displayFirstMenu();
  
  releaseMotors();
}

// end of Polarshield definition
// =================================================================
sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 2, 2014, 08:31
Quote

The error usually means that the the Accelstepper library was not loaded. Do the accelstepper example sketches work ok?

(It's a bit of a pain, but the version of accelstepper you need is the version in the zip file bundle - https://github.com/euphy/polargraphcontroller/releases. The newest version of accelstepper on Mike's site fixes a couple of bugs I _rely_ on, which is embarrassing.)

Other thing to check - apologies - you are compiling the whole project, not just the configuration.ino?

sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 2, 2014, 16:09
Quote

Confirming that my Accelstepper library is in Documents/Arduino/libraries/AccelStepper

Definitely compiling the whole project =).

*Bingo the sketched verified with the url you provided above. Just replaced all the libraries.

Can't wait to get this thing rolling.

Also, will you be selling the Polarshield 2.0 a la carte?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 2, 2014, 21:34
Quote

Its strange that it doesn't compile otherwise - the new version of setEnablePin must have a slightly different signature. I will get around to updating it one day (promise...).

I'm pretty sure I'll be offering the Polarshield 2.0 on it's own, or in a vitamin kit at some point. Main reason I'm holding off it to make sure it is happy working with lots of different kinds of arduinos. The last version was getting fussy. Over RAMPS, the only benefit you will get is the touchscreen. Of course RAMPS can have a screen and panel too, but there is no polargraph firmware that uses it.

good luck ๐Ÿ™‚
sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 4, 2014, 15:39
Quote

Hmmmm. Everything went to the board "okay" though I think my board may have physically given out, (something's fried I think) - only the Y-axis stepper terminals were working smoothly - the X was not. I tested different working driver chips on the X-axis stepper terminal but no go. I also tested the voltage and nothing seemed to high or low. Could anyone confirm with me that on the RAMPS 1.4 board itself I only need to be using the X and Y axis terminals and two driver chips? To be on the safe side I went ahead and ordered a new Mega R3 and RAMPS 1.4.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 4, 2014, 17:20
Quote

Hello, had another look at the Marlin firmware, it uses the proper pin numbering rather than the weird Ax way of doing it, which has revealed:

    #define X_STEP_PIN         54 // A0
    #define X_DIR_PIN          55 //A1
    #define X_ENABLE_PIN       38 

    #define Y_STEP_PIN         60 // A6
    #define Y_DIR_PIN          61 // A7
    #define Y_ENABLE_PIN       56 // A2

I think we had previously identified the X_ENABLE pin as being 36 rather than 38. Either that was a typo, or an output on a subtly different board - the assignments seems slightly randomised, and I can't quite remember which source I looked in to get them. But I would try

const byte motoraEnablePin = 38;

and see if that bears any fruit!

sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 5, 2014, 00:10
Quote

Okay. I will test out the new pin assignments on the older (assumed) damaged board(s) and the new one I bought, I will post my results here.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 5, 2014, 00:23
Quote

It's just that one pin, the x enable. If it was disconnected, then all that will have happened is that the driver would not get enabled, and so it wouldn't do anything.

As long as nothing _else_ has happened, it should spring into life. The way to damage these drivers is to disconnect the motors while they are energised - other than that, they're pretty robust.

sn

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 5, 2014, 18:51
Quote

Bingo, hopefully this will be an easy fix.

For anyone reading this, here's RAMPS 1.4 datasheet, pin assignments are on the upper-left hand side:

http://reprap.org/mediawiki/images/f/f6/RAMPS1.4schematic.png

vdrome
Beginner
Posts: 36
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 10, 2014, 16:56
Quote

Okay I finally got Mega + Ramps 1.4 (almost) working with the modified firmware installed - both motors are spinning finally. However - it seems like the X-AXIS is having issues. When I "set_home", rove around, and draw vectors, the gondola will literally drop down while moving about the drawing surface, like it's slipping when the it's attached. Also when it's drawing the gondola progressively drops vertically down during a job - when it's suppose to be drawing from left to right in rows.

I've tested the amperage on the driver chips themselves via the trim-pot and the ground - and they're around 1.8A on each one. I've also switched out driver-chips on the X-axis, but that doesn't seem to have made a difference.

Is there a particular voltage / amperage I should be running at, if in case that's the issue?

Here's my configuration code:

/**
*  Polargraph Server. - CORE
*  Written by Sandy Noble
*  Released under GNU License version 3.
*  http://www.polargraph.co.uk
*  http://code.google.com/p/polargraph/

Configuration.

This is one of the core files for the polargraph server program.  
It sets up the motor objects (AccelSteppers), and has default
values for the motor, sprocket and microstepping combinations used
by polargraphs so far.

Comment out the blocks of code you don't need.

*/
// motor configurations for the various electrical schemes

// =================================================================
// 1. Adafruit motorshield

//#include <AFMotor.h>
//const int stepType = INTERLEAVE;
//
//AF_Stepper afMotorA(motorStepsPerRev, 1);
//AF_Stepper afMotorB(motorStepsPerRev, 2);
//
//void forwarda() { afMotorA.onestep(FORWARD, stepType); }
//void backwarda() { afMotorA.onestep(BACKWARD, stepType); }
//AccelStepper motorA(forwarda, backwarda);
//
//void forwardb() { afMotorB.onestep(FORWARD, stepType); }
//void backwardb() { afMotorB.onestep(BACKWARD, stepType); }
//AccelStepper motorB(forwardb, backwardb);
//
//void configuration_motorSetup()
//{
//  // no initial setup for these kinds of motor drivers
//}
//void configuration_setup()
//{
//  defaultMachineWidth = 650;
//  defaultMachineHeight = 650;
//  defaultMmPerRev = 95;
//  defaultStepsPerRev = 400;
//  defaultStepMultiplier = 1;
//  delay(500);
//}
// end of Adafruit motorshield definition
// =================================================================


// =================================================================
// 2. Polarshield motor driver board
// This uses stepstick-format stepper drivers on arduino pins 3 to 8.

const byte motoraEnablePin = 38;
const byte motoraStepPin = A0;
const byte motoraDirPin = A1;

const byte motorbEnablePin = A2;
const byte motorbStepPin = A6;
const byte motorbDirPin = A7;

//const byte motorcEnablePin = 30;
//const byte motorcStepPin = 31;
//const byte motorcDirPin = 32;

AccelStepper motorA(1,motoraStepPin, motoraDirPin); 
AccelStepper motorB(1,motorbStepPin, motorbDirPin); 
//AccelStepper motorC(1,motorcStepPin, motorcDirPin); 

void configuration_motorSetup()
{
  pinMode(motoraEnablePin, OUTPUT);
  digitalWrite(motoraEnablePin, HIGH);
  pinMode(motorbEnablePin, OUTPUT);
  digitalWrite(motorbEnablePin, HIGH);
  motorA.setEnablePin(motoraEnablePin);
  motorA.setPinsInverted(false, false, true);
  motorB.setEnablePin(motorbEnablePin);
  motorB.setPinsInverted(true, false, true); // this one turns the opposite direction to A, hence inverted.
}

void configuration_setup()
{
  defaultMachineWidth = 650;
  defaultMachineHeight = 650;
  defaultMmPerRev = 95;
  defaultStepsPerRev = 400;
  defaultStepMultiplier = 1;

  // init SD card
  sd_initSD();
  lcd_initLCD();
  lcd_showSummary();
  delay(1000);
  //pinMode(2, INPUT_PULLUP);
  //attachInterrupt(INTERRUPT_TOUCH_PIN, lcd_touchInput, LOW);
  
  
  // calibration pins
  pinMode(ENDSTOP_X_MIN, INPUT);
  pinMode(ENDSTOP_Y_MIN, INPUT);
  pinMode(ENDSTOP_X_MAX, INPUT);
  pinMode(ENDSTOP_Y_MAX, INPUT);
  // do a write to turn on the internal pull up resistors
  digitalWrite(ENDSTOP_X_MIN, HIGH);
  digitalWrite(ENDSTOP_Y_MIN, HIGH);
  digitalWrite(ENDSTOP_X_MAX, HIGH);
  digitalWrite(ENDSTOP_Y_MAX, HIGH);
  
  lcd_displayFirstMenu();
  
  releaseMotors();
}

// end of Polarshield definition
// =================================================================
swarm
Newbie
Posts: 9
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 10, 2014, 21:58
Quote

Awsome ๐Ÿ™‚

Could you post a photo?

Furthermore what is your power supply spec and your stepper motors?

swarm
Newbie
Posts: 9
Permalink
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 10, 2014, 22:51
Quote

Hi I posted a photo about my RAMPS 1.4
is it correct?

https://drive.google.com/file/d/0B8pthQnh7lw5QXZRM2MwY0N4OGM/edit?usp=sharing

I have another question, what is power supply spec for 2 nema 17 5V and 1,2A if i use RAMPS 1.4?

Furthermore on a beadboard, i have an issue if i use the Krtizler circuit, my pololuA4988 canโ€™t control my NEMA 17 with 5V, only above 6V, but itโ€™s shaking why?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Arduino MEGA 2560R3 with RAMPS 1.4?
on: May 10, 2014, 23:41
Quote

The A4988 chip datasheet (http://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf) apparently specifies that it needs a minimum of 8v.

I usually run them at 7.5v and they're ok with that in practice - the lower you go the less likely it is to work.

Swarm: If you have motors rated at 1.2A, then you should - in principle - have a supply that can give 2.4A. No mean feat. In practice, I have almost always ran with PSUs that were under-specced. A few times it backfired, and led to some dim LEDs and some bad smells, so I can hardly recommend it.

vdrome: There are no current or power settings available in the firmware, so nothing to adjust there. It's purely hardware, and so whatever works for every other RAMPS user in the world should also work for you. If the motors seem to be holding tight when you first engage them (so you can't easily move them by hand), but then get progressively worse, you might be overheating them. The A4988 chips have a thermal overload protection that just turns off when it gets too hot, but then magically comes back on when it cools a little. The temperature is high though, so you would burn your finger on it, before it shut itself down. So it might be worth checking to see if anything is very hot.

sn

Pages: [1] 2 3
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.043 seconds.