this document best viewed at 1024x768 or higher resolution

LLABS USB Class
Member Functions
MyLL_USB
 
USB interface class for
--   For Win98/ME/2k/XP   --
download sample code and header files
download archive of all class documentation

Special note: Function calls that are followed by   "_SP" are designed for quick and simple (special) interface for a single device. Class member function calls of that type are designed to connect to the first device that is found and then apply all other functionality to that device. _SP style member functions provide a very simple way to develop when using a single device and none of our other USB type devices are connected.



 Constructor / Destructor

MyLL_USB::MyLL_USB();
MyLL_USB();

Creates a MyLL_USB object. You must call one of the forms of the Init function below before doing anything else with the object.

Use browser BACK button to return to where you were.





MyLL_USB::~MyLL_USB();
~MyLL_USB();

Destroys the object, frees all memory, and does any cleanup required when the MyLL_USB object is destroyed.

Use browser BACK button to return to where you were.








 Initialization


init

MyLL_USB::Init_SP();
BOOLEAN Init_SP();

**Special Init - see notes below

This member function is designed for use as a quick way to get going if you have only one of our USB devices connected and able to use all of the default parameters:
Device - First USB device that is found by function
Rate - 100Hz
Chan - 1

There are similar member functions that you can use once initialized that are just as simple to use and even make use of the default parameters that this function will initialize the device to. It is suggested that you use only function calls followed by "_SP" if you use this form of the initialization. Other non- "_SP" functions can be used if you first call member function   GetDefDevID_SP() to get the device ID that was uncovered by this function, to use in the other functions.

Return value shown below indicates if the device initialized successfully.

Arguments
None

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::Init();
BOOLEAN Init(USHORT usDevID);

**Similar to previous version of this call except you enter device ID.

This form of the Init call will attept to initialize the device represented by by the usDevID argument.

Arguments
usDevID:
16-bit USHORT data type representing the LL_USB device that you wish to intitialize.

Return value shown below indicates if the device initialized successfully.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::Init();
BOOLEAN Init(USHORT usDevID, BYTE bChan, DOUBLE* pdblRate);

**Recommended if using only one device.

This member function will attempt to initialize the device represented by the usDevID variable. If the function succeeds, it will return TRUE. If it fails, it will return FALSE. If the call fails, you can call MyLL_USB::GetLastAnyError (documented below) to get the error code.

Arguments
usDevID:
16-bit USHORT data type representing the LL_USB devices that you wish to intitialize.

Return value shown below indicates if the device initialized successfully.

bChan:
8-bit BYTE data type representing the channel for the LL_USB device that you wish to initialize.

pdblRate:
Pointer to a 64-bit double data types representing the rate for the usDevID that you wish to intitialize. If the device is successfully initialized, the variable pointed to by pdblRate will contain the rate of the device. The requested rate is often slightly adjusted due to hardware restrictions, so be sure to check the adjusted rate if the call successfully intializes the device by returning TRUE.

pfInitSuccess
Points to an 8-bit variable which will be set to TRUE if the device passed to the constructor successfully initializes.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::Init();
BOOLEAN Init(USHORT* pausDevID, BYTE* pabChan, DOUBLE* padblRate);

**Recommended (one of two) if using more than one device.

This form of the Init call will attept to initialize all of the devices pointed to by pausDevID. That pointer must point to an array of 32 16-bit variables. Set all members of that array to zero and then fill it with the IDs of the devices you want to initialize. Likewise, zero the array of 8-bit variable array pabChan and array of double type variables padblRate to zero and then place the appropriate channel and desired rate within those arrays.

The threaded version of this call is very similar. At the present time, since all features of the threaded version haven't yet been implemented, the two forms of this member function are almost identical.

Arguments
pausDevList:
Pointer to a 32-member array of 16-bit USHORT data types representing the LL_USB devices that you wish to intitialize. When the call returns, this array will contain only the devices that successfully initialized, and the pdblRate documented below will contain the corresponding adjusted rates.

pabChan:
Pointer to an 32-member array of 8-bit BYTE data types representing the channels for the LL_USB devices that you wish to initialize.

padblRate:
Pointer to a 32-member array of 64-bit double data types representing the rates for the LL_USB devices that you wish to intitialize. The offsets in the array of each rate should correspond with the offsets of the appropriate DeviceID in the pausDevList array described above. When the call returns the pausDevList array described above and this array will have only valid entries in them. The DLL will reorganize the arrays if any of the desired devices failed to initialize so that there are no "holes" in the arrays. The corresponding alignment of the two arrays will be maintained.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::Init();
BOOLEAN Init(USHORT* pausDevID, BYTE* pabChan,
DOUBLE* padblRate, BOOLEAN fThreaded);

**Recommended (one of two) if using more than one device.

This form of the Init function will attempt to initialize all of the devices pointed to by pausDevID. That pointer must point to an array of 32 16-bit variables. Set all members of that array to zero and then fill it with the IDs of the devices you want to initialize. Likewise, zero the array of 8-bit variable array pabChan and array of double type variables padblRate to zero and then place the appropriate channel and desired rate within those arrays.

