Skip to content

Code for rotary encoded wheels / tracking

License

Notifications You must be signed in to change notification settings

kavli-ntnu/wheel_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wheel tracker

Documentation for behavioral wheel used for head fixed in vivo recordings. It enables precise recordings of wheel movement and enforced motion via a stepper motor. The motor is coupled to the main axle via a one-way clutch. This way the animal can always outrun the (slower) motor movement, but is blocked from running backwards. Two microcontrollers are used, one for recording the wheel motion, one as stepper motor driver. This wheel is currently in use at both the femtonics as well as the miniscope setup.

alt text

Main assembly

The wheel is made from black foam and has a radius of 85mm and a width of 70mm. Larger diameters can be chosen if needed.

  • Customized aluminium parts: STEP files | Drawings
  • Thorlabs posts like RS2.5P/M - Ø25.0 mm Pedestal Pillar Post, M6 Taps, L = 65 mm (this is the minimum height for wheel radius 85 mm)
  • Thorlabs breadboard (e.g. MB3030/M)
  • One way clutch: HF0612 KULELAGER AS, Molde, NO (post@kulelager24.no)
  • Bearing: HK 0608 KULELAGER AS, Molde, NO
  • Shaft coupler 6 mm inner diameter (similar to this) to couple rotary encoder shaft and main axle of wheel
  • GT2 timing belt pulley (this one has to be enlarged to fit bearings)
  • GT2 timing belt

Rotary encoder and photo interrupter (microcontroller 1)

A YUMO Rotary Encoder (model E6B2-CWZ3E, see datasheet) connected to a teensy 3.5 is used to digitize the wheel motion. A t-slot photo interruper is used to record 360 degree turns.

Recording starts upon rising edge detection on frameclock_pin and stops when there was no signal on this pin for > 500 ms (adjustable, see code). This event and the detection of a beam break (photo interrupter) are detected as hardware interrupts on the teensy and sent over to the recording computer via USB serial (see section Recorder below) in 20 ms intervals (interval_). Before and after data is sent via serial the sync pin is switched, which can be used to record when communication happened (the delay between measurement of wheel position and initiation of data transfer is assumed to be negligible). This sync pin is connected to an event recorder (femtonics digital in or else). The teensy also registers user button presses (button_pin) and sends out a HIGH on motor_enable_pin to microcontroller 2 (see below) over a certain interval (interval_motor_). During this time a 1 will be sent over for entry Motor (see serial data below).

There is also arduino code for just the rotary encoder (code teensy3.5) in isolation (no motor + button interaction).

Several versions of ´only_rotary_teensy*´ are provided for various synchronisation setups:

  • only_rotary_teensy_btn : replacing the measurement input signal from an external recorder, a button attached to the arduino is used to start/stop recording manually
  • only_rotary_teensy_dtr : recording happens while an active serial connection is maintained, i.e. begins automatically whenever the listening Python script is started
  • only_rotary_teensy_prtc : the frame clock output pin is replaced by a pseudo-random timecode input. Whenever an input TTL is receieved, an additional output signal is sent over usb-serial declaring the timestamp (ms accuracy) at which the ttl was recieved. Can be used for post-processing alignment to the standard sync method in use for Neuropixels in the Moser group.

Motor (microcontroller 2)

For motor control a NEMA17 stepper motor is used, controlled by uStepper board, running a acceleration/deceleration protocol over defined number of steps. The stepper motor driver gets triggered by the Teensy 3.5 when a button is pressed.

Serial

Data is recorded via USB connection to the teensy (see save_tracking.py). It arrives in the form "Position_Interruped_InterruptedPosition_Motor", where Position is the integer rotary encoder position, Interrupted is either 0 or 1 for when a beam break was detected, InterruptedPosition is the integer position at the time when the beam was interrupted, Motor is either 0 or 1 for the times when the user pressed the button.

Camera

For behavioral recording this setup is paired with a fast camera that tracks the animal's movements on the wheel. The camera sends a HIGH during exposure which can be logged with an event recorder as for the teensy pulses (see above).

About

Code for rotary encoded wheels / tracking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published