summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrian-bowyer <adrian-bowyer@cb376a5e-1013-0410-a455-b6b1f9ac8223>2009-10-01 22:26:31 +0000
committeradrian-bowyer <adrian-bowyer@cb376a5e-1013-0410-a455-b6b1f9ac8223>2009-10-01 22:26:31 +0000
commitb647d3f06a2e545a953cacc62f13d41aa276ffc9 (patch)
treefa0cd29e35c1a4f735dc6f13fe536b2dc112ab11
parent0e6343263ec0bfbd827a8f52bfc8d42f2e3e74f0 (diff)
downloadreprap-backup-b647d3f06a2e545a953cacc62f13d41aa276ffc9.tar.gz
reprap-backup-b647d3f06a2e545a953cacc62f13d41aa276ffc9.zip
First fully-working version of the RS485 and 5D code.
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@3286 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/configuration.h.dist11
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/extruder.pde52
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde2
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/configuration.h.dist13
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/extruder.h2
-rwxr-xr-xtrunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/pins.h4
6 files changed, 78 insertions, 6 deletions
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/configuration.h.dist b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/configuration.h.dist
index 23ac1024..0dd90f5f 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/configuration.h.dist
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/configuration.h.dist
@@ -18,6 +18,17 @@
#define RX_ENABLE_PIN 4
#define TX_ENABLE_PIN 16
+// Pins to direct-drive the extruder stepper
+
+#define E_STEP_PIN 10
+#define E_DIR_PIN 9
+
+// I2C pins for the MAX 6675 temperature chip
+
+#define SO 18 // MISO
+#define SCK 19 // Serial Clock
+#define TC_0 17 // CS Pin of MAX6607
+
// Control pins for the A3949 chips
#define H1D 7
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/extruder.pde b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/extruder.pde
index 3193fd1a..0f2d81e7 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/extruder.pde
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Extruder/extruder.pde
@@ -12,6 +12,12 @@ extruder::extruder()
pinMode(E_STEP_PIN, INPUT);
pinMode(E_DIR_PIN, INPUT);
pinMode(POT, INPUT);
+ pinMode(SO, INPUT);
+ pinMode(SCK, OUTPUT);
+ pinMode(TC_0, OUTPUT);
+
+ digitalWrite(TC_0,HIGH); // Disable MAX6675
+
disableStep();
@@ -62,9 +68,53 @@ void extruder::manage()
slowManage();
}
+
+/* A function read_temp that returns an unsigned int
+ with the temp from the specified pin (if multiple MAX6675). The
+ function will return 9999 if the TC is open.
+
+ Usage: read_temp(int pin, int type, int error)
+ pin: the CS pin of the MAX6675
+ type: 0 for ˚F, 1 for ˚C
+ error: error compensation in digital counts
+ samples: number of measurement samples (max:10)
+
+ With thanks to: Ryan Mclaughlin - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230859336
+*/
+
int extruder::internalTemperature()
{
- return 99;
+ int value = 0;
+ byte error_tc;
+
+
+ digitalWrite(TC_0, 0); // Enable device
+
+ /* Cycle the clock for dummy bit 15 */
+ digitalWrite(SCK,HIGH);
+ digitalWrite(SCK,LOW);
+
+ /* Read bits 14-3 from MAX6675 for the Temp
+ Loop for each bit reading the value
+ */
+ for (int i=11; i>=0; i--)
+ {
+ digitalWrite(SCK,HIGH); // Set Clock to HIGH
+ value += digitalRead(SO) << i; // Read data and add it to our variable
+ digitalWrite(SCK,LOW); // Set Clock to LOW
+ }
+
+ /* Read the TC Input inp to check for TC Errors */
+ digitalWrite(SCK,HIGH); // Set Clock to HIGH
+ error_tc = digitalRead(SO); // Read data
+ digitalWrite(SCK,LOW); // Set Clock to LOW
+
+ digitalWrite(TC_0, HIGH); //Disable Device
+
+// if(error_tc)
+// return 2000;
+// else
+ return value/4;
}
void extruder::waitForTemperature()
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde
index c1bf5a87..efbfc3aa 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde
@@ -409,7 +409,9 @@ void cartesian_dda::disable_steppers()
//disable our steppers
digitalWrite(X_ENABLE_PIN, !ENABLE_ON);
digitalWrite(Y_ENABLE_PIN, !ENABLE_ON);
+#if DISABLE_Z
digitalWrite(Z_ENABLE_PIN, !ENABLE_ON);
+#endif
ex[extruder_in_use]->disableStep();
#endif
}
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/configuration.h.dist b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/configuration.h.dist
index 77c520d4..930ce94f 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/configuration.h.dist
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/configuration.h.dist
@@ -7,7 +7,7 @@
// RepRap Motherboard with RS485 extruders: 2
// Arduino Mega: 3
-#define MOTHERBOARD 2
+#define MOTHERBOARD 1
// The speed at which to talk with the host computer
@@ -39,7 +39,8 @@
// E_STEPS_PER_MM is the number of steps needed to
// extrude 1mm out of the nozzle.
-#define E_STEPS_PER_MM 0.706 // 5mm diameter drive - empirically adjusted
+//#define E_STEPS_PER_MM 0.706 // NEMA 17 extruder 5mm diameter drive - empirically adjusted
+#define E_STEPS_PER_MM 2.2 // NEMA 14 geared extruder 8mm diameter drive
#define E_STEPS_PER_INCH (E_STEPS_PER_MM*INCHES_TO_MM)
#define E_MOTOR_STEPS 400
@@ -64,9 +65,15 @@
#define ENABLE_ON HIGH
#endif
+// Set these to 1 to disable the Z axis when it's not being used,
+// and similarly for the extruder
+
+#define DISABLE_Z 0
+#define DISABLE_E 0
+
// Set to one if sensor outputs inverting (ie: 1 means open, 0 means closed)
// RepRap opto endstops are *not* inverting.
-#define ENDSTOPS_INVERTING 1
+#define ENDSTOPS_INVERTING 0
//our command string length
#define COMMAND_SIZE 128
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/extruder.h b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/extruder.h
index 3d340c13..24084348 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/extruder.h
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/extruder.h
@@ -91,7 +91,9 @@ inline void extruder::disableStep()
{
if(step_en_pin < 0)
return;
+#if DISABLE_E
digitalWrite(step_en_pin, !ENABLE_ON);
+#endif
}
inline void extruder::sStep()
diff --git a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/pins.h b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/pins.h
index 89ec8417..3871b52c 100755
--- a/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/pins.h
+++ b/trunk/users/adrian/FiveD_GCode/FiveD_GCode_Interpreter/pins.h
@@ -59,8 +59,8 @@
#define Z_STEP_PIN (byte)29
#define Z_DIR_PIN (byte)30
-#define Z_MIN_PIN (byte)1
-#define Z_MAX_PIN (byte)2
+#define Z_MIN_PIN (byte)2
+#define Z_MAX_PIN (byte)1
#define Z_ENABLE_PIN (byte)31