Don't think that will work as the Capturing timelapse sequences uses its own time delay,
where as you need to capture an image once you have moved the stepper motors which will be triggered by the stepper motor program, trying to get the 2 time delays to line up would be difficult if not impossible.
To capture consistent images you may want to look at section 3.5 of the doc but instead of capturing a sequence you just capture a single image each time.
if you can't find a away to do it with python code , you may be able to call the command line instruction using os.system() or subprocess.call()
I would suggest writing a short test python program to test this if you go down that route.( willing to try and help if you should need it.)
I have finished testing the two stepper motor program so its ready for hardware testing.
So bit of information about it first.
I have tried to make adjusting some common timings as easy as possible by using variables which you will find at the beginning of the program , with comments so you know what the do.
I would be careful about lowing the stops between the steppers moving ( zstop , picdelay ) as depending upon how stable your set up is you may need time for things to steady.
I have added a comment in the function were you need to add your picture taking code, along with a print and sleep line, both of thes can be removed or modified as you wish.
So here it is.........
Code: Select all
# final 2 stepper version 3.2
import RPi.GPIO as GPIO
import time
# setup gpio
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
control_pinsX = [7,11,13,15]
control_pinsZ = [19,21,23,29]
for pin in control_pinsX:
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, 0)
for pin in control_pinsZ:
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, 0)
# steps lists
# Stops X
stopsX = [0,546,1091,1637,2182,2728]
stop_countX = 0
# Stops Z
stopsZ = [0,114,228,342,455,569,683,797,910,1024,1138,1252,1365,1479,1593,1707,1820,1934,2048,2162,2275,2389,2503,2617,2730,2844,2958,3072,3185,3299,3413,3527,3640,3754,3868,3982,4096]
stop_countZ = 0
# gpio ouput values list
halfstep_seq = [
[1,0,0,0],
[1,1,0,0],
[0,1,0,0],
[0,1,1,0],
[0,0,1,0],
[0,0,1,1],
[0,0,0,1],
[1,0,0,1]
]
# stepper x starting halfstep value do not change
halfstep = 0
# stepper Z starting Halfstep value do not change
position = 0
# Stepper X cycles starting value
cycle = 1
# stop time after moving stepper Z you can reduce this if you want but not below 0.5
zstop = 5
# cmaera picture count start value
campic = 1
#step timer value adjust this value higher to slow stepping of motors typical values 0.001 0.001007
steptime = 0.001007
# delay for picture taking stop can be reduced once you have your picture taking code added but not below 0.5
picdelay = 5
def take_picture(campic):
print("place holder Take picture", campic)
# ----put you camera code in these lines to take pictures----
# campic is variable name for picture number counter
#
# --------------add more lines if need be -------------------
time.sleep(0.5)
def stepperz(Halfstep,stop_countZ):
# Stepper Z
start = stopsZ[stop_countZ]
if stop_countZ > 0:
start = start + 1
stop = stopsZ[stop_countZ + 1] + 1
for I in range(start, stop): # this now the number of steps for one move
#print(I)
for pin in range(4):
GPIO.output(control_pinsZ[pin], halfstep_seq[Halfstep][pin])
time.sleep(steptime)
Halfstep = Halfstep + 1
if Halfstep == 8:
Halfstep = 0
#stop
print("Z moved to", (stopsZ[stop_countZ + 1]))
time.sleep(1)
return Halfstep
# main program loop
print ("Program Start")
start = time.time()
for L in range(18): #loop for 18 times clockwise 18 counter clockwise
# Clock wise rotation including stops
for i in range(2729): # this now the number of steps for a 240 degrees rotation
#print(i)
for pin in range(4):
GPIO.output(control_pinsX[pin], halfstep_seq[halfstep][pin])
time.sleep(steptime)
halfstep = halfstep + 1
if halfstep == 8:
halfstep = 0
#stops
if i == (stopsX[stop_countX]):
print("X Moved to", (stopsX[stop_countX]))
time.sleep(picdelay)
#call to take picure
take_picture(campic)
campic = campic + 1
stop_countX = stop_countX + 1
# End of Clockwise rotation
print ("End of camera clockwise rotation cycle ", cycle )
# call stepper Z
stop_countZ = cycle - 1
Halfstep = position
position = stepperz(Halfstep,stop_countZ)
cycle = cycle + 1
stop_countX = 5 # reset stops
time.sleep(zstop)
# rotate back to start with stops
for i in range(2728, -1, -1): # this now the number of steps for the required rotation
#print(i)
for pin in range(4):
GPIO.output(control_pinsX[pin], halfstep_seq[halfstep][pin])
time.sleep(steptime)
halfstep = halfstep - 1
if halfstep == -1:
halfstep = 7
#stops
if i == (stopsX[stop_countX]):
print("X moved to", (stopsX[stop_countX]))
time.sleep(picdelay)
#call to take picure
take_picture(campic)
campic = campic + 1
stop_countX = stop_countX - 1
#End of counter clockwise rotation
print ("End of counter clockwise camera rotation cycle ", cycle)
# call stepper Z
stop_countZ = cycle - 1
Halfstep = position
position = stepperz(Halfstep,stop_countZ)
cycle = cycle + 1
stop_countX = 0 # reset stops
time.sleep(zstop)
GPIO.cleanup()
end = time.time()
runT = (end - start)
a=str(runT//3600)
b=str((runT%3600)//60)
c=str(round(((runT%3600)%60),3))
print ("End of program run it took {} hours {} mins {} seconds".format(a, b, c))
oh and about the time it takes to run once you add the code to take the pictures you may find it take even longer than 25 mins so you might need to find longer distraction tasks
