Ver código fonte

Fix DAC setDrvPct (#20205)

Orel 4 anos atrás
pai
commit
fe88fb7ed9
Nenhuma conta vinculada ao e-mail do autor do commit

+ 2
- 2
Marlin/src/feature/dac/dac_mcp4728.cpp Ver arquivo

@@ -123,8 +123,8 @@ uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_v
123 123
  * Receives all Drive strengths as 0-100 percent values, updates
124 124
  * DAC Values array and calls fastwrite to update the DAC.
125 125
  */
126
-void MCP4728::setDrvPct(xyze_uint8_t &pct) {
127
-  dac_values *= pct.asFloat() * 0.01f * (DAC_STEPPER_MAX);
126
+void MCP4728::setDrvPct(xyze_uint_t &pct) {
127
+  dac_values = pct * (DAC_STEPPER_MAX) * 0.01f;
128 128
   fastWrite();
129 129
 }
130 130
 

+ 1
- 1
Marlin/src/feature/dac/dac_mcp4728.h Ver arquivo

@@ -76,7 +76,7 @@ public:
76 76
   static uint8_t  fastWrite();
77 77
   static uint8_t  simpleCommand(const byte simpleCommand);
78 78
   static uint8_t  getDrvPct(const uint8_t channel);
79
-  static void     setDrvPct(xyze_uint8_t &pct);
79
+  static void     setDrvPct(xyze_uint_t &pct);
80 80
 };
81 81
 
82 82
 extern MCP4728 mcp4728;

+ 3
- 3
Marlin/src/feature/dac/stepper_dac.cpp Ver arquivo

@@ -33,7 +33,7 @@
33 33
 
34 34
 bool dac_present = false;
35 35
 constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER;
36
-xyze_uint8_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT;
36
+xyze_uint_t dac_channel_pct = DAC_MOTOR_CURRENT_DEFAULT;
37 37
 
38 38
 StepperDAC stepper_dac;
39 39
 
@@ -72,8 +72,8 @@ void StepperDAC::set_current_percent(const uint8_t channel, float val) {
72 72
   set_current_value(channel, _MIN(val, 100.0f) * (DAC_STEPPER_MAX) / 100.0f);
73 73
 }
74 74
 
75
-static float dac_perc(int8_t n) { return 100.0 * mcp4728.getValue(dac_order[n]) * RECIPROCAL(DAC_STEPPER_MAX); }
76
-static float dac_amps(int8_t n) { return mcp4728.getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE); }
75
+static float dac_perc(int8_t n) { return mcp4728.getDrvPct(dac_order[n]); }
76
+static float dac_amps(int8_t n) { return mcp4728.getValue(dac_order[n]) * 0.125 * RECIPROCAL(DAC_STEPPER_SENSE * 1000); }
77 77
 
78 78
 uint8_t StepperDAC::get_current_percent(const AxisEnum axis) { return mcp4728.getDrvPct(dac_order[axis]); }
79 79
 void StepperDAC::set_current_percents(xyze_uint8_t &pct) {

Carregando…
Cancelar
Salvar