Welcome! Log In Create A New Profile

Advanced

WORKING - Customise RAMPS 1.4 LCD

Posted by AndyH 
WORKING - Customise RAMPS 1.4 LCD
October 23, 2012 09:33AM
Hi,

I have just purchased a RAMPS 1.4 kit from a well known auction site and I am just starting to get my head around it.

I am currently using the latest iteration of the Marlin firmware and it seems to be working.

I have modified an ATX power supply and connected the PSON (green) wire to the RAMPS board and can turn the PSU on and off using the M80 / M81 serial commands.

With the kit I also have the LCD panel / SD Card reader for headless printing but I can not currently turn the PSU on or off without having a USB / serial connection to the RAMPS.

Could someone please direct me to the files which contain the LCD commands so I can add an entry under the 'control' heading for PSU ON / PSU OFF.

I will continue to search through the Marlin files but if someone can give me some pointers I think it will save a lot of head scratching.

Kind Regards

Andy Hodges

I will continue searching through

Edited 1 time(s). Last edit at 10/24/2012 07:56AM by AndyH.
Re: Customise RAMPS 1.4 LCD
October 23, 2012 10:27AM
Hello again,

By copying some of the control configuration I have managed to get an entry for Power Supply under the control menu of the LCD. If selected however this displays the motion_control sub menu as this is where I copied the code from.

So now I need help with creating a sub menu for PSU ON to send an M80 command and PSU OFF to send an M81 command.

Regards

Andy Hodges
Re: Customise RAMPS 1.4 LCD
October 24, 2012 04:08AM
Hi Andy,
Do you power your Arduino as well as your LCD Display with the ATX Power Supply?? I don't know right now how the the Arduino behaves... in my case I'm using a GEN7 together with my LCD. The ATMEGA on the GEN7 get's powered up from the ATX Standby 5V. The LCD only gets power when the PSU is on.
This means: If I would switch on my PSU without turning it on the ATMEGA would start and would pass it's LCD initialisation routine before the LCD got powerd up. -> Can't work this way

Creating new sub menues in Marlin isn't that hard. Just take a look at ultralcd.h and ultralcd.pde.
Each sub menu is a separate function f.ex. void MainMenu::showPrepare(){ ....}; take a deeper look at one of them and it should be clear how it works. You can copy the existing "for" loop and "switch" through your custom menue items in it. Don't forget to declarer your new function in ultralcd.h
Cause Marlin has a multi language support don't hardcode your LCD messages. Just create a variable and define it in language.h (you have to define it for each language)

ultralcd.pde
...
enum { ItemN_pson, ItemN_psoff };
void MainMenu::showPS()
{
...
case ItemN_pson:
MENUITEM(  lcdprintPGM(MSG_PS_ON)  ,  BLOCK;enquecommand("G80");beepshort(); ) ;
break;
case ItemN_psoff:
MENUITEM(  lcdprintPGM(MSG_PS_OFF)  ,  BLOCK;enquecommand("G81");beepshort(); ) ;
....
};

ultralcd.h
class MainMenu{
....
void showPS();
...

language.h

...
#if LANGUAGE_CHOICE == 1
....
#define MSG_PS_ON  "Turn PSU on" 
#define MSG_PS_OFF  "Turn PSU off"
... 
#if LANGUAGE_CHOICE == 2
....
#define MSG_PS_ON  "Turn PSU on" 
#define MSG_PS_OFF  "Turn PSU off"
...
Re: Customise RAMPS 1.4 LCD
October 24, 2012 04:23AM
Hi Scuba,

Thanks for replying to my post. The RAMPS kit I have purchased works perfectly from the 5vsb including the LCD display and encoder spinning smiley sticking its tongue out

I managed to find and modify the language.h file, adding the variables for the PSON and PSOFF messages, though I have only added them to the language 1 section at the moment.

I have, as my second post sugested, managed to get the LCD to display a new subsection under 'Control' for Power Supply but I could not see how to get the menu and commands together. Your first code example of ultralcd.pde would seem to show the required entries. I will try this today and let you know how I get on.

Again many thanks for the reply.

Regards

Andy Hodges
WORKING - Customise RAMPS 1.4 LCD
October 24, 2012 07:55AM
Hi Scuba,

It works thumbs up

As a first time user of Arduino devices I have never programmed them before, let alone modify the code.

I now have an entry for 'Power' on the main menu with PSU ON and PSU OFF as selections of its sub menu.

It took me a little while to get it sorted but without your input it would have taken a lot longer.

Thanks again Scuba, your advice was invaluable.



If anyone else is using the Marlin firmware and looking to enable ATX power supply control from the LCD then this is what I have done.

*Note - Due to Scuba's previous comments about his LCD not working until his ATX PSU was running fully this may not work with your RAMPS board. One way to test is to connect the 5vsb and ground lines and see if your LCD works, if not then sorry, this is not for you.

I purchased my RAMPS board from reprapdiscount in Hong Kong, through eBay, and it works on this version.


in the file language.h I have added the following message variables

