I am building a system using a raspberry pi 4 with a waveshare stepper hat that will control two stepper motors on lenses. 1 is an iris which opens according to steps and the other a flap. The flap is just open and close so no issues with the control and movement of the flap stepper but for the iris I attempted to do small steps up to 5800 over 120 seconds but the stepper wouldn’t move enough with steps of about 5 at a time and have experimented and so need to do a burst of say 200 at a time. But still need it to open gradually over the 120 seconds. An approximate 4 second pause should allow for 29 sets of 200 steps.
The GUI shows a counter counting down the timer for user info and so i want to add a time delay between each burst of 200 steps without affecting the countdown. I have had the timer working correctly but not succesful in showing the timer countdown on screen and stepping motor together.
def step_open_iris(self):
self.step_size = 200
if self.step_count<self.openingsize:
self.t1 = Timer(4, self.delaytimer)
self.t1.start()
Motor2.SetMicroStep('hardward' ,'fullstep')
Motor2.TurnStep(Dir='backward', steps=self.step_size, stepdelay=0.005)
self.step_count = self.step_count + self.step_size
self.showSteps()
Motor2.Stop()
Any assistance would be appreciated before I tear all my hair out!
I have created the GUI with start button and text boxes to set time and steps and a start button. I have added a thread for a timer as a means of producing a gap inbetween the 200 steps at a time. But it goes through the steps quickly so it does the 5800 steps in about 6 seconds and the timer continues then to countdown
Mark Lodge is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.