Arduino Mega 2560 R3
June 15, 2019 09:07AM
Hi All

Asking for some help. I recently purchased an Arduino Mega 2560 R3 with Ramps 1.6 and A4988 drivers.
When It arrived I flashed the firmware and test the Controller and Ramps board with the A4988, all worked.
When I installed it into my CNC I forgot and powered it on with 24V supply thru the Ramps controller with out removing D1 diode.

To say hte lease I fried the onboard 5V regulator. and maybe other parts as well. I have reordered the full set of boards.
Now for my questions?

Is there a single program that I can use to test All 54 (15 provide PWM output) with to check the status of the Arduino, it could be as simple as turning on an LED or spinning a fan.
And also test the 16 Analog Input Pins. I have tested the Arduino and it will still let me upland a program. and the Ramps Smart discount controller function.
these are IO pins Then I need to also test for a simple input the to test All 54 that will allow input.

If needed and I have to I will rewrite the Program for every Port though was hoping that a program was written where I could select from 0ne of the 54 output ports via the rotary encoder.
these are IO pins Then I need to also test for a simple input the to test All 16 that will allow input.

Though I can not get the Stepper motors to turn now. And would like to know if I should throw it away or use it for a Arduino test controller for experimenting with.
I have ordered the AM1117 regulator chip have tested the fuses, D9 (fan), D10 (hotend) work.


All suggestions welcome

Edited 1 time(s). Last edit at 06/15/2019 09:08AM by Roberts_Clif.


Electronics Technician / Computer Programmer
Re: Arduino Mega 2560 R3
June 15, 2019 10:15AM
Just testing for logic levels is only half the story... should really test for source and sink current... but that is getting not worth your time
there is also internal memory and eeprom that needs testing and other stuff (pull up resistors, timers, interrupts...)

re stepper drivers, they are very prone to voltage spikes and are probably dead

if basic testing all pins I would use registers, save you having to setup all pins manually and just link port a to port b, set port a to output, set port b all input send some bit patterns from port a to a to port b and verify the result. then flip inputs and outputs and test back the other way. this way you can test 8 digital pins at once.

Edited 1 time(s). Last edit at 06/15/2019 10:16AM by Dust.
Re: Arduino Mega 2560 R3
June 15, 2019 12:52PM
Hello Dust

I want to do more than just display logic levels though I need to start somewhere learning to Arduino programming.

I saw your post Here for the Full Graphics Smart controller.
Though I have not figured out how to make the code work, with a simple RepRap discount smart controller yet.

I have found this simple code to display text. That will display text. Next step is to get the rotary encoder and Buzzer to function to select a line knowing which line was selected...

// include the library code:
#include 

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 16, en = 17, d4 = 23, d5 = 25, d6 = 27, d7 = 29;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("1st row");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print("2nd row");
  lcd.setCursor(0, 2);
  lcd.print("3rd row");
  lcd.setCursor(0, 3);
  lcd.print("4th row");
}

Edited 3 time(s). Last edit at 06/15/2019 12:59PM by Roberts_Clif.


Electronics Technician / Computer Programmer
Re: Arduino Mega 2560 R3
June 15, 2019 05:30PM
I found this code only Can't seem to find the Rotary Encoder turn pins.
PushB = 35

#include 

const int rs = 16, en = 17, d4 = 23, d5 = 25, d6 = 27, d7 = 29;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//
#define PINA 31 // Does not work On Ramps 1.6 with Arduino Mega 2560 R3
#define PINB 33  // Does not work On Ramps 1.6 with Arduino Mega 2560 R3
#define PUSHB 35


volatile boolean turned;   // rotary was turned
volatile boolean fired;    // knob was pushed
volatile boolean up;  // true when turned cw

int CursorLine = 0;
int DisplayFirstLine = 0;

char* MenueLine[] = {" Option 1"," Option 2"," Option 3"," Option 4"," Option 5"};
char* One[] = {" One-1"," One-2"," One-3"," One-4"," One-5"};
char* Two[] = {" Two-1"," Two-2"," Two-3"," Two-4"," Two-5"};
char* Three[] = {" Three-1"," Three-2"," Three-3"," Three-4"," Three-5"};

int MenueItems;


// Variable for the button's current state.
// button_mode = 1 when the button is up, and 0 when the button is pressed.
// This variable is 'static' and persists because it is declared outside of a function.
int button_mode = 1;


