periodically to reset the watchdog timer.
Timeout of the watchdog on the U3 can be specified to cause a device reset, update the state of 1 digital I/O (must be configured
as output by user), or both.
Typical usage of the watchdog is to configure the reset defaults (condition of digital I/O and analog outputs) as desired (use the
“config defaults” option in LJControlPanel V2.26+), and then use the watchdog simply to reset the device on timeout. For initial
testing, “config defaults” in LJCP can be used to enable the watchdog all the time, but often it is desirable to enable/disable the
watchdog in user software so it is only active while that software is running.
Note that some USB hubs do not like to have any USB device repeatedly reset. With such hubs, the operating system will quit
reenumerating the device on reset and the computer will have to be rebooted, so avoid excessive resets with hubs that seem to
have this problem.
If the watchdog is accidentally configured to reset the processor with a very low timeout period (such as 1 second), it could be
difficult to establish any communication with the device. In such a case, the reset-to-default jumper can be used to turn off the
watchdog. Power up the U3 with a short from FIO6 to SPC (FIO2 to SCL on U3 1.20/1.21), then remove the jumper and power
cycle the device again. This resets all power-up settings to factory default values.
There is one IOType used to configure and control the watchdog:
LJ_ioSWDT_CONFIG // Channel is enable or disable constant.
The watchdog settings are stored in non-volatile flash memory (and reloaded at reset), so every request with this IOType causes a
flash erase/write. The flash has a rated endurance of at least 20000 writes, which is plenty for reasonable operation, but if this
IOType is called in a high-speed loop the flash could be damaged.
The following are special channels used with the watchdog config IOType above:
LJ_chSWDT_ENABLE // Value is timeout in seconds (1-65535).
LJ_chSWDT_DISABLE
The following are special channels, used with the put config IOType, to configure watchdog options. These parameters cause
settings to be updated in the driver only. The settings are not actually sent to the hardware until the LJ_ioSWDT_CONFIG IOType
(above) is used:
LJ_chSWDT_RESET_DEVICE
LJ_chSWDT_UDPATE_DIOA
LJ_chSWDT_DIOA_CHANNEL
LJ_chSWDT_DIOA_STATE
Following is example pseudocode to configure and enable the watchdog:
//Initialize EIO2 to output-low, which also forces the direction to output.
//It would probably be better to do this by configuring the power-up defaults.
AddRequest(lngHandle, LJ_ioPUT_DIGITAL_BIT, 10,0,0,0);
//Specify that the device should be reset on timeout.
AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSWDT_RESET_DEVICE,1,0,0);
//Specify that the state of the digital line should be updated on timeout.
AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSWDT_UDPATE_DIOA,1,0,0);
//Specify that EIO2 is the desired digital line.
AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSWDT_DIOA_CHANNEL,10,0,0);
//Specify that the digital line should be set high.
AddRequest(lngHandle, LJ_ioPUT_CONFIG, LJ_chSWDT_DIOA_STATE,1,0,0);
//Enable the watchdog with a 60 second timeout.
AddRequest(lngHandle, LJ_ioSWDT_CONFIG, LJ_chSWDT_ENABLE,60,0,0);
//Execute the requests.
GoOne(lngHandle);
Following is pseudocode to disable the watchdog:
//Disable the watchdog.
ePut(lngHandle, LJ_ioSWDT_CONFIG, LJ_chSWDT_DISABLE,0,0);
4.3.14 - Miscellaneous
The following are special channels, used with the get/put config IOTypes, to read/write the calibration memory and user memory:
LJ_chCAL_CONSTANTS // x1 points to an array with 64 doubles.
LJ_chUSER_MEM // x1 points to an array with 256 bytes.
For more information, see the low-level descriptions in Sections 5.2.6 – 5.2.8, and see the Memory example in the VC6_LJUD
archive.
The following wait IOType is used to create a delay between other actions:
LJ_ioPUT_WAIT // Channel ignored. Value = 0-4194176 microseconds.
Any value (in microseconds) from 0-4194176 can be passed, but the actual resolution is 128 microseconds (U3C = 128 us, U3B =
64 us, U3A = 128 us).
This is typically used to put a small delay between two actions that will execute in the same low-level Feedback command. It is
useful when the desired delay is less than what can be accomplished through software.
For example, a 1.024 millisecond pulse can be created by executing a single Add/Go/Get block that sequentially requests to set
FIO4 to output-high, wait 1024 microseconds, then set FIO4 to output-low.
4.4 - Errorcodes
All functions return an LJ_ERROR errorcode as listed in the following tables.
41