Quantcast
Channel: Reprap Forum - Firmware - Marlin
Viewing all articles
Browse latest Browse all 2838

integrating arduino code into hotend loop (no replies)

$
0
0
Hey all, I'm trying to get some code to run when the hotends hit a certain temperature and am after some advice.
I thought what I'd done below would work but I guess I have the logic wrong as It compiles fine but doesn't do what id expect.

I've written a simple sketch called i2cFan.h that contains the following:

// i2c fan settings
// address of PCF8574 IC
#define PCF8574_ADDR (0x20)
 
//variables
int extHot = 0;              // variable for setting the extruder temperature status
int prev_extHot = 0;         // variable for reading the previous extruder temperature status
int extFanOnTemp = 35;       // Fan on temperature
int CurrentHotendTemp = 0;   // current hotend temperature

void Tempcheck() {
if (CurrentHotendTemp>extFanOnTemp)
{
    extHot = 1;
}
else {
    extHot = 0;
}
if (extHotprev_extHot)
{
    prev_extHot = extHot;
    Wire.beginTransmission(PCF8574_ADDR);
    Wire.write(0xAA);
    Wire.endTransmission();
}    
else if(extHot == prev_extHot)
{
    prev_extHot = extHot;
}
}

In configuration_adv I've defined:
#define E0_AUTO_FAN_PIN 100 // imaginary pin

then in temperatures.cpp ive added
#define "i2cFan.h"

and I've changed the autofan hotend loop to:

HOTEND_LOOP()
      if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE)
        SBI(fanState, pgm_read_byte(&fanBit[e]));
      CurrentHotendTemp = (temp_hotend[0].celsius);
      Tempcheck();

I also initialised wire in marlin void_setup

Viewing all articles
Browse latest Browse all 2838

Trending Articles