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
close()[source]

Closes the serial connection to the Rotary Encoder board.

enable_evt_transmission()[source]

Enables the transmission of threshold crossing events to the Bpod state machine.

disable_evt_transmission()[source]

Disables the transmission of events.

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.

read_stream()[source]

Reads the data being streamed through the USB port.

current_position()[source]

Retrieves the current position.

set_zero_position()[source]

Sets current rotary encoder position to zero.

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.
enable_logging()[source]

Enables the logging to the SD Card.

disable_logging()[source]

Disables the logging to the SD Card.

get_logged_data()[source]

Retrieves the logged data in the SD Card.

set_prefix(prefix)[source]

Sets 1-character prefix for module output stream.

Variables:prefix (char) – One character to be used as prefix.
set_thresholds(thresholds)[source]

Sets the thresholds values to trigger the events.

Variables:thresholds (list(int)) – List, in maximum, of 6 thresholds to trigger events.
set_wrappoint(wrap_point)[source]

Sets wrap point (number of tics in a half-rotation)

Variables:wrap_point (int) – number of tics in a half-rotation.

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()