	#define MSG_POWER_ARROW " Power   \x7E"
	#define MSG_PS_ON " Turn PSU on"
	#define MSG_PS_OFF " Turn PSU off"

in the file ultralcd.h I edited the following line and added the text in bold.


  enum MainStatus{Main_Status, Main_Menu, Main_Power, Main_Prepare, Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl, Sub_PreheatPLASettings, Sub_PreheatABSSettings};

in ultralcd.pde I added all the following code at approx line 994


enum {
  ItemCP_exit, ItemCP_pson, ItemCP_psoff,
};

void MainMenu::showControlPower()
{
  uint8_t line=0;
 clearIfNecessary();
 for(int8_t i=lineoffset;iEdited 1 time(s). Last edit at 10/24/2012 07:55AM by AndyH.
Re: WORKING - Customise RAMPS 1.4 LCD
October 26, 2012 04:18PM
Have you considered asking for your changes to be merged into the existing code?

I reckon you might need to wrap your changes into #ifdef statements as this is not a menu choices that will suit everyone.
Re: WORKING - Customise RAMPS 1.4 LCD
December 20, 2012 06:37AM
Ask a noob question........... What does the FR 100% stand for on the LCD display?

I bet its somthing simple............ Please tell me as i just built mine smiling smiley
Re: WORKING - Customise RAMPS 1.4 LCD
December 20, 2012 08:05PM
Feed Rate?
Re: WORKING - Customise RAMPS 1.4 LCD
December 21, 2012 11:47AM
This may be a dumb question, but I have the LCD sd card addon, and have the D1 diode in the power arduino without USB. But can I connect the computer to it still? Safely?
Since now the arduino will be getting power from two places...
Re: WORKING - Customise RAMPS 1.4 LCD
January 01, 2013 01:39PM
littlebigmachine Wrote:
-------------------------------------------------------
> This may be a dumb question, but I have the LCD sd
> card addon, and have the D1 diode in the power
> arduino without USB. But can I connect the
> computer to it still? Safely?
> Since now the arduino will be getting power from
> two places...

Same exact setup as you.
I've had no problems with being hooked to 5vsb on power, while being connected to USB. I don't know if it's 'safe', but it seems fine.
Only issue is I have to disconnect my USB and PSU to fully power down my electronics.


Back on topic, thanks to the OP for this!
If I am not mistaken in my understanding of everything, ANYONE using Marlin with a properly configured LCD control/click encoder should be able to apply this change and have it work.

This really should be configured as an option like '#enable_lcd_psu_control' and put up for consideration for the Marlin master...
I'm new to this also.


I can't find the ultralcd.pde, you are describing.

Does the guide need updating? I have tested M80 and M81. They work.
Re: WORKING - Customise RAMPS 1.4 LCD
January 10, 2013 05:37AM
Hi,

It would appear that the recent updates of the frimware have resulted in a rewrite of the LCD scripts thereby making the about tutorial incorrect for the current version. So yes the guide needs updating but first I will need to work out how to get this working with the newer versions of Marlin.

Please don't expect this to be done soon as I have rather a lot on at the moment.

Regards

Andy Hodges
Re: WORKING - Customise RAMPS 1.4 LCD
January 11, 2013 03:54AM
[OT]
Hmmm, depending how recent these updates were, I may be behind on my version already!
[/OT]

Take your time, and it's an open community, any one of us could figure it out. All it takes is some time. And as hacker-geeks I have a feeling that's in short supply for most of us. Too much learning and doing always going on.

If I get around to it I'll see what I can do with it, if not hopefully someone will.
Re: WORKING - Customise RAMPS 1.4 LCD
January 13, 2013 06:46AM
Right, easier than I first thought...

Code Changes - As per previous instructions code additions are in bold

In language.h enter the following into the list of LCD Menu Messages

#define MSG_POWER "Power Control"
#define MSG_PSU_ON "PSU ON"       
#define MSG_PSU_OFF "PSU OFF"    

In file ultralcd.cpp add the following at approx line number 36

static void lcd_move_menu();
static void lcd_power_menu();     
static void lcd_control_menu();


In file ultralcd.cpp, at around line number 177 add the required code

/* Menu implementation */
static void lcd_main_menu()
{
    START_MENU();
    MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
    if (IS_SD_PRINTING)
    {
        MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
    }else{
        MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
    }
    MENU_ITEM(submenu, MSG_POWER, lcd_power_menu);          
    MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
#ifdef SDSUP...........

Again in file ultralcd.cpp, at around line 420 add the lines

static void lcd_move_menu()
{
    START_MENU();
    MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
    MENU_ITEM(submenu, "Move 10mm", lcd_move_menu_10mm);
    MENU_ITEM(submenu, "Move 1mm", lcd_move_menu_1mm);
    MENU_ITEM(submenu, "Move 0.1mm", lcd_move_menu_01mm);
    //TODOangry smiley,Y,Z,E
    END_MENU();
}

static void lcd_power_menu()                       
{                                                   
    START_MENU();                                  
    MENU_ITEM(back, MSG_MAIN, lcd_main_menu);      
    MENU_ITEM(gcode, MSG_PSU_ON, PSTR("M80"));      
    MENU_ITEM(gcode, MSG_PSU_OFF, PSTR("M81"));     
    END_MENU();                                     
}                                                  

static void lcd_control_menu()
{
    START_MENU();
    MENU_ITEM(back, MSG_MAIN, lcd_main_menu);


Save, compile, upload........ spinning smiley sticking its tongue out

Regards

Andy Hodges

Edited 1 time(s). Last edit at 01/13/2013 06:50AM by AndyH.
Re: WORKING - Customise RAMPS 1.4 LCD
January 21, 2013 04:17PM
Great. Worked straight away... thumbs upsmiling smiley
Re: WORKING - Customise RAMPS 1.4 LCD
February 01, 2013 04:35AM
Worked great,had given the same idea some thought already but the coding eludes me until I see it , then it all makes sense,
Thanks Andy
Re: WORKING - Customise RAMPS 1.4 LCD
February 01, 2013 05:11AM
Hi,

Glad it worked for you. One other thing I have found with newer versions of Marlin is that the PSU is on by default.

I didn't like this much as the whole idea was to be able to leave the PSU in standby and turn it on and off through the panel or M80 / M81 commands.

I appreciate that whilst this can still be done I don't want to have to issue an M81 or go through the LCD just because I have connected the mains cable.

If, like me, you want the system to be off when you connect the power then you need to do the following.

In the Marlin_Main.cpp file do a search for "suicide" and you will find the following section... Add comment (//) marks as per the bold text below.

void setup_powerhold()
{
 #ifdef SUICIDE_PIN
   #if (SUICIDE_PIN> -1)
      SET_OUTPUT(SUICIDE_PIN);
      WRITE(SUICIDE_PIN, HIGH);
   #endif
 #endif
 //#if (PS_ON_PIN > -1)
 //  SET_OUTPUT(PS_ON_PIN);
 //  WRITE(PS_ON_PIN, PS_ON_AWAKE);
// #endif
}

Regards

Andy Hodges
Re: WORKING - Customise RAMPS 1.4 LCD
February 15, 2013 10:32AM
I have now taken the time to incorporate these changes into a fork of the official Marlin guthub repo.

This has included menu entries for all 8 languages.

If my additions are accepted and merged into the main Marlin branch then there will be two choices you can make in configuration.h

1. #define LCD_DEFAULT_ON

Leave this uncommented for default Marlin behaviour (PSU on at Marlin startup)

comment this out to leave your PSU turned off until either an M80 is received or it is turned on through your LCD panel.

2. #define LCD_POWER_CONTROL

This is commented (disabled) by default, uncomment this to enable LCD Power Supply control.

Will have to wait and see if this makes it into the official brach... spinning smiley sticking its tongue out

Regards

Andy Hodges
Gentlemen,

seems that I found the right place for my Problem....

I have an Smart LCD Pannel fom RepRapdiscount - the display works only when I plug in the usb into my Ramps 1.4

everything works fine with the same firmware LCD and my other Ramps.

so I guess that there is a switch to define like for the SD detection ... for this ramps I got in eBay ??

Thanks for any Ideas

regards
Gerhard

Bavaria/Germany
Re: WORKING - Customise RAMPS 1.4 LCD
June 06, 2014 12:10PM
Install D1 and D2 diode, see on wiki.
Re: WORKING - Customise RAMPS 1.4 LCD
June 07, 2014 03:39AM
This thread is a year old!


_______________________________________
Waitaki 3D Printer
Re: WORKING - Customise RAMPS 1.4 LCD
February 25, 2015 01:42AM
@AndyH
Hi
I am new to this 3D printer.
I have installed marlin 1.0.2 and I have done changes according to my board..But I am confused about thermistor.

So Can u plz tell me which thermistor u r using...and which setting is done into configuration.h
It would be ur great pleasure...
Sorry, only registered users may post in this forum.

Click here to login