ceciliab
Posts: 56
Joined: Thu Apr 02, 2020 2:51 pm
Location: London

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 12:22 pm

Hi Bob, how are you?

There’s a problem with StepperX due to the gear ratio, don’t hate me!!!
I thought I could have solved it by re-calculating the number of teeth and by re-3Dprinting the gears, but it would be actually easier and waste-less to change the code instead. But I don’t know how much work this would actually involve.

Basically with what we have now, 240 degrees of the small gear corresponds to a 20 degrees movement of the big wheel.

Here below why:
Given a 15 teeth gear that needs to move a 180 teeth gear, I calculate:

Na = 15
Nb = 180

Nb / Na = ωa / ωb = 180 / 15 = 12

ωa / ωb = 12
ωb = ωa / 12
ωa = 240

ωb = 240 / 12 = 20

Here more info about the formula:
https://en.wikipedia.org/wiki/Gear_train

With this said, to understand how many cycles the small gear needs to complete to move the big wheel in a range of 240, I calculated the proportion:

20 : 240 = 240 : x
x = 2,880

2,880 / 360 = 8

***

Therefore, to move the camera in a 240 degrees range the small gear needs to complete 8 full cycles. Considering this, I thought it would have been smoother to think about the end of each cycle as a position where to shoot. Therefore there’ll be 9 shoots per each of the 240-degrees movements.

It will then be 8 cycles clockwise 8 cycle counter clockwise and so on for 36 times.

Would you still like / have time to give it a go?
Also, no news about the camera, but I discover yuv format can't be processed by the photogrammetry softwares.

Therefore it'll have to be one of these ones you listed:
'rgb' - Write the raw image data to a file in 24-bit RGB format
'rgba' - Write the raw image data to a file in 32-bit RGBA format
'bgr' - Write the raw image data to a file in 24-bit BGR format
'bgra' - Write the raw image data to a file in 32-bit BGRA format

Thanks!! Enjoy the suuun!

pcmanbob
Posts: 9467
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 12:37 pm

Well I am not going to re-write all the code,

but we should be able to make the exiting code do the steps required.

So refresh my memory how many steps to do one full rotation on the camera motor ?

if both motors are the same then it should be 4096.

So you will have 9 shots starting a position 0 then doing 1 full rotation to the next position and so on for 8 steps.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ceciliab
Posts: 56
Joined: Thu Apr 02, 2020 2:51 pm
Location: London

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 1:31 pm

Correct, both motors are the same, therefore one full rotation is 4096; and yes "9 shots starting a position 0 then doing 1 full rotation to the next position and so on for 8 steps."

This is the latest version of the code if useful:

Code: Select all

# final 2 stepper version 4

import RPi.GPIO as GPIO
import time
import picamera

# 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("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()


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
    

# file name entry
print ("Program Start")
print (" ")
print ("please input a file name for this program run")
name = input ("> ")
print(" ")
if name =="":
    name = (time.strftime("%d%H%M_"))

# main program loop  
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))
Thanks!

pcmanbob
Posts: 9467
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 4:46 pm

New stop points are [0,4096,8192,12288,16384,20480,24567,28672,32768]

thats 4096 between each stop.

Have only tested code for one clockwise and on counter clockwise rotation, but that worked ok, so should be good for the rest , but please test and confirm.

Code: Select all


# final 2 stepper version 5

import RPi.GPIO as GPIO
import time
import picamera

# 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,4096,8192,12288,16384,20480,24567,28672,32768]
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("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()


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
    

# file name entry
print ("Program Start")
print (" ")
print ("please input a file name for this program run")
name = input ("> ")
print(" ")
if name =="":
    name = (time.strftime("%d%H%M_"))

# main program loop  
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(32769):  # 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 = 8 # reset stops
    time.sleep(zstop)  
    
    # rotate back to start with stops
    for i in range(32768, -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))
[code]
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ceciliab
Posts: 56
Joined: Thu Apr 02, 2020 2:51 pm
Location: London

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 8:02 pm

Hey, sorry for this late reply.

It's super!

Just to let you know, this bit:

Code: Select all