This is a threaded version of the Init function. However since all features of this version of the Init member function haven't yet been implemented, the previous form and this one are almost identical.

Arguments
pausDevList:
Pointer to a 32-member array of 16-bit USHORT data types representing the LL_USB devices that you wish to intitialize. When the call returns, this array will contain only the devices that successfully initialized, and the pdblRate documented below will contain the corresponding adjusted rates.

pabChan:
Pointer to an 32-member array of 8-bit BYTE data types representing the channels for the LL_USB devices that you wish to initialize.

padblRate:
Same as MyLL_USB::Init function explanation above.

fThreaded:
8-bit BOOLEAN type variable indicating if you'd like for the initialization process to by run within a thread. If set to true, the constructor will make use of a threaded version of the initialization process within the DLL.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.






get default ID found by  Init_SP( ) 

MyLL_USB::GetDefDev_SP();
BOOLEAN GetDefDev_SP(USHORT* pusDevID);


This member function will return the device ID (if any) that it retrieved from the call it made to  Init_SP( )  . Use this function only if you used the Init_SP() member function.

Arguments
pusDevID:
Pointer to a 16-bit USHORT data type representing the LL_USB device.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.










 Rate and calibration


rate change

MyLL_USB::ChangeCurDevRate();
BOOLEAN ChangeCurDevRate(USHORT usDevID, DOUBLE* padblRate);

This member function is used to change the rate of a device. If scanning, do not place the devices that are currently scanning in the list since an attempt will be made to close and reenumerate any device that is currently in the list including the ones that are scanning if they are in the list.

Arguments

pdblRate:
Pointer to a 64 bit data variable. This is the rate that the device will be set to. Due to certain limitations of the device, all rates aren't valid and may be adjusted slightly. For example, a requested rate of 1000Hz may be altered to 1000.7Hz. The value pointed to by pdblRate will be set to the actual rate that the device was set to.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.



MyLL_USB::ChangeCurDevRate_SP();
BOOLEAN ChangeCurDevRate_SP(DOUBLE* padblRate);

This member function is used to change the rate of a device. Since there is no Device ID passed with this function, it is intended for use when only one device has been initialized preferably by using the no-arg  Init_SP( )  member function shown elsewhere within this documentation.

If scanning, you should first end the scan before calling this function.

Arguments

pdblRate:
Pointer to a 64 bit data variable. This is the rate that the device will be set to. Due to certain limitations of the device, all rates aren't valid and may be adjusted slightly. For example, a requested rate of 1000Hz may be altered to 1000.7Hz. The value pointed to by pdblRate will be set to the actual rate that the device was set to.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.




calibrate

MyLL_USB::Calibrate();
BOOLEAN Calibrate(USHORT usDevID);

This member function is used to calibrate a device. A full-scale and offset calibration is performed. If scanning, do not place the devices that are currently scanning in the list since the DLL will automatically attempt to close and reenumerate any device that is currently in the list including the ones that are scanning if they are in the list.

Arguments

usDevID:
16-bit data variable representing the device that you wish to calibrate.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.




MyLL_USB::Calibrate_SP();
BOOLEAN Calibrate_SP();

This member function is used to calibrate a device. Since there is no Device ID passed with this function, it is intended for use when only one device has been initialized preferably by using the no-arg  Init_SP( )  member function shown elsewhere within this documentation.

If scanning, scanning you should first end the scan before calling this function.

Arguments

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.









Basic I/O




channel

MyLL_USB::SetCurChan();
BOOLEAN SetCurChan(USHORT usDevID, BYTE bChan);

This member function is used to change the active channel of a device. It can be used anytime once the device has been initialized.

Valid channels for a Model-301 are 0,1,6,7 and for a Model-302 are 0-7. During multi-channel scan mode (explained elsewhere in this document), the channel changes are ignored. Channel 7 is concidered the "offset" channel and channel 6 is concidered the "full-scale" channel.

Arguments

usDevID:
16-bit data variable representing the device that you wish to send channel change to.

bChan:
8-bit data type representing the current channel the device listed above is to be set to.

pbReserved:
Pointer to an 8-bit data variable. This is currently reserved for future use.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.




MyLL_USB::SetCurChan_SP();
BOOLEAN SetCurChan_SP(BYTE bChan);

This member function is used to change the active channel of the device that was initialized using the  Init_SP( )  member function described elsewhere within this documentation.

Valid channels for a Model-301 are 0,1,6,7 and for a Model-302 are 0-7. During multi-channel scan mode (explained elsewhere in this document), the channel changes are ignored. Channel 7 is concidered the "offset" channel and channel 6 is concidered the "full-scale" channel.

bCurChan:
8-bit data type representing the current channel to set the device to.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this function returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::GetCurChan();
BOOLEAN GetCurChan(USHORT usDevID, BYTE* pbChan);

This member function is used to get the active channel of a device. It can be used anytime once the device has been initialized.

