Trammell Hudson avatar Trammell Hudson committed c5196f2 Draft

Updates for operating multi-axis

Comments (0)

Files changed (2)

 # type "make clean" after changing this, so all files will be rebuilt
 #
 #MCU = at90usb162       # Teensy 1.0
-MCU = atmega32u4        # Teensy 2.0
+#MCU = atmega32u4        # Teensy 2.0
 #MCU = at90usb646       # Teensy++ 1.0
-#MCU = at90usb1286      # Teensy++ 2.0
+MCU = at90usb1286      # Teensy++ 2.0
 
 
 # Processor frequency.
  * \file Servo driver.
  *
  * Generates a differential signal for controlling a servo motor.
- * Each teensy can control one servo.
+ * Each teensy++ can control six servos.
+ *
+ * Gnd		White
+ * Enable	Gray    D7 D7 D7 D7 D7 D7
+ * Ref-		Purple
+ * Ref+		Blue	B5 B6 B7 C6 C5 C4
+ * Qx		Green	D0 D1 D2 D3 E7 E6
+ * Qy		Yellow	F0 F1 F2 F3 F4 F5
  *
  * Joint #4:
  * Quadrature appers be about 30000 counts
 #include "bits.h"
 
 
-#define SERVO_RESET		0xB1
-#define SERVO_ENABLE_NEG	0xB2
-#define SERVO_ENABLE_POS	0xB3
-#define SERVO_ENABLE		0xB7
-#define SERVO_REF_NEG		0xD3
-#define SERVO_REF_POS		0xC6
+#define SERVO_ENABLE		0xD7
+#define SERVO_REF_POS		0xB5
 
-#define SERVO_QUAD_X		0xF1
-#define SERVO_QUAD_Y		0xF4
-#define SERVO_QUAD_INDEX	0xF5 // not used yet
+#define SERVO_QUAD_X		0xD0
+#define SERVO_QUAD_Y		0xF0
+//#define SERVO_QUAD_INDEX	0xF5 // not used yet
 
 #define LED			0xD6
 
 
 	if (cur_sign && val < 0)
 	{
-		OCR3A = 0;
+		OCR1A = 0;
 		_delay_ms(10);
 	} else
 	if (!cur_sign && val >= 0)
 	{
-		OCR3A = 1023;
+		OCR1A = 1023;
 		_delay_ms(10);
 	}
 #endif
 
-	OCR3A = output = val*4 + 512; // offset from EEPROM instead?
+	OCR1A = output = val*4 + 512; // offset from EEPROM instead?
 }
 
 
 void
 quad_decode(void)
 {
+#if 0
 	static uint8_t old_index;
 	if (in(SERVO_QUAD_INDEX))
 	{
 	} else {
 		old_index = 0;
 	}
+#endif
 
 	static uint8_t old_x;
 	uint8_t x = in(SERVO_QUAD_X) ? 1 : 0;
 	ddr(LED, 1);
 	out(LED, 1);
 
+	// Configure OC1x in fast-PWM mode, 10-bit
+	// REF+ is OC1A
+	sbi(TCCR1B, WGM12);
+	sbi(TCCR1A, WGM11);
+	sbi(TCCR1A, WGM10);
+
+	// Configure output mode to clear on match, set at top
+	sbi(TCCR1A, COM1A1);
+	cbi(TCCR1A, COM1A0);
+
+	// Configure clock 3 at clk/1
+	cbi(TCCR1B, CS12);
+	cbi(TCCR1B, CS11);
+	sbi(TCCR1B, CS10);
+
+
 	// Configure OC3x in fast-PWM mode, 10-bit
 	// REF+ is OC3A
 	sbi(TCCR3B, WGM32);
 	// The final enable is left floating when disabled.  When enabled
 	// it will also be driven low.
 	ddr(SERVO_ENABLE, 0); // not enabled
-	ddr(SERVO_ENABLE_POS, 1); // enabled, but not active yet
-	ddr(SERVO_ENABLE_NEG, 1);
 	out(SERVO_ENABLE, 0);
-	out(SERVO_ENABLE_POS, 0);
-	out(SERVO_ENABLE_NEG, 0);
 
 	// And configure the analog reference as output, pull down on both
 	// This way they are both at zero
-	ddr(SERVO_REF_NEG, 0); // leave as Hi-Z
-	out(SERVO_REF_NEG, 0); // leave as Hi-Z
+	//ddr(SERVO_REF_NEG, 0); // leave as Hi-Z
+	//out(SERVO_REF_NEG, 0); // leave as Hi-Z
 
 	ddr(SERVO_REF_POS, 1);
 	out(SERVO_REF_POS, 0);
 	// avoid missing counts, but that will require a cusotm board
 	ddr(SERVO_QUAD_X, 0);
 	ddr(SERVO_QUAD_Y, 0);
-	ddr(SERVO_QUAD_INDEX, 0);
+	//ddr(SERVO_QUAD_INDEX, 0);
 	out(SERVO_QUAD_X, 1);
 	out(SERVO_QUAD_Y, 1);
-	out(SERVO_QUAD_INDEX, 1);
+	//out(SERVO_QUAD_INDEX, 1);
 
 	// ADC0 is used to track the current measurement
 	// but may not be working yet?
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.