Skip to content

Commit

Permalink
MAINT: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasM2001 committed May 6, 2024
1 parent 5695595 commit e0c22df
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions examples/lab_devices/MotorStage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,19 @@
time.sleep(0.1)
dut["MotorStage"].LL(address=1)
time.sleep(0.1)
#####################################


def wait_pos(target,precision,address): #waits/prints position until desired precision is reached
print("Moving motore from:",dut["MotorStage"].get_position(address),"to" ,target) #absolute target
done=False
while done is False:
pos=dut["MotorStage"].get_position(address)
print("motor at",pos,"moving to",target)
if abs(pos-target)<= precision:
done=True
else:
time.sleep(0.5)
return pos


######################examples
##################################### examples

#print(dut["MotorStage"].get_channel(address=1),"status") # prints status code
#time.sleep(2)

########### example of an absoulute movement using sleep

print(dut["MotorStage"].get_position(address=1),"position before") #print position before movement

dut["MotorStage"].set_position(10000,address=1) #absolute movement

time.sleep(10) #wait for movement

time.sleep(1)
#dut["MotorStage"].set_position(10000,address=1) #absolute movement
#dut["MotorStage"].abort(address=1)#abort
dut["MotorStage"].find_edge(1,address=1) #find edge 0=postive 1=negative
dut["MotorStage"].wait_FE(address=1)
print(dut["MotorStage"].get_position(address=1),"position after") #print position after movement

########### example of an relative movement using wait_pos
Expand All @@ -59,7 +43,7 @@ def wait_pos(target,precision,address): #waits/prints position until desired pre
#target = dut["MotorStage"].get_position(address=1)+move_r #wait_pos needs absolute target

#dut["MotorStage"].move_relative(move_r,address=1) #relative movement
#wait_pos(target,500,1) #wait/print movement
#dut["MotorStage"].wait_pos(target,500,1) #wait/print movement

########### abort any movement abruptly:
#dut["MotorStage"].abort(address=1)

0 comments on commit e0c22df

Please sign in to comment.