Valid channels for a Model-301 are 0,1,6,7 and for a Model-302 are 0-7. During multi-channel scan mode (explained elsewhere in this document), the channel changes are ignored. Channel 7 is concidered the "offset" channel and channel 6 is concidered the "full-scale" channel.

Arguments

usDevID:
16-bit data variable representing the device that you wish to send channel change to.

bCurChan:
Pointer to an 8-bit data type to receive the value of the current channel for the device listed above.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::GetCurChan_SP();
BOOLEAN GetCurChan_SP(BYTE* pbChan);

This member function is used to get the active channel of the device that was initialized using the  Init_SP( )  member function described elswhere within this documentation.

Valid channels for a Model-301 are 0,1,6,7 and for a Model-302 are 0-7. During multi-channel scan mode (explained elsewhere in this document), the channel changes are ignored. Channel 7 is concidered the "offset" channel and channel 6 is concidered the "full-scale" channel.

Arguments

usDevID:
16-bit data variable representing the device that you wish to send channel change to.

bCurChan:
Pointer to an 8-bit data type to receive the value of the current channel for the device listed above.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.






analog output (Model 302 only)


MyLL_USB::SendAnalogOut();
BOOLEAN SendAnalogOut(USHORT usDevID, BYTE bDAC, DOUBLE dblVoltage);

This member function is used to send an analog voltage to a Model 302.

Arguments

usDevID:
16-bit data variable representing the device that you wish to send analog data to.

dblVoltage:
Voltage to send to Model-302

bDAC:
8-bit data variable that represents the channel to send the analog voltage to

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::SendAnalogOut_SP();
BOOLEAN SendAnalogOut_SP(BYTE bDAC, DOUBLE dblVoltage);

This member function is used to send an analog voltage to a Model 302 device initialized using the  Init_SP( )  member function described elsewhere within this documentation.

dblVoltage:
Voltage to send to Model-302

bDAC:
8-bit data variable that represents the channel to send the analog voltage to

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.






digital output


MyLL_USB::SendDigitalOutput();
BOOLEAN SendDigitalOutput(USHORT usDevID, BYTE bDigOutVal);

This function is used to send a digital output value to the device. It can be used anytime once the device has been initialized. Valid digital output values are 0-255.

Arguments

usDevID:
16-bit data variable representing the device that you wish to send the digital output to.

bDigOutVal:
8-bit digital output value that you want to send to device

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::SendDigitalOutput_SP();
BOOLEAN SendDigitalOutput_SP(BYTE bDigOutVal);

This function is used to send a digital output value to the device initialized by member function  Init_SP( )  described elsewhere within this documentation. It can be used anytime once the device has been initialized. Valid digital output values are 0-255.

Arguments

bDigOutVal:
8-bit digital output value that you want to send to device

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.






digital input


MyLL_USB::GetDigitalInput();
BOOLEAN GetDigitalInput(USHORT usDevID, BYTE* bDigInVal);

This function is used to read the 8-bit digital input value from the device. It can be used anytime once the device has been initialized.

Arguments

usDevID:
16-bit data variable representing the device that you wish to read the digital input value from

bDigInVal:
Pointer to an 8-bit data variable. The variable will contain the current digital input if the member function succeeds.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::GetDigitalInput_SP();
BOOLEAN GetDigitalInput_SP(BYTE* bDigInVal);

This function is used to read the 8-bit digital input value from the device that was using the member function  Init_SP( )  described elsewhere within this documentation.

Arguments

bDigInVal:
Pointer to an 8-bit data variable. The variable will contain the current digital input if the member function succeeds.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.








Polled data mode


get one voltage

MyLL_USB::GetOneVoltage();
BOOLEAN GetOneVoltage(USHORT usDevID, DOUBLE* pdblVoltage);

This call is used to read a single voltage from the device.

Arguments

usDevID:
16-bit data variable representing the device that you wish to read the voltage data from.

pdblVoltage:
Pointer to a 64-bit type variable. If the functions succeeds the variable pointed to will contain the voltage. Voltage is in range +-5Volts.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Special note:
If this call returns zero that could indicate a variety of error conditions such as the power or USB cable being disconnected. To find out the cause of the problem, we recommend using member function MyLL_USB::GetDevStatus() to get the current status of the device. That function also has the ability to recover from some errors that it incounters. For example if the device has lost power, but the power has been restored, the member function GetDevStatus() will attempt to regain control of the device.
Use browser BACK button to return to where you were.



MyLL_USB::GetOneVoltage_SP();
BOOLEAN GetOneVoltage_SP(DOUBLE* pdblVoltage);

This call is used to read a single voltage from the device that was initialized using the  Init_SP( )  function described elsewhere within this documentation.

Arguments

pdblVoltage:
Pointer to a 64-bit type variable. If the functions succeeds the variable pointed to will contain the voltage. Voltage is in range +-5Volts.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Special note:
See special note in previous function call documentation just above this one.
Use browser BACK button to return to where you were.



