Hi Chris,
I’m a first-year PhD student in the JazLab designing an MWorks experiment that interfaces with an incremental rotary encoder. I’m currently calculating the angle of the rotary encoder’s shaft using an Arduino Uno, and then I send the measured angle from the board to MWorks using pySerial. I’ve currently made an implementation of a simplified task that seems to work pretty well, where the position of a stimulus is set by the angle of the encoder. However, whenever I arbitrarily stop the protocol (i.e., by hitting the red “X” button or closing the MWClient window) and subsequently reload the protocol, the rendered stimulus will “glitch” at seemingly random times. The position of the stimulus is set directly by the angle of the encoder shaft, so I suspect that there’s an issue with clean-up actions of reading from the serial connection.
When I hit the green “pause” button and then resume the protocol by hitting “play",” no glitching is induced. The glitching also goes away if I kill the MWServer and MWClient applications and then restart them.
Do you have any suggestions on how to fix this glitching behavior? I’ve attached my Python code that reads from my rotary encoder (rotary_read.py), a template MWEL file I’ve modified to run my “Rotate Circle” protocol (main_mworks.mwel), and a google drive link with two videos that show the rendering at the first time I load it (“good_rotary”) and at the second time after I hit the red button (“bad_rotary”). Let me know if you would like the Arduino code too.
Thank you,
Nikasha
main_mworks.mwel (5.6 KB)
rotary_read.py (6.0 KB)
System Information:
- MacOS Sonoma 14.5
- Macbook Pro, 16-inch, 2019
- MWorks version 0.13
- Python version 3.11.3
- Arduino UNO