Merge pull request #329 from XPila/MK3
Meassuring voltages (pwr, bed), voltages menu
This commit is contained in:
commit
9639b58f4d
4 changed files with 98 additions and 19 deletions
|
@ -73,6 +73,10 @@
|
|||
|
||||
#define TEMP_PINDA_PIN 3 //A3
|
||||
|
||||
#define VOLT_PWR_PIN 4 //A4
|
||||
#define VOLT_BED_PIN 9 //A9
|
||||
|
||||
|
||||
#define E0_TMC2130_CS 66
|
||||
#define E0_TMC2130_DIAG 65
|
||||
#define E0_STEP_PIN 34
|
||||
|
@ -99,7 +103,7 @@
|
|||
|
||||
#ifdef NEWPANEL
|
||||
|
||||
#define LCD_PWM_PIN 32 // lcd backlight brightnes pwm control pin
|
||||
#define LCD_PWM_PIN -1//32 // lcd backlight brightnes pwm control pin
|
||||
#define LCD_PWM_MAX 0x0f // lcd pwm maximum value (0x07=64Hz, 0x0f=32Hz, 0x1f=16Hz)
|
||||
|
||||
#define BEEPER 84 // Beeper on AUX-4
|
||||
|
|
|
@ -58,6 +58,14 @@ int current_temperature_raw_ambient = 0 ;
|
|||
float current_temperature_ambient = 0.0;
|
||||
#endif //AMBIENT_THERMISTOR
|
||||
|
||||
#ifdef VOLT_PWR_PIN
|
||||
int current_voltage_raw_pwr = 0;
|
||||
#endif
|
||||
|
||||
#ifdef VOLT_BED_PIN
|
||||
int current_voltage_raw_bed = 0;
|
||||
#endif
|
||||
|
||||
int current_temperature_bed_raw = 0;
|
||||
float current_temperature_bed = 0.0;
|
||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||
|
@ -1582,7 +1590,9 @@ ISR(TIMER0_COMPB_vect)
|
|||
static unsigned long raw_temp_bed_value = 0;
|
||||
static unsigned long raw_temp_pinda_value = 0;
|
||||
static unsigned long raw_temp_ambient_value = 0;
|
||||
static unsigned char temp_state = 14;
|
||||
static unsigned long raw_volt_pwr_value = 0;
|
||||
static unsigned long raw_volt_bed_value = 0;
|
||||
static unsigned char temp_state = 18;
|
||||
static unsigned char pwm_count = (1 << SOFT_PWM_SCALE);
|
||||
static unsigned char soft_pwm_0;
|
||||
#ifdef SLOW_PWM_HEATERS
|
||||
|
@ -2059,14 +2069,54 @@ ISR(TIMER0_COMPB_vect)
|
|||
#if defined(TEMP_PINDA_PIN) && (TEMP_PINDA_PIN > -1)
|
||||
raw_temp_pinda_value += ADC;
|
||||
#endif
|
||||
temp_state = 14;
|
||||
break;
|
||||
|
||||
case 14: // Prepare VOLT_PWR
|
||||
#if defined(VOLT_PWR_PIN) && (VOLT_PWR_PIN > -1)
|
||||
#if VOLT_PWR_PIN > 7
|
||||
ADCSRB = 1<<MUX5;
|
||||
#else
|
||||
ADCSRB = 0;
|
||||
#endif
|
||||
ADMUX = ((1 << REFS0) | (VOLT_PWR_PIN & 0x07));
|
||||
ADCSRA |= 1<<ADSC; // Start conversion
|
||||
#endif
|
||||
lcd_buttons_update();
|
||||
temp_state = 15;
|
||||
break;
|
||||
|
||||
case 15: // Measure VOLT_PWR
|
||||
#if defined(VOLT_PWR_PIN) && (VOLT_PWR_PIN > -1)
|
||||
raw_volt_pwr_value += ADC;
|
||||
#endif
|
||||
temp_state = 16;
|
||||
break;
|
||||
|
||||
case 16: // Prepare VOLT_BED
|
||||
#if defined(VOLT_BED_PIN) && (VOLT_BED_PIN > -1)
|
||||
#if VOLT_BED_PIN > 7
|
||||
ADCSRB = 1<<MUX5;
|
||||
#else
|
||||
ADCSRB = 0;
|
||||
#endif
|
||||
ADMUX = ((1 << REFS0) | (VOLT_BED_PIN & 0x07));
|
||||
ADCSRA |= 1<<ADSC; // Start conversion
|
||||
#endif
|
||||
lcd_buttons_update();
|
||||
temp_state = 17;
|
||||
break;
|
||||
|
||||
case 17: // Measure VOLT_BED
|
||||
#if defined(VOLT_BED_PIN) && (VOLT_BED_PIN > -1)
|
||||
raw_volt_bed_value += ADC;
|
||||
#endif
|
||||
temp_state = 0;
|
||||
|
||||
temp_state = 0;
|
||||
|
||||
temp_count++;
|
||||
break;
|
||||
break;
|
||||
|
||||
|
||||
case 14: //Startup, delay initial temp reading a tiny bit so the hardware can settle.
|
||||
case 18: //Startup, delay initial temp reading a tiny bit so the hardware can settle.
|
||||
temp_state = 0;
|
||||
break;
|
||||
// default:
|
||||
|
@ -2095,6 +2145,13 @@ ISR(TIMER0_COMPB_vect)
|
|||
#ifdef AMBIENT_THERMISTOR
|
||||
current_temperature_raw_ambient = raw_temp_ambient_value;
|
||||
#endif //AMBIENT_THERMISTOR
|
||||
#ifdef VOLT_PWR_PIN
|
||||
current_voltage_raw_pwr = raw_volt_pwr_value;
|
||||
#endif
|
||||
#ifdef VOLT_BED_PIN
|
||||
current_voltage_raw_bed = raw_volt_bed_value;
|
||||
#endif
|
||||
|
||||
current_temperature_bed_raw = raw_temp_bed_value;
|
||||
}
|
||||
|
||||
|
@ -2112,6 +2169,8 @@ ISR(TIMER0_COMPB_vect)
|
|||
raw_temp_bed_value = 0;
|
||||
raw_temp_pinda_value = 0;
|
||||
raw_temp_ambient_value = 0;
|
||||
raw_volt_pwr_value = 0;
|
||||
raw_volt_bed_value = 0;
|
||||
|
||||
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
|
||||
if(current_temperature_raw[0] <= maxttemp_raw[0]) {
|
||||
|
|
|
@ -60,6 +60,14 @@ extern float current_temperature_pinda;
|
|||
extern float current_temperature_ambient;
|
||||
#endif
|
||||
|
||||
#ifdef VOLT_PWR_PIN
|
||||
extern int current_voltage_raw_pwr;
|
||||
#endif
|
||||
|
||||
#ifdef VOLT_BED_PIN
|
||||
extern int current_voltage_raw_bed;
|
||||
#endif
|
||||
|
||||
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
||||
extern float redundant_temperature;
|
||||
#endif
|
||||
|
|
|
@ -1564,18 +1564,24 @@ static void lcd_menu_debug()
|
|||
|
||||
static void lcd_menu_temperatures()
|
||||
{
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,1) "Ambient: %d%c" ESC_H(1,2) "PINDA: %d%c"), (int)current_temperature_ambient, '\x01', (int)current_temperature_pinda, '\x01');
|
||||
/*
|
||||
lcd.setCursor(1, 1);
|
||||
lcd.print("Ambient: ");
|
||||
lcd.setCursor(12, 1);
|
||||
lcd.print(ftostr31ns(current_temperature_ambient));
|
||||
lcd.print(LCD_STR_DEGREE);
|
||||
lcd.setCursor(1, 2);
|
||||
lcd.print("PINDA: ");
|
||||
lcd.setCursor(12, 2);
|
||||
lcd.print(ftostr31ns(current_temperature_pinda));
|
||||
lcd.print(LCD_STR_DEGREE);*/
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,0)"Nozzle: %d%c" ESC_H(1,1)"Bed: %d%c"), (int)current_temperature[0], '\x01', (int)current_temperature_bed, '\x01');
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,2)"Ambient: %d%c" ESC_H(1,3)"PINDA: %d%c"), (int)current_temperature_ambient, '\x01', (int)current_temperature_pinda, '\x01');
|
||||
if (lcd_clicked())
|
||||
{
|
||||
lcd_quick_feedback();
|
||||
lcd_return_to_status();
|
||||
}
|
||||
}
|
||||
|
||||
#define VOLT_DIV_R1 10000
|
||||
#define VOLT_DIV_R2 2370
|
||||
#define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1))
|
||||
#define VOLT_DIV_REF 5
|
||||
static void lcd_menu_voltages()
|
||||
{
|
||||
float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
|
||||
float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
|
||||
fprintf_P(lcdout, PSTR(ESC_H(1,1)"PWR: %d.%01dV" ESC_H(1,2)"BED: %d.%01dV"), (int)volt_pwr, (int)(10*fabs(volt_pwr - (int)volt_pwr)), (int)volt_bed, (int)(10*fabs(volt_bed - (int)volt_bed)));
|
||||
if (lcd_clicked())
|
||||
{
|
||||
lcd_quick_feedback();
|
||||
|
@ -1685,6 +1691,8 @@ static void lcd_support_menu()
|
|||
MENU_ITEM(submenu, PSTR("Belt status"), lcd_menu_belt_status);
|
||||
|
||||
MENU_ITEM(submenu, PSTR("Temperatures"), lcd_menu_temperatures);
|
||||
|
||||
MENU_ITEM(submenu, PSTR("Voltages"), lcd_menu_voltages);
|
||||
#endif //MK1BP
|
||||
END_MENU();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue