Skip to content

Commit

Permalink
added set start and stop point for stacking
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincentdecursay committed Dec 20, 2020
1 parent cc1005c commit 2fb20b3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 24 deletions.
1 change: 0 additions & 1 deletion code/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ camera_taking_picture_delay = 0.2
double_shot_is_enabled = 0

[STACKING]
number_of_shot = 40
number_of_step = 4
109 changes: 87 additions & 22 deletions code/meteor_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
double_shot_is_enabled = int(config['CAMERA']['double_shot_is_enabled']) # for the mirror lockup option

# STACKING CONFIG
number_of_shot = int(config['STACKING']['number_of_shot'])
number_of_step = int(config['STACKING']['number_of_step'])
current_position = 0
start_point = None
stop_point = None

# GPIO CONFIGURATION
io.setup(motor_enable_pin, io.OUT)
Expand Down Expand Up @@ -72,14 +74,18 @@ def step_once():
time.sleep(motor_delay)

def step_forward():
io.output(motor_direction_pin, True)
global current_position
io.output(motor_direction_pin, False)
time.sleep(motor_delay)
step_once()
current_position += 1

def step_reverse():
io.output(motor_direction_pin, False)
global current_position
io.output(motor_direction_pin, True)
time.sleep(motor_delay)
step_once()
current_position -= 1

# Full rotation forward, you need to configure the number of step in a 360 degree rotation
def rotate_forward():
Expand All @@ -89,25 +95,78 @@ def rotate_forward():
def rotate_reverse():
for x in range(0, pulses_per_rev):
step_reverse()

def stepper_goto(aimed_position):
global current_position
print_current_task('moving to start position', 0 )
if aimed_position > current_position :
while aimed_position != current_position + 1 :
step_forward()
elif aimed_position < current_position :
while aimed_position != current_position - 1 :
step_reverse()




# CAMERA FUNCTION
def take_picture():
if double_shot_is_enabled == 1:
take_picture()
io.output(camera_trigger_pin, True)
time.sleep(camera_trigger_delay)
io.output(camera_trigger_pin, False)
time.sleep(camera_taking_picture_delay)
time.sleep(camera_vibration_delay)
io.output(camera_trigger_pin, True)
time.sleep(camera_trigger_delay)
io.output(camera_trigger_pin, False)

def stacking():
print_current_task('stacking', 0 )
for x in range(0, number_of_shot):
take_picture()
time.sleep(camera_taking_picture_delay)
print_current_task('stacking : picture ' + str(x + 1) + '/' + str(number_of_shot), 0 )
for y in range(0, number_of_step):
step_forward()
global start_point
global stop_point
stepper_goto(start_point)
print_current_task('stacking', 0 )

number_of_shot = get_number_of_shot()

if start_point < stop_point :
for x in range(0, number_of_shot):
take_picture()
time.sleep(camera_taking_picture_delay)
print_current_task('stacking : picture ' + str(x + 1) + '/' + str(number_of_shot), 0 )
for y in range(0, number_of_step):
step_forward()
elif start_point > stop_point :
for x in range(0, number_of_shot):
take_picture()
time.sleep(camera_taking_picture_delay)
print_current_task('stacking : picture ' + str(x + 1) + '/' + str(number_of_shot), 0 )
for y in range(0, number_of_step):
step_reverse()

def set_start_point():
global start_point
start_point = current_position
print_screen()
print_current_task('Set start position', 1)


def set_stop_point():
global stop_point
stop_point = current_position
print_screen()
print_current_task('Set stop position', 1)


def get_number_of_shot():
global start_point
global stop_point
global number_of_step
if start_point == None or stop_point == None : # if one of the points is not set
return 0
else :
return ( abs(start_point - stop_point) // number_of_step )


def double_shot_enable():
global double_shot_is_enabled
Expand Down Expand Up @@ -135,7 +194,7 @@ def print_screen():
print(" / /\/\ | __| || __| (_) | | _\ | || (_| | (__| < " + term.orange("| |_| ") + term.orangered("_") + term.orange("| |"))
print(term.orangered(" \/ \/\___|\__\___|\___/|_| \__/\__\__,_|\___|_|\_\ ") + term.orange(" \___") + term.orangered("(_") + term.orange("|_|"))
print('===========================================================================')
print(term.bold(" current task:") + term.move_x(38) + "|" + " number of shot: " + term.bold(str(number_of_shot)))
print(term.bold(" current task:") + term.move_x(38) + "|" + " number of shot: " + term.bold(str(get_number_of_shot())))
print(term.move_x(38) + "|" + " number of step: " + term.bold(str(number_of_step)))
print(term.move_x(38) + "|")
print(term.move_x(38) + "|")
Expand All @@ -146,9 +205,10 @@ def print_screen():
print(' ' + term.bold('q') + ' quit | ' + term.bold('m') + ' disable motor ')
print(' ' + term.bold('r') + ' reverse step | ' + term.bold('f') + ' forward step | ' + term.bold('t') + ' reverse rotation | ' + term.bold('g') + ' forward rotation')
if double_shot_is_enabled == 0:
print(' ' + term.bold('s') + ' take a shot | ' + term.bold('z') + ' begin stacking! | ' + term.bold('d') + ' enable double shot')
print(' ' + term.bold('s') + ' take a shot | ' + term.bold('d') + ' enable double shot')
else:
print(' ' + term.bold('s') + ' take a shot | ' + term.bold('z') + ' begin stacking! | ' + term.bold('d') + ' disable double shot')
print(' ' + term.bold('s') + ' take a shot | ' + term.bold('d') + ' disable double shot')
print(' ' + term.bold('z') + ' begin stacking! | ' + term.bold('y') + ' set start point | ' + term.bold('h') + ' set stop point')


def print_current_task(current_task, status):
Expand Down Expand Up @@ -178,32 +238,37 @@ def getch():

while val.lower() != 'q':
val = getch()
if val.lower() == 'r':
if val.lower() == 'r':# make a step backward
step_forward()
print_current_task("reverse step",1)
elif val.lower() == 'f':
elif val.lower() == 'f': # make a step forward
step_reverse()
print_current_task("forward step",1)
elif val.lower() == 't':
elif val.lower() == 't': # make a 360 rotation backward
print_current_task("reverse rotation",0)
rotate_reverse()
print_current_task("reverse rotation",1)
elif val.lower() == 'g':
elif val.lower() == 'g': # make a 360 rotation backward
print_current_task("forward rotation",0)
rotate_forward()
print_current_task("forward rotation",1)
elif val.lower() == 'm':
elif val.lower() == 'm': # enable the stepper motor
stepper_enable()
elif val.lower() == 's':
elif val.lower() == 's': # take a picture
take_picture()
print_current_task("took a shot",1)
time.sleep(2)
val = ''
elif val.lower() == 'z':
elif val.lower() == 'z': # start stacking
stacking()
print_current_task("stack finished",1)
elif val.lower() == 'd':
elif val.lower() == 'y': # set start point for stacking
set_start_point()
elif val.lower() == 'h': # set stop point for stacking
set_stop_point()
elif val.lower() == 'd': # trigger the camera twice for each picture for the mirror lockup option
double_shot_enable()



io.output(motor_enable_pin, False)
Expand Down
1 change: 0 additions & 1 deletion software/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ camera_taking_picture_delay = 0.2
double_shot_is_enabled = 0

[STACKING]
number_of_shot = 40
number_of_step = 4
Binary file modified software/meteor_stack
Binary file not shown.

0 comments on commit 2fb20b3

Please sign in to comment.