|
|
@@ -72,6 +72,9 @@ static volatile bool endstop_z_hit=false;
|
|
72
|
72
|
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
|
73
|
73
|
bool abort_on_endstop_hit = false;
|
|
74
|
74
|
#endif
|
|
|
75
|
+#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
|
|
76
|
+ int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
|
|
77
|
+#endif
|
|
75
|
78
|
|
|
76
|
79
|
static bool old_x_min_endstop=false;
|
|
77
|
80
|
static bool old_x_max_endstop=false;
|
|
|
@@ -1198,6 +1201,16 @@ void digipot_init() //Initialize Digipot Motor Current
|
|
1198
|
1201
|
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
|
|
1199
|
1202
|
digipot_current(i,digipot_motor_current[i]);
|
|
1200
|
1203
|
#endif
|
|
|
1204
|
+ #ifdef MOTOR_CURRENT_PWM_XY_PIN
|
|
|
1205
|
+ pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
|
|
|
1206
|
+ pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
|
|
|
1207
|
+ pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
|
|
|
1208
|
+ digipot_current(0, motor_current_setting[0]);
|
|
|
1209
|
+ digipot_current(1, motor_current_setting[1]);
|
|
|
1210
|
+ digipot_current(2, motor_current_setting[2]);
|
|
|
1211
|
+ //Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
|
|
|
1212
|
+ TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
|
|
|
1213
|
+ #endif
|
|
1201
|
1214
|
}
|
|
1202
|
1215
|
|
|
1203
|
1216
|
void digipot_current(uint8_t driver, int current)
|
|
|
@@ -1206,6 +1219,11 @@ void digipot_current(uint8_t driver, int current)
|
|
1206
|
1219
|
const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
|
|
1207
|
1220
|
digitalPotWrite(digipot_ch[driver], current);
|
|
1208
|
1221
|
#endif
|
|
|
1222
|
+ #ifdef MOTOR_CURRENT_PWM_XY_PIN
|
|
|
1223
|
+ if (driver == 0) analogWrite(MOTOR_CURRENT_PWM_XY_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
|
|
|
1224
|
+ if (driver == 1) analogWrite(MOTOR_CURRENT_PWM_Z_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
|
|
|
1225
|
+ if (driver == 2) analogWrite(MOTOR_CURRENT_PWM_E_PIN, (long)current * 255L / (long)MOTOR_CURRENT_PWM_RANGE);
|
|
|
1226
|
+ #endif
|
|
1209
|
1227
|
}
|
|
1210
|
1228
|
|
|
1211
|
1229
|
void microstep_init()
|