// Interrupt Service Routine for a change to encoder pin A
void isr ()
{
  if (digitalRead (PINA))
    up = digitalRead ( PINB ) ;
  else
    up = !digitalRead ( PINB ) ;
  turned = true;
}  // end of isr


void setup ()
{
  digitalWrite (PINA, HIGH);       // enable pull-ups
  digitalWrite (PINB, HIGH);       // enable pull-ups
  digitalWrite (PUSHB, HIGH);   // enable pull-ups

  attachInterrupt(3, isr, CHANGE);
 
  lcd.begin (20,4);

}  // end of setup

void loop ()
{
 
  if (turned)
    {
   if (up)
      move_up();
    else
      move_down();
    turned = false;
    }

   clickPin();
   
}  // end of loop

void clickPin()
{
 
if ((digitalRead( PUSHB ) == LOW) &&   (button_mode == 1))
{
 // Button was up before, but is pressed now. Set the button to pressed
button_mode = 0; // Button is pressed.
  selection();
  fired = false;
}
else if ((digitalRead( PUSHB ) == HIGH) && (button_mode == 0))
  {
 // Button was down before, but is released now. Set the button to released.
 button_mode = 1;
  }
}
 
void print_menu()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("   Main Menu  ");
  for (int i=1;i<4;i++)
  {
    lcd.setCursor(0,i);
    lcd.print(MenueLine[DisplayFirstLine + i]);
  }
  lcd.setCursor(0,(CursorLine-DisplayFirstLine)+1);
}

void print_menu1()
{
  lcd.clear();
  for (int i=1;i<4;i++)
  {
    lcd.setCursor(0,i);
    lcd.print(One[DisplayFirstLine + i]);
  }
  lcd.setCursor(0,(CursorLine-DisplayFirstLine));
}

void print_menu2()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Menu option 2");
  for (int i=1;i<4;i++)
  {
    lcd.setCursor(0,i);
    lcd.print(Two[DisplayFirstLine + i]);
  }
  lcd.setCursor(0,(CursorLine-DisplayFirstLine));
}

void print_menu3()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Menu option 3");
  for (int i=1;i<4;i++)
  {
    lcd.setCursor(0,i);
    lcd.print(Three[DisplayFirstLine + i]);
  }
  lcd.setCursor(0,(CursorLine-DisplayFirstLine));
}

void move_down()
{
  if (CursorLine == (DisplayFirstLine+4-1))
  {
    DisplayFirstLine++;
  }
  if (CursorLine == (MenueItems-1))
  {
    CursorLine = 0;
    DisplayFirstLine = 0;
  }
  else
  {
    CursorLine=CursorLine+1;
  }
  print_menu();
}

void move_up()
{
  if ((DisplayFirstLine == 0) & (CursorLine == 0)) {
    DisplayFirstLine = MenueItems-4; 
  }
  else if (DisplayFirstLine == CursorLine)
  {
    DisplayFirstLine--;
  }
  if (CursorLine == 0)
  {
    CursorLine = MenueItems-1;
  }
  else
  {
    CursorLine=CursorLine-1;
  }
  print_menu();
}

void selection()
{

  lcd.clear();
  lcd.print("MY MENU:");
  lcd.setCursor(0,1);
  lcd.print("You selected:");
  lcd.setCursor(0,2);
  lcd.print(MenueLine[CursorLine]);
  delay(2000);
  lcd.clear();
 
  switch (CursorLine)
  {
    case 0:
      First();
      break;
    case 1:
      Second();
      break;
    case 2:
      Third();
      break;
    case 3:
      break; 
    default:
      break;
  }
}


void First()
{
  lcd.setCursor(0,0);
  lcd.print("You are in menu:");
  lcd.setCursor(0,1);
  lcd.print("ONE");
  print_menu1();
}

void Second()
{
  lcd.setCursor(0,0);
  lcd.print("You are in menu:");
  lcd.setCursor(0,1);
  lcd.print("TWO");
  print_menu2();

}

void Third()
{
  lcd.setCursor(0,0);
  lcd.print("You are in menu:");
  lcd.setCursor(0,1);
  lcd.print("THREE");
  print_menu3();
}

Must be missing something as Marlin 1.1.9BF works and has

  #if ENABLED(NEWPANEL)

    #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)

      #define BEEPER_PIN        37

      #if ENABLED(CR10_STOCKDISPLAY)
        #define BTN_EN1         17
        #define BTN_EN2         23
      #else
        #define BTN_EN1         31
        #define BTN_EN2         33
      #endif

        #define BTN_ENC         35
        #define SD_DETECT_PIN   49
        #define KILL_PIN        41

