Пример #1
0
void temp_tick(void)
{

    /* Read and average temperatures */
    current_temp[EXTRUDER_0] = read_temp(EXTRUDER_0);
    current_temp[HEATED_BED_0] = read_temp(HEATED_BED_0);

    ticks ++;
    if (ticks == NUM_TICKS)
    {
        /* Manage heater using simple ON/OFF logic, no PID */
        if (current_temp[EXTRUDER_0] < target_temp[EXTRUDER_0])
        {
            extruder_heater_on();
        }
        else
        {
            extruder_heater_off();
        }

        /* Manage heater using simple ON/OFF logic, no PID */
        if (current_temp[HEATED_BED_0] < target_temp[HEATED_BED_0])
        {
            heated_bed_on();
        }
        else
        {
            heated_bed_off();
        }

        ticks = 0;
    }
}
Пример #2
0
void temp_tick(void)
{

	/* Define a value for sequencial number of reads of ADC, to average the readed
	 * value and try filter high frequency noise.
	 */
#define ADC_READ_TIMES 4

	/* Read and average the ADC input signal */
	current_temp[EXTRUDER_0] = 0;
	for (uint8_t c = 0; c < ADC_READ_TIMES; c++)
	{
		/* Read EXTRUDER_0 temperature value and manage heater */
		current_temp[EXTRUDER_0] += read_temp(EXTRUDER_0);
	}
	current_temp[EXTRUDER_0] = current_temp[EXTRUDER_0] / ADC_READ_TIMES;

	/* Manage heater using simple ON/OFF logic, no PID */
	if (current_temp[EXTRUDER_0] < target_temp[EXTRUDER_0])
	{
		extruder_heater_on();
	}
	else
	{
		extruder_heater_off();
	}


	/* Read and average the ADC input signal */
	current_temp[HEATED_BED_0] = 0;
	for (uint8_t c = 0; c < ADC_READ_TIMES; c++)
	{
		/* Read HEATED_BED_0 temperature value and manage heater */
		current_temp[HEATED_BED_0] += read_temp(HEATED_BED_0);
	}
	current_temp[HEATED_BED_0] = current_temp[HEATED_BED_0] / ADC_READ_TIMES;

	/* Manage heater using simple ON/OFF logic, no PID */
	if (current_temp[HEATED_BED_0] < target_temp[HEATED_BED_0])
	{
		heated_bed_on();
	}
	else
	{
		heated_bed_off();
	}
}
Пример #3
0
void io_init(void)
{
  /* Extruder 0 Heater pin */
  pin_mode(EXTRUDER_0_HEATER_PORT, EXTRUDER_0_HEATER_PIN, OUTPUT);
  extruder_heater_off();

  /* Heated Bed 0 Heater pin */
  pin_mode(HEATED_BED_0_HEATER_PORT, HEATED_BED_0_HEATER_PIN, OUTPUT);
  heated_bed_off();

  /* setup I/O pins */
  pin_mode(STEPPERS_RESET_PORT, STEPPERS_RESET_PIN, OUTPUT);
  digital_write(STEPPERS_RESET_PORT, STEPPERS_RESET_PIN, 1); /* Disable reset for all stepper motors */

  pin_mode(X_STEP_PORT, X_STEP_PIN, OUTPUT);
  pin_mode(X_DIR_PORT, X_DIR_PIN, OUTPUT);
  pin_mode(X_ENABLE_PORT, X_ENABLE_PIN, OUTPUT);
  x_enable();
  pin_mode(X_MIN_PORT, X_MIN_PIN, INPUT);

  pin_mode(Y_STEP_PORT, Y_STEP_PIN, OUTPUT);
  pin_mode(Y_DIR_PORT, Y_DIR_PIN, OUTPUT);
  pin_mode(Y_ENABLE_PORT, Y_ENABLE_PIN, OUTPUT);
  y_enable();
  pin_mode(Y_MIN_PORT, Y_MIN_PIN, INPUT);

  pin_mode(Z_STEP_PORT, Z_STEP_PIN, OUTPUT);
  pin_mode(Z_DIR_PORT, Z_DIR_PIN, OUTPUT);
  pin_mode(Z_ENABLE_PORT, Z_ENABLE_PIN, OUTPUT);
  z_enable();
  pin_mode(Z_MIN_PORT, Z_MIN_PIN, INPUT);

  pin_mode(E_STEP_PORT, E_STEP_PIN, OUTPUT);
  pin_mode(E_DIR_PORT, E_DIR_PIN, OUTPUT);
  pin_mode(E_ENABLE_PORT, E_ENABLE_PIN, OUTPUT);
  e_enable();

  pin_mode(EXTRUDER_0_FAN_PORT, EXTRUDER_0_FAN_PIN, OUTPUT);
  extruder_fan_off();

  adc_init();
}