Selaa lähdekoodia

Merge pull request #4991 from thinkyhead/rc_max31855_fix

Patches for Stepper DAC and MAX31855
Scott Lahteine 8 vuotta sitten
vanhempi
commit
d41f2bdbd8
4 muutettua tiedostoa jossa 29 lisäystä ja 10 poistoa
  1. 10
    4
      Marlin/dac_mcp4728.cpp
  2. 3
    4
      Marlin/dac_mcp4728.h
  3. 1
    1
      Marlin/stepper_dac.cpp
  4. 15
    1
      Marlin/temperature.cpp

+ 10
- 4
Marlin/dac_mcp4728.cpp Näytä tiedosto

@@ -60,6 +60,7 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
60 60
   mcp4728_values[channel] = value;
61 61
   return mcp4728_fastWrite();
62 62
 }
63
+
63 64
 /**
64 65
  * Write all input resistor values to EEPROM using SequencialWrite method.
65 66
  * This will update both input register and EEPROM value
@@ -68,7 +69,7 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
68 69
 uint8_t mcp4728_eepromWrite() {
69 70
   Wire.beginTransmission(DAC_DEV_ADDRESS);
70 71
   Wire.write(SEQWRITE);
71
-  for (uint8_t channel = 0; channel < COUNT(channel); channel++) {
72
+  for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
72 73
     Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel]));
73 74
     Wire.write(lowByte(mcp4728_values[channel]));
74 75
   }
@@ -109,10 +110,15 @@ uint16_t mcp4728_getVout(uint8_t channel) {
109 110
 }
110 111
 */
111 112
 
112
-/* Returns DAC values as a 0-100 percentage of drive strength */
113
+/**
114
+ * Returns DAC values as a 0-100 percentage of drive strength
115
+ */
113 116
 uint16_t mcp4728_getDrvPct(uint8_t channel) { return uint16_t(100.0 * mcp4728_values[channel] / (DAC_STEPPER_MAX) + 0.5); }
114 117
 
115
-/* Recieves all Drive strengths as 0-100 percent values, updates DAC Values array and calls fastwrite to update the DAC */
118
+/**
119
+ * Receives all Drive strengths as 0-100 percent values, updates
120
+ * DAC Values array and calls fastwrite to update the DAC.
121
+ */
116 122
 void mcp4728_setDrvPct(int16_t pct[XYZE]) {
117 123
   LOOP_XYZE(i) mcp4728_values[i] = 0.01 * pct[i] * (DAC_STEPPER_MAX);
118 124
   mcp4728_fastWrite();
@@ -125,7 +131,7 @@ void mcp4728_setDrvPct(int16_t pct[XYZE]) {
125 131
  */
126 132
 uint8_t mcp4728_fastWrite() {
127 133
   Wire.beginTransmission(DAC_DEV_ADDRESS);
128
-  for (uint8_t channel = 0; channel < COUNT(channel); channel++) {
134
+  for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
129 135
     Wire.write(highByte(mcp4728_values[channel]));
130 136
     Wire.write(lowByte(mcp4728_values[channel]));
131 137
   }

+ 3
- 4
Marlin/dac_mcp4728.h Näytä tiedosto

@@ -24,8 +24,8 @@
24 24
  * Arduino library for MicroChip MCP4728 I2C D/A converter.
25 25
  */
26 26
 
27
-#ifndef mcp4728_h
28
-#define mcp4728_h
27
+#ifndef DAC_MCP4728_H
28
+#define DAC_MCP4728_H
29 29
 
30 30
 #include "MarlinConfig.h"
31 31
 
@@ -63,5 +63,4 @@ uint16_t mcp4728_getDrvPct(uint8_t channel);
63 63
 void mcp4728_setDrvPct(int16_t pct[XYZE]);
64 64
 
65 65
 #endif
66
-#endif
67
-
66
+#endif // DAC_MCP4728_H

+ 1
- 1
Marlin/stepper_dac.cpp Näytä tiedosto

@@ -87,7 +87,7 @@
87 87
   }
88 88
 
89 89
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
90
-  static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * (0.125 * (DAC_STEPPER_SENSE)); }
90
+  static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
91 91
   
92 92
   int16_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
93 93
   void dac_current_set_percents(int16_t pct[XYZE]) {

+ 15
- 1
Marlin/temperature.cpp Näytä tiedosto

@@ -1344,8 +1344,22 @@ void Temperature::disable_all_heaters() {
1344 1344
 
1345 1345
     WRITE(MAX6675_SS, 1); // disable TT_MAX6675
1346 1346
 
1347
-    if (max6675_temp & MAX6675_ERROR_MASK)
1347
+    if (max6675_temp & MAX6675_ERROR_MASK) {
1348
+      SERIAL_ERROR_START;
1349
+      SERIAL_ERRORPGM("Temp measurement error! ");
1350
+      #if MAX6675_ERROR_MASK == 7
1351
+        SERIAL_ERRORPGM("MAX31855 ");
1352
+        if (max6675_temp & 1)
1353
+          SERIAL_ERRORLNPGM("Open Circuit");
1354
+        else if (max6675_temp & 2)
1355
+          SERIAL_ERRORLNPGM("Short to GND");
1356
+        else if (max6675_temp & 4)
1357
+          SERIAL_ERRORLNPGM("Short to VCC");
1358
+      #else
1359
+        SERIAL_ERRORLNPGM("MAX6675");
1360
+      #endif
1348 1361
       max6675_temp = 4000; // thermocouple open
1362
+    }
1349 1363
     else
1350 1364
       max6675_temp >>= MAX6675_DISCARD_BITS;
1351 1365
 

Loading…
Peruuta
Tallenna