I have got the rotary encoder 4mm shaft (3530) and got the sample code example for quadrature encoder.
Code: Select all
from Phidget22.Phidget import *
from Phidget22.Devices.Encoder import *
import time
def onPositionChange(self, positionChange, timeChange, indexTriggered):
print("PositionChange: " + str(positionChange))
print("TimeChange: " + str(timeChange))
print("IndexTriggered: " + str(indexTriggered))
print("----------")
def main():
encoder0 = Encoder()
encoder0.setOnPositionChangeHandler(onPositionChange)
encoder0.openWaitForAttachment(5000)
try:
input("Press Enter to Stop\n")
except (Exception, KeyboardInterrupt):
pass
encoder0.close()
main()
By making some tests, it looks like for positionChange, I got around 1800 for 1 lap of the encoder, but how can I know the exact number ?
Thank you.