Skip to content

Commit

Permalink
Merge pull request #7 from UAA-Robo/PCB
Browse files Browse the repository at this point in the history
Fixed Shift lengths
  • Loading branch information
schromya authored Mar 8, 2024
2 parents 02826e9 + 73f6ade commit 4585abf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
30 changes: 16 additions & 14 deletions arduino/Tree_Ring/Tree_Ring.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@

int DIRECTION_PIN = 3;
int STEPPER_PIN = 4;
int LIMIT_SWITCH_PIN = 5;
int ENABLE_PIN = 7;
int RESET_PIN = 6;
int LIMIT_SWITCH_PIN = 10;
int ENABLE_PIN = 9;
int RESET_PIN = 5;

int incoming_byte;

bool IS_CLOCKWISE = true;
bool IS_ACTIVE = false;

int active_counter = 0;
int rotate_amount = 200; //steps per revolution for 200 pulses = 360 degree full cycle rotation

int rotate_amount = 1400;//1600; //steps per revolution for 200 pulses = 360 degree full cycle rotation
int millimeters = 3;
int actual_movement = rotate_amount * millimeters;

void setup()
{
Expand Down Expand Up @@ -43,9 +44,9 @@ void step(boolean dir,int steps)
for(int i=0;i<steps;i++)
{
digitalWrite(STEPPER_PIN, HIGH);
delayMicroseconds(600);//Adjust the speed of motor. Increase the value, motor speed become slower.
delayMicroseconds(150);//Adjust the speed of motor. Increase the value, motor speed become slower.
digitalWrite(STEPPER_PIN, LOW);
delayMicroseconds(600);
delayMicroseconds(150);
}
}

Expand All @@ -58,7 +59,7 @@ void zero(){
while(digitalRead(LIMIT_SWITCH_PIN) != 0){
step(true,20);
}
step(false,rotate_amount);
step(false,actual_movement);
Serial.write("Zeroed");
}

Expand Down Expand Up @@ -104,23 +105,24 @@ void loop()
}
if(incoming_byte == 82) { // R Move the platform.
activate();
step(IS_CLOCKWISE, rotate_amount * 3);
step(IS_CLOCKWISE, actual_movement);
}
if(incoming_byte == 90) { // Z Zero the platform.
activate();
zero();
}
if(incoming_byte == 43) { // + Increase Rotation Amount.
rotate_amount = rotate_amount + 20;
Serial.write(rotate_amount);
millimeters = millimeters + 1;
Serial.write(millimeters);
}
if(incoming_byte == 45) { // - Decrease Rotation amount.
rotate_amount = rotate_amount - 20;
Serial.write(rotate_amount);
millimeters = millimeters - 1;
Serial.write(millimeters);
}
if(incoming_byte == 61) { // = Get current Rotation Amount.
Serial.write(rotate_amount);
Serial.write(millimeters);
}
actual_movement = rotate_amount * millimeters;
}

// Put motor to sleep if not in use.
Expand Down
8 changes: 6 additions & 2 deletions automationScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def update_shift_length(self, shift_length: float) -> None:

current_shift_length = 3 # TODO: ask arduino for length

increments = int((shift_length -current_shift_length) / self._SHIFT_LENGTH_CHANGE)
increments = current_shift_length - int(shift_length)

if increments < 0:
for _ in range(abs(increments)):
Expand Down Expand Up @@ -218,10 +218,14 @@ def start_automation(self, image_name:str, core_length:float, shift_length:float
if not self.is_active(): break
self.get_picture(image_name)

time.sleep(1)
time.sleep(1.1)
while (self._IS_PAUSED and self.is_active()): pass
if not self.is_active(): break
self.shift_sample()

self.get_picture(image_name)
time.sleep(1.1)

self.change_status(False)
self._status_message = "Automation Stopped."

Expand Down

0 comments on commit 4585abf

Please sign in to comment.