MyLL_USB::GetOneVoltage();
BOOLEAN GetOneVoltage(USHORT usDevID, DOUBLE* pdblVoltage, DOUBLE dblRange);

**SPECIAL NOTE: This is for modified hardware with voltage range other than +-5 volts.

This call is used to read a single voltage from the device, allowing the user to select the voltage range for certain modified hardware..

Arguments

usDevID:
16-bit data variable representing the device that you wish to read the voltage data from.

pdblVoltage:
Pointer to a 64-bit type variable. If the functions succeeds the variable pointed to will contain the voltage. Voltage is calculated like this:
Values used:
rawcount = 24-bit count read from device
maxcount = 16777215 = Maximum 24 bit count
halfcount = 8388608 = Half of maximum count (gives +-)
Calculation:
(rawcount - halfcount) * ((dblRange / (DOUBLE)maxcount) * 2);

This function is useful for those who may have modified hardware with a different "range" setting than the normal +-5Volts.

dblRange:
64-bit data representing voltage range of your device. For example, +-5Volts = 10Volt range.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Special note: See special note attached to first listing of   GetOneVotage()   above.
Use browser BACK button to return to where you were.




get one count

MyLL_USB::GetOneCount();
BOOLEAN GetOneCount(USHORT usDevID, UINT* puiRawCount);

This call is used to read a 24-bit count from the device.

Arguments

usDevID:
16-bit data variable representing the device that you wish to read the voltage data from.

puiRawCount:
Pointer to a 32-bit variable to contain the 24-bit data returned by the device. In this function we return the actual 24-bit data rather than convert it to a voltage. This may be usefule for those who are either interested in knowing the actual "count" or those who have hardware that has been specially modified for an input range other than +-5 volts.

An example of converting the 24-bit data returned above to a range of +-5 volts is shown below:
INT iCntTemp = uiConvRawCount;
DOUBLE Voltage = (iCntTemp - 8388608) * 0.00000059604645

note: The 0.00000059604645 used above is maximum voltage range (10 volts) divided by maximum 24-bit count value 16777215 (0xFFFFFF). The 8388608 (0x800000) value used above sets the result to +-5 volts using the 10-volt range.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Special note: See special note attached to first listing of   GetOneVotage()   above.
Use browser BACK button to return to where you were.








Scanning data mode


start scan

There are two suggested methods for starting a scan. When using only a single device, the first of the two is recommended

note: When passing "number of channels" to any of the scan start member functions please understand the procedure for setting the value correctly when using the "calibration" type scans. When using a cal-scan, channel-7 is always returned and must be included in the "number of channels" that you request. When using a Model-301, even though there are only 4 available channels, the 4th channel is known as "channel-7" or most commonly known as the "offset" channel. Likewise the 3rd channel is referred to as "channel-6" or most commonly known as the "full scale" channel. To further explain... if you are performing a 2-channel scan using a Model-301 device, you must set the channels requested to 3 since channel 7 will be returned along with the two channels. It is up to you to subtract the value of channel 7 from each of the other channels. Keeping that in mind, a 4-channel calibration type scan using a Model-301 device returns the exact same amount of data as a 3-channel scan since the 4th channel (chan7) is included in both situations.


MyLL_USB::StartScan();
BOOLEAN StartScan(USHORT usDevID);

This member function is used to place a device into scan mode. If this function returns success then the device will be in scan mode and you can begin reading the data from the device using the MyLL_USB class member functions explained elsewhere within this document.

A scan started using this function will always scan using a CMND_SINGLE_CHAN_SCAN type of scan and will scan the current channel.


Arguments

usDevID:
16-bit data variable representing the device that you wish to start scanning.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::StartScan_SP();
BOOLEAN StartScan_SP();

This member function is used to place the device that was initialized using the class member function  Init_SP( )  (described elsewhere in this documentation) into scan mode. If this function returns success then the device will be in scan mode and you can begin reading the data from the device using the MyLL_USB class member functions explained elsewhere within this document.

A scan started using this function will always scan using a CMND_SINGLE_CHAN_SCAN type of scan and will scan the current channel.


Arguments

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.





MyLL_USB::StartScan();
BOOLEAN StartScan(BYTE bNumDevices, USHORT* pausDevID,
BYTE* pabScanType, BYTE* pabNumChans, BYTE* pabScanStarted);

This function is used to place one or more devices into scan mode. If this function returns success, inspect the members of the array pointed to by pabScanStarted to see the scan startup status of the various devices. The indexes in the array pointed to by pabScanStarted correspond to the devices in the array pointed to by pausDevID. You can begin reading the data from the devices that successfully started scanning by using the function calls explained elsewhere within this document.

Arguments

bNumDevices:
An 8-bit variable that indicates the number of devices in the list to start scanning.

pausDevID:
Pointer to a 32 member array of 16-bit variables representing the devices that you want to start scanning. Please set all non-valid members of the array to zero.

