Repetier-Firmware  0.80
Repetier/Repetier.pde File Reference
#include "Reptier.h"
#include "Eeprom.h"
#include "pins_arduino.h"
#include "fastio.h"
#include "ui.h"
#include <util/delay.h>
#include <SPI.h>

Defines

#define OVERFLOW_PERIODICAL   (int)(F_CPU/(TIMER0_PRESCALE*40))

Functions

void update_extruder_flags ()
void update_ramps_parameter ()
void setup ()
 Setup of the hardware.
void defaultLoopActions ()
void loop ()
long Div4U2U (unsigned long a, unsigned int b)
 Optimized division.
long CPUDivU2 (unsigned int divisor)
 approximates division of F_CPU/divisor
byte get_coordinates (GCode *com)
 Sets the destination coordinates to values stored in com.
unsigned int ComputeV (long timer, long accel)
unsigned long mulu6xu16to32 (unsigned int a, unsigned int b)
unsigned int mulu6xu16shift16 (unsigned int a, unsigned int b)
long bresenham_step ()
void kill (byte only_steppers)
 Stop heater and stepper motors. Disable power,if possible.
void setTimer (unsigned long delay)
 Sets the timer 1 compare value to delay ticks.
 ISR (TIMER1_COMPA_vect)
 Timer interrupt routine to drive the stepper motors.
 ISR (EXTRUDER_TIMER_VECTOR)
 Timer routine for extruder stepper.
 ISR (PWM_TIMER_VECTOR)

Variables

byte unit_inches = 0
 0 = Units are mm, 1 = units are inches.
float axis_steps_per_unit [4] = {XAXIS_STEPS_PER_MM,YAXIS_STEPS_PER_MM,ZAXIS_STEPS_PER_MM,1}
 Number of steps per mm needed.
float inv_axis_steps_per_unit [4]
 Inverse of axis_steps_per_unit for faster conversion.
float max_feedrate [4] = {MAX_FEEDRATE_X, MAX_FEEDRATE_Y, MAX_FEEDRATE_Z}
 Maximum allowed feedrate.
float homing_feedrate [3] = {HOMING_FEEDRATE_X, HOMING_FEEDRATE_Y, HOMING_FEEDRATE_Z}
byte STEP_PIN [3] = {X_STEP_PIN, Y_STEP_PIN, Z_STEP_PIN}
long max_acceleration_units_per_sq_second [4] = {MAX_ACCELERATION_UNITS_PER_SQ_SECOND_X,MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Y,MAX_ACCELERATION_UNITS_PER_SQ_SECOND_Z}
 X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts.
long max_travel_acceleration_units_per_sq_second [4] = {MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_X,MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Y,MAX_TRAVEL_ACCELERATION_UNITS_PER_SQ_SECOND_Z}
 X, Y, Z max acceleration in mm/s^2 for travel moves.
unsigned long axis_steps_per_sqr_second [4]
unsigned long axis_travel_steps_per_sqr_second [4]
PrinterState printer_state
byte relative_mode = false
 Determines absolute (false) or relative Coordinates (true).
byte relative_mode_e = false
 Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
byte debug_level = 6
 Bitfield defining debug output. 1 = echo, 2 = info, 4 = error, 8 = dry run., 16 = Only communication, 32 = No moves.
unsigned long previous_millis_cmd = 0
unsigned long max_inactive_time = MAX_INACTIVE_TIME*1000L
unsigned long stepper_inactive_time = STEPPER_INACTIVE_TIME*1000L
PrintLine lines [MOVE_CACHE_SIZE]
 Cache for print moves.
PrintLinecur = 0
 Current printing line.
byte lines_write_pos = 0
 Position where we write the next cached line move.
volatile byte lines_count = 0
 Number of lines cached 0 = nothing to do.
byte lines_pos = 0
 Position for executing line movement.
long baudrate = BAUDRATE
 Communication speed rate.
int maxadv2 = 0
float maxadvspeed = 0
byte pwm_pos [NUM_EXTRUDER+3]
int waitRelax = 0
byte printmoveSeen = 0
const uint16_t fast_div_lut[17] PROGMEM
int lastblk = -1
long cur_errupd
void(* resetFunc )(void)=0
long stepperWait = 0
volatile byte insideTimer1 = 0
byte extruder_wait_dirchange = 0
 Wait cycles, if direction changes. Prevents stepper from loosing steps.
char extruder_last_dir = 0
byte extruder_speed = 0

Define Documentation

#define OVERFLOW_PERIODICAL   (int)(F_CPU/(TIMER0_PRESCALE*40))

Function Documentation

