Commit 23f5f244 authored by MagoKimbra's avatar MagoKimbra

Del Kc

parent 1a6d824d
......@@ -87,7 +87,31 @@
//**********************************************************************
#if !defined(MKR4)
/***********************************************************************
*********************** Multiextruder NPr2 ***************************
***********************************************************************
* *
* Setting fot color meccanism NPr2 by NicolaP (www.3dmakerlab.it) *
* *
* Firmware by MagoKimbra magokimbra@hotmail.com *
* *
* Find angle setting by g-Code "M997 Cxxx" *
* *
***********************************************************************/
//#define NPR2
#ifdef NPR2
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE
#define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
#define DRIVER_MICROSTEP 4 // Microstep moltiplicator driver (set jumper MS1-2-3) off-on-off 1/4 microstepping.
#define CARTER_MOLTIPLICATOR 14.22 // CARTER MOLTIPLICATOR (gear ratio 13/31-10/31)
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruders
#endif
//**********************************************************************
#if !defined(MKR4) && !defined(NPR2)
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruders
#endif
......@@ -515,7 +539,8 @@
#define LCD_UNLOAD_FEEDRATE 8 // mm/s
#endif
// Show a progress bar on the LCD when printing from SD?
// Show a progress bar on HD44780 LCDs for SD printing
//#define LCD_PROGRESS_BAR
#ifdef LCD_PROGRESS_BAR
// Amount of time (ms) to show the bar
......@@ -526,6 +551,12 @@
#define PROGRESS_BAR_MSG_EXPIRE 0
// Enable this to show messages for MSG_TIME then hide them
//#define PROGRESS_BAR_MSG_ONCE
#ifdef DOGLCD
#warning LCD_PROGRESS_BAR does not apply to graphical displays at this time.
#endif
#ifdef FILAMENT_LCD_DISPLAY
#error LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both.
#endif
#endif
......
......@@ -91,13 +91,7 @@ void Config_StoreSettings()
EEPROM_WRITE_VAR(i,Kp);
EEPROM_WRITE_VAR(i,Ki);
EEPROM_WRITE_VAR(i,Kd);
#else
float dummy = 3000.0f;
EEPROM_WRITE_VAR(i,dummy);
dummy = 0.0f;
EEPROM_WRITE_VAR(i,dummy);
EEPROM_WRITE_VAR(i,dummy);
#endif
#endif // PIDTEMP
#ifndef DOGLCD
int lcd_contrast = 32;
#endif
......@@ -270,12 +264,17 @@ void Config_PrintSettings()
#ifdef PIDTEMP
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:");
for (int e = 0; e < EXTRUDERS; e++)
{
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 P",Kp[active_extruder]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[active_extruder]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[active_extruder]));
SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e);
SERIAL_ECHOPAIR(" P", Kp[e]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[e]));
SERIAL_ECHOLN("");
#endif
}
#endif // PIDTEMP
#ifdef FWRETRACT
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
......@@ -391,13 +390,14 @@ void Config_RetrieveSettings()
EEPROM_READ_VAR(i,gumPreheatHotendTemp);
EEPROM_READ_VAR(i,gumPreheatHPBTemp);
EEPROM_READ_VAR(i,gumPreheatFanSpeed);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
#ifdef PIDTEMP
// do not need to scale PID values as the values in EEPROM are already scaled
EEPROM_READ_VAR(i,Kp);
EEPROM_READ_VAR(i,Ki);
EEPROM_READ_VAR(i,Kd);
#endif // PIDTEMP
#ifndef DOGLCD
int lcd_contrast;
#endif
......@@ -461,7 +461,7 @@ void Config_ResetDefault()
float tmp5[]=DEFAULT_Kp;
float tmp6[]=DEFAULT_Ki;
float tmp7[]=DEFAULT_Kd;
#endif
#endif // PIDTEMP
for (short i=0;i<7;i++)
{
......@@ -517,6 +517,8 @@ void Config_ResetDefault()
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif
#ifdef PIDTEMP
// call updatePID (similar to when we have processed M301)
updatePID();
for (short i=0;i<4;i++)
{
#ifdef SINGLENOZZLE
......@@ -528,14 +530,8 @@ void Config_ResetDefault()
Ki[i] = scalePID_i(tmp6[i]);
Kd[i] = scalePID_d(tmp7[i]);
#endif
}
// call updatePID (similar to when we have processed M301)
updatePID();
#ifdef PID_ADD_EXTRUSION_RATE
Kc = DEFAULT_Kc;
#endif//PID_ADD_EXTRUSION_RATE
}
#endif//PIDTEMP
#ifdef FWRETRACT
......
......@@ -28,16 +28,6 @@
//#define WATCH_TEMP_PERIOD 40000 //40 seconds
//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds
#ifdef PIDTEMP
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#ifdef PID_ADD_EXTRUSION_RATE
#define DEFAULT_Kc (1) //heating power=Kc*(e_speed)
#endif
#endif
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
//The maximum buffered steps/sec of the extruder motor are called "se".
//You enter the autotemp mode by a M109 S<mintemp> B<maxtemp> F<factor>
......
......@@ -4497,29 +4497,36 @@ Sigma_Exit:
#ifdef PIDTEMP
case 301: // M301
{
if(code_seen('P')) Kp[active_extruder] = code_value();
if(code_seen('I')) Ki[active_extruder] = scalePID_i(code_value());
if(code_seen('D')) Kd[active_extruder] = scalePID_d(code_value());
#ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value();
#endif
// multi-extruder PID patch: M301 updates or prints a single extruder's PID values
// default behaviour (omitting E parameter) is to update for extruder 0 only
int e = 0; // extruder being updated
if (code_seen('E'))
{
e = (int)code_value();
}
if (e < EXTRUDERS) // catch bad input value
{
if (code_seen('P')) Kp[e] = code_value();
if (code_seen('I')) Ki[e] = scalePID_i(code_value());
if (code_seen('D')) Kd[e] = scalePID_d(code_value());
updatePID();
SERIAL_PROTOCOL(MSG_OK);
SERIAL_PROTOCOL(" e:"); // specify extruder in serial output
SERIAL_PROTOCOL(e);
SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(Kp[active_extruder]);
SERIAL_PROTOCOL(Kp[e]);
SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(Ki[active_extruder]));
SERIAL_PROTOCOL(unscalePID_i(Ki[e]));
SERIAL_PROTOCOL(" d:");
SERIAL_PROTOCOL(unscalePID_d(Kd[active_extruder]));
#ifdef PID_ADD_EXTRUSION_RATE
SERIAL_PROTOCOL(" c:");
//Kc does not have scaling applied above, or in resetting defaults
SERIAL_PROTOCOL(Kc);
#endif
SERIAL_PROTOCOL(unscalePID_d(Kd[e]));
SERIAL_PROTOCOLLN("");
}
else
{
SERIAL_ECHO_START;
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
}
}
break;
#endif //PIDTEMP
......
/**
*dogm_lcd_implementation.h
* dogm_lcd_implementation.h
*
*Graphics LCD implementation for 128x64 pixel LCDs by STB for ErikZalm/Marlin
*Demonstrator: http://www.reprap.org/wiki/STB_Electronics
*License: http://opensource.org/licenses/BSD-3-Clause
* Graphics LCD implementation for 128x64 pixel LCDs by STB for ErikZalm/Marlin
* Demonstrator: http://www.reprap.org/wiki/STB_Electronics
* License: http://opensource.org/licenses/BSD-3-Clause
*
*With the use of:
*u8glib by Oliver Kraus
*http://code.google.com/p/u8glib/
*License: http://opensource.org/licenses/BSD-3-Clause
* With the use of:
* u8glib by Oliver Kraus
* http://code.google.com/p/u8glib/
* License: http://opensource.org/licenses/BSD-3-Clause
*/
#ifndef DOGM_LCD_IMPLEMENTATION_H
#define DOGM_LCD_IMPLEMENTATION_H
#ifndef ULTRA_LCD_IMPLEMENTATION_DOGM_H
#define ULTRA_LCD_IMPLEMENTATION_DOGM_H
#define MARLIN_VERSION "4.0.1"
/**
* Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
......@@ -85,17 +86,21 @@ U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
#endif
static void lcd_implementation_init()
{
#ifdef LCD_PIN_BL
static void lcd_implementation_init() {
#ifdef LCD_PIN_BL
pinMode(LCD_PIN_BL, OUTPUT); // Enable LCD backlight
digitalWrite(LCD_PIN_BL, HIGH);
#endif
#endif
u8g.setContrast(lcd_contrast);
/*
// Uncomment this if you have the first generation (V1.10) of STBs board
// pinMode(17, OUTPUT); // Enable LCD backlight
// digitalWrite(17, HIGH);
pinMode(17, OUTPUT); // Enable LCD backlight
digitalWrite(17, HIGH);
//*/
u8g.firstPage();
do {
......@@ -105,63 +110,30 @@ static void lcd_implementation_init()
u8g.setColorIndex(1);
} while( u8g.nextPage() );
#ifdef LCD_SCREEN_ROT_90
#if defined(LCD_SCREEN_ROT_90)
u8g.setRot90(); // Rotate screen by 90°
#endif
#ifdef LCD_SCREEN_ROT_180
#elif defined(LCD_SCREEN_ROT_180)
u8g.setRot180(); // Rotate screen by 180°
#endif
#ifdef LCD_SCREEN_ROT_270
#elif defined(LCD_SCREEN_ROT_270)
u8g.setRot270(); // Rotate screen by 270°
#endif
#endif
u8g.firstPage();
do {
// RepRap init bmp
u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp);
u8g.drawBitmapP(7,7,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp);
// Welcome message
u8g.setFont(u8g_font_6x10_marlin);
u8g.drawStr(62,10,"MARLIN");
u8g.setFont(u8g_font_5x8);
u8g.drawStr(62,19,"V1.0.0 RC2-mm");
u8g.setFont(u8g_font_6x10_marlin);
u8g.drawStr(62,28,"by ErikZalm");
u8g.drawStr(62,41,"DOGM128 LCD");
u8g.setFont(u8g_font_5x8);
u8g.drawStr(62,48,"enhancements");
u8g.setFont(u8g_font_5x8);
u8g.drawStr(62,55,"by STB, MM");
u8g.drawStr(62,61,"uses u");
u8g.drawStr90(92,57,"8");
u8g.drawStr(100,61,"glib");
u8g.drawStr(7, 51, "V" MARLIN_VERSION " - marlin.reprap.org");
} while( u8g.nextPage() );
}
static void lcd_implementation_clear()
{
// NO NEED TO IMPLEMENT LIKE SO. Picture loop automatically clears the display.
//
// Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2
//
// u8g.firstPage();
// do {
// u8g.setColorIndex(0);
// u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight());
// u8g.setColorIndex(1);
// } while( u8g.nextPage() );
}
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
static void lcd_printPGM(const char* str)
{
static void lcd_printPGM(const char* str) {
char c;
while((c = pgm_read_byte(str++)) != '\0')
{
u8g.print(c);
}
while ((c = pgm_read_byte(str++))) u8g.print(c);
}
static void _draw_heater_status(int x, int heater) {
......@@ -184,8 +156,7 @@ static void _draw_heater_status(int x, int heater) {
}
}
static void lcd_implementation_status_screen()
{
static void lcd_implementation_status_screen() {
static unsigned char fan_rot = 0;
......@@ -195,35 +166,31 @@ static void lcd_implementation_status_screen()
u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp);
#ifdef SDSUPPORT
//SD Card Symbol
// SD Card Symbol
u8g.drawBox(42,42,8,7);
u8g.drawBox(50,44,2,5);
u8g.drawFrame(42,49,10,4);
u8g.drawPixel(50,43);
// Progress bar
// Progress bar frame
u8g.drawFrame(54,49,73,4);
// SD Card Progress bar and clock
u8g.setFont(FONT_STATUSMENU);
if (IS_SD_PRINTING)
{
// Progress bar
u8g.drawBox(55,50, (unsigned int)( (71 * card.percentDone())/100) ,2);
}
else {
// do nothing
if (IS_SD_PRINTING) {
// Progress bar solid part
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2);
}
u8g.setPrintPos(80,47);
if(starttime != 0)
{
if (starttime != 0) {
uint16_t time = millis()/60000 - starttime/60000;
u8g.print(itostr2(time/60));
u8g.print(':');
u8g.print(itostr2(time%60));
}else{
}
else {
lcd_printPGM(PSTR("--:--"));
}
#endif
......@@ -250,7 +217,6 @@ static void lcd_implementation_status_screen()
u8g.print("---");
#endif
// X, Y, Z-Coordinates
u8g.setFont(FONT_STATUSMENU);
u8g.drawBox(0,29,128,10);
......@@ -290,11 +256,10 @@ static void lcd_implementation_status_screen()
#ifndef FILAMENT_LCD_DISPLAY
u8g.print(lcd_status_message);
#else
if(message_millis+5000>millis()){ //Display both Status message line and Filament display on the last line
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message);
}
else
{
else {
lcd_printPGM(PSTR("dia:"));
u8g.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" factor:"));
......@@ -302,35 +267,31 @@ static void lcd_implementation_status_screen()
u8g.print('%');
}
#endif
}
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
{
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
char c;
uint8_t n = LCD_WIDTH - 1 - 2;
if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] ))
{
if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) {
u8g.setColorIndex(1); // black on white
u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black
} else u8g.setColorIndex(1); // unmarked text is black on white
}
else {
u8g.setColorIndex(1); // unmarked text is black on white
}
u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete
while( (c = pgm_read_byte(pstr)) != '\0' )
{
while((c = pgm_read_byte(pstr))) {
u8g.print(c);
pstr++;
n--;
}
while(n--){
u8g.print(' ');
}
while(n--) u8g.print(' ');
u8g.print(post_char);
u8g.print(' ');
......@@ -399,8 +360,7 @@ static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char p
#define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
void lcd_implementation_drawedit(const char* pstr, char* value)
{
void lcd_implementation_drawedit(const char* pstr, char* value) {
u8g.setPrintPos(0 * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
u8g.setFont(u8g_font_9x18);
lcd_printPGM(pstr);
......@@ -453,20 +413,16 @@ static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, ch
#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
static void lcd_implementation_quick_feedback()
{
#if BEEPER > -1
static void lcd_implementation_quick_feedback() {
#if BEEPER > -1
SET_OUTPUT(BEEPER);
for(int8_t i=0;i<10;i++)
{
for(int8_t i=0; i<10; i++) {
WRITE(BEEPER,HIGH);
delay(3);
WRITE(BEEPER,LOW);
delay(3);
}
#endif
#endif
}
#endif//ULTRA_LCD_IMPLEMENTATION_DOGM_H
#endif //__DOGM_LCD_IMPLEMENTATION_H
......@@ -79,7 +79,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Acel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -66,7 +66,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -79,7 +79,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Acc"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -79,7 +79,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -66,7 +66,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Acel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -66,7 +66,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Azelerazioa"
#define MSG_VXY_JERK "Vxy-astindua"
#define MSG_VZ_JERK "Vz-astindua"
......
......@@ -79,7 +79,6 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -60,9 +60,6 @@ float current_temperature_bed = 0.0;
float Kp[4];
float Ki[4];
float Kd[4];
#ifdef PID_ADD_EXTRUSION_RATE
float Kc;
#endif
#endif //PIDTEMP
#ifdef PIDTEMPBED
......
......@@ -23,9 +23,7 @@
#include "Marlin.h"
#include "planner.h"
#ifdef PID_ADD_EXTRUSION_RATE
#include "stepper.h"
#endif
// public functions
void tp_init(); //initialize the heating
......@@ -68,7 +66,7 @@ extern float current_temperature_bed;
#endif
#ifdef PIDTEMP
extern float Kp[4],Ki[4],Kd[4],Kc;
extern float Kp[4],Ki[4],Kd[4];
float scalePID_i(float i);
float scalePID_d(float d);
float unscalePID_i(float i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment