Skip to content

3. Documentation

AlexLM96 edited this page Dec 1, 2022 · 3 revisions

Overview of FORCE2 library code

FORCE2 source code is written in C++ (examples are written in Arduino). The main goal of the library is to provide the essential definitions and functions to create highly flexible behavioral paradigms. Broadly, the definitions and functions are divided into four parts: Lever, Dispensing, Logging, and Trial. Here is a brief description of each part. A comprehensive description and documentation of these variables and functions can be found in the API.

Trial

Functions and variables that control multiple aspects of the trial. These are the most customizable and relevant for the end user. Here are some examples of variables that may be modified:

  1. force.reqLeft : Minimum force required on the left lever for a successful left press.
  2. force.trial_window : Time after the center poke in which a trial is available (i.e. levers are sensing and mice can get a reward)

Lever

These functions configure the basic functionality of the FORCE2 levers, such as calibration, taring and sensing.

Dispensing

Functions that control the liquid dispensing, priming the syringe and flushing the liquid for cleaning. Customizable variables include the amount of liquid being dispensed.

Logging

Functions to log data to the SD card. Currently (12/1/22) neither the licking data nor the force press profile are being logged. This will change in future updates. Here is an example of what the .csv file looks like: [INSERT IMAGE]

Tutorial

In this tutorial we will replicate the example Fixed_Ratio example from scratch and then we will costumize it.

How-to Guides

API

Pin definitions

Name Pin id (Adafruit M4 express) Hardware
TFT_RST -1 () TFT display shield
TFT_CS 5 () TFT display shield
TFT_DC 6 () TFT display shield
DOUT1 13 (D3) Left load cell output
CLK1 12 (D12) Left load cell clock
LICKOMETER1 15 (A1) Left lickometer
PUMP1 4 (D4) Left pump
DOUT2 13 (D3) Right load cell output
CLK2 12 (D12) Right load cell clock
LICKOMETER2 15 (A1) Right lickometer
PUMP2 4 (D4) Right pump
POKE 17 (A3) Nosepoke
BEEPER 19 (A5) Beeper

Core Functions

Setup Functions

  • begin(): Initializes all pins, loads the settings, creates new data file, and initializes the levers.
  • run(): Senses the levers, updates the display with lever and trial values. If log_data is true, it logs data to the SD card.
  • readPoke(): Checks whether the nosepoke has been activated.

Trial functions

Lever functions

Dispensing functions

  • DispenseLeft(): Opens the left pump to dispense a drop of liquid.
  • DispenseRight(): Opens the right pump to dispense a drop of liquid.
  • check_lastDispense() :

Logging functions

Core variables

  • int trial_window: Time window (in milliseconds) after the nosepoke in which a trial can be completed
  • int trial_start: Time of nosepoke activation
  • int trial_length: Time since nosepoke activation
  • int reqLeft: Force requirement for a successful trial (left lever)
  • int reqRight: Force requirement for a successful trial (right lever)
  • int ratioLeft: Number of presses required for a successful trial (left lever)
  • int ratioRight: Number of presses required for a successful trial (right lever)
  • int hold_timeLeft: Required holding time (of lever press) for a successful trial (left lever)
  • int hold_timeRight: Required holding time (of lever press) for a successful trial (right lever)
  • int pressLengthLeft: Current uninterrupted lever holding time (updated by SenseLeft(), left lever)
  • int pressLengthRight: Current uninterrupted lever holding time (updated by SenseRight(), right lever)