long bresenham_step ( ) [inline]
unsigned int ComputeV ( long  timer,
long  accel 
) [inline]
long CPUDivU2 ( unsigned int  divisor)

approximates division of F_CPU/divisor

In the stepper interrupt a division is needed, which is a slow operation. The result is used for timer calculation where small errors are ok. This function uses lookup tables to find a fast approximation of the result.

long Div4U2U ( unsigned long  a,
unsigned int  b 
) [inline]

Optimized division.

Normally the C compiler will compute a long/long division, which takes ~670 Ticks. This version is optimized for a 16 bit dividend and recognises the special cases of a 24 bit and 16 bit dividend, which offen, but not always occur in updating the interval.

byte get_coordinates ( GCode com)

Sets the destination coordinates to values stored in com.

Home axis.

For the computation of the destination, the following facts are considered:

  • Are units inches or mm.
  • Reltive or absolute positioning with special case only extruder relative.
  • Offset in x and y direction for multiple extruder support.
ISR ( TIMER1_COMPA_vect  )

Timer interrupt routine to drive the stepper motors.

Timer routine for extruder stepper.

Several methods need to move the extruder. To get a optima result, all methods update the printer_state.extruderStepsNeeded with the number of additional steps needed. During this interrupt, one step is executed. This will keep the extruder moving, until the total wanted movement is achieved. This will be done with the maximum allowable speed for the extruder.

This timer is called 3906 timer per second. It is used to update pwm values for heater and some other frequent jobs.

void kill ( byte  only_steppers)

Stop heater and stepper motors. Disable power,if possible.

void loop ( )

Main processing loop. It checks perodically for new commands, checks temperatures and executes new incoming commands.

unsigned int mulu6xu16shift16 ( unsigned int  a,
unsigned int  b 
) [inline]
unsigned long mulu6xu16to32 ( unsigned int  a,
unsigned int  b 
) [inline]
void setTimer ( unsigned long  delay) [inline]

Sets the timer 1 compare value to delay ticks.

This function sets the OCR1A compare counter to get the next interrupt at delay ticks measured from the last interrupt. delay must be << 2^24

void setup ( )

Setup of the hardware.

Sets the output and input pins in accordance to your configuration. Initializes the serial interface. Interrupt routines to measure analog values and for the stepper timerloop are started.

< Current feedrate in mm/s.

Acceleration in steps/s^3 in printing mode.

Acceleration in steps/s^2 in movement mode.


Variable Documentation

unsigned long axis_steps_per_sqr_second[4]

Acceleration in steps/s^3 in printing mode.

Number of steps per mm needed.

Acceleration in steps/s^2 in movement mode.

Communication speed rate.

PrintLine* cur = 0

Current printing line.

long cur_errupd
byte debug_level = 6

Bitfield defining debug output. 1 = echo, 2 = info, 4 = error, 8 = dry run., 16 = Only communication, 32 = No moves.

byte extruder_speed = 0

Wait cycles, if direction changes. Prevents stepper from loosing steps.

volatile byte insideTimer1 = 0

Inverse of axis_steps_per_unit for faster conversion.

int lastblk = -1

Moves the stepper motors one step. If the last step is reached, the next movement is started. The function must be called from a timer loop. It returns the time for the next call. This is a modified version that implements a bresenham 'multi-step' algorithm where the dominant cartesian axis steps may be less than the changing dominant delta axis. Moves the stepper motors one step. If the last step is reached, the next movement is started. The function must be called from a timer loop. It returns the time for the next call.

Normal non delta algorithm

Cache for print moves.

volatile byte lines_count = 0

Number of lines cached 0 = nothing to do.

byte lines_pos = 0

Position for executing line movement.

byte lines_write_pos = 0

Position where we write the next cached line move.

Maximum allowed feedrate.

unsigned long max_inactive_time = MAX_INACTIVE_TIME*1000L
int maxadv2 = 0
float maxadvspeed = 0
unsigned long previous_millis_cmd = 0
byte printmoveSeen = 0
const uint16_t slow_div_lut [257] PROGMEM
Initial value:
 {0,F_CPU/4096,F_CPU/8192,F_CPU/12288,F_CPU/16384,F_CPU/20480,F_CPU/24576,F_CPU/28672,F_CPU/32768,F_CPU/36864
  ,F_CPU/40960,F_CPU/45056,F_CPU/49152,F_CPU/53248,F_CPU/57344,F_CPU/61440,F_CPU/65536}
byte relative_mode = false

Determines absolute (false) or relative Coordinates (true).

byte relative_mode_e = false

Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.

void(* resetFunc)(void)=0
long stepperWait = 0
byte unit_inches = 0

0 = Units are mm, 1 = units are inches.

int waitRelax = 0
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Defines