Skip to content

Commit

Permalink
Updated rotary encoder docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAkam committed Jan 4, 2024
1 parent d5a2674 commit 191dbb1
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions docs/user-guide/hardware.md
Expand Up @@ -535,13 +535,13 @@ motor_2 = Stepper_motor(step_pin='X1', direction_pin='X2') # Instantiating drive

### Rotary encoder

Class for acquiring data from a rotary encoder, used e.g. to measure the speed of a running wheel. The encoder must be an incremental rotary encoder that outputs a quadrature signal. The rotary encoder class can stream the position or velocity of the encoder to the computer at a specified sampling rate, and generate framework events when the position/velocity goes above/below a specified threshold. Currently the rotary encoder class expects the two lines carrying the quadrature signal to be connected to MicroPython pins 'X1' and 'X2' (Port 1 DIO_A and DIO_B on breakout board 1.2).
Class for acquiring data from a rotary encoder, used e.g. to measure the speed of a running wheel. The encoder must be an incremental rotary encoder that outputs a quadrature signal. The rotary encoder class streams the position or velocity of the encoder to the computer at a specified sampling rate, and can generate framework events when the position/velocity goes above/below a specified threshold. Currently the rotary encoder class expects the two lines carrying the quadrature signal to be connected to MicroPython pins 'X1' and 'X2' (Port 1 DIO_A and DIO_B on breakout board 1.2).

The rotary encoder adaptor board connects an Avago HEDM-55xx series rotary encoder ([datasheet](https://docs.broadcom.com/docs/AV02-1046EN)) to a pyControl behaviour port. The rotary encoder adaptor must be plugged into port_1 on breakout board 1.2.

For an example task using a rotary encoder to measure running speed and trigger framework events when running starts and stops see [*running_wheel*](https://github.com/pyControl/code/blob/master/tasks/example/running_wheel.py).

Decoding the quadrature signal from the encoder is handled by dedicated low level routines on the pyboard microcontroller, so load on the microcontrollers is not affected by the rate of edges generated by the encoder. The maximum rate at which edges can be registered is not specified but given the dedicated processing hardware is unlikely to be limiting in behavioural applications. As with the `Analog_input` a maximum sampling rate of 1KHz is recommended as data is saved with ms resolution timestamps.
Decoding the quadrature signal from the encoder is handled by dedicated low level routines on the pyboard microcontroller, so load on the microcontrollers is not affected by the rate of edges generated by the encoder. The maximum rate at which edges can be registered is not specified but given the dedicated processing hardware is unlikely to be limiting in behavioural applications.

[GitHub](https://github.com/pyControl/hardware/tree/master/Rotary_encoder), [Open Ephys](https://open-ephys.org/pycontrol/pycontrol-peripherals), [LabMaker](https://www.labmaker.org/products/pycontrol-rotary-encoder)

Expand Down Expand Up @@ -571,12 +571,6 @@ class Rotary_encoder(name, sampling_rate, output='velocity', threshold=None,

`reverse` Set to *True* to reverse the direction of rotation which is considered a positive velocity.

*Methods:*

`Rotary_encoder.record()` Start streaming position/velocity measurements to computer. Data is saved in the same file format as data generated by [analog inputs](#analog-input).

`Rotary_encoder.stop()` Stop streaming data to computer. If rising or falling events are specified for the position of the encoder these will be generated regardless of whether or not the encoder is streaming data to the computer.

*Attributes:*

`Rotary_encoder.velocity` The current velocity of the encoder.
Expand All @@ -592,11 +586,9 @@ class Rotary_encoder(name, sampling_rate, output='velocity', threshold=None,
# 'running_start' and 'running_stop' when the speed goes above/below a threshold of
# 200 encoder counts/second.

running_wheel = Rotary_encoder(sampling_rate=100, output='velocity', threshold=200,
running_wheel = Rotary_encoder(name='running_wheel', sampling_rate=100, output='velocity', threshold=200,
rising_event='running_start', falling_event='running_stop')

running_wheel.record() # Start streaming running speed to computer.

current_speed = running_wheel.velocity # Get the current speed of the encoder.
```

Expand Down

0 comments on commit 191dbb1

Please sign in to comment.