Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| daq-and-datalogging:documents:usb-tc-temp-ulx-for-labview-digital-io [2023/06/13 16:32] – created Scandiweb | daq-and-datalogging:documents:usb-tc-temp-ulx-for-labview-digital-io [2023/07/11 05:18] (current) – Scandiweb | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== USB-QUAD08 C/C++ Windows Example | + | ====== |
| - | The example program | + | Here is an example program |
| - | It also demonstrates device discovery which doesn' | + | Requires NI LabVIEW 2010 or newer. |
| - | < | + | Disclaimer: |
| - | // VC_2008_USB_QUAD08_Encoder.cpp : Defines the entry point for the console | + | The attached Code or Example is provided As Is. \\ |
| - | // | + | It has not been tested or validated as a product,\\ |
| - | #include " | + | for use in a deployed |
| + | You assume all risks for use of the Code or Example.\\ | ||
| + | This example will also work with: | ||
| + | WEB-TC, | ||
| + | WEB-TEMP, | ||
| + | WLS-TC (requires WLS-IFC), | ||
| + | WLS-TEMP (requires WLS-IFC), | ||
| + | USB-5201, | ||
| + | USB-5203.\\ | ||
| - | /* Include files */ | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include " | ||
| - | |||
| - | #define RATE 100 | ||
| - | #define ChanCount 1 | ||
| - | #define COUNT 100 | ||
| - | #define MAXNUMDEVS 100 | ||
| - | |||
| - | void main () | ||
| - | { | ||
| - | /* Variable Declarations */ | ||
| - | int i=0; | ||
| - | long curCount=0; | ||
| - | long curIndex=0; | ||
| - | |||
| - | int ULStat = 0; | ||
| - | |||
| - | long Rate = RATE; | ||
| - | short Status; | ||
| - | long halfbuf = COUNT/2; | ||
| - | bool NextReadUpper = false; | ||
| - | |||
| - | |||
| - | int numberOfDevices = MAXNUMDEVS; | ||
| - | | ||
| - | | ||
| - | |||
| - | int BoardNum = -1; | ||
| - | |||
| - | float Rev = (float)CURRENTREVNUM; | ||
| - | | ||
| - | | ||
| - | |||
| - | | ||
| - | |||
| - | //Ignore InstaCal device discovery | ||
| - | cbIgnoreInstaCal(); | ||
| - | |||
| - | //locate USB devices | ||
| - | ULStat = cbGetDaqDeviceInventory(USB_IFC, | ||
| - | for( i = 0; i < numberOfDevices; | ||
| - | { | ||
| - | DeviceDescriptor = inventory[i]; | ||
| - | |||
| - | // | ||
| - | // | ||
| - | // C:\Program Files (x86)\Measurement Computing\DAQ | ||
| - | if(DeviceDescriptor.ProductID == 0xCA) | ||
| - | { | ||
| - | BoardNum = i; | ||
| - | ULStat = cbCreateDaqDevice(BoardNum, | ||
| - | printf(" | ||
| - | break; | ||
| - | } | ||
| - | |||
| - | } | ||
| - | |||
| - | | ||
| - | { | ||
| - | | ||
| - | | ||
| - | | ||
| - | } | ||
| - | |||
| - | |||
| - | // | ||
| - | | ||
| - | | ||
| - | | ||
| - | |||
| - | |||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | printf(" | ||
| - | |||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | if (ULStat != 0) | ||
| - | | ||
| - | | ||
| - | |||
| - | // | ||
| - | | ||
| - | 0, | ||
| - | 1, | ||
| - | COUNT, | ||
| - | & | ||
| - | MemHandle, | ||
| - | Options); | ||
| - | if(ULStat != 0) | ||
| - | printf(" | ||
| - | |||
| - | |||
| - | |||
| - | while(!_kbhit()) | ||
| - | { | ||
| - | // | ||
| - | //it uses a NextReadUpper flag so that each half of the buffer is read once | ||
| - | |||
| - | ULStat = cbGetStatus(BoardNum,& | ||
| - | |||
| - | if(ULStat != 0){ | ||
| - | printf(" | ||
| - | break; | ||
| - | } | ||
| - | if((curIndex > halfbuf) && (NextReadUpper == false)) | ||
| - | { | ||
| - | NextReadUpper = true; | ||
| - | //print first value from lower half | ||
| - | printf(" | ||
| - | |||
| - | } | ||
| - | else if((curIndex < halfbuf) && (NextReadUpper == true)) | ||
| - | { | ||
| - | NextReadUpper = false; | ||
| - | //print first value from upper half | ||
| - | printf (" | ||
| - | |||
| - | } | ||
| - | Sleep(100); | ||
| - | |||
| - | } | ||
| - | |||
| - | |||
| - | |||
| - | cbStopBackground(BoardNum, | ||
| - | cbWinBufFree(MemHandle); | ||
| - | cbReleaseDaqDevice(BoardNum); | ||
| - | |||
| - | printf(" | ||
| - | getch(); | ||
| - | } | ||
| - | </ | ||
| **Attachments**\\ | **Attachments**\\ | ||
| - | [[ https:// | + | [[ https:// |