pabScanType:
Pointer to a 32 member array of 8-bit data types that indicate the type of scan.
  CMND_SINGLE_CHAN_SCAN   1
  CMND_MULTI_CHAN_SCAN   2
  CMND_MULTI_CHAN_CAL_SCAN   3
  CMND_SINGLE_CHAN_DIGIN_SCAN   4
  CMND_MULTI_CHAN_DIGIN_SCAN   5
  CMND_MULTI_CHAN_DIGIN_CAL_SCAN   6

pabNumChans:
Pointer to a 32 member array of 8-bit data types that indicates the number of channels you want to scan for each device in the device ID array. This value is ignored when in any of the single-channel scan modes. Valid values for Model-301 type devices is 1-4 and for Model-302 type devices 1-8.

pabScanStarted:
Pointer to a 32 member array of 8-bit data types. When the function returns, the value of each member will indicate the status of the starting of the scan for the correspoinding device ID. The values are:
0 = failed to start
1 = start success
2 = already scanning.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.






read scan data

There are several methods for reading scan data depending on the type of scan you are doing and the number of devices. The first method shown below is recommended if you are scanning only a single device using a single channel and a non-digital input type scan. Please remember that a digital input is returned with each packet even when using non-digital input type scans. The difference is that with a digital input type of scan, the digital input is included with each channel data with every read from each channel which is used mostly for triggering of a particular channel using the digital input bit(s).

MyLL_USB::GetScanVoltage_SP();
BOOLEAN GetScanVoltage_SP(
PSCAN_INFO_USB_PNTS_SINGLE pScanInfoPntsSingle, DOUBLE* padblVoltages);

* This function is recommended to read scan data from a single device that was initialized using the class member function  Init_SP( )  described elsewhere within this documention. This is one of the easies ways to read the scan data for a single device since there is a minimum number of arguments to the call and the 24-bit raw data is converted +-5 volts before being returned to the caller.

Arguments

