---
title: "Versatile"
canonical: "https://docs.cuesystem.com/space/CVCDD/439877691/Versatile"
format: markdown
---
> Macro (toc)

---

# Description

![image](media://b8e7473c-8bfa-4793-9f01-fcaa5ec52df5)

# Functions

## Close

This function closes the output pin to the ground by the internal transistor. The function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function Close () As Boolean
```

## ClosePulse

This function closes the output pin to the ground for the specified time pulsetime. The function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function ClosePulse (pulsetime As Time) As Boolean
```

## GetDigitalLeadingEdgeAppeared

The function returns an appearance of a leading edge on a channel. It returns True if since the last call to this command the input has been ever in active level (the leading edge appeared), False otherwise. If this command has not been called yet, then the starting point is the beginning of the digital measurement. The digital signal measurement must be activated before with the function StartDigitalSignalMeasurement.

#### Syntax

```visualbasic
Function GetDigitalLeadingEdgeAppeared () As Boolean
```

## GetDigitalLevel

The function returns True if an input is in active level or False otherwise. The digital signal measurement must be activated before with function StartDigitalSignalMeasurement.

#### Syntax

```visualbasic
Function GetDigitalLevel() As Boolean
```

## GetDigitalPulseCount

The function returns the number of transitions from an inactive to an active level on a channel. If clearpulsecount = True, then the counter resets and counts again. The maximum number of pulses is determined by the maximum positive value of Long numbers. The digital signal measurement must be activated before with function StartDigitalSignalMeasurement.

#### Syntax

```visualbasic
Function GetDigitalPulseCount(Optional clearpulsecount As Boolean := False) As Long
```

## GetResistance

The function returns the value (in Ohm) of resistance connected to versatile channel. The measurement of resistance must be activated before with function StartResistanceMeasurement.

#### Syntax

```visualbasic
Function GetResistance() As Double
```

## GetVoltage

This function returns current voltage (in Volt) of the signal pin of versatile channel. The measurement of voltage must be activated before with function StartVoltageMeasurement.

#### Syntax

```visualbasic
Function GetVoltage() As Double
```

## IsClosed

This function returns True, if the input pin is closed to the ground by internal transistor. It returns False if the internal transistor is opened.

#### Syntax

```visualbasic
Function IsClosed () As Boolean
```

## IsPullupOn

This function returns True if the internal pullup is ON and it returns False if the pullup is OFF.

#### Syntax

```visualbasic
Function IsPullupOn () As Boolean
```

## Open

The function opens the internal transistor. It is inverse function to Close (). It returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function Open () As Boolean
```

## PullupOff

This function switches the internal pullup OFF. It returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function PullupOff () As Boolean
```

## PullupOn

This function switches the internal pullup ON. It returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function PullupOn () As Boolean
```

## SetOutputState

The function sets complex output state of the channel with optional interruption of the currently running program. Parameter outputstate (data type _VersatileOutputState structure) defines the output value of channel. It is possible individually set up all three of the active elements of the output channel, i.e. Close, Pullup and Pulldown switches. For each of the switches can be defined, whether it should be closed, open or left in the current state. See CVC Help, _VersatileOutputState Structure and VersatileOutputControl Enum for more details.

If optional parameter stopoutputprogram is True, it interrupts currently running program. If False currently running program is not affected.

Function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function SetOutputState(outputstate As _VersatileOutputState, Optional stopoutputprogram As Boolean := True) As Boolean
```

## StartDigitalSignalMeasurement

The function switches the channel to digital input mode and pulse counter. Only in this mode, commands GetDigitalLeadingEdgeAppeared, GetDigitalLevel, GetDigitalPulseCount, WaitForDigitalLeadingEdge, WaitWhileDigitalLevelActive, work.

Optional parameter samplingperiod is a time delay between individual measurement samples. Recommended sampling period depends on the rate of change of the input signal. Sampling period should be at least 2 times shorter than the fastest input signal change.

Optional parameter threshold determines the decision level (threshold) of the input circuit. Predefined ranges are available as _DigitalThreshold Enum values. It is possible to use a threshold 1.5 V (enum _DigitalThreshold.V_1_5 := 1), or or 6 V (enum _DigitalThreshold.V_6 := 2).

Optional parameter activelevel determines if the active level on a channel is higher or lower then threshold voltage. This affects the behavior of commands GetDigitalLeadingEdgeAppeared, WaitForDigitalLeadingEdge, WaitForDigitalLeadingEdge and GetDigitalPulseCount. Predefined constants for parameter activelevel are as follows:

- _DIGITAL_LEVEL_HIGH := True, active level is above threshold voltage.
- _DIGITAL_LEVEL_LOW := False, active level is below threshold voltage.

Optional parameter filter affects the filtering of the measuring channel. It can be set in the range 0-16. Value 0 means do not filter, 16 is the maximum filtration. A higher value means a more stable result of filtration, but slower response to fast changes on the input. Level of filtration affects the number of sampling periods, for which there is a steady response to a step change in the input signal. Function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function StartDigitalSignalMeasurement( Optional samplingperiod As Time := :0.01, Optional threshold As Long := _DigitalThreshold.V_6, Optional activelevel As Boolean := _DIGITAL_LEVEL_HIGH, Optional filter As Long := 3) As Boolean
```

## StartResistanceMeasurement

The function switches the channel to the resistance measurement mode. In order to execute commands based on resistance measurements, the input of the channel must be in this mode. This function affects the output of the channel - turns off the output section. The measuring range is 0-200KΩ. Available ranges are 0-2 KΩ, 0-20 KΩ, 0-200 KΩ. For resistance measurement the channel is equipped with automatic range switching.

Optional parameter samplingperiod is a time delay between individual measurement samples. Recommended sampling period depends on the rate of change of the measured resistance. Sampling period should be at least 10 times shorter than the period of the change of the resistance.

Optional parameter range affects the measuring range. Predefined ranges are available as _ResistanceRange Enum values. It is possible to use a range of 0 - 2 KΩ (enum _ResistanceRange.R_2K := 1), 0 - 20 KΩ (enum _ResistanceRange.R_20K := 2), 0 - 200 KΩ (enum _ResistanceRange.R_200K := 3) or automatic range switching according to the value of the measured resistance (enum _ResistanceRange.Auto := 0).

Optional parameter filter affects the filtering of the measuring channel. It can be set in the range 0-16. Value 0 means do not filter, 16 is the maximum filtration. A higher value means a more stable result of filtration, but slower response to fast changes on the input. Level of filtration affects the number of sampling periods, for which there is a steady response to a step change in the measured value.

Function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function StartResistanceMeasurement(Optional samplingperiod As Time := :0.1, Optional range As Long := _ResistanceRange.Auto, Optional filter As Long := 8) As Boolean
```

## StartVoltageMeasurement

The function switches the channel to the voltage measurement mode. In order to execute commands based on voltage measurement, the input of the channel must be in this mode. It does not affect the output of the channel. This is the default mode.

The measuring range is 0 - 10 V. For voltage measurement the channel is equipped with automatic range switching. When measuring voltage above 2.5 V an input voltage divider is used.

Optional parameter samplingperiod is a time delay between individual measurement samples. Recommended sampling period depends on the rate of change of the input signal. Sampling period should be at least 10 times shorter than the period of the input signal.

Optional parameter range affects the measuring range. Predefined ranges are available as _VoltageRange Enum values. It is possible to use a range of 0 - 2.5 V (enum _VoltageRange.V_2_5 := 1), 0 - 10 V (enum _VoltageRange.V_10 := 2) or automatic range switching according to the magnitude of the input signal (enum _VoltageRange.Auto := 0).

Optional parameter filter affects the filtering of the measuring channel. It can be set in the range 0-16. Value 0 means do not filter, 16 is the maximum filtration. A higher value means a more stable result of filtration, but slower response to fast changes on the input. Level of filtration affects the number of sampling periods, for which there is a steady response to a step change in the input signal.

Function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function StartVoltageMeasurement(Optional samplingperiod As Time := :0.01, Optional range As Long := _VoltageRange.Auto, Optional filter As Long := 9) As Boolean
```

## WaitForDigitalLeadingEdge

The function waits for leading edge on the channel and until the timeout elapsed. Leading edge is the transition from the inactive to the active level. The digital signal measurement must be activated before with function StartDigitalSignalMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the leading edge appeared. If this happens the memory for the appearance of leading edge is erased. Function returns False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitForDigitalLeadingEdge(Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileDigitalLevelActive

The function waits while the input signal on the channel is in the active level and until the timeout elapsed. The digital signal measurement must be activated before with function StartDigitalSignalMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the function is finished before timeout has passed. It returns False when time elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileDigitalLevelActive(Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileResistanceAbove

The function waits while the measured value lies above resistance and until the timeout elapsed. The measurement of resistance must be activated before with function StartResistanceMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes below resistance. It returns False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileResistanceAbove( resistance As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileResistanceBelow

The function waits while the measured value lies below resistance and until the timeout elapsed. The measurement of resistance must be activated before with function StartResistanceMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes above resistance. It is False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileResistanceBelow( resistance As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileResistanceInRange

The function waits while the measured value lies within resistance1 and resistance2 levels and until the timeout elapsed. The measurement of resistance must be activated before with function StartResistanceMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes outside range resistance1 to resistance2. It is False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileResistanceInRange( resistance1 As Double, resistance2 As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileVoltageAbove

The function waits while the measured value lies above voltage and until the timeout elapsed. The measurement of voltage must be activated before with function StartVoltageMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes below voltage. It returns False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileVoltageAbove( voltage As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileVoltageBelow

The function waits while the measured value lies below voltage and until the timeout elapsed. The measurement of voltage must be activated before with function StartVoltageMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes above voltage. It returns False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileVoltageBelow( voltage As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

## WaitWhileVoltageInRange

The function waits while the measured value lies within voltage1 and voltage2 levels and until the timeout elapsed. The measurement of voltage must be activated before with function StartVoltageMeasurement.

Optional parameter timeout, defaults to _TIME_INFINITE, is time to wait.

Function returns True if the measured value goes outside range voltage1 to voltage2. It is False when timeout elapsed or if an error occurs.

#### Syntax

```visualbasic
Function WaitWhileVoltageInRange( voltage1 As Double, voltage2 As Double, Optional timeout As Time := _TIME_INFINITE) As Boolean
```