# -------------------------------------------------------------------
#  Config file for the "rawlog-grabber" application
# Read more online: 
# http://www.mrpt.org/list-of-mrpt-apps/application-rawlog-grabber/
# -------------------------------------------------------------------

#  Each section [XXXXX] (but [global]) setups a thread in the RawLogGrabber 
#   standalone application. Each thread collects data from some
#   sensor or device, then the main thread groups and orders them before
#   streaming everything to a rawlog file.
#
#  The name of the sections will become the sensor label. The driver for
#   each sensor is actually determined by the field "driver", which must
#   match the name of some class in HWDRIVERS implementing CGenericSensor.


# =======================================================
#  Section: Global settings to the application
#  =======================================================
[global]
# The prefix can contain a relative or absolute path.
# The final name will be <PREFIX>_date_time.rawlog
rawlog_prefix		= ./datalog_daq

# Milliseconds between thread launches
time_between_launches	= 1000

use_sensoryframes	= 0
GRABBER_PERIOD_MS	= 1000


# =======================================================
#  NIDAQ Board
# =======================================================
[NIDAQ_BOARD]
driver			= CNationalInstrumentsDAQ
process_rate	= 1000	// Hz

# Number of tasks (each will run in a thread). Task indices are 0-based.
# (Parameters below follow NI's DAQmx API notation)
num_tasks  = 2

# Channels, separated by commas if more than one.
#  - "ai": Analog inputs
#  - "ao": Analog outputs
#  - "di": Digital inputs
#  - "do": Digital inputs
#  - "ci_period", 
#    "ci_count_edges", "ci_pulse_width",
#    "ci_lin_encoder", "ci_ang_encoder" : Counters & encoders (WARNING: NI says "a task can include only one counter input channel")
#  - "co_pulses": Output digital pulses (WARNING: NI says "a task can include only one counter output channel")
#

# TASK 0
task0.channels = ai
task0.samplesPerSecond = 1000         // Samples per second. Continuous (infinite) sampling is assumed.
task0.samplesPerChannelToRead = 1000  // The number of samples to grab at once from each channel.
#task0.bufferSamplesPerChannel = 200000 // Increase if you have errors about " Onboard device memory overflow.(...)"

#Source of the sample clock (only if needed)
# task0.sampleClkSource = /Dev1/OnboardClock


# Analog input channel params. 
task0.ai.physicalChannel = Dev1/ai0
task0.ai.physicalChannelCount = 1  // *IMPORTANT* This must be the total number of channels listed in "physicalChannel" (e.g. 4 for "Dev1/ai0:3")
task0.ai.terminalConfig  = DAQmx_Val_RSE // DAQmx_Val_Cfg_Default | DAQmx_Val_RSE | DAQmx_Val_NRSE | DAQmx_Val_Diff   // One of these strings
task0.ai.minVal          = -10.0    // Volts
task0.ai.maxVal          =  10.0    // Volts

# TASK 1
task1.channels = ci_ang_encoder
task1.samplesPerSecond = 1000         // Samples per second. Continuous (infinite) sampling is assumed.
task1.samplesPerChannelToRead = 1  // The number of samples to grab at once from each channel.
#task1.bufferSamplesPerChannel = 200000 // Increase if you have errors about " Onboard device memory overflow.(...)"

#Source of the sample clock
task1.sampleClkSource = /Dev1/PFI0

# Counter:  uses an angular encoder to measure angular position
task1.ci_ang_encoder.counter      = Dev1/ctr0
task1.ci_ang_encoder.decodingType = DAQmx_Val_X4   // DAQmx_Val_X1 | DAQmx_Val_X2 | DAQmx_Val_X4 | DAQmx_Val_TwoPulseCounting // One of these strings
task1.ci_ang_encoder.ZidxEnable   = false //  enable z indexing
task1.ci_ang_encoder.ZidxVal      = 0 // The value, in units, to which to reset the measurement when signal Z is high and signal A and signal B are at the states you specify with ZidxPhase.
task1.ci_ang_encoder.ZidxPhase    = DAQmx_Val_ALowBLow // DAQmx_Val_AHighBHigh | DAQmx_Val_AHighBLow | DAQmx_Val_ALowBHigh | DAQmx_Val_ALowBLow  // One of these strings
task1.ci_ang_encoder.units        = DAQmx_Val_Degrees // DAQmx_Val_Degrees | DAQmx_Val_Radians | DAQmx_Val_Ticks  // One of these strings
task1.ci_ang_encoder.pulsesPerRev = 1024  // The number of pulses the encoder generates per revolution. 
task1.ci_ang_encoder.initialAngle = 0.0 // The position of the encoder when the measurement begins. This value is in units.