The rotary switch is arranged so that if you turn in one direction BTN_EN1 is grounded, an if you spin in the other direction BTN_EN2 in grounded this grounding occurs in pulses.
I must then need to float a HIGH to then detect the lows. I see no reason for this not working.

Edited 10 time(s). Last edit at 06/16/2019 08:36AM by Roberts_Clif.


Electronics Technician / Computer Programmer
Re: Arduino Mega 2560 R3
June 21, 2019 12:54PM
Quote
Roberts_Clif
Hi All

Asking for some help. I recently purchased an Arduino Mega 2560 R3 with Ramps 1.6 and A4988 drivers.
When It arrived I flashed the firmware and test the Controller and Ramps board with the A4988, all worked.
When I installed it into my CNC I forgot and powered it on with 24V supply thru the Ramps controller with out removing D1 diode.

To say hte lease I fried the onboard 5V regulator. and maybe other parts as well. I have reordered the full set of boards.
Now for my questions?

Is there a single program that I can use to test All 54 (15 provide PWM output) with to check the status of the Arduino, it could be as simple as turning on an LED or spinning a fan.
And also test the 16 Analog Input Pins. I have tested the Arduino and it will still let me upland a program. and the Ramps Smart discount controller function.
these are IO pins Then I need to also test for a simple input the to test All 54 that will allow input.

If needed and I have to I will rewrite the Program for every Port though was hoping that a program was written where I could select from 0ne of the 54 output ports via the rotary encoder.
these are IO pins Then I need to also test for a simple input the to test All 16 that will allow input.

Though I can not get the Stepper motors to turn now. And would like to know if I should throw it away or use it for a Arduino test controller for experimenting with.
I have ordered the AM1117 regulator chip have tested the fuses, D9 (fan), D10 (hotend) work.


All suggestions welcome

I suppose that the first thing that I would do is see if the 5V regulator fried and stopped outputting or fried and became a 24V line to the 5V bus.
Connect it all up with 12 or 24V and see what is on the 5V bus. If it is 0V or something really low then you probably only lost the regulator. If the regulator is acting as a wire short then you can save yourself time and just recycle the board set. As Dust said, lots of subtle things can be wrong that may time time to show up. I wouldn't risk any new ports or bother with trying to fix a board that had 24V put on the 5V rail.

DLC


Kits: He3D K200 Kossel, Folgertech Kossel 2020 upgraded E3Dv6, Anet A8 upgraded E3Dv6, Tevo Tarantula enhanced parts and dual-head
Scratch: Large bed Cartesian, Linear slide Delta, Maker-Beam XL Micro Delta
Re: Arduino Mega 2560 R3
June 21, 2019 07:12PM
Quote
dlc60

I suppose that the first thing that I would do is see if the 5V regulator fried and stopped outputting or fried and became a 24V line to the 5V bus.
Connect it all up with 12 or 24V and see what is on the 5V bus. If it is 0V or something really low then you probably only lost the regulator. If the regulator is acting as a wire short then you can save yourself time and just recycle the board set. As Dust said, lots of subtle things can be wrong that may time time to show up. I wouldn't risk any new ports or bother with trying to fix a board that had 24V put on the 5V rail.

DLC

After assembling the MPCNC wanted to do one more final test before continuing forward.

You will not believe this but the first test out, blew the Adruino's AMS1117-5 regulator.
So ordered the new regulators and of course you can get 10 for the price of one so purchased a lot of 10.
After replacing the regulator tried the test again an every thing worked except the Stepper motors.

Troubleshooting high and low could not do any thing to get them working again.
Did what anyone who wanted the system up and running would do, Ordered the whole shooting match again.
Arduino Mega with Ramps 1.6 and five A4988 stepper motor drivers.

Today I received the new electronics and started to test, an wouldn't you know it the thing will do run.
After more troubleshooting I found a single A4988 stepper motor driver module was shorted out.
Removed the shorted driver and tested as much as possible with only 4 Driver modules.
These boards are working, Now I decided to test the other electronics parts.
And found that all original drivers modules are dead, the shorted one making 6 dead stepper motor modules.
Did determined that the Arduino and Ramps 1.6 survived the AMS1117-5 regulator destruction thrice.
The original accidental 24 volt, while measuring the 5volt pins on Arduino and while measuring something else. These AMS1117-5 sure are not very sturdy are they.

