# FilePretrig()

Scan a range of channels continuously while waiting for a trigger.

Once the trigger occurs, FilePretrig() returns the specified number of samples, including the specified number of pre-trigger samples to a disk file. This method waits for a trigger signal to occur on the Trigger Input. Once the trigger occurs, it returns the specified number (TotalCount) of A/D samples, including the specified number of pre-trigger points. It collects the data at the specified sampling rate (rate) from the specified range (lowChan-highChan) of A/D channels from the specified board. If the A/D board has programmable gain then it sets the gain to the specified range. The collected data is returned to a file. See board specific info to determine if this method is supported by your board.

Member of the MccBoard class.

## Function Prototype

VB .NET

Public Function FilePretrig(ByVal lowChan As Integer, ByVal highChan As Integer, ByRef pretrigCount As Integer, ByRef totalCount As Integer, ByRef rate As Integer, ByVal range As MccDaq.Range, ByVal fileName As String, ByVal options As MccDaq.ScanOptions) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo FilePretrig(int lowChan, int highChan, ref int pretrigCount, ref int totalCount, ref int rate, MccDaq.Range range, string fileName, >MccDaq.ScanOptions options)

## Parameters

lowChan

First A/D channel of the scan.

highChan

Last A/D channel of the scan.

The maximum allowable channel depends on which type of A/D board is being used. For boards that have both single ended and differential inputs the maximum allowable channel number also depends on how the board is configured Refer to board–specific information for the maximum number of channels allowed in differential and single ended modes.

pretrigCount

Specifies the number of samples before the trigger that will be returned. PretrigCount must be less than 16000, and PretrigCount must also be less than TotalCount – 512.

If the trigger occurs too early, then fewer than the requested number of pre-trigger samples will be collected. In that case a TooFew error will occur. The PretrigCount will be set to indicate how many samples were collected and the post trigger samples will still be collected.

totalCount

Sets the total number of samples to be collected and stored in the file. totalCount must be greater than or equal to pretrigCount + 512.

If the trigger occurs too early, fewer than the requested number of samples will be collected and a TooFew error will occur. The totalCount will be set to indicate how many samples were actually collected.

rate

Sample rate in samples per second (Hz) per channel. The maximum sampling rate depends on the A/D board that is being used. This is the rate at which scans are triggered.

If you are sampling 4 channels, 0 – 3, then specifying a rate of 10,000 scans per second (10 kHz) will result in the A/D converter rate of 40 kHz: 4 channels at 10,000 samples per channel per second. This is different from some software, where you specify the total A/D chip rate. In those systems, the per channel rate is equal to the A/D rate divided by the number of channels in a scan. This parameter also returns the value of the actual set. This may be different from the requested rate because of pacer limitations.

range

If the selected A/D board does not have a programmable range feature, this parameter is ignored. Otherwise, set the Range parameter to any range that is supported by the selected A/D board. Refer to board–specific information for a list of the supported A/D ranges of each device.

fileName

The name of the file in which to store the data. If the file doesn't exist, it will be created.

options

Bit fields that control various options. Set it to one of the constants in the options parameter values section below.

## Returns

- An ErrorInfo object that indicates the status of the operation.
- preTrigCount – actual number of pre-trigger samples collected
- totalCount – actual number of samples collected
- rate – the actual sampling rate

### options parameter values

All of the options settings are MccDaq.ScanOptions enumerated constants. To set a variable to one of these constants, you must refer to the MccDaq object and the ScanOptions enumeration (for example, variable = MccDaq.ScanOptions.ExtClock or variable = MccDaq.ScanOptions.DtConnect).

ExtClock | If this option is used then conversions will be controlled by the signal on the trigger input line rather than by the internal pacer clock. Each conversion will be triggered on the appropriate edge of the trigger input signal (see board specific info). When this option is used the Rate parameter is ignored. The sampling rate is dependent on the trigger signal.
DtConnect | Samples are sent to the DT-Connect port if the board is equipped with one.

## Notes

- OverRun error - (Error code 29) This error indicates that the data was not written to the file as fast as the data was sampled. Consequently some data was lost. The value in TotalCount will be the number of points that were successfully collected.