Arduino Mega 2560 R3 June 15, 2019 09:07AM |
Registered: 6 years ago Posts: 1,863 |
Re: Arduino Mega 2560 R3 June 15, 2019 10:15AM |
Admin Registered: 13 years ago Posts: 6,995 |
Re: Arduino Mega 2560 R3 June 15, 2019 12:52PM |
Registered: 6 years ago Posts: 1,863 |
// 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"); }
Re: Arduino Mega 2560 R3 June 15, 2019 05:30PM |
Registered: 6 years ago Posts: 1,863 |
#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(); }
#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
Re: Arduino Mega 2560 R3 June 21, 2019 12:54PM |
Registered: 6 years ago Posts: 619 |
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
Re: Arduino Mega 2560 R3 June 21, 2019 07:12PM |
Registered: 6 years ago Posts: 1,863 |
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
AMS1117-5.0 Max VIN is 15V Microcontroller ATmega2560 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limit) 6-20V
Re: Arduino Mega 2560 R3 June 22, 2019 02:09AM |
Registered: 10 years ago Posts: 14,672 |
Re: Arduino Mega 2560 R3 June 22, 2019 10:08AM |
Registered: 6 years ago Posts: 1,863 |
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].
Re: Arduino Mega 2560 R3 June 23, 2019 06:44AM |
Registered: 10 years ago Posts: 14,672 |
Quote
Roberts_Clif
I have deturmined that the Ardunio Control as designed is OK!
Re: Arduino Mega 2560 R3 June 23, 2019 10:30AM |
Registered: 6 years ago Posts: 1,863 |
Quote
dc42
A decent 5V regulator should have been added to the RAMPS design years ago.