AMS1117-5.0 
Max VIN is 15V

Microcontroller 	ATmega2560
Operating Voltage 	        5V
Input Voltage (recommended) 	7-12V
Input Voltage (limit) 	        6-20V

Today I ordered ten stepper motor driver modules. Next time I want to have spares do not need more Arduino and Ramps 1.6 spares.

Edited 8 time(s). Last edit at 06/21/2019 07:44PM by Roberts_Clif.


Electronics Technician / Computer Programmer
Re: Arduino Mega 2560 R3
June 22, 2019 02:09AM
Instead of buying loads of spares, you could get properly-designed electronics that is designed to withstand the most common types of abuse. See [youtu.be].



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Arduino Mega 2560 R3
June 22, 2019 10:08AM
Quote
dc42
Instead of buying loads of spares, you could get properly-designed electronics that is designed to withstand the most common types of abuse. See [youtu.be].

This V1 Engineering MPCNC project was to be an inexpensive proof of concept.

I wanted to gain experiences in working with the Arduino and Ramps boards. I wanted to see for myself why this product is so popular an test the good/bad.
Did not expect the first Arduino controller to break it was working at 21.5 volts perfectly. If I have no experience with the Product then it is next to impossible to help those who do.

I have deturmined that the Ardunio Control as designed is OK! Though it could be redesigned to house a 5 volt regulator with a lot better specs.

For instances.
The next generation should have a 5volt Regulator capable of handling at lease 24 Vin the current AMS1117-5.0 is the worst regulator they could have chosen.
Now for the good, the Arduino Mega 2560 R3 survived three AMS1117-5.0 regulator deaths, some with a small mushroom puff of smoke and that distinctive PoP!
Some died without a whimper no audible sounds no smoke at all just quickly cease to function. So for those of us who can replace the Regulator it is a good choice.
An tho I have plenty of spare AMS1117-5.0 regulators if it dies again I will be replacing it with a 3 amp adjustable/fixed output Step Down Buck Converter.
Buck converter Adjustable Range:0.8-17V, fixed voltage (1.8V 2.5V 3.3V 5V 9V 12V)



It survived the death of five A4988 Stepper motor driver modules without harming the Mega 2650 these are a simple replacement after you know that they are bad.
I have a better Controller it is a spare for my two 3D Printers, an was planing to purchase spare parts for the new MPCNC just was not intending on it being now.
And with the 4 Spare Stepper motor driver modules will be better prepared for trouble shooting on the next mishap.

This spare Arduino Mega 2560 R3 will also give me a test Arduino to build all the various projects that are available that interest me.

In a few more day will receive the Spare Drivers and when time available will continue the MPCNC Build.

Edited 7 time(s). Last edit at 06/22/2019 10:58AM by Roberts_Clif.


Electronics Technician / Computer Programmer
Re: Arduino Mega 2560 R3
June 23, 2019 06:44AM
Quote
Roberts_Clif
I have deturmined that the Ardunio Control as designed is OK!

Arduino/RAMPS is OK electrically if the system doesn't include a display or servo. It's probably just about OK with a 20x4 text display. It's not OK with a 12864 graphics display because of the extra current draw of the backlight, which frequently causes the 5V regulator to overheat. It's probably not OK with most TFT displays either.

A decent 5V regulator should have been added to the RAMPS design years ago.

Edited 1 time(s). Last edit at 06/23/2019 06:45AM by dc42.



Large delta printer [miscsolutions.wordpress.com], Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Arduino Mega 2560 R3
June 23, 2019 10:30AM
Quote
dc42

A decent 5V regulator should have been added to the RAMPS design years ago.


I agree and will be adding this 3 amp adjustable/fixed output Step Down Buck Converter it is a simple way to to quickly upgrade the regulator to 3 Amps.

It will still need to be deturmined if just replacing the AMS1117-5.0 with this 3 amp adjustable/fixed output Step Down Buck Converter will be a sufficient change.

I have seen that some are adding a TO220 Regular to the circuit though in some cases looks terrible others not so bad.
I believe this or any similar DC-DC Step Down Buck adjustable/fixed output Converter module is compact enough to look good, an be secured with double sided tape.
This could be used for other projects with its fixed an Adjustable voltages levels, I have started with a single purchase of a 5 pack.

Edited 1 time(s). Last edit at 06/23/2019 11:02AM by Roberts_Clif.


Electronics Technician / Computer Programmer
Sorry, only registered users may post in this forum.

Click here to login