pScanInfoPntsSingle:
pointer to an array of structured data defined below:
typedef struct SCAN_INFO_USB_PNTS_SINGLE{
USHORT usDevID; //   current device ID number
USHORT usNumPntsToRead; //   number of points to read (most efficient to use multiples of 10)
UINT uiNumPntsInBuff; //   number of unread points currently in buffer
UINT uiStatusFlags; //   important scanning status information (see table below)
BYTE bLastDigin; //   the last digital input that was read
SCAN_INFO_USB_PNTS_SINGLE, *PSCAN_INFO_USB_PNTS_SINGLE;
'NOTE:  The following are possible bit settings for uiStatusFlags shown above
#define SCAN_RUNNING 0x1 not currently used
#define SCAN_DATA_REQUEST_SUCCEEDED 0x2 not currently used
#define SCAN_ENDING 0x4 not currently used
#define SCAN_HALTED 0x8 if set, the device is no longer scanning
#define SCAN_CHECKSUM_ERROR 0x10 if set there has been a checksum error
#define SCAN_VOLTAGE_BUFFER_WRAP 0x20 indicates a wrap in the DLL's data buffer
#define SCAN_MICRO_CODE_BUFF_WRAP 0x40 indicates a wrap in the device's data buffer
#define SCAN_DEVICE_IO_ERROR 0x80 indicates I/O error
#define SCAN_DEVICE_DISCONNECTED 0x100 The device has been disconnected
#define SCAN_DEVICE_NOT_FOUND 0x200 not currently used



padblVoltages:
Pointer to an array of 64-bit floating point data types to contain the voltages. The array must be the size indicated by the   usNumPntsToRead   member of the array pointed to by the   pScanInfoPntsSingle   argument described above.



Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::GetScanVoltage();
BOOLEAN GetScanVoltage(
PSCAN_INFO_USB_PNTS_SINGLE pScanInfoPntsSingle, DOUBLE* padblVoltages);

* This function is recommended to read scan data from a single device that you pass as member of structured describe below.

Arguments

pScanInfoPntsSingle:
same as GetScanVoltage_SP() except you set device ID in struct.


padblVoltages:
same as GetScanVoltage_SP() above.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.


MyLL_USB::GetScanData();
BOOLEAN GetScanData(PSCAN_INFO_USB paScanInfo, PSCAN_PACKET_USB paScanPacket);
* This function is recommended to read scan data from a single device using a digital input type scan. As with the previous member function shown above, it can be used with any type of scan and any arguments or return values that don't apply to the type of scan will be ignored. This member function is not recommended for single channel type scans due to the amount memory that will be waisted as a result of using the structured data.

Arguments

paScanInfo:
pointer to an array of structured data defined below:
typedef struct SCAN_INFO_USB{
USHORT usDevID; //   current device ID number
USHORT usNumPacketsMax; //   maximum number of packets to read
USHORT usNumPacketsMin; //   minimum number of packets to read
BOOLEAN fOkayToReadLess; //   indicates okay to read less than usNumPacketsMax
UINT uiStatusFlags; //   important scanning status information (see table below)
UINT uiNumPacketsInBuff; //   on return, indicates number of packets waiting in buffer
USHORT usNumPacketsRead; //   on return, indicates number of packets read
BYTE bLastDigin; //   on return, indicates most recent digital input value
SCAN_INFO_USB, *PSCAN_INFO_USB;
'NOTE:  The following are possible bit settings for uiStatusFlags shown above
#define SCAN_RUNNING 0x1 not currently used
#define SCAN_DATA_REQUEST_SUCCEEDED 0x2 not currently used
#define SCAN_ENDING 0x4 not currently used
#define SCAN_HALTED 0x8 if set, the device is no longer scanning
#define SCAN_CHECKSUM_ERROR 0x10 if set there has been a checksum error
#define SCAN_VOLTAGE_BUFFER_WRAP 0x20 indicates a wrap in the DLL's data buffer
#define SCAN_MICRO_CODE_BUFF_WRAP 0x40 indicates a wrap in the device's data buffer
#define SCAN_DEVICE_IO_ERROR 0x80 indicates I/O error
#define SCAN_DEVICE_DISCONNECTED 0x100 The device has been disconnected
#define SCAN_DEVICE_NOT_FOUND 0x200 not currently used


paScanPacket
Pointer to an array of structured data defined below:
typedef struct SCAN_PACKET_USB{
UINT bDataChan0; //   data for channel 0
BYTE bDiginChan0; //   digital input read when channel 0 was read
UINT bDataChan1; //   data for channel 1
BYTE bDiginChan1; //   digital input read when channel 1 was read
UINT bDataChan2; //   data for channel 2
BYTE bDiginChan2; //   digital input read when channel 2 was read
UINT bDataChan3; //   data for channel 3
BYTE bDiginChan3; //   digital input read when channel 3 was read
UINT bDataChan4; //   data for channel 4
BYTE bDiginChan4; //   digital input read when channel 4 was read
UINT bDataChan5; //   data for channel 5
BYTE bDiginChan5; //   digital input read when channel 5 was read
UINT bDataChan6; //   data for channel 6
BYTE bDiginChan6; //   digital input read when channel 6 was read
UINT bDataChan7; //   data for channel 7
BYTE bDiginChan7; //   digital input read when channel 7 was read
SCAN_INFO_USB, *PSCAN_INFO_USB;


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.




MyLL_USB::GetScanData();
BOOLEAN GetScanData(
USHORT usDevID, USHORT usNumPntsToRead, USHORT* pusNumPntsRead,
UINT* pauiDataBuff, UINT* puiStatusFlags, UINT* puiPntsInBuff, BYTE* pbLastDigin);

* This function is recommended to read scan data from a single device using a non-digital input type of scan.
Arguments

usDevID:
16-bit data variable representing the device that you wish to read scan data from

usNumPntsToRead:
16-bit data type that indicates the number of points that you want to read. Be certain that your data buffer is large enough to hold all data by sizing it using the value of this variable or larger.

pusNumPntsRead:
Pointer to a 16-bit data type that will be set upon return indicating the number of points that were actually read.

pauiDataBuff:
Pointer to an array of 32-bit data types. This is the raw 24-bit data that represents the voltage count read by the device. An example of converting the 24-bit data returned above to a range of +-5 volts is shown below:
INT iCntTemp = uiConvRawCount; DOUBLE Voltage = (iCntTemp - 8388608) * 0.00000059604645

note: The 0.00000059604645 used above is maximum voltage range (10 volts) divided by maximum 24-bit count value 16777215 (0xFFFFFF). The 8388608 (0x800000) value used above sets the result to +-5 volts using the 10-volt range

puiStatusFlags:
Pointer to a 32-member array of 32-bit data types. Upon return from the function call each member will be set with the current scan status of the corresponding device in the DevID array. It's important to watch for a status of SCAN_HALTED. The possible values are indicated below. Please notice that the values represent various bits of the 32-bit value so they are easily "ANDed" to check individual status values.
  SCAN_DATA_REQUEST_SUCCEEDED   0x2
  SCAN_ENDING   0x4
  SCAN_HALTED   0x8
  SCAN_CHECKSUM_ERROR   0x10
  SCAN_VOLTAGE_BUFFER_WRAP   0x20
  SCAN_MICRO_CODE_BUFF_WRAP   0x40
  SCAN_DEVICE_IO_ERROR   0x80
  SCAN_DEVICE_UNRECOVERABLE_ERROR   0x100
  SCAN_DEVICE_NOT_FOUND   0x200

puiPntsInBuff
Pointer to a 32-bit data type. Upon return, the variable pointed to will contain the number of points which are ready to be read from the buffer.


pbLastDigin
Pointer to an 8-bit data type. Upon return, the variable pointed to will contain the value of the most recent digital input.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.




MyLL_USB::GetScanData();
BOOLEAN GetScanData(USHORT usDevID, USHORT usNumPntsToReadMax,
USHORT usNumPntsToReadMin, USHORT* pusNumPntsRead, UINT* pauiDataBuff,
BYTE* pabDiginBuff, BOOLEAN fOkayToReadLess, UINT* pauiStatusFlags,
UINT* pauiPntsInBuff, BYTE* pbLastDigin);

* This function is recommended to read scan data from a single device using a digital input type scan but can also be used for non-digital input type of scan if the Min-Max functionality of this function is desired which the member function shown above does not supply. For non-digital input reading of data, the array pointed to by pabDiginBuff will remain untouched, but the argument must still be present in the calling of this function.

Arguments

usDevID:
16-bit data variable representing the device that you wish to read scan data from

usNumPntsToReadMax:
16-bit data type that indicates the maximum number of points that you want to read. Be certain that your data buffer is large enough to hold all data by sizing it using the value of this variable or larger.

usNumPntsToReadMin:
16-bit data type that indicates the maximum number of points that you want to read. Be certain that your data buffer is large enough to hold all data by sizing it using the value of this variable or larger. If fOkayToReadLess is set and number of points in buffer is less than usNumPntsToReadMax but equal to or greater than this value, then the number of points indicated by this value will be read from the buffer.

pusNumPntsRead:
Pointer to a 16-bit data type that will be set upon return idicating the actual number for poinnts that were read.

pauiDataBuff:
Pointer to an array of 32-bit data types. This is the raw 24-bit data that represents the voltage read by the device.

Please see explanation above for converting this value to a voltage.

pabDiginBuff:
Pointer to an array of 8-bit data types. Upon return ach member of this array will be contain the digital input value that was read at the same time as the corresponding channel voltage data in the puiDataBuff array. This is useful for triggering using a particular digital input.

fOkayToReadLess:
An 32-bit data type. If set, and if current number of points in buffer is less than usNumPntsToReadMax but equal to usNumPntsToReadMin, then the number of points indicated by usNumPntsToReadMin will be read.

pauiStatusFlags:
Pointer to a 32-bit data type that upon return will contain a value indicating the current status of the scan. Please see the table further up for the values.

puiPntsInBuff
Pointer to a 32-bit data type. Upon return, the variable pointed to will contain the number of points which are ready to be read from the buffer.


pbLastDigin
Pointer to an 8-bit data type. Upon return, the variable pointed to will contain the value of the most recent digital input.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.




end scan

There are three member functions available for ending a scan. Two are designed to end the scans for a single device and the other for multiple devices.

MyLL_USB::EndScan_SP();
BOOLEAN EndScan_SP();

This function that requires no arguments, takes the device that was initialized using the class member function  Init_SP( )  out of scanning mode and must be called to terminate a scan. If you are scanning, you must always use this function before exiting your application or reinitializing the scanning device.

Arguments

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::EndScan();
BOOLEAN EndScan(USHORT usDevID);

This function takes the device out of scanning mode and must be called to terminate a scan. If you are scanning, you must always use this function before exiting your application or reinitializing the scanning device.

Arguments

usDevID:
16-bit data variable representing the device that you wish to end the scan.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.



MyLL_USB::EndScan();
BOOLEAN EndScan(BYTE bNumDevices, USHORT* pausDevID);

This function takes the device(s) out of scanning mode and must be called to terminate a scan. If you are scanning, you must always use this function before exiting your application or reinitializing the scanning device.

Arguments

bNumDevices:
8-bit data variable representing the number of devices in the array pointed to by pausDevID

pausDevID:
32-member array of 16-bit type variables containing the IDs of the devices to end scan.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.

Use browser BACK button to return to where you were.






Miscellaneous functions


get device status

There are various member functions available for getting the initialization status as well as status associated with error and non-error conditions of the devices.

MyLL_USB::GetCurDevInitStatus_SP();
BOOLEAN GetCurDevInitStatus_SP();

Use this function to determine if a device a device previously initializeds using class member function  Init_SP( )  is currently initialized.

Arguments

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::GetCurDevInitStatus();
BOOLEAN GetCurDevInitStatus(USHORT usDevID);

Use this function to determine if a device is currently initialized.

Arguments

usDevID:
Device to test

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::GetDevStatus_SP();
BOOLEAN GetDevStatus_SP(UINT* puiConnectionStat, UINT* puiPowerStat);

Use this function to determine if a device originally initialized using the class member function  Init_SP( )  is currently initialized.

Arguments

puiConnectionStat:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set as indicated in the table below. This status indicator is a low-level mechanism for determining the current connection and ownership status of a device.

  DEV_NOT_FOUND   0x0
  DEV_FOUND   0x1
  DEV_DISCONNECTED   0x2
  DEV_ENUMERATED   0x4
  DEV_READY   0x8
  DEV_OWNED_BY_ANOTHER   0x10
  DEV_UNKNOWN_ERR   0x20

puiConnectionStat:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set as indicated in the table below. This status indicator is a low-level mechanism for determining the current power-related status of a device.

  PWR_NO_INFO_AVAILABLE   0x0
  PWR_NO_RESET_REQUIRED   0x1
  PWR_NO_DEVICE   0x2
  PWR_RESET_PIPE_FAILED   0x4
  PWR_RESET_PIPE_SUCCESS   0x8
  PWR_RESET_DEV_FAILED   0x10
  PWR_RESET_DEV_SUCCESS   0x20
  PWR_NO_POWER   0x40
  PWR_YES_POWER   0x80

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::GetDevStatus();
BOOLEAN GetDevStatus(USHORT usDevID, UINT* puiConnectionStat, UINT* puiPowerStat);

Use this function to determine if a device is currently initialized.

Arguments

usDevID:
Device to test

puiConnectionStat:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set. This status indicator is a low-level mechanism for determining the current connection and ownership status of a device.

*See table for   GetDevStatus_SP()   above for meaning of status bits.

puiConnectionStat:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set. This status indicator is a low-level mechanism for determining the current power-related status of a device.

*See table for   GetDevStatus_SP()   above for meaning of status bits.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastAnyError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.





MyLL_USB::GetLastDevError_SP();
BOOLEAN GetLastDevError_SP(UINT* puiErrorCode);

Use this function to get the last error status of a device that was originally initialized with the  Init_SP( )  class member function.

Arguments

puiErrorCode:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set as indicated in the table below. This status indicator is used to determine any errors (if any) that may have occured with a previous member function call using this device.

  ERR_NO_ERROR   0x0
  ERR_IVALID_OS   0x1
  ERR_DLL_NOT_FOUND   0x2
  ERR_DLL_FUNCTION_NOT_FOUND   0x4
  ERR_NO_DEVICES_INITIALIZED   0x8
  ERR_MEM_ALLOC_ERROR   0x10
  ERR_INVALID_DEV_ID   0x20
  ERR_DEV_NOT_FOUND   0x40
  ERR_FAILED_INIT   0x80
  ERR_DEV_NOT_INITIALIZED   0x100
  ERR_FAILED_IO   0x200
  ERR_FAILED_SCAN_STARTUP   0x400
  ERR_DEV_NOT_SCANNING   0x800
  ERR_DEV_BUSY_SCANNING   0x1000
  ERR_WRONG_DEV_TYPE   0x2000
  ERR_UNKNOWN_ERROR   0xFFFFFFFF

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed


Use browser BACK button to return to where you were.



MyLL_USB::GetLastDevError();
BOOLEAN GetLastDevError(UINT usDevID, UINT* puiErrorCode);

Use this function to determine if a device is currently initialized.

Arguments

usDevID:
Device to test

puiErrorCode:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set. This status indicator is used to determine any errors (if any) that may have occured with a previous member function call using this device.

*See table above for   GetLastDevError_SP()   above for meaning of status bits.

Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed


Use browser BACK button to return to where you were.



MyLL_USB::GetLastAnyError();
BOOLEAN GetLastAnyError(UINT* puiErrorCode);

Use this function to determine if the last error associated with any function call to any device.

Arguments

puiErrorCode:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set as indicated in the table below. This status indicator is used to determine any errors (if any) that may have occured with a previous member function call related to any device. See definition of status bits in table above for call to class member function   GetLastDevError()


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed


Use browser BACK button to return to where you were.



MyLL_USB::GetLastAnyError_SP();
BOOLEAN GetLastAnyError_SP();

This class member function does the exact same thing as function described above except it has a different name to keep naming convention consistant.

Arguments

puiErrorCode:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will have various status bits of the 32-bit variable set as indicated in the table below. This status indicator is used to determine any errors (if any) that may have occured with a previous member function call related to any device. See definition of status bits in table above for call to class member function   GetLastDevError()


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed


Use browser BACK button to return to where you were.



MyLL_USB::GetCurDevScanStatus_SP();
BOOLEAN GetCurDevScanStatus_SP(
BOOLEAN* pfOkayToStartScan, BOOLEAN* pfScanning);

Use this function to determine the current scanning status of the device that was originally initialized using the  Init_SP( )  class member function.

Arguments

pfOkayToStartScan:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will be set to TRUE if it is okay to start scanning, otherwise it will be set to FALSE.


pfScanning:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will be set to TRUE the device is currently scanning, otherwise it will be set to FALSE.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastDevError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.



MyLL_USB::GetCurDevScanStatus();
BOOLEAN GetCurDevScanStatus(
USHORT usDevID, BOOLEAN* pfOkayToStartScan, BOOLEAN* pfScanning);

Use this function to determine the current scanning status of the device passes as an argument to the is class member function.

Arguments

pfOkayToStartScan:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will be set to TRUE if it is okay to start scanning, otherwise it will be set to FALSE.


pfScanning:
Pointer to a 32-bit data variable. Upon return from the function, the variable pointed to will be set to TRUE the device is currently scanning, otherwise it will be set to FALSE.


Return type:
8-bit. 1 (TRUE) = success,    0 (FALSE) = failed
Use member function   GetLastDevError()   (shown elsewhere int this documentation) to get error code if this functin returns FALSE.


Use browser BACK button to return to where you were.
































































C/C++ Developer's USB Class usage examples





















Use browser BACK button to return to where you were.
lawsnlab@lawsonlabs.com
last modified: 5-22-02