summaryrefslogtreecommitdiff
path: root/branches
diff options
context:
space:
mode:
authorsmcauliffe <smcauliffe@cb376a5e-1013-0410-a455-b6b1f9ac8223>2007-07-16 10:39:33 +0000
committersmcauliffe <smcauliffe@cb376a5e-1013-0410-a455-b6b1f9ac8223>2007-07-16 10:39:33 +0000
commitada160b800a58d75c4297aedcce9d96b63a3f701 (patch)
tree409a9cb2fce373553a76ded3a45d6c2c04f72857 /branches
parent52fd827282fce425a1f66823a8b408af3e2a2c37 (diff)
downloadreprap-backup-ada160b800a58d75c4297aedcce9d96b63a3f701.tar.gz
reprap-backup-ada160b800a58d75c4297aedcce9d96b63a3f701.zip
Start of merge of latest code. Commit prior to duplicating/renaming extruder directory.
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@747 cb376a5e-1013-0410-a455-b6b1f9ac8223
Diffstat (limited to 'branches')
-rw-r--r--branches/autoconf-firmware/devices/extruder_0/Makefile.am (renamed from branches/autoconf-firmware/devices/extruder/Makefile.am)0
-rw-r--r--branches/autoconf-firmware/devices/extruder_0/Makefile.in (renamed from branches/autoconf-firmware/devices/extruder/Makefile.in)0
-rw-r--r--branches/autoconf-firmware/devices/extruder_0/extruder.h (renamed from branches/autoconf-firmware/devices/extruder/extruder.h)0
-rw-r--r--branches/autoconf-firmware/devices/extruder_0/extruder1.c (renamed from branches/autoconf-firmware/devices/extruder/extruder1.c)0
-rw-r--r--branches/autoconf-firmware/devices/extruder_0/extruder2.c (renamed from branches/autoconf-firmware/devices/extruder/extruder2.c)0
-rw-r--r--branches/autoconf-firmware/devices/stepmotor/stepmotor.h11
-rw-r--r--branches/autoconf-firmware/devices/stepmotor/stepmotor1.c24
-rw-r--r--branches/autoconf-firmware/devices/stepmotor/stepmotor2.c153
8 files changed, 178 insertions, 10 deletions
diff --git a/branches/autoconf-firmware/devices/extruder/Makefile.am b/branches/autoconf-firmware/devices/extruder_0/Makefile.am
index 9bfac01d..9bfac01d 100644
--- a/branches/autoconf-firmware/devices/extruder/Makefile.am
+++ b/branches/autoconf-firmware/devices/extruder_0/Makefile.am
diff --git a/branches/autoconf-firmware/devices/extruder/Makefile.in b/branches/autoconf-firmware/devices/extruder_0/Makefile.in
index cf5df87b..cf5df87b 100644
--- a/branches/autoconf-firmware/devices/extruder/Makefile.in
+++ b/branches/autoconf-firmware/devices/extruder_0/Makefile.in
diff --git a/branches/autoconf-firmware/devices/extruder/extruder.h b/branches/autoconf-firmware/devices/extruder_0/extruder.h
index 8fe0ee6c..8fe0ee6c 100644
--- a/branches/autoconf-firmware/devices/extruder/extruder.h
+++ b/branches/autoconf-firmware/devices/extruder_0/extruder.h
diff --git a/branches/autoconf-firmware/devices/extruder/extruder1.c b/branches/autoconf-firmware/devices/extruder_0/extruder1.c
index a8ea3b69..a8ea3b69 100644
--- a/branches/autoconf-firmware/devices/extruder/extruder1.c
+++ b/branches/autoconf-firmware/devices/extruder_0/extruder1.c
diff --git a/branches/autoconf-firmware/devices/extruder/extruder2.c b/branches/autoconf-firmware/devices/extruder_0/extruder2.c
index b3491b40..b3491b40 100644
--- a/branches/autoconf-firmware/devices/extruder/extruder2.c
+++ b/branches/autoconf-firmware/devices/extruder_0/extruder2.c
diff --git a/branches/autoconf-firmware/devices/stepmotor/stepmotor.h b/branches/autoconf-firmware/devices/stepmotor/stepmotor.h
index 3e72bfe1..4a59c95c 100644
--- a/branches/autoconf-firmware/devices/stepmotor/stepmotor.h
+++ b/branches/autoconf-firmware/devices/stepmotor/stepmotor.h
@@ -36,13 +36,22 @@
#include "pic14.h"
+// Half-stepping not needed for 400-step-per-rev motors
+//#define HALFSTEP
+#define UNIVERSAL_PCB
+
void init2();
void timerTick();
void processCommand();
void syncStrobe();
+#ifdef UNIVERSAL_PCB
+#define SYNCA RA1
+#define SYNCA_TRIS TRISA1
+#else
#define SYNCA RA2
#define SYNCA_TRIS TRISA2
+#endif
#define MINSENSOR RB0
#define MAXSENSOR RA5
@@ -52,4 +61,6 @@ void syncStrobe();
#define PWM RB3
#define PWM_TRIS TRISB3
+
+
#endif
diff --git a/branches/autoconf-firmware/devices/stepmotor/stepmotor1.c b/branches/autoconf-firmware/devices/stepmotor/stepmotor1.c
index 92da7154..24b14db8 100644
--- a/branches/autoconf-firmware/devices/stepmotor/stepmotor1.c
+++ b/branches/autoconf-firmware/devices/stepmotor/stepmotor1.c
@@ -59,11 +59,33 @@ void init1()
OPTION_REG = BIN(01011111); // Disable TMR0 on RA4, 1:128 WDT, pullups on
CMCON = 0xff; // Comparator module defaults
+#ifdef UNIVERSAL_PCB
+ TRISA = BIN(00101010); // Port A outputs except 1,3 (sync) and 5 (Max)
+ // RA0 is L298 4
+ // RA1 is Sync
+ // RA2 is L298 3
+ // RA3 is Sync
+ // RA4 is the indicator LED
+ // RA5 is Max sensor
+ // RA6 is not used for the stepper
+ // RA7 is not used for the stepper
+ TRISB = BIN(00000011); // Port B 0,1 input, 2-7 outputs
+ // RB0 is Min sensor
+ // RB1 is Rx
+ // RB2 is Tx
+ // RB3 is PWM output to L298
+ // RB4 is L298 2
+ // RB5 is L298 1
+ // RB6 is not used
+ // RB7 is not used
+#else
TRISA = BIN(00101100); // Port A outputs except 2,3 (sync)
// RA3 is input for max limit sensor
- // RA5 can only be used as an input
+ // RA4 is the indicator LED
+ // RA5 can only be used as an input
TRISB = BIN(00000111); // Port B 0-2 input, 3-7 outputs
// Port B3 is PWM output
+#endif
PIE1 = BIN(00000000); // All peripheral interrupts initially disabled
INTCON = BIN(00000000); // Interrupts disabled
PIR1 = 0; // Clear peripheral interrupt flags
diff --git a/branches/autoconf-firmware/devices/stepmotor/stepmotor2.c b/branches/autoconf-firmware/devices/stepmotor/stepmotor2.c
index 0f9a9d93..95520413 100644
--- a/branches/autoconf-firmware/devices/stepmotor/stepmotor2.c
+++ b/branches/autoconf-firmware/devices/stepmotor/stepmotor2.c
@@ -45,7 +45,8 @@
// stepCount value and the stepValue function. Currently
// stepCount must be a power of 2.
-// I/O ports:
+// I/O ports - old design:
+
// B0 - Min optointerrupter (optional)
// B1 - UART Receive
// B2 - UART Transmit
@@ -55,7 +56,26 @@
// A3 - Sync B input/output (optional)
// A5 - Max optointerrupter (optional)
-#define HALFSTEP
+// I/O ports - Universal PCB:
+
+// RA0 is L298 4
+// RA1 is Sync
+// RA2 is L298 3
+// RA3 is Sync
+// RA4 is the indicator LED
+// RA5 is Max sensor
+// RA6 is not used for the stepper
+// RA7 is not used for the stepper
+
+// RB0 is Min sensor
+// RB1 is Rx
+// RB2 is Tx
+// RB3 is PWM output to L298
+// RB4 is L298 2
+// RB5 is L298 1
+// RB6 is not used
+// RB7 is not used
+
#ifdef HALFSTEP
#define stepCount 8
@@ -136,6 +156,90 @@ void init2()
maxPosition.bytes[1] = 0;
}
+#ifdef UNIVERSAL_PCB
+
+#pragma save
+#pragma nooverlay
+
+void motor_stop()
+{
+ PORTB = PORTB & BIN(11001111);
+ PORTA = PORTA & BIN(11111010);
+_asm /// @todo Remove when sdcc bug fixed
+ BANKSEL _coilPosition
+_endasm;
+}
+#pragma restore
+
+#pragma save
+#pragma nooverlay
+
+void motor_click()
+{
+ byte cp;
+#ifdef HALFSTEP
+ cp = coilPosition;
+#else
+ cp = coilPosition << 1;
+#endif
+ switch(cp) {
+ case 0:
+ PORTB5 = 1;
+ PORTB4 = 0;
+ PORTA2 = 0;
+ PORTA0 = 0;
+ break;
+ case 1:
+ PORTB5 = 1;
+ PORTB4 = 0;
+ PORTA2 = 1;
+ PORTA0 = 0;
+ break;
+ case 2:
+ PORTB5 = 0;
+ PORTB4 = 0;
+ PORTA2 = 1;
+ PORTA0 = 0;
+ break;
+ case 3:
+ PORTB5 = 0;
+ PORTB4 = 1;
+ PORTA2 = 1;
+ PORTA0 = 0;
+ break;
+ case 4:
+ PORTB5 = 0;
+ PORTB4 = 1;
+ PORTA2 = 0;
+ PORTA0 = 0;
+ break;
+ case 5:
+ PORTB5 = 0;
+ PORTB4 = 1;
+ PORTA2 = 0;
+ PORTA0 = 1;
+ break;
+ case 6:
+ PORTB5 = 0;
+ PORTB4 = 0;
+ PORTA2 = 0;
+ PORTA0 = 1;
+ break;
+ case 7:
+ PORTB5 = 1;
+ PORTB4 = 0;
+ PORTA2 = 0;
+ PORTA0 = 1;
+ break;
+ }
+_asm /// @todo Remove when sdcc bug fixed
+ BANKSEL _coilPosition
+_endasm;
+}
+#pragma restore
+
+#else
+
#ifdef HALFSTEP
byte stepValue()
{
@@ -180,16 +284,44 @@ byte stepValue()
#pragma save
#pragma nooverlay
+void motor_stop()
+{
+ PORTB = PULLUPS;
+_asm /// @todo Remove when sdcc bug fixed
+ BANKSEL _coilPosition
+_endasm;
+}
+#pragma restore
+
+#pragma save
+#pragma nooverlay
+void motor_click()
+{
+ PORTB = stepValue();
+_asm /// @todo Remove when sdcc bug fixed
+ BANKSEL _coilPosition
+_endasm;
+}
+#pragma restore
+
+#endif
+
+
+
+#pragma save
+#pragma nooverlay
+
void forward1()
{
+ flashLED();
if (MAXSENSOR) {
// We hit the end so go idle
- PORTB = PULLUPS;
+ motor_stop();
function = func_idle;
} else {
currentPosition.ival++;
coilPosition = (coilPosition + 1) & (stepCount - 1);
- PORTB = stepValue();
+ motor_click();
}
_asm /// @todo Remove when sdcc bug fixed
BANKSEL _coilPosition
@@ -201,14 +333,15 @@ _endasm;
#pragma nooverlay
void reverse1()
{
+ flashLED();
if (MINSENSOR) {
// We hit the end so go idle
- PORTB = PULLUPS;
+ motor_stop();
function = func_idle;
} else {
currentPosition.ival--;
coilPosition = (coilPosition + stepCount - 1) & (stepCount - 1);
- PORTB = stepValue();
+ motor_click();
}
_asm /// @todo Remove when sdcc bug fixed
BANKSEL _coilPosition;
@@ -243,7 +376,7 @@ void strobe_sync() {
SYNCA_TRIS = 0; // Set to output during stobe
// Spin for a few cycles
- for(delay = 0; delay < 254; delay++)
+ for(delay = 0; delay <= 254; delay++)
;
SYNCA_TRIS = 1; // Back to input so we don't drive the sync line
@@ -293,6 +426,7 @@ void timerTick()
case func_idle:
TMR1ON = 0;
speed = 0;
+ LEDon();
break;
case func_forward:
forward1();
@@ -308,8 +442,9 @@ void timerTick()
} else {
// Reached, switch to 0 speed
speed = 0;
+ LEDon();
// Uncomment next line to remove torque on arrival
- //PORTB = PULLUPS;
+ //motor_stop();
if (seekNotify != 255) {
sendMessage(seekNotify);
sendDataByte(CMD_SEEK);
@@ -444,7 +579,7 @@ void processCommand()
case CMD_FREE:
// Free motor (release torque)
- PORTB = PULLUPS;
+ motor_stop();
function = func_idle;
break;