Commit a80a738acc247fdb5a37c79b3b9cf90aa7c81505
authorMichel Pollet <buserror@gmail.com>
Thu, 5 Apr 2012 16:45:34 +0000 (17:45 +0100)
committerMichel Pollet <buserror@gmail.com>
Thu, 5 Apr 2012 16:45:34 +0000 (17:45 +0100)
Return millivolts, not ADC values

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
examples/board_reprap/reprap.c
examples/board_reprap/thermistor.c

index 5bdc93b9f3316e0f57e1d72c188faedc8ebfc217..b1b787db8c190e8a77db5aa37089932f3d21e617 100644 (file)
@@ -54,6 +54,7 @@
 
 thermistor_t   therm_hotend;
 thermistor_t   therm_hotbed;
+thermistor_t   therm_spare;
 button_t button;
 uart_pty_t uart_pty;
 int do_button_press = 0;
@@ -253,10 +254,12 @@ int main(int argc, char *argv[])
        uart_pty_init(avr, &uart_pty);
        uart_pty_connect(&uart_pty, '0');
 
-       thermistor_init(avr, &therm_hotend, TEMP_0_PIN,
-                       (short*)temptable_5, sizeof(temptable_5) / sizeof(short) / 2, OVERSAMPLENR, 22.5f);
-       thermistor_init(avr, &therm_hotbed, TEMP_BED_PIN,
-                       (short*)temptable_5, sizeof(temptable_5) / sizeof(short) / 2, OVERSAMPLENR, 22.0f);
+       thermistor_init(avr, &therm_hotend, 0,
+                       (short*)temptable_5, sizeof(temptable_5) / sizeof(short) / 2, OVERSAMPLENR, 25.0f);
+       thermistor_init(avr, &therm_hotbed, 2,
+                       (short*)temptable_5, sizeof(temptable_5) / sizeof(short) / 2, OVERSAMPLENR, 30.0f);
+       thermistor_init(avr, &therm_spare, 1,
+                       (short*)temptable_5, sizeof(temptable_5) / sizeof(short) / 2, OVERSAMPLENR, 10.0f);
 
        /*
         * OpenGL init, can be ignored
index 8c2ddd8bc6c383e6fcaca727b7fe3ff52d8c7338..9776dd29954ab3dc81538d0474c9b71428fbb97c 100644 (file)
@@ -31,7 +31,8 @@
 #include "thermistor.h"
 
 /*
- * called when a byte is send via the uart on the AVR
+ * called the ADC could use a new value
+ * The value returned is NOT in "ADC" mode, it's in millivolts
  */
 static void thermistor_in_hook(struct avr_irq_t * irq, uint32_t value, void * param)
 {
@@ -45,10 +46,11 @@ static void thermistor_in_hook(struct avr_irq_t * irq, uint32_t value, void * pa
 
        short *t = p->table;
        for (int ei = 0; ei < p->table_entries; ei++, t += 2) {
-               if (t[1] < p->current) {
-                       printf("%s(%2d) %.2f matches %3dC is %d adc\n", __func__, v.src,
-                                       p->current, t[1], t[0] / p->oversampling);
-                       avr_raise_irq(p->irq + IRQ_TERM_ADC_VALUE_OUT, t[0] / p->oversampling);
+               if (t[1] <= p->current) {
+               //      printf("%s(%2d) %.2f matches %3dC is %d adc\n", __func__, v.src,
+               //                      p->current, t[1], t[0] / p->oversampling);
+                       avr_raise_irq(p->irq + IRQ_TERM_ADC_VALUE_OUT,
+                                                ((t[0] / p->oversampling) * 5000) / 0x3ff);
                        return;
                }
        }