def take_picture(campic):
    print("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()
was giving a TypeError: cannot concatenate 'str' and 'int' objects.
Therefore I replace it with the one from version # final 2 stepper version 4, which was:

Code: Select all

def take_picture(campic):
    print("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()
Also, is there a reason why when it asks to input a file name for this program run it only allows numbers and no letters? There's no problem for me to have numbers, just curious if it's an on purpose thing.

Ps tomorrow I should be shipped the final camera, and will start shooting when free from work! Hopefully will get some good obj soon (:
(I changed smile direction because I don't like they got translated into emoji ihih)

Thanks!! Have a good evening

pcmanbob
Posts: 9467
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 8:21 pm

The code as posted runs just fine on my pi and allows both letters and numbers.

The problems you discribe suggests you are running it with python which is python 2

The code was specifically written to run under python 3

So when calling the program on the command line you need to use

Python3 filename.py

The two lots of code you posted are identical, they have to be because version 5 is the same code as version 4 with just the stops and total steps changed for stepper X .
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ceciliab
Posts: 56
Joined: Thu Apr 02, 2020 2:51 pm
Location: London

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 9:11 pm

Uhh! My bad sorry I pasted the same twice.

Again this is the latest which gives the TypeError:

Code: Select all

def take_picture(campic):
    print("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()
And this the one I replaced it with - with witch it works fine:

Code: Select all

def take_picture(campic):
    print("Take picture", campic)
    # the following line contains the path and file name that will be use to save file
    filename = "/home/pi/" + str(campic) + ".jpg"
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()
    time.sleep(0.5)
The only difference is one more time.sleep(0.5) at the end, as you can see in option 2

Thanks for the other info. Didn't know about it!

pcmanbob
Posts: 9467
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Stepper 288yj-48 - stop and restart from the latest position

Sun Apr 26, 2020 11:02 pm

So comparing V4 to V5 the camera taking function is exactly the same ( they must be because as I said V5 is just V4 with the stepping for stepper X changed ).

So I have only ever posted two versions that had the full picture tasking code in them V5 & V5, so I don't know were you got this code from

Code: Select all

def take_picture(campic):
    print("Take picture", campic)
    # the following line contains the path and file name that will be use to save file
    filename = "/home/pi/" + str(campic) + ".jpg"
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()
    time.sleep(0.5)
    
I suspect its something you put together from V3 and the camtest program I posted.

So please down load V5 again save it to a new file and use that for your project or you are going to end up in a big mess which corrupted code that will fail.

So running V5 on my pi ,

first using python 2 , so at the command line python twostepv5.py

the code runs as far as asking you to input a file name then it crashers with this error

pi@Desktop-pi:~ $ python twostepv5.py
Program Start

please input a file name for this program run
> abc123def
Traceback (most recent call last):
File "twostepv5.py", line 107, in <module>
name = input ("> ")
File "<string>", line 1, in <module>
NameError: name 'abc123def' is not defined

exactly as I was expecting because of the way input works under python 2.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

now running exactly the same program V5 using python 3 , so at the command line python3 twostepv5.py

the program runs as I said accepting both letters and numbers.

pi@Desktop-pi:~ $ python3 twostepv5.py
Program Start

please input a file name for this program run
> abc123def

X Moved to 0
Take picture 1
X Moved to 4096
Take picture 2
X Moved to 8192
Take picture 3
X Moved to 12288

which results in 3 jpg files being created ( I stopped the program after 3 pictures had been taken ).

Image

So my program works exactly as required you just have to run it with the right version of python.
that being python3

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

So I have updated V5 of the program to V5.2 , this new version now has a test to check the program is being run with python 3.

So please download this version ( V5.2 ) of the code and use this from now on.

Code: Select all

#!/usr/bin/python3
# final 2 stepper version 5.2

import RPi.GPIO as GPIO
import time
import picamera
import sys

# test python version
version = sys.version.split('.')[0]
if version == "2":
    print("This program must be run with python3")
    print("python used aborting program ")
    sys.exit()

# 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,4096,8192,12288,16384,20480,24567,28672,32768]
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("Take picture", campic)
    # the following line contains the path and file name that will be use to save file 
    filename = "/home/pi/" + name + str(campic) + ".jpg"
    
    with picamera.PiCamera() as camera:
        camera.resolution = (1920, 1080)
        camera.start_preview()
        time.sleep(2)
        camera.capture(filename)
        time.sleep(0.5)
        camera.stop_preview()


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
    

# file name entry
print ("Program Start")
print (" ")
print ("please input a file name for this program run")
name = input ("> ")
print(" ")
if name =="":
    name = (time.strftime("%d%H%M_"))

# main program loop  
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(32769):  # 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 = 8 # reset stops
    time.sleep(zstop)  
    
    # rotate back to start with stops
    for i in range(32768, -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))
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ceciliab
Posts: 56
Joined: Thu Apr 02, 2020 2:51 pm
Location: London

Re: Stepper 288yj-48 - stop and restart from the latest position

Mon Apr 27, 2020 5:40 pm

It works.

Thanks for having tidied everything up Bob! An ok will run with Python3.

Have a great evening!

Return to “Python”