diff options
-rw-r--r-- | Configuration.h | 35 | ||||
-rw-r--r-- | Heat.cpp | 23 | ||||
-rw-r--r-- | Heat.h | 47 | ||||
-rw-r--r-- | LICENCE | 3 | ||||
-rw-r--r-- | Move.cpp | 21 | ||||
-rw-r--r-- | Move.h | 34 | ||||
-rw-r--r-- | Platform.cpp | 58 | ||||
-rw-r--r-- | Platform.h | 165 | ||||
-rw-r--r-- | README | 40 | ||||
-rw-r--r-- | RepRapFirmware.h | 54 | ||||
-rw-r--r-- | RepRapFirmware.ino | 48 |
11 files changed, 528 insertions, 0 deletions
diff --git a/Configuration.h b/Configuration.h new file mode 100644 index 00000000..67a49738 --- /dev/null +++ b/Configuration.h @@ -0,0 +1,35 @@ +/**************************************************************************************************** + +RepRapFirmware - Configuration + +This is where all machine-independent configuration and other definitions are set up. Nothing that +depends on any particular RepRap, RepRap component, or RepRap controller should go in here. Define +machine-dependent things in Platform.h + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#define ABS_ZERO -273.15 + +#define FLASH_LED 'F' // First byte of a message that is to flash an LED; the next two bytes define + // the frequency and M/S ratio. +#define DISPLAY_MESSAGE 'L' // First byte of a message that is to appear on a local display; the L is + // not displayed; \f and \n should be supported. +#define HOST_MESSAGE 'H' // First byte of a message that is to be sent to the host; the H is not sent. + + +#endif diff --git a/Heat.cpp b/Heat.cpp new file mode 100644 index 00000000..b716951e --- /dev/null +++ b/Heat.cpp @@ -0,0 +1,23 @@ +/**************************************************************************************************** + +RepRapFirmware - Heat + +This is all the code to deal with heat and temperature. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#include "RepRapFirmware.h" + + @@ -0,0 +1,47 @@ +/**************************************************************************************************** + +RepRapFirmware - Heat + +This is all the code to deal with heat and temperature. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#ifndef HEAT_H +#define HEAT_H + +class PID +{ + public: + + PID(); + + private: + +}; + +class Heat +{ + + public: + + Heat(); + ControlHeaters(); + + private: + +}; + + +#endif diff --git a/LICENCE b/LICENCE new file mode 100644 index 00000000..952f8005 --- /dev/null +++ b/LICENCE @@ -0,0 +1,3 @@ +RepRap Firmware + +Licence: GPL diff --git a/Move.cpp b/Move.cpp new file mode 100644 index 00000000..b644ddfe --- /dev/null +++ b/Move.cpp @@ -0,0 +1,21 @@ +/**************************************************************************************************** + +RepRapFirmware - Move + +This is all the code to deal with movement and kinematics. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#include "RepRapFirmware.h" @@ -0,0 +1,34 @@ +/**************************************************************************************************** + +RepRapFirmware - Move + +This is all the code to deal with movement and kinematics. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#ifndef MOVE_H +#define MOVE_H + +class Move +{ + public: + + Move(); + + private: + +}; + +#endif diff --git a/Platform.cpp b/Platform.cpp new file mode 100644 index 00000000..0ccb843d --- /dev/null +++ b/Platform.cpp @@ -0,0 +1,58 @@ +/**************************************************************************************************** + +RepRapFirmware - Platform: RepRapPro Mendel with Melzi controller; Arduino/Sanguino toolchain + +Platform contains all the code and definitons to deal with machine-dependent things such as control +pins, bed area, number of extruders, tolerable accelerations and speeds and so on. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#include "RepRapFirmware.h" + +extern "C" +{ + // Don't put anything else in here; put it in + // the Platform constructor (m/c dependent), reprap->init() (m/c independent); + // or reprap->spin() and the other functions it calls. + + void setup() + { + reprap->init(); + } + + void loop() + { + reprap->spin(); + } +} + + +//=========================================================================== +//=============================Thermal Settings ============================ +//=========================================================================== + +// See http://en.wikipedia.org/wiki/Thermistor#B_or_.CE.B2_parameter_equation + +// BETA is the B value +// RS is the value of the series resistor in ohms +// R_INF is R0.exp(-BETA/T0), where R0 is the thermistor resistance at T0 (T0 is in kelvin) +// Normally T0 is 298.15K (25 C). If you write that expression in brackets in the #define the compiler +// should compute it for you (i.e. it won't need to be calculated at run time). + +// If the A->D converter has a range of 0..1023 and the measured voltage is V (between 0 and 1023) +// then the thermistor resistance, R = V.RS/(1023 - V) +// and the temperature, T = BETA/ln(R/R_INF) +// To get degrees celsius (instead of kelvin) add -273.15 to T +//#define THERMISTOR_R_INFS ( THERMISTOR_25_RS*exp(-THERMISTOR_BETAS/298.15) ) // Compute in Platform constructor diff --git a/Platform.h b/Platform.h new file mode 100644 index 00000000..327b77e1 --- /dev/null +++ b/Platform.h @@ -0,0 +1,165 @@ +/**************************************************************************************************** + +RepRapFirmware - Platform: RepRapPro Mendel with Melzi controller; Arduino/Sanguino toolchain + +Platform contains all the code and definitons to deal with machine-dependent things such as control +pins, bed area, number of extruders, tolerable accelerations and speeds and so on. + +No definitions that are system-independent should go in here. Put them in Configuration.h. Note that +the lengths of arrays such as DRIVES (see below) are defined here, so any array initialiser that depends on those +lengths, for example: + +#define DRIVES 4 +. +. +. +#define DRIVE_RELATIVE_MODES {false, false, false, true} + +also needs to go here. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#ifndef PLATFORM_H +#define PLATFORM_H + +// System #includes + +#include <stdio.h> + +/**************************************************************************************************/ + +// The physical capabilities of the machine + +#define DRIVES 4 // The number of drives in the machine, including X, Y, and Z plus extruder drives +#define AXES 3 // The number of movement axes in the machine, usually just X, Y and Z. <= DRIVES +#define HEATERS 2 // The number of heaters in the machine, including the heated bed if any. + +// The numbers of entries in each array must correspond with the values of DRIVES, +// AXES, or HEATERS. Set values to -1 to flag unavailability. + +// DRIVES + +#define STEP_PINS {1, 2, 3, 4} +#define DIRECTION_PINS {5, 6, 7, 8} +#define ENABLE_PINS {9, 10, 11, 12} +#define ENABLE_ON {0, 0, 0, 0} // For inverting stepper enable pins (active low) use 0, non inverting (active high) use 1. +#define DISABLE_DRIVES {false, false, true, false} // Set true to disable a drive when it becomes idle +#define MAX_FEEDRATES {300, 300, 3, 45} // mm/sec +#define MAX_ACCELERATIONS {800, 800, 30, 250} // mm/sec^2?? Maximum start speed for accelerated moves. +#define DRIVE_STEPS_PER_UNIT {91.4286, 91.4286, 4000, 929} +#define JERKS {15.0, 15.0, 0.4, 15.0} // (mm/sec) +#define DRIVE_RELATIVE_MODES {false, false, false, true} // false for default absolute movement, true for relative to last position + +// AXES + +#define LOW_STOP_PINS {13, 14, 15} +#define HIGH_STOP_PINS {16, 17, 18} +#define ENDSTOPS_INVERTING {false, false, false} // set to true to invert the logic of the endstops; assumes LOW and HIGH behave the same +#define AXIS_LENGTHS {210, 210, 140} // mm +#define FAST_HOME_FEEDRATES {50*60, 50*60, 1*60} // mm/min + +#define X_AXIS 0 // The index of the X axis +#define Y_AXIS 1 // The index of the Y axis +#define Z_AXIS 2 // The index of the Z axis + +// HEATERS + +#define TEMP_SENSE_PINS {21, 22} +#define HEAT_ON_PINS {23, 24} +#define THERMISTOR_BETAS {3480.0, 3960.0} // Bed thermistor: RS 484-0149; EPCOS B57550G103J; Extruder thermistor: RS 198-961 +#define THERMISTOR_SERIES_RS {4700, 4700} // Ohms in series with the thermistors +#define THERMISTOR_25_RS {10000.0, 100000.0} // Thermistor ohms at 25 C = 298.15 K +#define USE_PID {false, true} // PID or bang-bang for this heater? +#define PID_KIS {-1, 100} // PID constants... +#define PID_KDS {-1, 100} +#define PID_KPS {-1, 100} +#define PID_I_LIMITS {-1, 100} // ... to here +#define TEMP_INTERVAL 0.5 // secs - check and control temperatures this often + +#define AD_RANGE 16383 // The A->D converter that measures temperatures gives an int this big as its max value + +#define HOT_BED 0 // The index of the heated bed; set to -1 if there is no heated bed + + +/****************************************************************************************************/ + +// Miscellaneous... + +#define LED_PIN 0 // Indicator LED + +#define BAUD_RATE 250000 // Communication speed of the USB if needed. + +/****************************************************************************************************/ + +class Platform +{ + public: + + Platform(); + +//------------------------------------------------------------------------------------------------------------- + +// These are the functions that form the interface between Platform and the rest of the firmware. + + void init(); // Set the machine up after a restart. If called subsequently this should set the machine up as if + // it has just been restarted; it can do this by executing an actual restart if you like, but beware the + // loop of death... + + // Communications and data storage; opening something unsupported returns -1. + + char* FileList() // Returns a comma-separated?? list of all the files on local storage (for example on an SD card). + int OpenFile(char* fileName, boolean write); // Open a local file (for example on an SD card). + int OpenHost(); // Open a pseudofile that gives read/write communications to the host computer. + int OpenMessage(); // Open a pseudofile that writes to the message system. Messages may simply flash an LED, or, + // say, display the messages on an LCD. This may also transmit the messages to the host. + int OpenStore(boolean write); // Non-volatile non-removable storage such as EEPROM. + void Read(int file, char* string); // Read printable characters from a file into the string up to the next \n or \r, + // which are not returned. Return string[0] == 0 if there's nothing there. + void Write(int file, char* string); // Write the 0-terminated string to a file. End the string with \n or \r if you want them. + void Close(int file); // Close a file or device, writing any unwritten buffer contents first. + + // Movement + + void setDirection(int drive, boolean forwards); + void step(int drive); + void disable(int drive); // There is no drive enable; drives get enabled automatically the first time they are used. + void home(int axis); + + // Heat and temperature + + float getTemperature(int heater); + void setTemperature(int heater, float temperature); + +//------------------------------------------------------------------------------------------------------- + + private: + + + + int8_t stepPins[DRIVES] = STEP_PINS; + int8_t directionPins[DRIVES] = DIRECTION_PINS; +#define ENABLE_PINS {9, 10,11,12} +#define LOW_STOP_PINS {13, 14, 15, 16} +#define HIGH_STOP_PINS {17, 18, 19, 20} + +}; + +extern "C" +{ + void setup(void); + void loop(void); +} + +#endif @@ -0,0 +1,40 @@ +This firmware is intended to be a fully object-oriented highly modular control p +rogram for +RepRap self-replicating 3D printers. + +It owes a lot to Marlin and to the original RepRap FiveD_GCode. + +General design principles: + + * Control by RepRap G Codes. These are taken to be machine independent, thoug +h some may be unsupported. + * Full use of C++ OO techniques, + * Make classes hide their data, + * Make everything as stateless as possible, + * No use of conditional compilation except for #include guards - if you need t +hat, you should be + forking the repository to make a new branch - let the repository take the + strain, + * Concentration of all machine-dependent defintions and code in Platform.h and + Platform.cpp, + * No specials for (X,Y) or (Z) - all movement is 3-dimensional, + * Try to be efficient in memory use, but this is not critical, + * Labour hard to be efficient in time use, and this is critical, + * Don't abhor floats - they work fast enough if you're clever, + * Don't avoid arrays and structs/classes, + * Don't avoid pointers, + * Use operator and function overloading where appropriate, particulary for vec +tor algebra. + +-------------------------------------------------------------------------------- +--------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL diff --git a/RepRapFirmware.h b/RepRapFirmware.h new file mode 100644 index 00000000..af59accc --- /dev/null +++ b/RepRapFirmware.h @@ -0,0 +1,54 @@ +/**************************************************************************************************** + +RepRapFirmware - Main Include + +This defines versions etc, includes all the other include files in the right order and defines the +master RepRap class. No other definitions or information should be in here. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#ifndef REPRAPFIRMWARE_H +#define REPRAPFIRMWARE_H + +#define NAME "RepRapFirmware" +#define VERSION "0.1" +#define DATE "2012-11-18" +#define LAST_AUTHOR "reprappro.com" + +#include "Configuration.h" +#include "Platform.h" +#include "Move.h" +#include "Heat.h" + +class RepRap +{ + public: + + RepRap(); + init(); + spin(); + + private: + + Platform* platform; + Move* move; + Heat* heat; + + +}; + +extern RepRap* reprap; + +#endif diff --git a/RepRapFirmware.ino b/RepRapFirmware.ino new file mode 100644 index 00000000..29dc9035 --- /dev/null +++ b/RepRapFirmware.ino @@ -0,0 +1,48 @@ +/**************************************************************************************************** + +RepRapFirmware - Main Program + +This firmware is intended to be a fully object-oriented highly modular control program for +RepRap self-replicating 3D printers. + +It owes a lot to Marlin and to the original RepRap FiveD_GCode. + +General design principles: + + * Control by RepRap G Codes. These are taken to be machine independent, though some may be unsupported. + * Full use of C++ OO techniques, + * Make classes hide their data, + * Make everything as stateless as possible, + * No use of conditional compilation except for #include guards - if you need that, you should be + forking the repository to make a new branch - let the repository take the strain, + * Concentration of all machine-dependent defintions and code in Platform.h and Platform.cpp, + * No specials for (X,Y) or (Z) - all movement is 3-dimensional, + * Try to be efficient in memory use, but this is not critical, + * Labour hard to be efficient in time use, and this is critical, + * Don't abhor floats - they work fast enough if you're clever, + * Don't avoid arrays and structs/classes, + * Don't avoid pointers, + * Use operator and function overloading where appropriate, particulary for vector algebra. + +----------------------------------------------------------------------------------------------------- + +Version 0.1 + +18 November 2012 + +Adrian Bowyer +RepRap Professional Ltd +http://reprappro.com + +Licence: GPL + +****************************************************************************************************/ + +#include "RepRapFirmware.h" + +RepRap* reprap; + + + + + |