Commit 2ddf7334 authored by Simone Primarosa's avatar Simone Primarosa

Merge pull request #64 from simonepri/master

Update 4.1.5 dev
parents d3858654 251c6e3e
Power consumption sensor (Hall effect sensor like ACS712)
---------------------------------------------------------
Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption
Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable.
You have to change the POWER_SENSITIVITY with the one that you can find in the datasheet. (in case of ACS712: set to .100 for 20A version or set .066 for 30A version)
After setted POWER_VOLTAGE and POWER_SENSITIVITY you have to found correct value for POWER_ZERO.
You can do it by using "M70 Z" gcode and read the calculated value from serial messages.
Before calling "M70 Z" you have to disconnect the cable for measure the current from the sensor leaving only +5, OUT and GND connections.
Insert new values into FW and recompile.
Now you can reconnect the current cable to the sensor.
Now you have to set right value for POWER_ERROR.
Get a good multimeter and meacure DC current coming out from the power supply.
In order to get an accurate value power-on something (Eg. Heater, Motor, Fan) DO NOT POWER-ON THE BED OR YOU MAY KILL IT!!!!
Call "M70 Ax" where 'x' is the value measured by the multimeter.
Insert new values into FW and recompile.
With this module we measure the Printer power consumption ignoring the Power Supply power consumption,
so we consider the POWER_EFFICIENCY of our supply to be 100%.
WARNING: from this moment the procedure can be REALLY HARMFUL to health unless you have a little experience so DO NOT DO IT IF YOU DO NOT KNOW WHAT YOU ARE DOING!!!
If you want to approximately add the supply consumption you have measure the AC current with a good multimeter
and moltiple it with the mains voltage (110V AC - 220V AC).
MULTIMETER_WATT = MULTIMETER_CURRENTMAINS_VOLTAGE
Call "M70 Wx" where 'x' is MULTIMETER_WATT;
Insert new values into FW and recompile.
Now you AC712 it should be calibrated.
\ No newline at end of file
### Version 4.1.5 ### Version 4.1.5
* Added M70 gcode for calibrate AC721 current sensor
* Added documentation for calibrate AC721 current sensor
* Critical stepper motor frequency bugfix * Critical stepper motor frequency bugfix
* Introduced more intuitive menu tree. * Introduced more intuitive menu tree.
* Added a menu option to fix loose steps from LCD * Added a menu option to fix loose steps from LCD
......
...@@ -623,23 +623,39 @@ ...@@ -623,23 +623,39 @@
/**********************************************************************\ /**********************************************************************\
* Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption * Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption
* Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable. * Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable.
* You have to change the SENSITIVITY with the one that you can find in the datasheet. (in case of ACS712: set to .100 for 20A version or set .066 for 30A version) * You have to change the POWER_SENSITIVITY with the one that you can find in the datasheet. (in case of ACS712: set to .100 for 20A version or set .066 for 30A version)
* With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without *
* any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value. * After setted POWER_VOLTAGE and POWER_SENSITIVITY you have to found correct value for POWER_ZERO
* You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage. * You can do it by using "M70 Z" gcode and read the calculated value from serial messages.
* MULTIMETER_WATT := MULTIMETER_CURRENT * MAINS_VOLTAGE * Before calling "M70 Z" you have to disconnect the cable for measure the current from the sensor leaving only +5, OUT and GND connections.
* Now you have a Wattage value that you can compare with the one measured from ACS712. * Insert new values into FW and recompile.
* NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT * Now you can reconnect the current cable to the sensor.
* For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability *
* Now you have to set right value for POWER_ERROR.
* Get a good multimeter and meacure DC current coming out from the power supply.
* In order to get an accurate value power-on something (Eg. Heater, Motor, Fan) DO NOT POWER-ON THE BED OR YOU MAY KILL IT!!!!
* Call "M70 Ax" where 'x' is the value measured by the multimeter.
* Insert new values into FW and recompile.
*
* With this module we measure the Printer power consumption ignoring the Power Supply power consumption,
* so we consider the POWER_EFFICIENCY of our supply to be 100%.
* WARNING: from this moment the procedure can be REALLY HARMFUL to health unless you have a little experience so DO NOT DO IT IF YOU DO NOT KNOW WHAT YOU ARE DOING!!!
* If you want to approximately add the supply consumption you have measure the AC current with a good multimeter
* and moltiple it with the mains voltage (110V AC - 220V AC).
* MULTIMETER_WATT = MULTIMETER_CURRENT * MAINS_VOLTAGE
* Call "M70 Wx" where 'x' is MULTIMETER_WATT;
* Insert new values into FW and recompile.
*
* Now you AC712 it should be calibrated.
**********************************************************************/ **********************************************************************/
// Uncomment below to enable // Uncomment below to enable
//#define POWER_CONSUMPTION //#define POWER_CONSUMPTION
#if ENABLED(POWER_CONSUMPTION) #if ENABLED(POWER_CONSUMPTION)
#define POWER_VOLTAGE 12.00 //(V) The power supply OUT voltage #define POWER_VOLTAGE 12.00 //(V) The power supply OUT voltage
#define POWER_ZERO 2.54459 //(V) The /\V coming out from the sensor when no current flow.
#define POWER_SENSITIVITY 0.066 //(V/A) How much increase V for 1A of increase #define POWER_SENSITIVITY 0.066 //(V/A) How much increase V for 1A of increase
#define POWER_OFFSET 0.015 //(A) Help to get 0A when no load is connected. #define POWER_OFFSET 0.005 //(A) Help to get 0A when no load is connected.
#define POWER_ERROR 3.0 //(%) Ammortize measure error. #define POWER_ZERO 2.500 //(V) The /\V coming out from the sensor when no current flow.
#define POWER_ERROR 0.0 //(%) Ammortize measure error.
#define POWER_EFFICIENCY 100.0 //(%) The power efficency of the power supply #define POWER_EFFICIENCY 100.0 //(%) The power efficency of the power supply
//When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec.
......
...@@ -293,6 +293,9 @@ extern int fanSpeed; ...@@ -293,6 +293,9 @@ extern int fanSpeed;
extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured
extern unsigned long startpower; extern unsigned long startpower;
extern unsigned long stoppower; extern unsigned long stoppower;
extern float raw_analog2voltage();
extern float analog2error(float current);
extern float analog2efficiency(float watt);
#endif #endif
#if ENABLED(IDLE_OOZING_PREVENT) #if ENABLED(IDLE_OOZING_PREVENT)
......
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
* M33 - Get the longname version of a path * M33 - Get the longname version of a path
* M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
* M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] * M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
* M70 - Power consumption sensor calibration
* M80 - Turn on Power Supply * M80 - Turn on Power Supply
* M81 - Turn off Power Supply * M81 - Turn off Power Supply
* M82 - Set E codes absolute (default) * M82 - Set E codes absolute (default)
...@@ -4693,6 +4694,34 @@ inline void gcode_M42() { ...@@ -4693,6 +4694,34 @@ inline void gcode_M42() {
#endif // AUTO_BED_LEVELING_FEATURE && Z_PROBE_REPEATABILITY_TEST #endif // AUTO_BED_LEVELING_FEATURE && Z_PROBE_REPEATABILITY_TEST
#if HAS_POWER_CONSUMPTION_SENSOR
/**
* M70 - Power consumption sensor calibration
*
* Z - Calibrate zero current offset
* A - Isert readed DC Current value (Ampere)
* W - Insert readed AC Wattage value (Watt)
*/
inline void gcode_M70() {
if(code_seen('Z')) {
ECHO_EMV("Actual POWER_ZERO:", POWER_ZERO, 7);
ECHO_EMV("New POWER_ZERO:", raw_analog2voltage(), 7);
ECHO_EM("Insert new calculated values into the FW and call \"M70 A\" for the next calibration step.");
}
else if(code_seen('A')) {
ECHO_EMV("Actual POWER_ERROR:", POWER_ERROR, 7);
ECHO_EMV("New POWER_ERROR:", analog2error(code_value()), 7);
ECHO_EM("Insert new calculated values into the FW and call \"M70 W\" for the last calibration step.");
}
else if(code_seen('W')) {
ECHO_EMV("Actual POWER_EFFICIENCY:", POWER_EFFICIENCY, 7);
ECHO_EMV("New POWER_EFFICIENCY:", analog2efficiency(code_value()), 7);
ECHO_EM("Insert new calculated values into the FW and then ACS712 it should be calibrated correctly.");
}
}
#endif
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
/** /**
...@@ -6766,6 +6795,11 @@ void process_next_command() { ...@@ -6766,6 +6795,11 @@ void process_next_command() {
gcode_M48(); break; gcode_M48(); break;
#endif #endif
#if HAS_POWER_CONSUMPTION_SENSOR
case 70: // M70 - Power consumption sensor calibration
gcode_M70(); break;
#endif
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
case 80: // M80 - Turn on Power Supply case 80: // M80 - Turn on Power Supply
gcode_M80(); break; gcode_M80(); break;
......
...@@ -384,13 +384,6 @@ ...@@ -384,13 +384,6 @@
#define Z_SAFE_HOMING #define Z_SAFE_HOMING
#endif #endif
/**
* Babystepping
*/
#if ENABLED(CARTESIAN)
#define BABYSTEPPING // On Cartesian printer this can be enabled as default as fully working
#endif
/** /**
* MAX_STEP_FREQUENCY differs for TOSHIBA OR ARDUINO DUE OR ARDUINO MEGA * MAX_STEP_FREQUENCY differs for TOSHIBA OR ARDUINO DUE OR ARDUINO MEGA
*/ */
......
...@@ -804,7 +804,10 @@ static void updateTemperaturesFromRawValues() { ...@@ -804,7 +804,10 @@ static void updateTemperaturesFromRawValues() {
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
static float watt_overflow = 0.0; static float watt_overflow = 0.0;
power_consumption_meas = analog2power(); power_consumption_meas = analog2power();
//MYSERIAL.println(analog2current(),3); /*ECHO_MV("raw:", raw_analog2voltage(), 5);
ECHO_MV(" - V:", analog2voltage(), 5);
ECHO_MV(" - I:", analog2current(), 5);
ECHO_EMV(" - P:", analog2power(), 5);*/
watt_overflow += (power_consumption_meas * from_last_update) / 3600000.0; watt_overflow += (power_consumption_meas * from_last_update) / 3600000.0;
if (watt_overflow >= 1.0) { if (watt_overflow >= 1.0) {
power_consumption_hour++; power_consumption_hour++;
...@@ -850,14 +853,34 @@ static void updateTemperaturesFromRawValues() { ...@@ -850,14 +853,34 @@ static void updateTemperaturesFromRawValues() {
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// Convert raw Power Consumption to watt // Convert raw Power Consumption to watt
float raw_analog2voltage() {
return (5.0 * current_raw_powconsumption) / (1023 * OVERSAMPLENR);
}
float analog2voltage() {
float power_zero_raw = (POWER_ZERO * 1023 * OVERSAMPLENR) / 5.0;
float rel_raw_power = (current_raw_powconsumption < power_zero_raw) ? (2 * power_zero_raw - current_raw_powconsumption) : (current_raw_powconsumption);
return ((5.0 * rel_raw_power) / (1023 * OVERSAMPLENR)) - POWER_ZERO;
}
float analog2current() { float analog2current() {
float temp = (((5.0 * current_raw_powconsumption) / (1023 * OVERSAMPLENR)) - POWER_ZERO) / POWER_SENSITIVITY; float temp = analog2voltage() / POWER_SENSITIVITY;
temp = ((100 - POWER_ERROR) / 100) * (temp + (temp / 100)) - POWER_OFFSET; temp = (((100 - POWER_ERROR) / 100) * temp) - POWER_OFFSET;
return temp > 0 ? temp : 0; return temp > 0 ? temp : 0;
} }
float analog2power() { float analog2power() {
return (analog2current() * POWER_VOLTAGE * 100) / POWER_EFFICIENCY; return (analog2current() * POWER_VOLTAGE * 100) / POWER_EFFICIENCY;
} }
float analog2error(float current) {
float temp1 = (analog2voltage() / POWER_SENSITIVITY - POWER_OFFSET) * POWER_VOLTAGE;
if(temp1 <= 0) return 0.0;
float temp2 = (current) * POWER_VOLTAGE;
if(temp2 <= 0) return 0.0;
return ((temp2/temp1)-1)*100;
}
float analog2efficiency(float watt) {
return (analog2current() * POWER_VOLTAGE * 100) / watt;
}
#endif #endif
/** /**
...@@ -1301,12 +1324,7 @@ static void set_current_temp_raw() { ...@@ -1301,12 +1324,7 @@ static void set_current_temp_raw() {
current_temperature_bed_raw = raw_temp_bed_value; current_temperature_bed_raw = raw_temp_bed_value;
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
#ifdef __SAM3X8E__ current_raw_powconsumption = raw_powconsumption_value;
float power_zero_raw = (POWER_ZERO * 1023 * OVERSAMPLENR) / 3.3;
#else
float power_zero_raw = (POWER_ZERO * 1023 * OVERSAMPLENR) / 5.0;
#endif
current_raw_powconsumption = (raw_powconsumption_value < power_zero_raw) ? (2 * power_zero_raw - raw_powconsumption_value) : (raw_powconsumption_value);
#endif #endif
temp_meas_ready = true; temp_meas_ready = true;
} }
......
...@@ -39,8 +39,12 @@ void manage_heater(); //it is critical that this is called periodically. ...@@ -39,8 +39,12 @@ void manage_heater(); //it is critical that this is called periodically.
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// For converting raw Power Consumption to watt // For converting raw Power Consumption to watt
float analog2voltage();
float analog2current(); float analog2current();
float analog2power(); float analog2power();
float raw_analog2voltage();
float analog2error(float current);
float analog2efficiency(float watt);
#endif #endif
// low level conversion routines // low level conversion routines
......
<img align="right" src="Documentation/Logo/MarlinKimbra%20Logo%20GitHub.png" /> <img align="right" src="Documentation/Logo/MarlinKimbra%20Logo%20GitHub.png" />
# MarlinKimbra 3D Printer Firmware # MarlinKimbra 3D Printer Firmware
## Version 4.1.5 RC (Release Candidate) ## Version 4.1.5 dev
* [Configuration & Compilation](/Documentation/Compilation.md) * [Configuration & Compilation](/Documentation/Compilation.md)
* Supported * Supported
......
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