1047 encoder reporting first timeChange value as 0 on mac, values between 2-3 on Windows
Posted: Thu Oct 12, 2023 1:35 pm
Am testing 1047 encoder using same simple test code and same version of Phidget22 library on both macos and windows 11 and there is a difference between the first reported timeChange value passed to my onPositionChange() handler.
The first timeChange value is 0 on macos while values appear to range between 2-4 on windows 11.
Am using the same version of the Phidget22 library.
Including 3 sequential runs of simple test on windows and the macos. Am including test program at end along with json file that contains serial number for encoder. This file has values for the encoders used on each computer.
[Q1] Why is first reported timeChange 0ms on macos?
[Q2] Why isn't first reported timeChange on windows11 approximately 1/data_rate (about 8ms)?
I would like to see the same results in both os environments.
windows 11: initial timeChange values range from 2-4
macos 13.5.2: initial timeChange values are 0
encoder-1047-sample.py
phidget-serial-numbers.json
The first timeChange value is 0 on macos while values appear to range between 2-4 on windows 11.
Am using the same version of the Phidget22 library.
Including 3 sequential runs of simple test on windows and the macos. Am including test program at end along with json file that contains serial number for encoder. This file has values for the encoders used on each computer.
[Q1] Why is first reported timeChange 0ms on macos?
[Q2] Why isn't first reported timeChange on windows11 approximately 1/data_rate (about 8ms)?
I would like to see the same results in both os environments.
windows 11: initial timeChange values range from 2-4
Code: Select all
phidget> python -m pip show Phidget22
Name: Phidget22
Version: 1.17.20230824
Summary: Phidget22 Python wrapper library
Home-page: http://www.phidgets.com
Author: Phidgets Inc
Author-email: support@phidgets.com
License: MIT
Location: C:\Users\dev\AppData\Local\Programs\Python\Python311\Lib\site-packages
Requires:
Required-by:
phidget> python .\encoder-1047-sample.py
PositionChange: 0
TimeChange: 3.788
----------
PositionChange: 0
TimeChange: 7.648333
----------
PositionChange: 0
TimeChange: 7.632833
----------
phidget> python .\encoder-1047-sample.py
PositionChange: 0
TimeChange: 3.791
----------
PositionChange: 0
TimeChange: 7.6335
----------
PositionChange: 0
TimeChange: 7.635
----------
phidget> python .\encoder-1047-sample.py
PositionChange: 0
TimeChange: 2.525
----------
PositionChange: 0
TimeChange: 8.8985
----------
PositionChange: 0
TimeChange: 7.632167
----------
Code: Select all
phidget main % pip3 show Phidget22
Name: Phidget22
Version: 1.17.20230824
Summary: Phidget22 Python wrapper library
Home-page: http://www.phidgets.com
Author: Phidgets Inc
Author-email: support@phidgets.com
License: MIT
Location: /opt/homebrew/lib/python3.11/site-packages
Requires:
Required-by:
phidget main % python3 encoder-1047-sample.py
PositionChange: 0
TimeChange: 0.0
----------
PositionChange: 0
TimeChange: 7.628333
----------
PositionChange: 0
TimeChange: 8.898
----------
phidget main % python3 encoder-1047-sample.py
PositionChange: 0
TimeChange: 0.0
----------
PositionChange: 0
TimeChange: 8.897333
----------
PositionChange: 0
TimeChange: 7.636167
----------
phidget main % python3 encoder-1047-sample.py
PositionChange: 0
TimeChange: 0.0
----------
PositionChange: 0
TimeChange: 7.625167
----------
PositionChange: 0
TimeChange: 8.897667
----------
Code: Select all
from Phidget22.Phidget import *
from Phidget22.Devices.Encoder import *
import time
import json
serial_numbers = json.load(open('phidget-serial-numbers.json'))
encoder_1047_serial_number = serial_numbers['encoder_1047']
samples = 0
max_samples = 3
def onPositionChange(self, positionChange, timeChange, indexTriggered):
global samples
if samples < max_samples:
print("PositionChange: " + str(positionChange))
print("TimeChange: " + str(timeChange))
print("----------")
samples += 1
def main():
print()
en0 = Encoder()
en0.setDeviceSerialNumber(encoder_1047_serial_number)
en0.openWaitForAttachment(5000)
en0.setDataRate(125)
en0.setOnPositionChangeHandler(onPositionChange)
while samples < max_samples:
pass
en0.close()
print()
main()
Code: Select all
{
"vint": 538832,
"encoder_1047": 699896
}