Stops the watchdog timer.

Namespace:  Quanser.Hardware
Assembly:  Quanser.Hardware.Hil (in Quanser.Hardware.Hil.dll)

Syntax

Visual Basic (Declaration)
Public Sub WatchdogStop
C#
public void WatchdogStop()
Visual C++
public:
void WatchdogStop()
JavaScript
function watchdogStop();

Remarks

The WatchdogStop method stops the watchdog timer. The watchdog timer will no longer expire so the WatchdogReload()()() method need no longer be called. Stopping the watchdog timer does not clear the watchdog state if the watchdog has already expired. Use the WatchdogClear()()() method for this purpose.

Examples

This example configures a watchdog timer that will expire every 0.1 seconds and reset the analog outputs to 0V and the digital outputs to tristate upon expiration. Also create a task for performing real-time control that reads four encoder channels every millisecond. The watchdog is reloaded every sampling instant. Exceptions are ignored for simplicity.
C# Copy Code
int [] encoderChannels = { 0, 1, 2, 3 };
double frequency       = 1000;
int    samples         = 5000;
int    samplesInBuffer = frequency;
int    samplesToRead   = 1;
double timeout         = 0.1;
int    index;

int []              counts          = new int [samplesToRead * encoderChannels.Length];
int []              digitalChannels = new int [16];
Hil.DigitalState [] digitalStates   = new Hil.DigitalState [digitalChannels.Length];
int []              analogChannels  = new int [4];
double []           analogStates    = new double [analogChannels.Length];

Hil.Task task;

for (index = 0; index < analogChannels.Length; index++) {
    analogChannels[index] = index;
    analogStates[index] = 0;
}
for (index = 0; index < digitalChannels.Length; index++) {
    digitalChannels[index] = index;
    digitalStates[index] = Hil.DigitalState.Tristate;
}

card.WatchdogSetAnalogExpirationState(analogChannels, analogStates);
card.WatchdogSetDigitalExpirationState(digitalChannels, digitalStates);

task = card.TaskCreateEncoderReader(samplesInBuffer, channels);

card.WatchdogStart(timeout);
task.Start(Hil.Clock.Hardware0, frequency, samples);
for (int index = 0; index < samples; index += samplesToRead) {
    /* 
        Block (if necessary) waiting for next samplesToRead samples.
        Returns every millisecond (since samplesToRead is 1 and frequency is 1000)
        with the next sample.
    */
    task.ReadEncoder(samplesToRead, buffer);

    /* Reload watchdog before using counts for control */
    card.WatchdogReload();

    /* ... do control calculations and output motor torques using WriteAnalog(array<Int32>[]()[], array<Double>[]()[]) ... */
}
task.Stop();
card.WatchdogStop();
Visual Basic Copy Code
Dim encoderChannels() As Integer = {0, 1, 2, 3}
Dim frequency As Double = 1000
Dim samples As Integer = 5000
Dim samplesInBuffer As Integer = frequency
Dim samplesToRead As Integer = 1
Dim timeout As Double = 0.1
Dim index As Integer

Dim counts(samplesToRead * encoderChannels.Length - 1) As Integer
Dim digitalChannels(15) As Integer
Dim digitalStates(digitalChannels.Length - 1) As Hil.DigitalState
Dim analogChannels(4) As Integer
Dim analogStates(analogChannels.Length - 1) As Double

Hil.Task task

For index = 0 To analogChannels.Length
    analogChannels(index) = index
    analogStates(index) = 0
Next
For index = 0 To digitalChannels.Length
    digitalChannels(index) = index
    digitalStates(index) = Hil.DigitalState.Tristate
Next

card.WatchdogSetAnalogExpirationState(analogChannels, analogStates)
card.WatchdogSetDigitalExpirationState(digitalChannels, digitalStates)

task = card.TaskCreateEncoderReader(samplesInBuffer, channels)

card.WatchdogStart(timeout)
task.Start(Hil.Clock.Hardware0, frequency, samples)
For index = 0 To samples Step samplesToRead
    ' Block (if necessary) waiting for next samplesToRead samples.
    ' Returns every millisecond (since samplesToRead is 1 and frequency is 1000)
    ' with the next sample.
    task.ReadEncoder(samplesToRead, buffer)

    ' Reload watchdog before using counts for control
    card.WatchdogReload()

    ' ... do control calculations and output motor torques using WriteAnalog(array<Int32>[]()[], array<Double>[]()[]) ...
Next
task.Stop()
card.WatchdogStop()
Visual C++ Copy Code
array<int>^ encoderChannels = { 0, 1, 2, 3 };
double     frequency       = 1000;
int        samples         = 5000;
int        samplesInBuffer = frequency;
int        samplesToRead   = 1;
double     timeout         = 0.1;
int        index;

array<int>^               counts          = gcnew array<int>(samplesToRead * encoderChannels->Length);
array<int>^               digitalChannels = gcnew array<int>(16);
array<Hil::DigitalState>^ digitalStates   = gcnew array<Hil::DigitalState>(digitalChannels->Length);
array<int>^               analogChannels  = gcnew array<int>(4);
array<double>^            analogStates    = gcnew array<double>(analogChannels->Length);

Hil::Task^ task;

for (index = 0; index < analogChannels->Length; index++) {
    analogChannels[index] = index;
    analogStates[index] = 0;
}
for (index = 0; index < digitalChannels->Length; index++) {
    digitalChannels[index] = index;
    digitalStates[index] = Hil::DigitalState::Tristate;
}

card->WatchdogSetAnalogExpirationState(analogChannels, analogStates);
card->WatchdogSetDigitalExpirationState(digitalChannels, digitalStates);

task = card->TaskCreateEncoderReader(samplesInBuffer, channels);

card->WatchdogStart(timeout);
task->Start(Hil::Clock::Hardware0, frequency, samples);
for (int index = 0; index < samples; index += samplesToRead) {
    /* 
        Block (if necessary) waiting for next samplesToRead samples.
        Returns every millisecond (since samplesToRead is 1 and frequency is 1000)
        with the next sample.
    */
    task->ReadEncoder(samplesToRead, buffer);

    /* Reload watchdog before using counts for control */
    card->WatchdogReload();

    /* ... do control calculations and output motor torques using WriteAnalog(array<Int32>[]()[], array<Double>[]()[]) ... */
}
task->Stop();
card->WatchdogStop();

Exceptions

ExceptionCondition
Quanser.Hardware..::.HilException If the watchdog cannot be stopped then an exception is thrown. This situtation typically arises if the board does not support a watchdog timer, or the hardware resources required are in use by a task.

See Also