USB
¶
-
class
pybpod_rotaryencoder_module.module_api.
RotaryEncoderModule
(serialport=None)[source]¶ Constructor of the RotaryEncoderModule object A serial connection to the Rotary Encoder board is opened at the construction of the object.
Variables: serialport (str) – PC serial port where the module is connected -
open
(serialport)[source]¶ Opens a serial connection to the Rotary Encoder board.
Variables: serialport (str) – PC serial port where the module is connected
-
enable_evt_transmission
()[source]¶ Enables the transmission of threshold crossing events to the Bpod state machine.
-
enable_module_outputstream
()[source]¶ Enables the streaming of current position data directly to another Bpod module (e.g. DDS, AnalogOutput).
-
disable_module_outputstream
()[source]¶ Disables the streaming of current position data directly to another Bpod module.
-
enable_stream
()[source]¶ Enables the streaming of the position and the time measurements to the USB port.
-
disable_stream
()[source]¶ Disables the streaming of the position and the time measurements to the USB port.
-
set_position
(degrees)[source]¶ Sets the current position in degrees.
Variables: degrees (int) – current position in degrees.
-
enable_thresholds
(thresholds)[source]¶ Enables the thresholds.
Variables: thresholds (list(boolean)) – list of 6 booleans indicating which thresholds are active to trigger events.
-
set_prefix
(prefix)[source]¶ Sets 1-character prefix for module output stream.
Variables: prefix (char) – One character to be used as prefix.
-
Usage example¶
from pybpod_rotaryencoder_module.module_api import RotaryEncoderModule
m = RotaryEncoderModule('/dev/ttyACM1')
m.start_logging()
m.enable_stream()
#print the first 100 outputs
count = 0
while count<100:
data = m.read_stream()
if len(data)==0:
continue
else:
count += 1
print(data)
m.disable_stream()
m.stop_logging()
m.set_zero_position()
m.close()