temp.c File Reference

Manage temperature sensors. More...

#include "temp.h"
#include <stdlib.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include "arduino.h"
#include "delay.h"
#include "debug.h"
#include "sersendf.h"
#include "heater.h"
#include "config.h"
#include <avr/io.h>

Data Structures

struct  temp_sensor_definition_t
 holds metadata for each temperature sensor More...

Defines

#define DEFINE_TEMP_SENSOR(name, type, pin, additional)   { (type), (pin), (HEATER_ ## name), (additional) },
 help build list of sensors from entries in config.h
#define HOST
#define STEPS_PER_M_X   333333
#define STEPS_PER_M_Y   333333
#define STEPS_PER_M_Z   333333
#define MAXIMUM_FEEDRATE_X   2000
#define MAXIMUM_FEEDRATE_Y   2000
#define MAXIMUM_FEEDRATE_Z   2000
#define SEARCH_FEEDRATE_X   60
#define SEARCH_FEEDRATE_Y   60
#define SEARCH_FEEDRATE_Z   60
#define X_MIN   0.0
#define X_MAX   720.0
#define Y_MIN   0.0
#define Y_MAX   420.0
#define Z_MIN   0.0
#define Z_MAX   110.0
#define ACCELERATION_RAMPING
#define ACCELERATION   50.
#define _READ(IO)   (IO ## _RPORT & MASK(IO ## _PIN))
#define _WRITE(IO, v)   do { if (v) { IO ## _WPORT |= MASK(IO ## _PIN); } else { IO ## _WPORT &= ~MASK(IO ## _PIN); }; } while (0)
#define _TOGGLE(IO)   do { IO ## _RPORT = MASK(IO ## _PIN); } while (0)
#define _SET_INPUT(IO)   do { IO ## _DDR &= ~MASK(IO ## _PIN); } while (0)
#define _SET_OUTPUT(IO)   do { IO ## _DDR |= MASK(IO ## _PIN); } while (0)
#define _GET_INPUT(IO)   ((IO ## _DDR & MASK(IO ## _PIN)) == 0)
#define _GET_OUTPUT(IO)   ((IO ## _DDR & MASK(IO ## _PIN)) != 0)
#define READ(IO)   _READ(IO)
#define WRITE(IO, v)   _WRITE(IO, v)
#define TOGGLE(IO)   _TOGGLE(IO)
#define SET_INPUT(IO)   _SET_INPUT(IO)
#define SET_OUTPUT(IO)   _SET_OUTPUT(IO)
#define GET_INPUT(IO)   _GET_INPUT(IO)
#define GET_OUTPUT(IO)   _GET_OUTPUT(IO)
#define X_STEP_PIN   AIO0
#define X_DIR_PIN   AIO1
#define X_MIN_PIN   AIO2
#define X_INVERT_DIR   1
#define X_INVERT_MIN   1
#define Y_STEP_PIN   AIO3
#define Y_DIR_PIN   AIO4
#define Y_MIN_PIN   AIO5
#define Y_INVERT_MIN   1
#define Z_STEP_PIN   DIO2
#define Z_DIR_PIN   DIO4
#define Z_MIN_PIN   DIO7
#define Z_INVERT_MIN   1
#define CHARGEPUMP_PIN   DIO3
#define ESTOP_IN_PIN   DIO8
#define ESTOP_INVERT_IN   1
#define BAUD   115200
#define XONXOFF
#define MOVEBUFFER_SIZE   8
#define USE_WATCHDOG
#define STEP_INTERRUPT_INTERRUPTIBLE   0
#define ENDSTOP_STEPS   4

Enumerations

enum  temp_flags_enum { PRESENT, TCOPEN }

Functions

void temp_init ()
 set up temp sensors. Currently only the 'intercom' sensor needs initialisation.
void temp_sensor_tick ()
 called every 10ms from clock.c - check all temp sensors that are ready for checking
uint8_t temp_achieved ()
 report whether all temp sensors are reading their target temperatures used for M109 and friends
void temp_set (temp_sensor_t index, uint16_t temperature)
 specify a target temperature
uint16_t temp_get (temp_sensor_t index)
 return most recent reading for a sensor
void temp_print (temp_sensor_t index)
 send temperatures to host

Variables

struct {
   temp_flags_enum   temp_flags
 flags
   uint16_t   last_read_temp
 last received reading
   uint16_t   target_temp
 manipulate attached heater to attempt to achieve this value
   uint16_t   temp_residency
 how long have we been close to target temperature in temp ticks?
   uint16_t   next_read_time
 how long until we can read this sensor again?
temp_sensors_runtime [NUM_TEMP_SENSORS]
 this struct holds the runtime sensor data- read temperatures, targets, etc

Detailed Description

Manage temperature sensors.

Note:
ALL temperatures are stored as 14.2 fixed point in teacup, so we have a range of 0 - 16383.75 celsius and a precision of 0.25 celsius. That includes the ThermistorTable, which is why you can't copy and paste one from other firmwares which don't do this.

Function Documentation

uint16_t temp_get ( temp_sensor_t  index  ) 

return most recent reading for a sensor

Parameters:
index sensor to read
void temp_print ( temp_sensor_t  index  ) 

send temperatures to host

Parameters:
index sensor value to send
void temp_set ( temp_sensor_t  index,
uint16_t  temperature 
)

specify a target temperature

Parameters:
index sensor to set a target for
temperature target temperature to aim for
 All Data Structures Files Functions Variables Defines
Generated on Mon Jul 30 16:33:59 2012 for Teacup by  doxygen 1.6.3