Browse files

added a test spin button to help get turntable calibrated

added gear ratio for my new turntable
changed default laser offset to 45 degrees
  • Loading branch information...
1 parent 5c58f05 commit efd3cc4ab36aabfe068e7c6ff357e6da20791f32 @tbuser committed Aug 14, 2011
Showing with 25 additions and 12 deletions.
  1. +10 −6 firmware/firmware.pde
  2. +15 −6 spinscan.pde
View
16 firmware/firmware.pde
@@ -2,7 +2,8 @@ int ledPin = 13;
int laserPin = 2;
int dirPin = 3;
int stepPin = 4;
-int stepSpeed = 10000;
+int stepSpeed = 4000;
+float gearRatio = 61/10;
void setup() {
pinMode(laserPin, OUTPUT);
@@ -13,9 +14,9 @@ void setup() {
Serial.begin(9600);
}
-void stepper(int turnDegrees, int stepSpeed) {
+void stepper(float turnDegrees, int stepSpeed) {
boolean dir;
- int steps;
+ float steps;
if (turnDegrees > 0) {
dir = true;
@@ -27,12 +28,12 @@ void stepper(int turnDegrees, int stepSpeed) {
// delay(50);
- steps = turnDegrees/360 * 1600;
+ steps = turnDegrees/360.0 * 1600.0 * gearRatio;
for (int i=0; i<steps ;i++) {
- digitalWrite(stepPin, HIGH);
- delayMicroseconds(stepSpeed);
digitalWrite(stepPin, LOW);
+// delayMicroseconds(150);
+ digitalWrite(stepPin, HIGH);
delayMicroseconds(stepSpeed);
}
}
@@ -61,6 +62,9 @@ void loop() {
stepper(360, stepSpeed);
laser(false);
Serial.println("OK");
+ } else if (val == '4') {
+ stepper(360, stepSpeed);
+ Serial.println("OK");
} else {
Serial.println("Unknown Command");
}
View
21 spinscan.pde
@@ -55,9 +55,9 @@ float camHFOV = 50.0;
// degrees
float camVFOV = camHFOV * 4.0 / 5.0;
// from camera to center of table in mm
-float camDistance = 304.8;
+float camDistance = 304.8; // 1 foot
// degrees
-float laserOffset = 15.0;
+float laserOffset = 45.0; // 15? 45?
int frameSkip = 1;
int pointSkip = 1;
float radiansToDegrees = 180.0 / 3.14159;
@@ -140,9 +140,11 @@ void setup() {
laserOffsetField.setText(str(laserOffset));
controlP5.addButton("processScans", 0, 10, 320, 90, 15).captionLabel().set("Process Scans!");
+
+ controlP5.addButton("testSpin", 0, 10, 360, 90, 15).captionLabel().set("Test Spin");
// loadTextureScan();
- loadLaserScan();
+// loadLaserScan();
}
void draw() {
@@ -362,8 +364,8 @@ public void camConnect() {
}
public void processScans() {
-// plyFilename = selectOutput("Save scan .ply to...");
- plyFilename = "data/gnome.ply";
+ plyFilename = selectOutput("Save scan .ply to...");
+// plyFilename = "data/gnome.ply";
if (plyFilename == null) {
println("ERROR: No ply output file was selected");
} else {
@@ -373,6 +375,12 @@ public void processScans() {
}
}
+public void testSpin() {
+ if (serialConnected && !recording) {
+ serial.write('4');
+ }
+}
+
//public float ASAtoSAS(float angleA, float lengthB, float angleC, float lengthA, float angleB, float lengthC) {
public float ASAtoSAS(float angleA, float lengthB, float angleC) {
float lengthA = 0.0;
@@ -438,7 +446,8 @@ public void processScanFrame() {
for (int x = 0; x < videoWidth; x++) {
int pixelValue = laserImage.pixels[index];
- float pixelBrightness = brightness(pixelValue);
+// float pixelBrightness = brightness(pixelValue);
+ float pixelBrightness = pixelValue >> 16 & 0xFF;
if (pixelBrightness > brightestValue && pixelBrightness > threshold) {
brightestValue = pixelBrightness;

0 comments on commit efd3cc4

Please sign in to comment.