Home

DT9840 Series Host Communication Library User's Manual

image

Contents

1. DTCommLib BAS Data Types Constants Enumerated Types Structures and Callback Functions Members Name Description Name Description Name Description Name Description Name Description Name Description Name Description ClockDout A Boolean value that specifies whether to clock digital output values while analog output values are being clocked If TRUE digital output values are output with analog output values at the frequency of the sample clock when any of the following functions in the DT9840 Series DSP Library is called DT ScanLoop DT BlockLoop DT FunctionGen DT ListLoop DT WriteDACDIO If FALSE digital output values are not clocked out when analog output values are clocked out Dummyl A variable of type Integer that is used internally by the system for padding Do not use this variable Port0Out A Boolean variable that specifies whether digital port 0 is an input or an output port If FALSE digital port 0 is an input port if TRUE digital port 0 is an output port Dummy2 A variable of type Integer that is used internally by the system for padding Do not use this variable PortlOut A Boolean variable that specifies whether digital port 1 is an input or an output port If FALSE digital port 1 is an input port if TRUE digital port 1 is an output port Dummy3 A variable of type Integer that is used internally by the
2. DT TIMEOUT DT INVALID CHAN TYPE T INVALID POINTER DT CALLBACK NOT FOUND 131 Appendix B 132 Definition cont DT CHAN DISCONNECTE DT INCOMPAT DT CHAN A D LREA CHAN ALREA TOO BIG FOR CHAN D TOO BIG FOR BOARD D E CHAN TYPE DY OPEN DY CLOSEI D BUFFER BUFFER VOLTAGE OU l OF RANGE AD VALUE OUT OF RANGE NO SYNC DATA RECEI D INVALID DSP DT INVALID HOST DT DT CH DT CH NVALID BUF SIZE AN OPENEI VED BUFFER SIZE PTR BUFFER SIZE PTR D FOR WRITE AN OPENEI D FOR READ D INVALID BOARD NAME BASE ERR DT HOST INVALID INVALTI BOARD DT INVALII j ENAME DT INVALII B P F B B D D INVALID D D D DT FAILUR INVAL W bal DT INVALID MSG PTR DT INVALID MSG I D DRIVER D BOARD D OARD HANDLE OARD INDEX OARD INFO N DOW HAN DLE BUF LEN DT INVALID DSP ADDRESS CANT OPEN CANT FIND NO BOARD FOR INDEX NO CHAN
3. LASH WRITE FAILED DT DAC UNDERRUN DT NOT IEPE BOARD DT F DT F LASH VERIFY FAILED Comm DT H DT unication errors detected by host OST CHAN ALREADY OPEN HOST COMM BASE ERR 3000 DT H OST CHAN ALREADY CLOSE DT H OST BUFFER EMPTY DT H DT H OST RCV BUFFER PULL OST MSG UNKNOWN TYPE DT H DT H OST MSG INVALID LENGTH OST CHAN BUFFER FULL DT H OST SEND BUFFER FULL Comm O unication errors detected by DT9841 DT 9841 CHAN ALREADY OPEN DT 9841 COMM BASE ERR 4000 DT 9841 CHAN ALREADY CLOSED DT 9841 BUFFER EMPTY DT 9841 RCV BUFFER FULL DT 9841 MSG UNKNOWN TYPE DT 9841 MSG INVALID LENGTH DT 9841 CHAN BUFFER FULL DT 9841 SEND BUFFER FULL End Enum Public Interface DTCommLib BAS Members Each member corresponds to an error code Refer to Appendix A starting on page 107 for more information on error codes Data Types Constants Enumerated Types Structures and Callback Functions EDGE TYPE Enumerated Type Definition Public Enum EDGE TYPE SELECTED GATE RISES 0 SELECTED GATE FALLS 1 EXT CLOCK RISES 2 EXT CLOCK FALLS 3 End Enum Public Interface DTCommLib BAS Members Name SELECTED GATE RISES Description If you specify this element
4. Host Computer DT9840 Series Module Input Module Module Channel Output Buffer Input Buffer Buffers Chan 1 TN USB rite gt Read Data Chan 2 p gt Data Chan 3 Figure 6 Module and Channel Buffers When Writing Data to a DT9840 Series Module Host Computer DT9840 Series Module Input Channel Module Module Buffers Input Buffer Output Buffer Chan 1 USB Read a a Wte Data lt amp Chan 2 tg gt Data Chan 3 Figure 7 Module and Channel Buffers When Reading Data from a DT9840 Series Module You can also specify the upper 16 bits of the debug flag that is passed to the DT9840 Series module using the DT_BoardOpen function You can use this flag on the host to control serial debugging functions such as printing to the serial port on the DT9840 Series module DT_BoardOpen returns a handle to the DT9840 Series module that is used by all subsequent communication functions to identify the module When you are finished call DT_BoardClose to close the module and release any resources that were allocated to it 24 Using the DT9840 Series Host Communication Library Downloading and Running a DSP Program If you have not already done so write your Code Composer program for the DT9840 Series modules using the DT9840 Series DSP Library Code Composer creates a COFF file Common Object File Format with a OUT exte
5. time from the module with DT ChanReadAvailable Read the currently available data synchronous write Acknowledge receipt of the data with DT ChanAcknowledge command Convert raw analog data to voltage y To convert a single value call DT_ADValueToVolts to convert a scan of values call Yes DT_ADScanToVolts to convert gt values for a single channel within a block call DT ADChanBlockToVolts to convert a block of values call DT ADBlockToVolts Unregister the callback function that A handles communication events with DT UnregisterCallback Close the communication channel on the host with DT_ChanClose i Close the DT9840 Series module with DT BoardClose 41 Chapter 3 42 NL Function Reference for Visual C Programmers DT ADBIockEIGVOLIS a hes dala ga beens eae e We IP RI EE 45 IST ADEChanBlockTaValis eet ce eee ER ce Se PO ce defe eps 46 DEAD euet Eee ed emm vem e re attt owt bed eet etit tt nus 47 DT Ale To YO ii wv eb uet EE ed RR DS a boxe be 48 DT Boards eese vue ree rre e botte pce e baee o AO d uis pd end duae Eus 49 DTI BoardDownload esse sete tret ete e RR Rc er ee e eR en td 50 DT Gara Gee e 2 uiis REIR A ek te E a eR e ea Ee 51 PT BoardGeiN ame eui e oat o det ete D eet N ee Pre cette eoe A 5 Dig NI pP 52 DI BoardReadFrom Memory iocos nee
6. DTSTATUS J DTErrors H Each member corresponds to an error code Refer to Appendix A starting on page 107 and to the DT9840 Series DSP Library User s Manual for more information on error codes EDGE TYPE Enumerated Type Definition Include File Elements Name Description 134 typedef enum SELECTED GATE RISES SELECTED GATE FALLS EXT CLOCK RISES EXT CLOCK FALLS EDGE TYPE DTCommonAPI H SELECTED_GATE_RISES If you specify this element a rising edge low to high transition on the external gate input pin starts or stops the measurement operation The software automatically sets the gate type to EXT NORMAL _ GATE in this mode Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Name Description Notes SELECTED GATE FALLS If you specify this element a falling edge high to low transition on the external gate input pin starts or stops the measurement operation The software automatically sets the gate type to EXT NORMAL GATE in this mode EXTERNAL CLOCK RISES If you specify this element a rising edge low to high transition on t
7. LED D4 LED CR14 amp H10 LED D5 LED CR7 amp H20 LED_D6 LED CR12 amp H40 LED_D7 LED CR13 amp H80 LED ALL LEDs CR7 to CR14 amp HFF LED HBEAT LED CR7 amp H20 LED RED LED CR7 amp H20 This LED turns red LED GREEN LED CR14 amp H10 This LED turns green DACO REC The data register for analog output channel 0 DEVICE REG BASE amp H8000 DAC1_REG The data register for analog output channel 1 DEVICE REG BASE amp H8004 DIG OUT REG The digital output register DEVICE REG BASE amp H8008 Port 2 is not used for the DT9841 VIB module CTRO PERIOD REG The period register for counter timer 0 DEVICE REG BASE amp HCO00 167 Appendix B 168 CTR1 PERIOD REG The period register for counter timer 1 DEVICE REG BASE amp HC004 CTR2_PERIOD_REG The period register for counter timer 2 DEVICE REG BASE amp HC008 CTRO_PULSE_REG The pulse register for counter timer 0 DEVICE REG BASE amp HCO10 CTR1 PULSE REG The pulse register for counter timer 1 DEVICE REG BASE amp HC014 CTR2_PULSE_REG The pulse register for counter timer 2 DEVICE_REG_BASE amp HC018 CTRO_CTRL_REG The control register for counter timer 0 DEVICE REG BASE amp HC020 CTR1 CTRL REG The control register for counter timer 1 DEVICE REG BASE amp HCO024 CTR2 CTRL REG The control register for counter timer 2 DEVICE REG BASE amp H
8. define BUFF_SIZE 8 1024 CHAN_HANDLE hChan CHAR ChBuff BUFF SIZE 1 Write 100 bytes from ChBuff on the host to the module Status DT ChanAsyncWrite hChan amp ChBuff 100 Function Reference for Visual C Programmers DT ChanBytesAvailable Syntax Include File Description Parameters Name Description Name Description Return Values Example DT ChanClose Syntax Include File Description Parameters Name Description DTSTATUS DT ChanBytesAvailable CHAN HANDLE hChan ULONG pBytesAvailable 7 DTCommonAPI H Returns the number of bytes that are currently available in the specified channel buffer hChan A variable of type CHAN HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 63 pBytesAvailable A pointer to an unsigned integer variable in which the number of bytes from the specified channel buffer is returned See Appendix A starting on page 107 CHAN HANDLE hChan ULONG NumBytesAvailable Read the number of bytes available and put it in NumBytesAvailable Status DT ChanBytesAvailable amp NumBytesAvailable hChan DTSTATUS DT ChanClose CHAN HANDLE hChan DTCommonAPI H Closes a previously opened communication channel on the host and releases all allocated resources
9. An unsigned integer array of five elements that is currently unused Data Types Constants Enumerated Types Structures and Callback Functions CTR SETUP Structure Definition Include File Elements Name Description Name Description Name Description typedef struct COUNT MODE CountMode CLOCK SRC ClkSrc ULONG PeriodCount ULONG PulseWidthCount POLARITY OutputPolarity GATE TYPE GateType EDGE TYPE MeasureModeStartEdge EDGE TYPE MeasureModeStopEdge ULONG Unused 5 CTR SETUP DTCommonAPI H CountMode A variable of type COUNT_MODE described on page 126 that defines the operation of the specified counter timer ClkSrc A variable of type CLOCK SRC described on page 125 that defines the clock input source for the counter timer In measure mode and continuous measure mode the software automatically sets this value to INTERNAL 18MHz PeriodCount An unsigned integer variable that defines the initial value that is loaded into the specified counter timer Values range from 1 to FFFFFFFFh The counter timer counts from PeriodCount to FFFFFFFFh rolls over to 0 the terminal count and then reloads PeriodCount In event counting operations this variable determines the value at which to start counting In pulse output operations this variable determines the frequency of the pulse output signal This variable is automatically set to 0 if measure mode or contin
10. Description Name Description Name Description Opens a unidirectional stream based communication channel by name creates an input buffer for the channel if it was opened for reading and returns a handle to that channel This handle is then used by all subsequent channel communication functions to identify the channel hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 ChanName A fixed length NULL terminated STRING variable that specifies the name of the communication channel to open ChanType A variable of type CHAN TYPE described on page 171 that specifies the type of operation to perform on the communication channel An unsigned integer variable or constant that specifies the size in bytes of the input buffer for a communication channel that was opened for reading If ChanType READ CHAN BufSize determines how much data the communication channel on the host computer can receive from the DT9840 Series module at one time In general the size of the channel input buffer should be at least as large as the largest single write of data from the module Note that a channel input buffer that is larger than needed has no negative performance impact on I O operations If ChanType WRITE CHAN BufSize is ignored on the host but is passed to the module Therefore you could use this value to indicate to
11. Download the file LEDflash out to the module and do not verify the download operation Status DT BoardDownload hBoard LEDflash out FALSE DTSTATUS DT BoardGetInfo BRD HANDLE hBoard BRD INFO pBoardInfo DTCommLib H Returns information about the connected DT9840 Series module including its memory configuration hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 pBoardInfo A pointer to variable of type BRD INFO described on page 143 in which the type name state memory configuration and FPGA version of the specified DT9840 Series module is returned Ensure that TCF file for your module has the appropriate settings Refer to the DT9840 Series DSP Library User s Manual for more information about TCF files See Appendix A starting on page 107 Return info about the DT9840 Series module BRD INFO pBoardInfo Status DT BoardGetInfo hBoard amp pBoardInfo DTSTATUS DT BoardGetName WORD BoardIndex BOARD NAME BoardName DTCommLib H Returns the name of a connected DT9840 Series module 51 Chapter 4 Parameters Name Description Name Description Notes Return Values
12. Status DT_BoardGetName BoardIndex BoardName Declare Function DT_BoardOpen Lib DTCommLib dll ByVal BoardName As String ByRef hBoard As Long ByRef BoardOptions As Any As DTSTATUS DTCommLib BAS Opens a DT9840 Series module by name sets the size the module input and output buffers and returns a handle to the module This handle is then used by all subsequent communication functions to identify the module BoardName A fixed length STRING variable that specifies the ASCII name of the DT9840 Series module to open You assign this name when you configure the device driver If BoardName is a NULL string or empty string the first DT9840 Series module that is connected to the host computer is opened This is the simplest method of opening a module in systems where only one DT9840 Series module is installed Refer to the DT9840 Series Getting Started Manual for more information on assigning a module name hBoard A variable of type LONG in which the handle to the open DT9840 Series module is returned If the module cannot be opened NULL is returned 89 Chapter 5 Name Description Notes Return Values Example BoardOptions A variable of type ANY If you do not want to specify the size of the module input and output buffers specify NULL for BoardOptions to set the module input and output buffers to their default sizes 64 kBytes This is the norm
13. e DIEVENT MODULE UNPLUGGED described on page 212 this event can occur in either the host or DSP program e DTEVENT MODULE PLUGGED described on page 211 this event can occur in a DSP program only DTEVENT ALL COMM EVENTS Specify this constant to monitor all of the host communication events To register for multiple events OR the appropriate constants together Function Reference for Visual C Programmers Notes Return Values Example DT UnregisterCallback Syntax Description Include File Parameters Name Description Various events are generated when specific actions occur in the system such as when a module is opened a message is received and so on The DT9840 Series Host Communication Library and DT9840 Series DSP Library post messages that correspond to these events You can write your host application program to respond to these events If you call DT RegisterMsgHandler with a valid window handle and specify the events to trap an appropriate Windows message is sent to the registered window when the event occurs Refer to Appendix C starting on page 207for detailed information on each message that can be returned When you are finished with the Windows message handler use DT UnregisterMsgHandler described on page 76 to unregister the window As an alternative to Windows messages you can use a callback function to get information related to the module Use DT RegisterCallback described
14. ACCoupling A Boolean variable that indicates whether AC coupling is enabled or disabled for the analog input channel If the value is TRUE AC coupling is enabled If the value is FALSE AC coupling is disabled and DC coupling is used This structure is used by the IEPE SETUP structure described on page 154 and applies to the DT9841 VIB module only typedef struct IEPE CHAN INFO Chan NUM ADC REGS IEPE SETUP DTCommonAPI H Chan NUM_ADC_REGS An array of type IEPE_CHAN_INFO described on page 153 that specifies the IEPE parameters for all of the analog input channels on the DT9841 VIB module The array is defined to be as large as the number of analog input registers Refer to page 117 or more information on NUM_ADC_REGS This structure applies to the DT9841 VIB module only Data Types Constants Enumerated Types Structures and Callback Functions INPUT SCAN BLOCK Structure Definition Include File Elements Name Description Name Description typedef struct struct INPUT_SCAN_BLOCK pNext ULONG nScansThisBlock ULONG AllocSize ULONG BlockNum BOOL BlockComplete INPUT SCAN RCD Scans 1 INPUT SCAN BLOCK DTCommonAPI H pNext A pointer of type INPUT_SCAN_BLOCK that points to the next block in the list For block loop operations the value of pNext is NULL For list loop operations the value of pNext is passed to th
15. As DTSTATUS DTCommLib BAS Returns the data that is currently available from an open communication channel on the DT9840 Series module up to the size of the channel input buffer BufSize hChan A variable of type LONG that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 99 Buffer A variable of type ANY in which the data from the DT9840 Series module is returned You can read from any data type structure or array BufSize A variable of type LONG that specifies the size of the Buffer variable in bytes This value is the maximum number of bytes that can be read from the DT9840 Series module and stored in the Buffer variable at one time BytesRead A variable of type LONG in which the number of bytes that were read is returned this value can never be greater than BufSize When the number that is returned is less than BufSize not all of the data from the DT9840 Series module is available but the data that is available is returned to the host application When the number that is returned is equal to BufSize more than the requested data from the DT9840 Series module is available but only the portion of data that fits in the Buffer variable is returned 103 Chapter 5 Notes Return Values Example DT GetErrorString Syntax Public Interface Description Parameters Name Description N
16. Description Name Description Name Description Name Description CTR SETUP Data Type Definition Public Interface Members Name Description Unused1 An unsigned integer variable that is currently unused specify 0 for this member Unused2 An unsigned integer variable that is currently unused specify 0 for this member Unused3 An unsigned integer variable that is currently unused specify 0 for this member Unused4 An unsigned integer variable that is currently unused specify 0 for this member Unused5 An unsigned integer variable that is currently unused specify 0 for this member Type CTR SETUP CountMode As COUNT MODE ClkSrc As CLOCK SRC PeriodCount As Long PulseWidthCount As Long OutputPolarity As POLARITY GateType As GATE TYPE MeasureModeStartEdge As EDGE TYPE MeasureModeStopEdge As EDGE TYPE Unusedl As Long Unused2 As Long Unused3 As Long Unused4 As Long Unused5 As Long End Type DTCommLib BAS CountMode A variable of type COUNT MODE described on page 173 that defines the operation of the specified counter timer Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description ClkSrc A variable of type CLOCK SRC described on page 171 that defines the clock input source for the counter timer In measure mode and continuous measure mode the software automa
17. Downloads a compiled DSP program over the USB bus to the DSP processor on the DT9840 Series module This function supports the standard output format COFF file of Code Composer Studio for compiled programs hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 Filename A fixed length STRING variable that specifies the name of the DSP COFF file to download to the DT9840 Series module b Verify A variable of type BOOLEAN that specifies whether or not to verify the download operation Function Reference for Visual Basic Programmers Description cont Notes Return Values Example DT BoardGetlnfo Syntax Include File Description Parameters Name Description Name Description Notes Set bVerify to TRUE if you want each segment that is downloaded to the DT9840 Series module to be read back from DSP memory and verified Setting this parameter to TRUE slows down the download significantly but ensures that the DSP program is not loaded into a non existent memory location Set bVerify to FALSE if you do not want to verify the download operation This function resets the DSP processor before downloading the program After the program is downloaded call DT_BoardRun described on page 92 to run the program See Appendix A starting on page 107 Download the file LEDflash out to the
18. NVALID SAMPLE RATE D NO DIGITAL OUT PORTS DT NO DIGITA 1 IN PORTS DT IN DT OUT OOP IS RUNNING OOP IS RUNNING D NO LOOP RUNNING D DSP BIOS ERROR NO MORE CHANNELS D VALUE z 5 D_BLOCK INVAID AD CHAN DT NO OUTPUTS ENABLED D SCAN D COUNTER D SETUP PTR D MASK DT HANDLER ALREADY INSTALLED S OUTPUT INVALID COMPARE VALUE COMPARE IS OUTPUT MASK IS OUTPUT INVALID DA CHAN NPUT 1 B rn S CLOCK NOT RUNNI NG DT NOT SB MASTER D NOT SB SLAVE 179 Appendix B 180 Definition cont DT S B NOT ENABLED DT INVALID CLOCK SRC DT M DT INVALID COUNT MODE EASURE IN PROGRESS DT ONESHOT IN PROGRESS DT SB NOT READY DT NO DAC FILTER DT SB IS BUSY DT SB TIMEOUT DT NVALID DMA BUFFER DT N O DMA CHAN DT E RROR FILTER DT R DT MUST INIT LIBRARY ANGE NOT SUPPORTEI Is DT N O SB MODULE FOR INDEX DT ADC OVERRUN
19. Param2 This parameter is not used NULL You can use this event with DT RegisterCallback in your DSP program to detect D A overrun errors This event never occurs on the host system If this event occurs in your DSP program ensure that the host computer provides analog output data to the DT9840 Series module faster than the DACs are converting the data If you are running DT ScanLoop at 100 KHz you may get a DTEVENT AD OVERRUN or DTEVENT DA UNDERRUN event the first time through the scan loop This event occurs because the interrupt service routine takes longer to execute the first time through the scan loop Ignore these events the first time through the loop subsequent events however should be addressed DTEVENT ERROR Paraml Param2 Indicates that a synchronous error such as a DT_ChanSyncWrite failure occurred in the host application or an asynchronous communication error background task failure occurred in the host application Communication Events and Messages Parameters Name Paraml Description The handle of the module that generated the error Name Param2 Description The error code Notes Currently this event occurs only on the host In response to this event the Windows message DTMSG ERROR is sent to the host application DTEVENT INPUT SCAN BLOCK OVERRUN Syntax DTEVENT INPUT SCAN BLOCK OVERRUN Paraml Param2 Description Indicat
20. Programming Flowcharts Typical Communication Operations e cues coa esee eeeeteee Peace tee nd eed 37 Typical Event Driven Communication Operations 2 00 66 ccc eens 39 35 Chapter 3 The following flowcharts show the steps required to perform typical communication operations that are initiated from the host using the DT9840 Series Host Communication Library 36 Programming Flowcharts Typical Communication Operations Open the DT9840 Series module fromN the host application with Ra DT_BoardOpen Download a DSP application COFF format to the DT9840 Series module with DT_BoardDownload v Run the downloaded DSP application on the module with DT BoardRun Y Open the communication channel on the host with DT ChanOpen Convert voltage data to raw analog data Write data to the module To convert a single value call DT VoltsToDAValue to convert a scan of values call DT VoltsToDAScan to convert values for a single channel within a block call DT VoltsToDAChanBlock to convert a block of values call DT_VoltsToDABlock Write a specified number of bytes to the module asynchronously with DT ChanAsyncWrite y C Go to the next page 2 37 Chapter 3 38 C Continued from previous page 3 Reada specified number of bytes at one time Read data from the modul
21. output pulse width fclks per output pulse x COUNTER CLOCK PERIOD For example if the clock period is 55 55 ns and two clock occur for each output pulse then the output pulse width is 111 11 ns output duty cycle output pulse width output period For example if the output pulse width is 222 2 ns and the output pulse period is 333 3 ns then the output duty cycle is 66 66 OutputPolarity A variable of type POLARITY described on page 185 that defines the polarity of the output pulse for the specified counter timer Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Name Description Name Description Name Description Name Description Name Description In measure mode if POLARITY is ACTIVE HIGH when you call DT TriggerCTR the counter output is low while the measurement is in progress and high when the measurement is complete If POLARITY is ACTIVE LOW when you call DT TriggerCTR the counter output is high while the measurement is in progress and low when the measurement is complete GateType A variable of type GATE TYPE described on page 182 that defines the type of gate to use for the specified counter timer For measure mode and continuous measure mode this value is automatically set to EXT NORMAL GATE if you specify the EDGE TYPE is SELCTED GATE RISES or SELECTED
22. 32 38 41 45 DT ADChanBlockToVolts 13 32 38 41 46 DT ADScanToVolts 13 32 38 41 47 84 DT ADValueToVolts 13 32 38 41 48 85 DT VoltsTODABlock 14 33 37 40 77 DT VoltsToDAChanBlock 14 33 37 40 78 DT VoltsToDAScan 14 33 37 40 80 105 DT VoltsToDAValue 14 37 40 81 106 DT VoltstoDAValue 33 converting raw analog data to voltage values a channel with in a block of data 32 217 Index 218 a scan of data 32 a single value 32 blocks of data 32 converting voltage values to raw analog data a channel with in a block of data 33 a scan of data 33 a single value 33 blocks of data 33 COUNT MODE enumerated type in Visual Basic 173 in Visual C 126 counter timer constants in Visual Basic 169 in Visual C 122 CTR_SETUP data type Visual Basic 194 CTR_SETUP structure Visual C 147 D DAC_FILTER_TYPE enumerated type in Visual Basic 176 in Visual C 130 DAC RANGE enumerated type in Visual Basic 177 in Visual C 131 DAC SETUP data type Visual Basic 198 DAC SETUP structure Visual C 150 data types in Visual Basic 186 in Visual C 116 DATA FILE HDR data type Visual Basic 200 DATA_FILE_HDR structure 151 DIO_SETUP data type Visual Basic 200 DIO SETUP structure Visual C 152 downloading a DSP program 25 DT 9841 MSG UNKNOWN TYPE 114 DT AD VALUE OUT OF RANGE 109 DT ADBlockToVolts 13 32 38 41 45 DT ADChanBlockToVolts 13 32 38 41 46 DT ADScanToVolts 13 32 38 41 in Visua
23. DT ChanAcknowledge hChan 59 Chapter 4 60 DT ChanAsyncWrite Syntax Include File Description Parameters Name Description Name Description Name Description Notes Return Values Example DTSTATUS DT ChanAsyncWrite CHAN HANDLE hChan VOID pBuffer ULONG NumBytes DTCommonAPI H Asynchronously writes a specified number of bytes from an open communication channel on the host to a DT9840 Series module hChan A variable of type CHAN_HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT_ChanOpen described on page 63 pBuffer A pointer to a variable of type VOID that contains the data to write to the DT9840 Series module NumBytes An unsigned integer variable or constant that specifies the number of bytes to write to the DT9840 Series module This function writes the data and returns immediately It does not wait for an acknowledgement from the DT9840 Series module If the communication channel is busy or backed up with data the actual transfer to the DT9840 Series module continues in the background this function does not block If you want to write data to the DT9840 Series module asynchronously and wait for an acknowledgement from the module that the data was received use DT_ChanSyncWrite described on page 68 instead See Appendix A starting on page 107
24. Example DT BoardOpen Syntax Include File Description 52 BoardIndex A variable of type WORD that specifies the index of the DT9840 Series module whose name you want to return The first DT9840 Series module installed in the system has a BoardIndex of 0 BoardName A variable of type BOARD_NAME described on page 116 in which the ASCII name of the DT9840 Series module is returned This function is rarely needed It is used only in very generalized cases where for example a host based application requires the names of all connected DT9840 Series modules at runtime More typical programs deal with a single DT9840 Series module with a well known name In these cases the host application can open the module directly by name with DT_BoardOpen described on page 52 See Appendix A starting on page 107 Print the names of all DT9840 Series modules installed in the system BOARD_NAME BoardName int BoardIndex BoardIndex 0 While DT BoardGetName BoardIndex BoardName DT SUCCESS Printf Board d name s n BoardIndex BoardName BoardIndex DTSTATUS DT BoardOpen CHAR BoardName BRD HANDLE phBoard BOARD OPTIONS pBoardOptions DTCommLib H Opens a DT9840 Series module by name sets the size the module input and output buffers and returns a hand
25. The data register for analog output channel 1 DEVICE REG BASE 0x8004 DIG OUT REG The digital output register DEVICE REG BASE 0x8008 Port 2 is not used for the DT9841 VIB module CTRO PERIOD REG The period register for counter timer 0 DEVICE REG BASE 0xC000 CTR1 PERIOD REG The period register for counter timer 1 DEVICE REG BASE 0xC004 CTR2 PERIOD REG The period register for counter timer 2 DEVICE REG BASE 0xC008 CTRO PULSE REG The pulse register for counter timer 0 DEVICE REG BASE 0xC010 CTR1 PULSE REG The pulse register for counter timer 1 DEVICE REG BASE 0xC014 CTR2 PULSE REG The pulse register for counter timer 2 DEVICE REG BASE 0xC018 Data Types Constants Enumerated Types Structures and Callback Functions CTRO_CTRL_REG The control register for counter timer 0 DEVICE REG BASE 0xC020 CTR1_CTRL_REG The control register for counter timer 1 DEVICE REG BASE 0xC024 CTR2 CTRL REG The control register for counter timer 2 DEVICE REG BASE 0xC028 CTR STATUS REG The status register for the counter timers DEVICE REG BASE 0xC030 DIG IN MASK REG The mask register for digital input port 0 DEVICE REG BASE 0x10000 You can program this register to generate an interrupt when any bit of port 0 changes state DIG PORTO REG The register for digital I O port 0 DEVICE REG BASE 0x10004 DIG PORTI1 REG The register for digital I O
26. Type CLOCK SETUP ClockSource As AD Dummyl As Long DA CLK SRC SampleRate As Double MaxSampleRate As Double Double ActualSampleRate As Double ClockType As CLOCK TYPE Unusedl As Unused2 As Unused3 As Unused4 As Unused5 As End Type MinSampleRate As Long Long Long Long Long DTCommLib BAS ClockSource A variable of type AD DA CLK SRC described on page 170 that specifies the clock source for the input output operation Dummy1 A variable of type Long that is used internally by the system for padding Do not use this variable Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Name Description Name Description Name Description SampleRate A variable of type Double that specifies the frequency in Hz for the internal sample clock For the DT9841 DT9841E and DT9841 VIB modules values range from 200 Hz to 100 000 Hz For the DT9842 2 and DT9842 8 modules values range from 0 Hz to 100 000 Hz The actual frequency that the module can achieve may be slightly different than the frequency you specified due to the accuracy of the clock frequency 0 01 The actual clock frequency is returned in ActualSampleRate For the DT9841 DT9841E and DT9841 VIB modules the module multiplies the value that you specify for the internal clock frequency by 512 to set the oscillator on the modul
27. all other counter timer operations 149 Appendix B 150 Name Description DAC SETUP Structure Definition Include File Elements Name Description Name Description Name Description Unused 5 An unsigned integer array with five elements that is currently unused typedef struct DAC FILTER TYPE FilterType LONG DAInitialValue NUM DAC CHANS ERROR MODE SELECT ErrorOption DAC RANGE DacRange ULONG Unused 5 DAC SETUP DTCommonAPI H FilterType A variable of type DAC_FILTER_TYPE described on page 130 that specifies the reconstruction filter to apply to the analog output channels on the DT9840 Series module DAlInitialValue For clocked analog output operations an array of integer variables that specifies the initial raw counts to output to the analog output channels when DT SetupDAC described in the DT9840 Series DSP Library User s Manual is called ErrorOption A variable of type ERROR MODE SELECT described on page 135 that specifies whether to continue or stop the analog output operation when an D A underrun error is detected If you are performing an output operation and an input operation simultaneously using DT ScanLoop DT BlockLoop or DT ListLoop the following restrictions apply to ErrorOption e If ErrorOption in the ADC SETUP structure is set to CONTINUE ON ERROR set ErrorOption in the DAC SETUP structure to CONTI
28. application The host application program should read the data from the communication channel as soon as possible by calling DT ChanReadAvailable described on page 67 or with DT ChanRead described on page 65 In most well designed programs this event should not occur In most cases this event indicates that one or more of the following conditions exists on the host Thechannel input buffer is too small for the application Increase the size of the channel input buffer by calling DT ChanOpen described on page 63 in your host application program e The application program was busy with another operation for too long and did not read the data from the communication channel in a timely manner Reorganize the host application program so that reading data from the channel input buffer is a high priority operation 209 Appendix C Notes cont DTEVENT DA UNDERRUN Syntax Description Parameters Name Description Name Description Notes DTEVENT ERROR Syntax Description 210 The host application is reading fewer bytes than the DSP program on the module is writing to it If the host application program is calling DT ChanRead instead of DT_ChanRead Available ensure that it is reading as many bytes as are being written by the DT9840 Series module DTEVENT DA UNDERRUN Paraml Param2 Indicates that an D A underrun error occurred Param1 This parameter is not used NULL
29. DT INVALID DSP BUFFER SIZE PTR DT INVALID HOST BUFFER SIZE PTR DT INVALID BUF SIZE DT CHAN OPENED FOR WRITE DT CHAN OPENED FOR READ Errors that are specific to the host DT INVALID BOARD NAME DT HOST BASE ERR 1000 DT INVALID BOARD HANDLE DT INVALID PHBOARD DT INVALID FILENAME DT INVALID BOARD INDEX DIT INVALID BOARD INFO DT INVALID WINDOW HANDLE DT FAILURE DT INVALID MSG PTR DT INVALID MSG BUF LEN DT INVALID DSP ADDRESS DT CANT OPEN DRIVER DT CANT FIND BOARD DT NO BOARD FOR INDEX DT NO CHAN FOR INDEX DT NO MESSAGING Data Types Constants Enumerated Types Structures and Callback Functions Definition cont DT WINDOW NOT FOUND DT F ILE NOT FOUND D DRIVER VERSION D IRMWARE VERSION inl TB D DT NO PROGRAM LOADED DSP VERSION DT ERROR F if READ D ERROR INVALID COFF DT DT NVALID BUFFER ADDRESS ERROR MEMORY MISMATCH DT USB ERROR DT NVALID DSP ADDRESS PTR DT NVALID REGISTER BOARD ALREADY OPEN ONS NVALID BOARD OPTI BOARD NOT RESPONDI NG BOARD WAS SHUTDOWN Errors PROGRAM TOO LARGE that are specific to the DT9841 p 2000 GENERAL DT9841 ERROR DT 9841 BASE ERR DT
30. DTBoardWriteRegister BoardHandle LED REG CurrentLEDValue Declare Function DT BoardWriteToMemory Lib DTCommLib dll ByVal hBoard As Long ByRef SrcPCBuffer As Long ByVa ByVa As NumBytes As Long DestDSPAddress As Long DTSTATUS DTCommLib BAS Writes data from a variable on the host computer to an address in DSP memory on the DT9840 Series module with no assistance from the DSP hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 Function Reference for Visual Basic Programmers Name Description Name Description Name Description Notes Return Values Example DT ChanAsyncWrite Syntax Public Interface SrcPCBuffer A variable of type LONG that contains the data from the host to write to the DSP on the DT9840 Series module NumBytes A variable of type LONG that specifies the number of bytes to write to the DSP on the DT9840 Series module DestDSPAddress A variable of type LONG that specifies the address of DSP memory on the DT9840 Series module to write to Although you can write to any DSP address using this function it is highly recommended that you write to a known DSP address Writing to an arbitrary DSP address can cause major system problems This function operates synchronously and take precedence ov
31. Data TranslationNDT9840 Series LIBS x64 dtcommlib lib Host applications built with the 32 bit DT9840 Series Host Communication Library will run on 32 bit and 64 bit platforms Host applications built with the 64 bit DT9840 Series Host Communication Library will run on 64 bit platforms only 16 Overview Product Support This section provides information about obtaining support if you have trouble using the DT9840 Series Host Communication Library General Checklist Should you experience problems using the DT9840 Series Host Communication Library follow these steps 1 Read all the appropriate sections of this manual including any Read This First information 2 Check the DT9840 Series Software CD for a README file If present read this file for the latest installation and usage information 3 Check that you have installed your software properly For information refer to the DT9840 Series Getting Started Manual 4 Check that you have installed a DT9840 Series module properly using the instructions in the DT9840 Series Getting Started Manual Note If you are still having problems follow the instructions provided in the next section Service and Support If you have difficulty using the DT9840 Series Host Communication Library Data Translation s Technical Support Department is available to provide technical assistance To request technical support go to our web site at http www datatranslation com a
32. Dim BoardHandle As Long Status DT BoardRun BoardHandle 0 Declare Function DT BoardWriteRegister Lib DTCommLib dll ByVal hBoard As Long ByVal Register As Long ByVal Value As Long As DTSTATUS DTCommLib BAS Writes a value to a specified register on the DT9840 Series module hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 Register A variable of type LONG that specifies the register on the DT9840 Series module to write to 93 Chapter 5 Name Description Notes Return Values Example DT BoardWriteToMemory Syntax Public Interface Description Parameters Name Description 94 Value A variable of type LONG that specifies the value to write to the specified register on the DT9840 Series module The DICommAPI BAS file defines constants that you can use for Register Refer to page 164 for more information on these constants See Appendix A starting on page 107 BoardHandle On the module specified by set the state of the debug LEDs Dim Status As DTSTATUS Dim BoardHandle As Long Dim CurrentLEDValue Mask CurrentLEDValue 0 Mask 1 For i 0 to 7 f LED i Value 1 Then CurrentLEDValue CurrentLEDValue or Mask End If i As Long Mask Mask 2 Next Status
33. For the DT9841 DT9841E and DT9841 VIB this number is 28 For the DT9842 2 and DT9842 8 this number is 216 BIP10 COUNTS PER VOLT The number of counts per volt for the 10 V range of the specified module This is defined as follows NUM STEPS COUNTS PER STEP BIP10 VOLTS SPAN BIP2PT5 COUNTS PER VOLT The number of counts per volt for the 2 5 V range of the specified module This is defined as follows NUM STEPS COUNTS PER STEP BIP2PT5 VOLTS SPAN 165 Appendix B 166 BIP10 VOLIS PER COUNT The number of volts per count for the 10 V range of the specified module This is defined as follows 1 BIP10 COUNTS PER VOLT e BIP2PT5 VOLIS PER COUNT The number of volts per count for the 2 5 V range of the specified module This is defined as follows 1 BIP2PT5 COUNTS PER VOLT e BIP10 MAX VOLIS The voltage that corresponds to the maximum count value for the 10 V range of the specified module This is defined as follows 10 BIPIO VOLTS PER COUNT e BIP2PT5 MAX VOLIS The voltage that corresponds to the maximum count value for the 2 5 V range of the specified module This is defined as follows 2 5 BIPZPT5 VOLTS PER COUNT e BIP10 MIN VOLIS The voltage that corresponds to the minimum count value for the 10 V range of the specified module This is defined as 10 e BIP2PT5 MIN VOLIS The voltage that corresponds to the minimum count value for the 2 5 V range of the specified module This va
34. GATE TYPE GATED OFF 0 GATED ON 1 EXT NORMAL GATE 2 EXT INVERTED GATE 3 End Enum Public Interface DTCommLib BAS Members Name GATED OFF Description If you specify this element the gate is disabled Name GATED ON Description If you specify this element a software command enables the counter timer operation immediately after execution This gate type is not supported for up down counting measure mode continuous measure mode one shot or repetitive one shot operations Name EXT NORMAL GATE Description For standard counting operations enables the operation when the external gate signal is high and disables the operation when the external gate signal is low For one shot and repetitive one shot operations enables the operation on the transition from the low level to the high level rising edge and disables the operation on the transition from the high level to the low level falling edge For up down counting mode increments the counter when the external gate signal is high and decrements the counter when the external gate signal is low For measure mode and continuous measure mode this value is automatically set to EXT NORMAL GATE if you specify the EDGE TYPE is SELCTED GATE RISES or SELECTED GATE FALLS 182 Data Types Constants Enumerated Types Structures and Callback Functions Name Description Definition Include File Elements Name Description Name Descrip
35. Related Documents Refer to the following documents for more information DT9840 Series Getting Started Manual UM 19199 This manual included on the DT9840 Series Software CD describes the how to install a DT9840 Series module and related software DT9840 Series User s Manual UM 19197 This manual included on the DT9840 Series Software CD describes the hardware features of the DT9840 Series function modules including the hardware registers specifications and connector pin assignment information DT9840 Series DSP Library User s Manual UM 19591 This manual included on the DT9840 Series Software CD describes how to write a DSP program to perform communication I O and conversion operations on a DT9840 Series module Documentation for Code Composer Studio Integrated Development Environment IDE from Texas Instruments Documentation for Texas Instruments TMS320C6713 DSP processor Microsoft Windows XP Windows Vista or Windows 7 documentation Microsoft Visual Studio documentation USB 1 1 and USB 2 0 specifications available on the USB web site http www usb org Where to Get Help Should you run into problems installing or using the DT9840 Series Host Communication Library the Data Translation Technical Support Department is available to provide technical assistance Refer to page 17 for more information If you are outside the United States or Canada call your local distributor whose number is listed on Data Tr
36. Return Values Example DAChan An unsigned integer variable or constant that specifies on which analog output channel within the block to perform the conversion For the DT9841 DT9841E DT9841 VIB and DT9842 2 valid values are 0 and 1 For the DT9842 8 valid values are 0 to 7 NumScans An unsigned integer variable or constant that specifies the number of scans in each block to convert If you want to convert all of the values in the block corresponding to a specified analog output channel set NumScans to the value of ScansThisBlock in the OUTPUT SCAN BLOCK structure described on page 158 pOutBlock A pointer to an array of type OUTPUT SCAN BLOCK described on page 158 in which the raw analog output values are returned VoltageRange A variable of type DAC RANGE described on page 131 that specifies the analog output voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 OUTPUT SCAN BLOCK pOutBlock DOUBLE OutVolts MAX SCAN SIZE ULONG NumScans Converts an array of output voltages in the 10 V range to equivalent raw DA values and stores them in an Output Block as the values for one DA channel This example assumes that pOutBlock points to an output block that needs to be filled with raw DA values before being sent to the hardware NumScans must be less than MA
37. bytes from DSPAdd on the module to HostValue on the host computer Status DT BoardReadFromMemory hBoard DSPAdd 50 amp HostValue DTSTATUS DT BoardReadRegister BRD HANDLE hBoard ULONG Register ULONG pValue DTCommLib H Reads the value of a specific register on a DT9840 Series module hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 Register An unsigned integer variable or constant that specifies the register on the DT9840 Series module to read 55 Chapter 4 Name Description Notes Return Values Example DT BoardRun Syntax Include File Description Parameters Name Description Name Description Notes 56 pValue A pointer to an unsigned integer variable in which the value of the specified register on the DT9840 Series module is returned The DTCommonAPLH include file defines constants that you can use for Register Refer to page 116 for more information on these constants See Appendix A starting on page 107 BRD HANDLE BrdHandle ULONG pValue Read the value of the register for analog input channel 0 Status DT BoardReadRegister BrdHandle ADO IN REG amp pValue DTSTATUS DT BoardRun BRD HANDLE hBoard CHAR
38. described on page 212 This event occurs only on the host DTEVENT INPUT SCAN BLOCK OVERRUN described on page 211 DTEVENT OUTPUT SCAN BLOCK UNDERRUN described on page 214 DTEVENT AD OVERRUN described on page 208 DTEVENT DA UNDERRUN described on page 210 162 Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Name Description pContext A pointer to a variable of type VOID that is passed to this function when DT RegisterCallback described on page 70 is called A typical use for pContext is to pass a this pointer in C so that the callback function has access to the object that registered the callback If the events DTEVENT INPUT SCAN BLOCK OVERRUN DTEVENT OUTPUT SCAN BLOCK UNDERRUN DTEVENT AD OVERRUN or DTEVENT DA UNDERRUN occur pContext must point to a global variable constant or dynamically allocated block and NOT to a variable on a stack These events can only occur in a DSP program Param1 An integer variable returned by this function whose value depends on the event that occurred Refer to Appendix C starting on page 207 for more information Param2 An integer variable returned by this function whose value depends on the event that occurred Refer to Appendix C starting on page 207 for more information 163 Appendix B 164 For Visual Basic Programmers This section descri
39. each DT9840 Series module that is opened internal module buffers are created on the host that are used to store messages that are read from and written to the module Module buffers are used in concert with channel buffers described on page 26 to move data between the host and the module You can specify the size of each module input buffer used for reading data and output buffer used for writing or use the default buffer sizes 64 kBytes A matching module buffer is created on the DT9840 Series module Ata minimum the size of the module input buffer must be at least as large as the largest message that the module will send to the host using the DT ChanSyncWrite or DT ChanAsyncWririte function in the DSP program The size of the module output buffer must be at least as large as the largest message that the host will send to the module using the DT ChanSyncWrite or DT ChanAsyncWrite function in the host application If the amount of memory used by your host application is not a concern we recommend that you set the size of each module buffer to a multiple of the largest message DT ChanSyncWrite or DT ChanAsyncWrite that is sent Figure 6 illustrates how module buffers and channel buffers are used when the host writes data to the DT9840 Series module Figure 7 illustrates how module buffers and channel buffers are used when the host reads data from the DT9840 Series module 23 Chapter 2
40. for writing READ CHAN with DT ChanOpen 28 DT CHAN OPENED FOR Tried to write to a channel that Open the channel as type READ was opened for reading WRITE CHAN with DT ChanOpen 1000 DT INVALID BOARD NAME The BoardName argument is Check the module name using invalid DT BoardGetName 1001 DT INVALID BOARD HANDLE The board handle argument is Specify an appropriate module not valid handle that was returned by DT BoardOpen 1002 DT INVALID PHBOARD The phBoard argument is not Pass a valid pointer for phBoard valid 1003 DT INVALID FILENAME The pFilename argument is not Pass a valid pointer for pFilename valid 1004 DT INVALID BOARD INDEX The Boardindex argument is not If a single module is installed in the valid system specify O for the board index If more than one module is installed in the system specify an appropriate value for the board index The modules are numbered sequentially starting at O 1005 DT INVALID BOARD INFO The pBoardinfo argument is not Pass a valid pointer for pBoardinfo valid 1006 DT INVALID WINDOW The hWindow argument is not Specify an appropriate window HANDLE valid handle 1007 DT FAILURE General Error indicates an This error indicates that an internal internal error problem occurred in the DT9840 Series Host Communication Library This error should never occur in a properly installed and running system Contact Technical Support see page 17 1008 DT INVALID MSG PTR The pMsg argument is not valid
41. functions in the DT9840 Series DSP Library You can structure your programs in the following ways Typical Communication Programming Host Initiated Write the host program to open communication channels and write the DSP program to open its end of the communication channels as shown in Figure 2 No events are used so you must ensure that both programs open the communication channels in the same order Host Program DT9840 Series Module Open a DT9840 Series module DT BoardOpen and return a handle to it fal gt DT9840 Seri Download a DSP program to the DSP PRO DT BoardDownload DT9840 Series module DT BoardRun Run the downloaded program o The host opens a communication channel with a specified name In response the DSP program on the module opens a communication channel with the same name DT_ChanOpen po The host writes data asynchronously to the open channel In response the module reads data from the open DT_ChanAsyncWrite channel DT_ChanRead DT_ChanOpen Figure 2 Typical Communication Programming Host Initiated e Typical Communication Programming DSP Initiated Write the DSP program to open communication channels and write the host program to open its end of the communication channels as shown in Figure 3 No events are used so you must ensure that both programs open the communication channels in the same order Using the DT9840 Series Host Communicat
42. input buffer BUFFER bigger than board s send buffer on the host is large enough to hold the data that is being written from the module 21 DT VOLTAGE OUT OF Voltage being converted is out The voltage value must be within RANGE of range of D A 10 V 22 DT AD VALUE OUT OF A D value is out of range or The A D value must be 32 bits wide RANGE full scale and left justified the right eight bits must be filled with zeros 23 DT NO SYNC DATA No synchronous msg was An acknowledge should be sent only RECEIVED received but Acknowledge was when the host receives a sent synchronous write command from the module 24 DT INVALID DSP BUFFER An invalid pointer was passed Pass a valid pointer for pDSPBufSize SIZE PTR as the pDSPBufSize argument 25 DT INVALID HOST BUFFER An invalid pointer was passed Pass a valid pointer for pHostBufSize SIZE PTR as the pHostBufSize argument 109 Appendix A Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 26 DT INVALID BUF SIZE The BufSize argument is invalid Specify a value for BufSize that is greater than O In general the value of BufSize should be at least as large as the largest single write of data from the DSP application 27 DT CHAN OPENED FOR Tried to read from a channel that Open the channel as type WRITE was opened
43. input buffer on the DT9840 Series module is full the module must read the specified amount of data from the channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible This function is useful if you want to synchronize the operation of the host application with the DSP application on the module Typically DT ChanAsyncWrite described on page 59 is easier to use and has higher performance than DT ChanSyncWrite See Appendix A starting on page 107 CHAN HANDLE hChan CHAR ChBuff 8993 Write 100 bytes from ChBuff to the module and wait for a response from the module Timeout if a response is not received in 10000 ms Status DT ChanSyncWrite hChan amp ChBuff 100 10000 CHAR DT GetErrorString DTSTATUS Status CHAR pErrString DTCommonAPI H Returns an ASCII string that corresponds to a specific error code 69 Chapter 4 Parameters Name Description Name Description Notes Return Values Example DT RegisterCallback Syntax Include File Description 70 Status An unsigned integer variable or constant that specifies the error code for which to return a string descriptor pErrString A pointer to a variable of type CHAR in which a copy of the string that is returned by this function is stored If NULL the returned ASCII string is no
44. interval of the signal between the specified start and stop edges The pulse width and period count are automatically set to 0 You can use the following equations to determine the frequency and period of the signal based on the value of the counter e Frequency 18 MHz Number of Counts e Period 1 Frequency DAC FILTER TYPE Enumerated Type Definition Public Interface Public Enum DAC FILTER TYPE NONE 0 FIVE_KHZ 1 TWENTY_KHZ 2 End Enum DTCommLib BAS Data Types Constants Enumerated Types Structures and Callback Functions Members Name Description Name Description Name Description NONE If you specify this element no filter will be applied to the analog output channels Use this setting for DT9842 2 and DT9842 8 modules FIVE KHZ If you specify this element a 5 kHz reconstruction filter is applied to each analog output channel on the DT9841 DT9841E and DT9841 VIB This setting is recommended for slow clock rates This element is ignored for the DT9842 and DT9842 8 modules TWENTY KHZ If you specify this element a 20 kHz reconstruction filter is applied to each analog output channel on the DT9841 DT9841E and DT9841 VIB This setting is recommended for fast clock rates This element is ignored for the DT9842 and DT9842 8 modules DAC RANGE Enumerated Type Definition Public Interface Members Name Description Name Description Public E
45. is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 147 The pulse output then stays inactive and the counter stays disabled until the one shot trigger enable bit is set The active polarity of the pulse output pulse is determined by OutputPolarity described on page 149 127 Appendix B 128 Name Description Name Description REPETITIVE ONE SHOT If you specify this element the counter timer outputs a single pulse when the specified external gate signal is active Specify an internal C T clock source and either a normal external gate or an inverted external gate When the operation is enabled with an external gate the counter begins incrementing When the counter increments to the value of PulseWidthCount described on page 148 the value of the counter is output The output stays active until the counter rolls over to 0 the terminal count The output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 147 The user output then stays inactive and the counter stays disabled until the next active gate occurs All gates that occur while the counter is incrementing are ignored The active polarity of the pulse output pulse is determined by OutputPolarity described on page 149 MEASURE If you specify this element the counter timer measures the inte
46. least as large as the largest message that the DT9840 Series module will send to the host using the DT ChanSyncWrite or DT ChanAsyncWririte function in the DSP program on the module If the amount of memory used by the host application is nota concern we recommend that you set the size of the module input buffer to a multiple of the largest message DT ChanSyncWrite or DT ChanAsyncWrite that the DT9840 Series module will send to the host WriteBufSizeInKb A variable of type Long that specifies the size of the module output buffer in kilobytes If you specify 0 for WriteBufSizeInKb the default size 64 kBytes is used At a minimum the size of the module output buffer must be at least as large as the largest message that the host will send to the DT9840 Series module using the DT ChanSyncWrite or DT_ChanAsyncWrite function in the host application If the amount of memory used by the host application is not a concern we recommend that you set the size of the module output buffer to a multiple of the largest message DT_ChanSyncWrite or DT_ChanAsyncWrite that the host will send to the DT9840 Series module DbgFlag A variable of type Long that is passed from the DT9840 Series Host Communication Library to the DT9840 Series DSP Library and is used to control serial debugging on the module The DT9840 Series DSP Library uses the lowest 16 bits of this value The upper 16 bits is available to your host program to define as you w
47. measure mode operation is complete or not using DT ReadCTRStatus When the operation is complete read the value of the counter using DT ReadCTR Use the following equations to determine the frequency period and pulse width of the signal e Frequency 18 MHz Number of Counts e Period 1 Frequency Pulse width Number of Counts 18 MHz Note In measure mode the internal C T clock is used to calculate the interval of the signal between the specified start and stop edges The pulse width and period count are automatically set to 0 You can specify the polarity of the output signal during and after the measurement UP_DOWN If you specify this element the counter timer increments when the specified external gate is enabled and decrements when the specified external gate is disabled The counter timer increments or decrements on the rising edge of the external clock input signal Use UP DOWN mode only when the position of the object being monitored stays within the range of the counter as the operation is not be reliable if the counter increments above FFFFFFFh or decrements below 0 Specify an external C T clock source this mode does not support a cascaded C T source Specify either a normal external gate or inverted external gate signal When the operation is enabled the counter increments to the value specified by PulseWidthCount described on page 196 and activates the pulse output The pulse output stays active
48. module and do not verify the download operation Dim Status As DTSTATUS Dim BoardHandle As Long Status DT_BoardDownload BoardHandle LEDflash out False Declare Function DT_BoardGetInfo Lib DTCommLib dll ByVal hBoard As Long ByRef BoardStatus As BRD As DTSTATUS NFO DTCommLib H Returns information about the connected DT9840 Series module including its memory configuration hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT_BoardOpen described on page 89 BoardStatus A variable of type BRD_INFO described on page 190 in which the type name state memory configuration and FPGA version of the specified DT9840 Series module is returned Ensure that TCF file for your module has the appropriate settings Refer to the DT9840 Series DSP Library User s Manual for more information about TCF files 87 Chapter 5 Return Values Example DT BoardGetName Syntax Public Interface Description Parameters Name Description Name Description Notes Return Values 88 See Appendix A starting on page 107 Return the type of DT9840 Series module installed in the system Dim Status As DTSTATUS Dim BoardHandle As BRD HANDLE Dim BoardInfo As BRD INFO Status DT BoardGetName B
49. module does not write the specified number of bytes in 1000 ms a timeout occurs Status DT ChanRead hChan amp HostBuff 100 1000 Function Reference for Visual C Programmers DT ChanReadAvailable Syntax Include File Description Parameters Name Description Name Description Name Description Name Description Notes DTSTATUS DT ChanReadAvailable CHAN HANDLE hChan VOID pBuffer ONG BufSize LONG pBytesRead set dep d DTCommonAPI H Returns the data that is available from the DT9840 Series module up to the size of the channel input buffer BufSize hChan A variable of type CHAN_HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT_ChanOpen described on page 63 pBuffer A pointer to a variable of type VOID in which the data from the DT9840 Series module is returned BufSize An unsigned integer variable or constant that specifies the size of the pBuffer variable on the host computer in bytes This value is the maximum number of bytes that can be read from the DT9840 Series module and stored in pBuffer at one time pBytesRead A pointer to an unsigned integer variable in which the number of bytes that were read is returned this value can never be greater than BufSize When the number that is returned is less than Bu
50. of bytes that is returned is less than the size of the channel input buffer not all of the data from the DSP program is available but the data that is available is returned to the host When the number of bytes that is returned is equal to the size of the channel input buffer more than the requested data from the DSP program is available but only the portion of data that fits in the channel input buffer is returned The most data that can be returned at one time cannot be larger than the size of the channel input buffer You can return the number of bytes that are currently available in a specified channel buffer by using the DT ChanBytesAvailable function Note that the following issues may arise when the host application program reads data from a communication channel causing a DTEVENT CHAN IN BUFFER FULL event described on page 209 to be generated The channel input buffer is too small for the application Increase the size of the channel input buffer by calling DT ChanOpen described on page 63 in your host application program Theapplication program was busy with another operation for too long and did not read the data from the communication channel in a timely manner Reorganize the host application program so that reading data from the communication channel is a high priority operation The host application is reading fewer bytes than the DSP program is writing to it If the host application program is calling DT ChanRead i
51. on page 70 to register a callback function See Appendix A starting on page 107 BRD HANDLE hBoard HWND hWinHandle Register a window handle in which a message will be posted when the DSP has opened its side of the communication channel in response to a request from the host Status DT RegisterMsgHandler hBoard hwinHandle DTEVENT REMOTE CHAN OP I NED DTSTATUS DT_UnregisterCallback BRD_HANDLE hBoard CALLBACKPROC pCallback H Unregisters a callback function that was previously registered using the DT_RegisterCallback function described on page 70 DTCommonAPI H hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT_BoardOpen described on page 52 75 Chapter 4 Name pCallback Description A pointer to a user defined callback function of type CALLBACKPROC described on page 162 that you want to unregister Notes None Return Values See Appendix A starting on page 107 Example Unregister the callback function RemoteChanOpenProc DTStatus DT UnregisterCallback hBoard RemoteChanOpenProc DT UnregisterMsgHandler Syntax DTSTATUS DT UnregisterMsgHandler BRD HANDLE hBoard HWND hWindow Include File DTCommLib H Description Unregisters the messag
52. open matching channels and establish communication with them The DT9840 Series module must open its side of the channel within the specified timeout period ora DT_TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible When dealing with multiple channels ensure that your host and DSP applications open the communication channels in the same order For example if your host application opens channels 1 2 and 3 ensure that your DSP program opens channel 1 before it opens channel 2 and opens channels 1 and 2 before opening channel 3 When you are finished with it ensure that you close the communication channel using DT_ChanClose described on page 61 to release any resources that were associated with it See Appendix A starting on page 107 BRD HANDLE bHandle CHAN HANDLE hChan Open chan1 on the host for reading with a input buffer size of 8992 bytes and return the handle to the channel in hChan If the DSP program does not open its side of the channel in 10000 ms time out Status DT ChanOpen bHandle CHAR chan1 READ CHAN 8992 amp hChan 10000 DTSTATUS DT ChanRead CHAN HANDLE hChan VOID pBuffer ULONG NumBytes ULONG TimeoutInMS Y DTCommonAPI H 65 Chapter 4 66 Description Parameters Name Description Name Description Name Descri
53. port 1 DEVICE REG BASE 0x10008 DIG PORT2 REG The register for digital I O port 2 DEVICE REG BASE 0x1000C Port 2 is not used for the DT9841 VIB module SB CTRL REG The Control and Address CE3 register for the Scalable Bus DEVICE REG BASE 0x14000 SB XFER CTRL REG The Scalable Bus Transfer Control register DEVICE REG BASE 0x14004 SB XFER STATUS REG The Scalable Bus Transfer Status register DEVICE REG BASE 0x14008 SB REG BASE The Scalable Bus write register 0xA0000000 SB OUT REG The Scalable Bus write register SB REG BASE SB IN REG The Scalable Bus input register SB REG BASE 4 Error Constants The following error constants are defined in the DTErrors H file which is referenced by DTCommLib H DT COMMON BASE ERR A value of 0 DT HOST BASE ERR A value of 1000 DT 9841 BASE ERR A value of 2000 DT HOST COMM BASE ERR A value of 3000 DT 9841 COMM BASE ERR A value of 4000 DT LAST ERR BASE A value of 4000 121 Appendix B Event Constants The following event constants are defined in the DTCommon H file which is referenced by DT9841 H DTEVENT REMOTE CHAN OPENED A value of 0x00000001 DTEVENT REMOTE CHAN CLOSED A value of 0x00000002 DTEVENT ASYNC DATA RECEIVED A value of 0x00000004 DTEVENT SYNC DATA RECEIVED A value of 0x00000008 DTEVENT CHAN IN BUFFER FULL A value of 0x00000010 DTEVENT OUT BUFFER SPACE AVAILABLE A value of 0x00000
54. program over the USB bus Functions to the DSP on a DT9840 Series module DT BoardRun Runs a previously downloaded DSP program on a DT9840 Series module Write Functions DT BoardWriteToMemory Writes data from a variable on the host computer to an address in DSP memory on a DT9840 Series module with no assistance from the DSP DT BoardWriteRegister Writes a value to a specified register on a DT9840 Series module Read Functions DT BoardReadFromMemory Reads data from an address in DSP memory on a DT9840 Series module to a variable on the host computer with no assistance from the DSP DT BoardReadRegister Reads the value of a specified register on the DT9840 Series module Communication DT BoardGetName Returns the name of a connected DT9840 Series Support Functions module DT BoaraGetlnfo Returns information about the type of module that is connected DT GetErrorString Returns an ASCII string that corresponds to specified error code 11 Chapter 1 Table 1 Board Level Functions cont Function Type Function Name Description Event Handling Functions DT RegisterMsgHandler Registers the window in which all future Windows messages that are associated with specified events are received a DT UnregisterMsgHandler Unregisters a previously registered Windows message handler DT RegisterCallback Registers a callback function that is called whenever
55. system for padding Do not use this variable Port2Out A Boolean variable that specifies whether digital port 2 is an input or an output port If FALSE digital port 2 is an input port if TRUE digital port 2 is an output port 201 Appendix B 202 Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description Dummy4 A variable of type Integer that is used internally by the system for padding Do not use this variable DeglitchPort0 A Boolean variable that specifies whether to enable or disable deglitch circuitry on digital port 0 this function minimizes false triggers due to noise and is particularly useful when using the interrupt on change feature If TRUE a 10 ms deglitch function is enabled for digital port 0 If FALSE the 10 ms deglitch function is disabled for digital port 0 This parameter is ignored if PortOOut is TRUE Dummy5 A variable of type Integer that is used internally by the system for padding Do not use this variable InitialDOValue A variable of type Long that specifies the initial value to output to the digital output lines when DT SetupDIO described in the DT9840 Series DSP Library User s Manual is called Dummy6 A variable of type Integer that is used internally by the system for padding Do not use th
56. that were associated with it hChan A variable of type CHAN_HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT_ChanOpen described on page 63 61 Chapter 4 Notes Return Values Example DT ChanGetlnfo Syntax Include File Description Parameters Name Description Name Description Name Description Name Description Name Description Name Description 62 None See Appendix A starting on page 107 Close channel hChan on the host Status DT ChanClose hChan DTSTATUS DT ChanGetInfo BRD HANDLE hBoard WORD ChanIndex CHAN NAME ChanName CHAN TYPE pChanType ULONG pHostBufSize ULONG pDSPBufSize ey DTCommonAPI H Returns information about the channel that is associated with the specified ChanIndex hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 ChanIndex A variable of type WORD that specifies the index of the communication channel The first open communication channel has a ChanIndex of 0 ChanName A variable of type CHAN_NAME described on page 116 in which the ASCII name of the active communication channel is returned pChanType A pointer to a variable of CHAN_TYPE described o
57. the DTCommLib H file e ADC_SETUP described on page 140 BOARD OPTIONS described on page 141 CHAN OPEN INFO described on page 145 CLOCK SETUP described page 145 CTR_SETUP described on page 147 DAC SETUB described on page 150 DATA FILE HDR or PDATA FILE HDR described on page 139 DIO_SETUP described on page 152 IEPE CHAN INFO described on page 153 IEPE_SETUP described on page 154 INPUT SCAN BLOCK described on page 155 139 Appendix B 140 e I NPUT SCAN RCD described on page 156 OUTPUT SCAN BLOCK described on page 158 OUTPUT SCAN RCD described on page 160 e TRIGGER SETUD described on page 160 The following structures are defined in the DTCommLib H file BRD INFO described on page 143 e MSG INFO and PMSG INFO structures described on page 158 ADC SETUP Structure Definition Include File Elements Name Description typedef struct ULONG Termination ERROR_MODE_SELECT ErrorOption ULONG Unused 5 ADC_SETUP DTCommonAPI H Termination An unsigned integer variable that enables or disables 1 kQ bias return termination resistors for the analog input channels on the DT9841 and DT9841E modules Since the DT9841 VIB DT9842 2 and DT9842 8 modules have single ended inputs only this element is ignored for these modules This feature is particularly useful with floating signal sources on the DT9841 and DT9841E Refer to the DT9840 Series Getting Started Manual for more in
58. the DSP program how large to create the matching channel input buffer on the module if you wish hChan A variable of type LONG in which the handle to the opened communication channel is returned If this procedure fails hChan is NULL TimeoutInMS A variable of type LONG that specifies the timeout value in milliseconds If TimeoutInMS 0 the timeout period is disabled Function Reference for Visual Basic Programmers Notes Return Values Example DT ChanRead Syntax Public Interface Description Once the communication channel is open you can use the other channel functions to send data to receive data from and manage the communication channel A host application can open an arbitrarily named channel and write data to or read data from it The corresponding program on the DT9840 Series module can then use this name to open the channel and establish communication with it The DT9840 Series module must open its side of the channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible When dealing with multiple channels ensure that your host and DSP applications open the communication channels in the same order For example if your host application opens channels 1 2 and 3 ensure that your DSP program opens channel 1 before it opens channel 2 and opens channels 1 and 2 before opening channel 3 W
59. the DSP program on the DT9840 Series module Refer to page 24 for more information on buffers You can open multiple channels between the host computer and a DT9840 Series module at any time and interleave data over the USB bus Each channel is a unidirectional buffered byte stream therefore dealing with a communication channel from the host application program is similar to reading data from and writing data to a file If you are using multiple channels and do not know their names you can use DT ChanGetInfo to return the names and other information about the communication channels The corresponding DSP program on the module can use the same channel name to open the channel on its end and establish communication with it The DSP program on the DT9840 Series module must open its side of the communication channel within a specified timeout period or a DT TIMEOUT error is returned You can write the host application program to detect the timeout error and recover if possible Note When dealing with multiple channels ensure that your host and DSP applications open the communication channels in the same order For example if your host application opens channels 1 2 and 3 ensure that your DSP program opens channel 1 before it opens channel 2 and opens channels 1 and 2 before opening channel 3 Once you have opened a communication channel you can read data from the communication channel as described on page 27 or write data t
60. the Scalable Bus is not enabled for the module Refer to the DT9840 Series Getting Started Manual for more information on enabling the Scalable Bus using the DT9840 Series Control Panel applet Dummy2 A variable of type Integer that is used internally by the system for padding Do not use this variable SBAddress An integer variable that contains the Scalable Bus address of the module If the module is the master a bus address of 0 is returned If the module is a slave a bus address of 1 through 3 is returned Refer to the DT9840 Series Getting Started Manual for more information on assigning addresses to modules using the DT9840 Series Control Panel applet 191 Appendix B Name Description Name Description Name Description CLOCK SETUP Data Type Definition Public Interface Members Name Description Name Description 192 SBTerminated A Boolean variable that indicates whether the Scalable Bus is terminated for the module If TRUE the Scalable Bus is terminated for the module If FALSE the Scalable Bus is not terminated for the module Refer to the DT9840 Series Getting Started Manual for more information on terminating the Scalable Bus using the DT9840 Series Control Panel applet Dummy3 A variable of type Integer that is used internally by the system for padding Do not use this variable Reserved An integer array of 15 elements that is reserved for future use
61. until the counter rolls over to 0 the terminal count The pulse output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 195 175 Appendix B 176 Description cont Name Description The active polarity of the pulse output pulse is determined by OutputPolarity described on page 196 This sequence repeats as long as the counter is enabled by the gate You can read the value of the counter at any time using DT ReadCTR CONTINUOUS MEASURE If you specify this element the counter starts incrementing when it detects a specified start edge and stops incrementing when it detects the next start edge the stop edge is ignored in this mode When the operation completes the counter remains idle until it is next read On the next read the current value of the counter from the previous edge to edge measurement operation is returned and the next edge to edge measurement operation is started automatically Connect the signal that you want to measure to either the clock input pin or the gate input pin of the counter timer that you want to use Then specify the measurement start edge Refer to page 181 for more information on the start edge Read the value of the counter using DT ReadCTR If you read the counter before the measurement is complete 0 is returned Note Incontinuous measure mode the internal C T clock is used to calculate the
62. value is TRUE AC coupling is enabled If the value is FALSE AC coupling is disabled and DC coupling is used Notes This data type is used by the IEPE SETUP data type described on page 154 and applies to the DT9841 VIB module only IEPE SETUP DataType Definition Type IEPE SETUP Chan NUM ADC REGS 1 As IEPE CHAN INFO End Type Include File DTCommLib BAS Elements Name Chan NUM_ADC_REGS Description An array of type IEPE CHAN INFO described on page 203 that specifies the IEPE parameters for all of the analog input channels on the DT9841 VIB module 203 Appendix B 204 Description cont Notes The array is defined to be as large as the number of analog input registers Refer to page 164 or more information on NUM ADC REGS This data type applies to the DT9841 VIB module only INPUT SCAN RCD Data Type Definition Public Interface Members Name Description Name Description Type INPUT SCAN RCD ADCValues NUM ADC REGS 1 As Long FlagsAndDin As Long CounterValues NUM COUNTERS 1 As Long End Type DTCommLib BAS ADCValues NUM_ADC_REGS A Long array in which the acquired value of all the analog input channels is returned The array is defined to be as large as the number of analog input registers Refer to page 164 for more information on NUM_ADC_REGS FlagsandDin A variable of type Long in which the state of the digital input ports and the eig
63. want the smoothest possible analog output signal this is particularly true at clock frequencies lower than 50 KHz 199 Appendix B DATA FILE HDR Definition Include File Elements Name Description Name Description Notes DIO SETUP Data Type Definition Public Interface 200 Type DATA FILE HDR DataFileID As Long NumBytes As Long End Type DTCommLib BAS DataFileID A variable of type Long that identifies the data file This variable must be set to the value of DATA_FILE_MAGIC_NUMBER defined on page 169 NumBytes A variable of type Long that specifies the number of bytes to write to or read from the 64 KB reserved block of flash memory This value should be greater than 0 and less than USER DATA MEM SIZE defined on page 169 This data type is used to define the header of each data file to write to or read from flash memory using the DT9840 Series Flash Programmer Utility The header is followed by the actual data to write to or read from the 64 KB reserved block in flash memory Type DIO_SETUP ClockDout As Boolean Dummy1 As Integer Port00ut As Boolean Dummy2 As Integer PortlOut As Boolean Dummy3 As Integer Port20ut As Boolean Dummy4 As Integer DeglitchPort0 As Boolean Dummy5 As Integer InitialDOValue As Long Dummy6 As Integer Unusedl As Long Unused2 As Long Unused3 As Long Unused4 As Long Unused5 As Long End Type
64. 020 DTEVENT ERROR A value of 0x00000040 DTEVENT MODULE UNPLUGGED A value of 0x00000080 e DTEVENT ALL COMM EVENTS A value of 0x0000003F Message Constants The following message constants are defined in the DTCommLib H file e DTMSG REMOTE CHAN OPENED WM APP 300 DTMSG REMOTE CHAN CLOSED WM APP 301 DTMSG ASYNC DATA RECEIVED WM APP 302 e DTMSG SYNC DATA RECEIVED WM APP 303 e DTMSG CHAN IN BUFFER FULL WM APP 305 e DTMSG OUT BUFFER SPACE AVAILABLE WM APP 306 DTMSG ERROR WM APP 307 DTMSG MODULE UNPLUGGED WM APP 308 Counter Timer Constants The following register constants are defined in the DTCommonAPI H file which is referenced in the DTCommLib H file COUNTER RESOLUTION A value of FFFFFFFFh 2 1 when using the internal clock source for counter timer operations e CASCADED RESOLUTION A value of FFFFFFFFFFFFFFFFh 2 when using the cascaded clock source for counter timer operations e COUNTER CLOCK FREQ A value of 18 MHz the time base for the internal clock for counter timer operations COUNTER CLOCK PERIOD A value of 55 ns 1 COUNTER CLOCK FREQ 122 Data Types Constants Enumerated Types Structures and Callback Functions Flash Memory Constants The following flash memory constants are defined in the DTCommonAPI H file e USER DATA MEM SIZE A value of 0x10000 DATA FILE MAGIC NUMBER A value of 0x09191956 Enumerated Types T
65. 1 23 51 88 DT BoardOpen 11 23 37 39 52 89 DT BoardReadFromMemory 11 28 54 90 DT BoardReadRegister 11 28 55 91 DT BoardRun 11 25 37 39 56 92 DT BoardWriteRegister 11 30 57 93 DT BoardWriteToMemory 11 30 58 94 DT GetErrorString 11 DT RegisterCallback 12 31 39 70 DT RegisterMsgHandler 12 31 73 DT UnregisterCallback 12 31 41 75 DT UnregisterMsgHandler 12 31 76 BRD INFO data type Visual Basic 190 building host programs 16 Index C callback functions 162 CALLBACKPRCC callback function 162 CHAN OPEN INTO structure Visual C 145 CHAN TYPE enumerated type in Visual Basic 171 in Visual C 124 channel level functions DT ChanAcknowledge 12 29 38 41 59 DT ChanAsyncWrite 12 29 37 40 60 95 DT ChanBytesAvailable 13 27 61 96 DT ChanClose 12 26 38 41 61 97 DT ChanGetInfo 13 26 62 98 DT ChanOpen 12 26 37 39 63 99 DT ChanRead 13 27 38 41 65 101 DT ChanRead Available 13 27 38 41 67 103 DT ChanSyncWrite 12 29 40 68 DT GetErrorString 34 69 104 CLOCK SETUP data type Visual Basic 192 CLOCK SETUP structure Visual C 145 CLOCK SRC enumerated type in Visual Basic 171 in Visual C 125 CLOCK TYPE enumerated type 126 in Visual Basic 172 closing a module 24 26 communication channel information 26 constants error 122 in Visual Basic 164 in Visual C 116 conversion constants in Visual Basic 165 in Visual C 118 conversion functions DT ADBlockToVolts 13
66. 126 in Visual Basic 169 in Visual C 123 error constants 122 in Visual Basic 169 in Visual C 121 error handling 34 ERROR MODE SELECT enumerated type in Visual Basic 181 in Visual C 135 errors 107 108 DT 9841 MSG UNKNOWN TYPE 114 DT AD VALUE OUT OF RANGE 109 DT BOARD ALREADY OPEN 113 DT BOARD NOT RESPONDING 113 DT BOARD WAS SHUTDOWN 113 DT BUFFER TOO SMALL 108 DT CALLBACK NOT FOUND 108 DT CANT FIND BOARD 111 DT CANT OPEN DRIVER 111 DT CHAN ALREADY CLOSED 109 DT CHAN ALREADY OPEN 109 DT CHAN DISCONNECTED 109 DT CHAN OPENED FOR READ 110 DT CHAN OPENED FOR WRITE 110 DT DRIVER VERSION 111 DT DSP VERSION 112 DT ERROR FILE READ 112 DT ERROR INVALID COFF 112 DT ERROR MEMORY MISMATCH 112 DT FAILURE 110 DT FILE NOT FOUND 111 DT FIRMWARE VERSION 112 DT HOST BUFFER EMPTY 113 DT HOST CHAN ALREADY CLOSED 113 DT HOST CHAN ALREADY OPEN 113 DT HOST CHAN BUFFER FULL 114 DT HOST MSG INVALID LENGTH 114 DT HOST RCV BUFFER FULL 114 DT HOST SEND BUFFER FULL 114 DT INCOMPATIBLE CHAN TYPE 109 DT INVALID BOARD HANDLE 110 DT INVALID BOARD INDEX 110 DT INVALID BOARD INFO 110 DT INVALID BOARD NAME 110 DT INVALID PHBOARD 110 DT INVALID PHCHAN 108 DT INVALID BUF SIZE 110 DT INVALID BUFFER ADDRESS 112 DT INVALID BUFFER PTR 108 DT INVALID BYTES READ PTR 108 DT INVALID CALLBACK PTR 108 DT INVALID CHAN HANDLE 108 DT INVALID CHAN NAME 108 DT INVALID CHAN TYPE 108 DT INVALID DSP ADDRESS PTR 113 DT INVALID DSP
67. 170 that specifies the analog input voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 Convert Value into a voltage in the 10 V range and store in Volts Dim Status As DTSTATUS Dim Value As Long Dim Volts As Double Status DT ADValueToVolts Value Volts BIP10 VOLTS SPAN Declare Function DT BoardClose Lib DTCommLib dl1 ByVal hBoard As Long As DTSTATUS Closes a previously opened module and releases all allocated resources that were associated with it 85 Chapter 5 Public Interface Parameters Name Description Notes Return Values Example DT BoardDownload Syntax Public Interface Description Parameters Name Description Name Description Name Description 86 DTCommLib BAS hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 None See Appendix A starting on page 107 Close the module with handle BoardHandle Dim Status As DTSTATUS Dim BoardHandle As Long Status DT BoardClose BoardHandle Declare Function DT BoardDownload Lib DTCommLib dll ByVal hBoard As Long ByVal FileName As String ByVal bVerify As Boolean As DTSTATUS DTCommLib BAS
68. 1E modules Data Types Constants Enumerated Types Structures and Callback Functions ADS IN REG The data register for analog input channel 3 DEVICE REG BASE amp H400C Ignore this register for DT9841E modules AD4_IN_REG The data register for analog input channel 4 DEVICE_REG_BASE amp H4010 Ignore this register for DT9841E modules AD5_IN_REG The data register for analog input channel 5 DEVICE_REG_BASE amp H4014 Ignore this register for DT9841E modules AD6 IN REG The data register for analog input channel 6 DEVICE REG BASE amp H4018 Ignore this register for DT9841E modules AD7 IN REG The data register for analog input channel 7 DEVICE REG BASE amp HA01C Ignore this register for DT9841E modules DIG IN REG The input register for digital input ports 0 1 and 2 and the flag bits DEVICE REG BASE amp H4020 Port 2 is not used for the DT9841 VIB module CTRO IN REG The input register for counter timer 0 DEVICE REG BASE amp H4024 CTR1 IN REG The input register for counter timer 1 DEVICE REG BASE amp H4028 CTR2 IN REG The input register for counter timer 2 DEVICE REG BASE amp HA02C LED REG The register for the diagnostic LEDs DEVICE REG BASE amp H4030 The following constants are provided for controlling individual LEDs LED D0 LED CR9 amp H01 LED D1 LED CR10 amp H02 LED D2 LED CR11 amp H04 LED D3 LED CR8 amp H08
69. 2PT5 COUNTS PER VOLT BIP10 VOLTS PER STEP The number of volts per step for the 10 V range of the specified module This is defined as follows BIPIO VOLTS PER COUNT COUNTS PER STEP BIP2PT5 VOLIS PER STEP The number of volts per step for the 2 5 V range of the specified module This is defined as follows BIPZPT5 VOLTS PER COUNT COUNTS PER STEP BIP10 MAX VOLTS The voltage that corresponds to the maximum count value for the 10 V range of the specified module This is defined as follows 10 L BIP10 VOLTS PER COUNT BIP2PT5 MAX VOLIS The voltage that corresponds to the maximum count value for the 2 5 V range of the specified module This is defined as follows 2 5 L BIPZPT5 VOLTS PER COUNT Data Types Constants Enumerated Types Structures and Callback Functions e BIP10 MIN VOLTS The voltage that corresponds to the minimum count value for the 10 V range of the specified module For all DT9840 Series modules this is defined as 10L e BIP2PT5 MIN VOLIS The voltage that corresponds to the minimum count value for the 2 5 V range of the specified module This range 2 5 L is supported by the DT9841 DT9841E and DT9841 VIB modules Register Constants The following register constants are defined in the DTCommonAPI H file which is referenced in the DTCommLib H file These constants are provided if you want to read the registers of a DT9840 Series module using DT BoardReadRegister describe
70. 9 in Visual C 63 DT ChanRead 13 27 38 41 in Visual Basic 101 in Visual C 65 DT ChanRead Available 13 27 38 41 in Visual Basic 103 in Visual C 67 DT_ChanSyncWrite 12 29 40 in Visual C 68 DT_DRIVER_VERSION 111 DT_DSP_ VERSION 112 DT_DSP_VERSION 112 DT ERROR MEMORY MISMATCH 112 DT ERROR FILE READ 112 DT ERROR INVALID COFF 112 DT FAILURE 110 DT FILE NOT FOUND 111 DT FIRMWARE VERSION 112 DT GetErrorString 11 34 in Visual Basic 104 in Visual C 69 DT HOST BUFFER EMPTY 113 DT HOST CHAN ALREADY CLOSED 113 DT HOST CHAN ALREADY OPEN 113 DT HOST CHAN BUFFER FULL 114 DT HOST MSG INVALID LENGTH 114 DT HOST RCV BUFFER FULL 114 DT HOST SEND BUFFER FULL 114 DT INCOMPATIBLE CHAN TYPE 109 DT INVALID BUFFER ADDRESS 112 DT INVALID BYTES READ PTR 108 DT INVALID CHAN TYPE 108 DT INVALID PHBOARD 110 DT INVALID PHCHAN 108 DT INVALID BOARD HANDLE 110 DT INVALID BOARD INDEX 110 DT INVALID BOARD INFO 110 DT INVALID BOARD NAME 110 DT INVALID BUF SIZE 110 DT INVALID BUFFER PTR 108 DT INVALID CALLBACK PTR 108 DT INVALID CHAN HANDLE 108 DT INVALID CHAN NAME 108 DT INVALID CHAN TYPE 108 DT INVALID DSP ADDRESS 111 DT INVALID DSP ADDRESS PTR 113 DT INVALID DSP BUFFER SIZE PTR 109 DT INVALID FILENAME 110 DT INVALID HOST BUFFER SIZE PTR 109 DT INVALID MSG BUF LEN 110 DT INVALID MSG PTR 110 DT INVALID NUM BYTES 108 DT INVALID POINTER 108 DT INVALID REGISTER 113 DT INVALID WINDOW HANDLE 110 DT NO PROGR
71. A Ee rete ue 123 Structures iu ones eed eie ER ge RR retrato SURE Ete nene et dete 139 DATA FILE HDR or PDATA FILE HDR Structure 2 000 151 Callback E tctohs z5 vi ou beet Cee RU US tee ton ate Maa es 162 For Visual Basic Programmers o o o o oooooooorrr enn 164 Constants pene edu ed be ELT pe bb trt bei 164 Global Constants 1 eet ta eret or ce D eh ole lts evan 164 Conversion Constants sumi ace Ree TRES ee eee Reese pre E 165 Register Constants iere td Den Perte d t Pea aped See e Geta oe 166 Error Constants sot Bi cheap Se Mae eee uisa PERAGERE 169 Counter Timer Constants usce Boe Bee ehe Rer ben tte ae aly Wee wg BRAGS 169 Flash Memory Constants s suasane neran neran nrun eee eee ee 169 Enumerated Types 5 isus e erem we y e Ry Rer ee ee s 169 Data TYPES iien ina ee aa e a Dike Palma sores a uu wa EE GR ae e dete ue ae perite 186 Appendix C Communication Events and Messages 207 DTEVENT AD OVERRUN essseee eh a hm sh 208 DTEVENT ASYNC DATA RECEIVED sssseeee m 208 DTEVENT CHAN IN BUFFER FULL ssesseee e e 209 DTEVENT DA UNDERRUN ssseseee ee hn rmn 210 DTEVENT ERROR eaaet t ena ume UN See MIT caes 210 DTEVENT INPUT SCAN BLOCK OVERRUN sssesseee ene 211 DIEVENT MODULE PLUGGED s en bis boss esed T Eae EIC EN DUCERE 211 DTEVENT MODULE UNPLUGGED ssesseee e he 212 DTEVENT OUT BUFFER SPACE AVAILABLE se
72. A FILE HDR PDATA FILE HDR DTCommonAPI H DataFileID An unsigned integer variable that identifies the data file This variable must be set to the value of DATA_FILE_MAGIC_NUMBER defined on page 123 NumBytes An unsigned integer variable that specifies the number of bytes to write to or read from the 64 KB reserved block of flash memory This value should be greater than 0 and less than USER_DATA_MEM_SIZE defined on page 123 151 Appendix B 152 Notes DIO SETUP Structure Definition Include File Elements Name Description Name Description This structure is used to define the header of each data file to write to or read from flash memory using the DT9840 Series Flash Programmer Utility The header is followed by the actual data to write to or read from the 64 KB reserved block in flash memory typedef struct BOOL ClockDout BOOL Port0Out BOOL Port10ut BOOL Port20ut BOOL DeglitchPort0 ULONG InitialDOValue ULONG Unused 5 DIO SETUP DTCommonAPI H ClockDout A Boolean value that specifies whether to clock digital output values from the DT9840 Series module while analog output values are being clocked out If TRUE digital output values are output with analog output values at the frequency of the sample clock when any of the following functions in the DT9840 Series DSP Library is called DT
73. AM LOADED 112 DT NO BOARD FOR INDEX 111 DT NO CHAN FOR INDEX 111 DT NO MEMORY 108 DT NO MESSAGING 111 DT NO SYNC DATA RECEIVED 109 DT NOT IMPLEMENTED 108 DT PROGRAM TOO LARGE 113 DT ReadCTR 127 128 129 130 173 175 176 DT ReadCTRStatus 128 175 DT RegisterCallback 12 31 39 70 DT RegisterMsgHandler 12 31 73 DT SUCCESS 108 DT TIMEOUT 108 DT TOO BIG FOR BOARD BUFFER 109 DT TOO BIG FOR CHAN BUFFER 109 DT TriggerCTR 128 175 DT UnregisterCallback 12 31 41 75 DT UnregisterMsgHandler 12 31 76 DT USB ERROR 112 DT VOLTAGE OUT OF RANGE 109 DT VoltsToDABlock 14 33 37 40 77 DT VoltsToDAChanBlock 14 33 37 40 78 DT VoltsToD AScan 14 33 37 40 in Visual Basic 105 in Visual C 80 DT VoltsToDAValue 14 37 40 in Visual Basic 106 in Visual C 81 DT VoltstoDAValue 33 DT WINDOW NOT FOUND 111 DTEVENT AD OVERRUN 208 DTEVENT ASYNC DATA RECEIVED 208 DTEVENT CHAN IN BUFFER FULL 209 DTEVENT DA UNDERRUN 210 DTEVENT ERROR 210 DTEVENT INPUT SCAN BLOCK OVERRUN 211 DTEVENT MODULE PLUGGED 211 DTEVENT MODULE UNPLUGGED 212 DTEVENT OUT BUFFER SPACE AVAILABLE 213 DTEVENT OUTPUT SCAN BLOCK UNDERRUN 214 DTEVENT REMOTE CHAN CLOSED 214 219 Index 220 DTEVENT REMOTE CHAN OPENED 215 DTEVENT SYNC DATA RECEIVED 215 DTSTATUS enumerated type in Visual Basic 178 in Visual C 131 E EDGE TYPE enumerated type in Visual Basic 181 in Visual C 134 enumerated types CLOCK TYPE
74. An unsigned integer variable or constant that specifies the DSP address on the DT9840 Series module that you want to read NumBytes An unsigned integer variable or constant that specifies the number of bytes to read from the DSP on the DT9840 Series module pDestPCBuffer A pointer to a variable of type VOID on the host in which the data from the DSP on the DT9840 Series module is returned Function Reference for Visual C Programmers Notes Return Values Example DT BoardReadRegister Syntax Include File Description Parameters Name Description Name Description Although you can read from any DSP address using this function it is highly recommended that you read from a known DSP address Reading from an arbitrary DSP address can cause major system problems This function operates synchronously and take precedence over all other communication operations For example if you use this function to read 2 MBytes of data from the DT9840 Series module all other messaging between the host computer and the module is suspended until all 2 MBytes has been transferred Unlike most other functions in this library DT BoardReadFromMemory does not require that a DSP program is running on the module To read specific registers on the DT9840 Series module use DT BoardReadRegister described on page 55 See Appendix A starting on page 107 BRD HANDLE hBoard ULONG DSPAdd ULONG HostValue Return 50
75. BUFFER SIZE PTR 109 DT INVALID FILENAME 110 DT INVALID HOST BUFFER SIZE PTR 109 DT INVALID MSG BUF LEN 110 DT INVALID MSG PTR 110 DT INVALID NUM BYTES 108 DT INVALID POINTER 108 DT INVALID REGISTER 113 DT INVALID WINDOW HANDLE 110 DT NO BOARD FOR INDEX 111 DT NO CHAN FOR INDEX 111 DT NO MEMORY 108 DT NO MESSAGING 111 DT NO PROGRAM LOADED 112 DT NO SYNC DATA RECEIVED 109 DT NOT IMPLEMENTED 108 DT PROGRAM TOO LARGE 113 DT SUCCESS 108 DT TIMEOUT 108 DT TOO BIG FOR BOARD BUFFER 109 DT TOO BIG FOR CHAN BUFFER 109 DT USB ERROR 112 DT VOLTAGE OUT OF RANGE 109 DT WINDOW NOT FOUND 111 event driven operations how to perform 39 events DTEVENT AD OVERRUN 208 DTEVENT ASYNC DATA RECEIVED 208 DTEVENT CHAN IN BUFFER FULL 209 DTEVENT DA UNDERRUN 210 DTEVENT ERROR 210 DTEVENT INPUT SCAN BLOCK OVERRUN 211 DTEVENT MODULE PLUGGED 211 Index DTEVENT MODULE UNPLUGGED 212 DTEVENT OUT BUFFER SPACE AVAILABLE 213 DTEVENT OUTPUT SCAN BLOCK UNDERRUN 214 DTEVENT REMOTE CHAN CLOSED 214 DTEVENT REMOTE CHAN OPENED 215 DTEVENT SYNC DATA RECEIVED 215 G GATE TYPE enumerated type in Visual Basic 182 in Visual C 135 general purpose constants in Visual C 117 H handling errors 34 help 8 17 j IEPE CHAN INFO data type Visual Basic 203 IEPE CHAN INFO structure Visual C 153 IEPE SETUP data type Visual Basic 208 IEPE SETUP structure Visual C 154 INP
76. C028 CTR STATUS REG The status register for the counter timers DEVICE REG BASE amp HC030 DIG_IN_MASK_REG The mask register for digital input port 0 DEVICE_REG_BASE amp H10000 You can program this register to generate an interrupt when any bit of port 0 changes state DIG PORTO REG The register for digital I O port 0 DEVICE REG BASE amp H10004 DIG PORTI1 REG The register for digital I O port 1 DEVICE REG BASE amp H10008 DIG PORT2 REG The register for digital I O port 2 DEVICE REG BASE amp H1000C Port 2 is not used for the DT9841 VIB module SB CTRL REG The Control and Address CE3 register for the Scalable Bus DEVICE REG BASE amp HB0014000 SB XFER CTRL REG The Scalable Bus Transfer Control register amp HB0014004 SB XFER STATUS REG The Scalable Bus Transfer Status register amp HB0014008 SB REG BASE The Scalable Bus write register HA0000000 SB OUT REG The Scalable Bus write register amp HA0000000 SB IN REG The Scalable Bus input register amp H A0000004 Data Types Constants Enumerated Types Structures and Callback Functions Error Constants The following error constants are defined in the DTCommLib BAS file DT COMMON BASE ERR A value of 0 DT HOST BASE ERR A value of 1000 DT 9841 BASE ERR A value of 2000 DT HOST COMM BASE ERR A value of 3000 DT 9841 COMM BASE ERR A value of 4000 Counter Timer Constants The following regis
77. DATA TRANSLATION UM 19593 Q DT9840 Series Host Communication Library User s Manual Fifteenth Edition August 2013 Data Translation Inc 100 Locke Drive Marlboro MA 01752 1192 508 481 3700 www datatranslation com Fax 508 481 8620 E mail info datx com Copyright O 2013 by Data Translation Inc All rights reserved Information furnished by Data Translation Inc is believed to be accurate and reliable however no responsibility is assumed by Data Translation Inc for its use nor for any infringements of patents or other rights of third parties which may result from its use No license is granted by implication or otherwise under any patent rights of Data Translation Inc Use duplication or disclosure by the United States Government is subject to restrictions as set forth in subparagraph c 1 ii of the Rights in Technical Data and Computer software clause at 48 C F R 252 227 7013 or in subparagraph c 2 of the Commercial Computer Software Registered Rights clause at 48 C F R 52 227 19 as applicable Data Translation Inc 100 Locke Drive Marlboro MA 01752 Data Translation is a registered trademark of Data Translation Inc All other brand and product names are trademarks or registered trademarks of their respective companies Table of Contents About this Manual oococcooccnccoc eh hn nnn 7 Intended Audience opere pepe E Re ete ERR EE e PCR ee e wed Bee 7 What You Should Le
78. DTSTATUS DT BoardWriteRegister BRD HANDLE hBoard ULONG Register ULONG Value DTCommLib H Writes a value to a specified register on a DT9840 Series module hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 Register An unsigned integer variable or constant that specifies the register on the DT9840 Series module to write to pValue An unsigned integer variable that specifies the value to write to the specified register on the DT9840 Series module The DTCommonAPLH include file defines constants that you can use for Register Refer to page 116 for more information on these constants See Appendix A starting on page 107 Write a value of 0 to the ADO input register BRD HANDLE BrdHandle Status DT BoardWriteRegister BrdHandle ADO IN REG 0 57 Chapter 4 58 DT BoardWriteToMemory Syntax Include File Description Parameters Name Description Name Description Name Description Name Description Notes DTSTATUS DT BoardWriteToMemory BRD HANDLE hBoard VOID pSrcPCBuffer ULONG NumBytes ULONG DestDSPAddress DTCommLib H Writes data from a variable on the host computer to an address in DSP memory on a DT9840 Ser
79. FOR INDEX NO MESSAGI DT WINDOW NO FILE NOT FOUND DT DRIVER VERSION NG FOUND FIRMWARE VERSION DT DSP VERSI ON D COFF INVALID BUFFER ADDRESS DT INVALID DSP ADI DT INVALID REGISTER DT BOARD ALREA DT NO PROGRAM LOADED DT ERROR FILE READ DT ERROR INVAL DT DT ERROR MEMORY MISMATCH DT USB ERROR DRESS PTR DY OPENED Data Types Constants Enumerated Types Structures and Callback Functions Definition cont DT INVA DT DT DT_GENERAL_DT9841 DT_9841_BASE_ERR ID_BOARD_OPTIONS BOARD_NOT_RESPONDING BOARD_WAS_SHUTI DT_PROGRAM_TOO_LARGE DOWN _ERROR DT_NOT_SB_MASTER DT_NOT_SB_SLAVE DT NO S DT INVALID SAMPLE RATE DT NO DIGITAL OUT PORTS DT NO DIGITAL IN PO
80. GATE FALLS MeasureModeStartEdge Used for measure mode operations and continuous measure mode operations only a variable of type EDGE TYPE described on page 181 that specifies what edge of the signal connected to the external gate or external clock input pin starts the measurement In continuous measure mode the counter increments from the first start edge to the next start edge the stop edge is ignored This variable is ignored for all other counter timer operations MeasureModeStopEdge Used for measure operations only a variable of type EDGE TYPE described on page 181 that specifies what edge of the signal connected to the external gate or external clock input pin stops the measurement This variable is ignored for all other counter timer operations Unused1 An unsigned integer variable that is currently unused specify 0 for this member Unused2 An unsigned integer variable that is currently unused specify 0 for this member Unused3 An unsigned integer variable that is currently unused specify 0 for this member Unused4 An unsigned integer variable that is currently unused specify 0 for this member 197 Appendix B Name Description DAC SETUP Data Type Definition Public Interface Members Name Description Name Description Name Description 198 Unused5 An unsigned integer variable that is currently unused specify 0 for this member Type DAC SETUP Fi
81. INFO and PMSG INFO Structures Definition Include File Elements Name Description Name Description typedef struct PVOID pMessage ULONG NumBytes MSG_INFO PMSG_INFO DTCommLib H pMessage A pointer to a variable of type VOID that either specifies the message to send or receives the message that is sent NumBytes An unsigned integer variable that identifies the number of bytes in the message to send or that have been received OUTPUT_SCAN_BLOCK Structure Definition Include File Elements Name Description 158 typedef struct struct OUTPUT_SCAN_BLOCK pNext ULONG nScansThisBlock ULONG AllocSize ULONG BlockNum BOOL BlockComplete OUTPUT SCAN RCD Scans 1 OUTPUT SCAN BLOCK DTCommonAPI H pNext Specifies a pointer of type OUTPUT_SCAN_BLOCK that points to the next block in the list For block loop operations the value of pNext is NULL Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Name Description Name Description For list loop operations the value of pNext is passed to this structure when DT MallocOutputBlockList described in the DT9840 Series DSP Library User s Manual is called If the list was allocated for a continuous list loop operation the last block s pNext pointer points to the first b
82. LEAN Anytime the DSP application writes data to the host the DSP application should empty the cache CACHE FLUSH after the data is written Using the DT9840 Series Host Communication Library Handling Channel Communication Events Various events are generated when specific actions occur in the system such as when a channel is opened data is received and so on The DT9840 Series Host Communication Library and DT9840 Series DSP Library post Windows messages that correspond to these events Refer to Appendix C starting on page 207 for more information on events and messages You can write an application to trap and handle these events messages The host application can act as a server for the DT9840 Series module where the host program waits for messages from the module that indicate whether the module is requesting data or needs service The host application can then perform an appropriate action in response to each message The DT9840 Series Host Communication Library provides two mechanisms for monitoring asynchronous events that can be generated in your running system when using Visual C Callback functions Typically console based programs use callback functions to monitor asynchronous events When a specific event occurs a registered callback function is called to notify you that the event occurred It is the responsibility of the programmer to define this callback function so that it handles the specified events appropriate
83. MPLE RATE The minimum sample rate For the DT9841 DT9841E and DT9841 VIB this is 200 Hz For the DT9842 2 and DT9842 8 this value is 0 Hz MAX SAMPLE RATE The maximum sample rate This is 100000 Hz for all DT9840 Series modules DT BOARD TYPE The specific DT9840 Series module this value is 9841 to identify the DT9841 and DT9841 VIB 98412 to identify the DT9841E module 9842 to identify the DT9842 2 or 9848 to identify the DT9842 8 NUM ADC REGS The number of analog input registers All DT9840 Series modules have 8 analog input registers For the DT9841E the first two registers correspond to analog input channels 0 and 1 the data in the remaining registers should be ignored NUM ADC CHANS The number of analog input channels For the DT9841 DT9841 VIB DT9842 2 and DT9842 8 this value is 8 For the DT9841E module the value of NUM ADC CHANS is 2 NUM COUNTERS The number of counter timer channels for all DT9840 Series modules this value is 3 NUM DIN The number of 24 bit digital input lines for all DT9840 Series modules this value is 1 For the DT9841 VIB only the first 16 bits are accessible the 8 remaining bits should be ignored NUM DOUT The number of 24 bit digital output lines for all DT9840 Series modules this value is 1 For the DT9841 VIB only the first 16 bits are accessible the 8 remaining bits should be ignored NUM ADC STEPS The number of steps for the A D converter on the module F
84. N IN BUFFER FULL cese br R RR RE AEA 209 DTEVENT DA UNDERRUN orice s gti i iE A EAEE A KG xe eR REDE 210 DIEVENTI ERROR dm Bde A tad 210 BDIEVENT INPUT SCAN BLOCK OVERRUN cec e e ERERYY RR eR 211 DIBEVENI MODULE PLUGGED os cec a RIPE ERE CER 211 DTEVENT MODULE UNPLUGGED omita e emet RES IRI RC REST E 212 DIEVENT OUT BUFFER 5PALB AVAILABLE ouest RR RR RR Hr 213 DTEVENT OUTPUT SCAN BLOCK UNDERRUN sees enne 214 DIEVENT REMOTE CHAN CLOSED coo ici Re eR RES IRR E enn 214 BIBEVENT REMOTE CHAN OPENED cce ert ere x RR REM RESCRYR 215 DIBEVENTI SYNC DATA RECEIVED erc rhe ri 215 207 Appendix C DTEVENT AD OVERRUN Syntax Description Parameters Name Description Name Description Notes DTEVENT AD OVERRUN Paraml Param2 Indicates that an A D overrun error occurred Param1 This parameter is not used NULL Param2 This parameter is not used NULL You can use this event with DT RegisterCallback in your DSP program to detect A D overrun errors This event never occurs on the host system If this event occurs in your DSP program ensure that the host program reads analog input data from the DT9840 Series module as fast as it is being acquired If you are running DT ScanLoop at 100 KHz you may get a DTEVENT AD OVERRUN or DTEVENT DA UNDERRUN event the first time through the scan loop This event occurs because the interrupt service routine takes longer to execute the first time through th
85. NDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 73 Chapter 4 74 Description cont Name Description Name Description If you specify a valid value for hBoard the registered event handler is called for events that occur on the associated DT9840 Series module If you specify NULL for Board all events regardless of the module are sent to the registered event handler hWindow A variable of type HWND that specifies the handle to the window in which all future Windows messages that are associated with the specified DT9840 Series module are displayed EventTraps An unsigned integer variable that specifies the type of event about which to be notified The following constants are defined e DTEVENT REMOTE CHAN OPENED described on page 215 e DTEVENT REMOTE CHAN CLOSED described on page 214 DTEVENT ASYNC DATA RECEIVED described on page 208 DTEVENT SYNC DATA RECEIVED described on page 215 e DTEVENT CHAN IN BUFFER FULL described on page 209 DTEVENT OUT BUFFER SPACE AVAILABLE described on page 213 DTEVENT ERROR described on page 210 DTEVENT AD OVERRUN described on page 208 this event occurs in the DSP program on the DT9840 Series module only DTEVENT DA UNDERRUN described on page 210 this event occurs in the DSP program on the DT9840 Series module only
86. NUE ON ERROR In this case if either a D A underrun or A D overrun error occurs the user defined callback functions for both operations are still invoked Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Notes e If ErrorOption in the ADC SETUP structure is set to STOP ON ERROR set ErrorOption in the DAC SETUP structure to STOP ON ERROR In this case if either a D A underrun or A D overrun error occurs both operations stop and the user defined callbacks are NOT invoked DacRange A variable of type DAC RANGE described on page 131 that specifies the output range for the analog output channels Unused 5 An unsigned integer array of five elements that is currently unused On the DT9842 2 the two analog output channels are 180 degrees out of phase with each other On the DT9842 8 each analog output channel is 45 degrees out of phase with the previous channel To convert a voltage to a raw initial value use DT VoltsToDAValue described on page 81 We recommend that you turn on the 20 kHz filter whenever you want the smoothest possible analog output signal this is particularly true at clock frequencies lower than 50 kHz DATA FILE HDR or PDATA FILE HDR Structure Definition Include File Elements Name Description Name Description typedef struct ULONG DataFileID ULONG NumBytes DAT
87. OID that is passed to a user defined callback function when DT RegisterCallback is called A typical use for pContext is to pass a this pointer in C so that the callback function has access to the object that registered the callback Various events are generated when specific actions occur in the system such as when a module is opened a message is received and so on The DT9840 Series Host Communication Library and DT9840 Series DSP Library post messages that correspond to these events You can write your host application program to respond to these events If you call DT RegisterCallback and specify the events to trap a user specified callback function is called whenever one of these events occurs Refer to Appendix C starting on page 207 for more information on events and messages When you are finished with the callback function use DT UnregisterCallback described on page 75 to unregister the callback function As an alternative to callback functions you can use a Windows message handler to get information related to the module Use DT RegisterMsgHandler described on page 73 to register a Windows message handler See Appendix A starting on page 107 Register a callback to handle channel open requests from the specified module hBoard DT RegisterCallback hBoard RemoteChanOpenProc DTEVENT REMOTE CHAN OPENED NULL RemoteChanOpenProc is invoked when the module opens a cha
88. OTS i e RR A PEU Eres Rd erae wea e e Us 34 Chapter 3 Programming Flowcharts 0 000 ccs e eee eee eee eee 35 Typical Communication Operations 00 0 0 eee eee eee ee 37 Typical Event Driven Communication Operations sd vxwdomrede Rr ur reb ERU er PE ER e ias U d Edad esed 39 Chapter 4 Function Reference for Visual C Programmers 43 IX ADBl ckToVolts s en CRI ERI e EURO GO E deed 45 DI ADCharnBlockToVolts is ta En ERR Ue red aput eU eene ed 46 DT ADSc ndoVols al Lm mL eA URL dM ria M ui rM A Ee rts 47 DI ADwValueloVolts ELE A ae NI NOE es 48 DI BoardClose xr borage tee et ter da 49 DI Board Download xis uti AER ERE A ra Be EXC REE Sa BS ot 50 Contents D TBoardGetInto o iue etre st Ee test gate toe dte obedece rade teo LEE 5 ID T BeardGetlNamie er beso t o e eee eee tes ET er NS 5 IDESBOatrdOpern 2e ee ea AE ll refers a Hades its ute 52 DT BoardReadFromMemory oo 54 DT_BoardReadRegister ss cows eee Re teet Re e d ee eee a ge 55 od Board Rut once E URP URN ME E e dete 56 DT BoardWriteRegister lisse en 57 DT BoardWriteTOMemory ssssssss nn 58 DT ChanAcknowled ges v eL o e eR e eS euet eie ius 59 DT ChanAsync Write vemoss se eR pm me p AREE RO ee oo eR ted 60 DT ChanBytesAvailable sisse nn 61 DECRECE EAM ERI RIT e 61 DIAC hanget Osenar ene t as edt mda aede e bap ee he dites Rm ed oon 62 DI ChanOp en rine eU ee ERE II aem pet mening ed Ante ende toe
89. Pass a valid pointer for pMsg 1009 DT INVALID MSG BUF LEN The MsgBufLen argument is not This error indicates an internal valid communication error This error should never occur in a properly installed and running system Contact Technical Support see page 17 110 Error Codes Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 1010 DT INVALID DSP ADDRESS The DSPAdaress must be an even multiple of 4 Specify an appropriate value for DSPAddress This value must be an even multiple of 4 Refer to the DT9840 Series User s Manual for DSP addresses 1011 DT CANT OPEN DRIVER Cannot open the DT9841 device driver This error should never occur in a properly installed and running System Typically this indicates that a software installation problem occurred Contact Technical Support see page 17 1012 DT CANT FIND BOARD Cannot find a board with the specified name Check the module name using DT BoardGetName 1013 DT NO BOARD FOR INDEX No board exists for specified board index If a single module is installed in the system specify O for the board index If more than one module is installed in the system specify an appropriate value for the board index The modules are numbered sequentially starting at O 1014 DT NO CHAN FOR INDEX No channel exists for
90. RE VERSION Version of DT9840Ld sys driver not compatible with dt9840k sys This version of the DT9840 Series Communication Library is not compatible with the DT9840 Series module that you are attempting to communicate with This error should never occur in a properly installed and running system It indicates a compatibility problem between the host software and the software on the module Contact Technical Support see page 17 1020 DT DSP VERSION The versions of the DSP program and the DT9841 are incompatible The version of the DSP application program that was downloaded to the DT9840 Series module is incompatible with the USB communication software on the module This error should never occur in a properly installed and running system Contact Technical Support see page 17 1021 DT NO PROGRAM LOADED Can t run program because none have been downloaded yet Download a program using DT BoardDownload before calling DT BoardRun 1022 DT ERROR FILE READ Error in reading from file This error indicates that an internal problem occurred while reading a COFF file The most likely cause is that the file is corrupted This error should never occur when loading a valid COFF file Check your file 1023 DT ERROR INVALID COFF File to be downloaded is not COFF formatted Specify a file that adheres to the Code Composer format COFF 1024 DT INVALID BUFFER ADDRESS The DSPAdare
91. RTS DT IN LOOP IS RUNNING DT OUT LOOP IS RUNNING DT NO LOOP RUNNING DT DSP BIOS ERROR DT NO MORE CHANNELS DT INVALID VALUE DT INVALID BLOCK DT INVAID AD CHAN DT INVALID SCAN DT NO OUTPUTS ENABLED DT INVALID COUNTER DT INVALID SETUP PTR DT INVALID MASK DT HANDLER ALREADY INSTALLED DT BIT IS OUTPUT DT INVALID COMPARE VALUE DT COMPARE IS OUTPUT DT MASK IS OUTPUT DT INVALID DA CHAN DT BIT IS INPUT DT CLOCK NOT RUNNING DT SB NOT ENABLED DT INVALID CLOCK SRC DT INVALID COUNT MODE DT MEASURE IN PROGRESS DT ONESHOT IN PROGRESS DT SB NOT READY DT NO DAC FILTER DT SB IS BUSY DT SB TIMEOUT DT INVALID DMA BUFFER DT NO DMA CHAN DT ERROR FILTER DT MUST INIT LIBRARY DT RANGE NOT SUPPORTED B MODULE FOR INDEX O 133 Appendix B Definition cont Include File Elements DT ADC OVERRUN DT DAC UNDERRUN DT NOT IEPE BOARD DT FLASH WRITE FAILED DT FLASH VERIFY FAILED DT HOST CHAN ALREADY OPEN DT HOST COMM BASE ERR DT HOST CHAN ALREADY CLOSED DT HOST BUFFER EMPTY DT HOST RCV BUFFER FULL DT HOST MSG UNKNOWN TYPE DT HOST MSG INVALID LENGTH DT HOST CHAN BUFFER FULL DT HOST SEND BUFFER FULL DT 9841 CHAN ALREADY OPEN DT 9841 COMM BASE ERR DT 9841 CHAN ALREADY CLOSED DT 9841 BUFFER EMPTY DT 9841 RCV BUFFER FULL DT 9841 MSG UNKNOWN TYPE DT 9841 MSG INVALID LENGTH DT 9841 CHAN BUFFER FULL DT 9841 SEND BUFFER FULL
92. ScanLoop DT BlockLoop DT FunctionGen DT ListLoop DT WriteDACDIO If FALSE digital output values are not clocked out when analog output values are clocked out Port0Out A Boolean variable that specifies whether digital port 0 on the DT9840 Series module is an input or an output port If FALSE digital port 0 is an input port if TRUE digital port 0 is an output port Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Name Description Name Description Name Description IEPE CHAN INFO Structure Definition Include File PortlOut A Boolean variable that specifies whether digital port 1 on the DT9840 Series module is an input or an output port If FALSE digital port 1 is an input port if TRUE digital port 1 is an output port Port2Out A Boolean variable that specifies whether digital port 2 on the DT9840 Series module is an input or an output port If FALSE digital port 2 is an input port if TRUE digital port 2 is an output port DeglitchPort0 A Boolean variable that specifies whether to enable or disable deglitch circuitry on digital port 0 of the DT9840 Series module this function minimizes false triggers due to noise and is particularly useful when using the interrupt on change feature If TRUE a 10 ms deglitch function is enabled for digital port 0 If FALSE the 10 ms deglitch function is disabled
93. The resulting signal from the oscillator is then divided by 2 to provide a clock signal to the A D and D A converters that is oversampled 256 times and has a 50 duty cycle For example if you specify an internal clock frequency of 100 kHz internally the DT9841 DT9841E and DT9841 VIB modules set the oscillator to 51 2 MHz then divides the resulting signal by 2 to provide a 25 6 MHz signal with a 50 duty cycle to the A D and D A converters MaxSampleRate A variable of type DOUBLE that indicates the maximum frequency in Hz of the internal sample clock on the DT9840 Series module This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual For all DT9840 Series modules this value is always 100 000 Hz MinSampleRate A variable of type DOUBLE that indicates the minimum frequency in Hz of the internal sample clock on the DT9840 Series module This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual For the DT9841 DT9841E and DT9841 VIB this value is 200 Hz For the DT9842 2 and DT9842 8 this value is 0 Hz ActualSampleRate A variable of type DOUBLE that indicates the actual sample frequency in Hz that the DT9840 Series module could achieve This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual ClockIype A variable of type CLOCK TYPE described on page 126 that indicates the clock to use Unused
94. UT SCAN BLOCK structure Visual C 155 INPUT SCAN RCD data type Visual Basic 204 INPUT SCAN RCD structure Visual C 156 M message constants in Visual C 122 MODEL ID enumerated type in Visual Basic 183 in Visual C 137 module name 23 MSG_INFO structure Visual C 158 O opening a communication channel 26 opening a module 23 OUTPUT_SCAN_ BLOCK structure Visual C 158 OUTPUT_SCAN_RCD data type Visual Basic 205 OUTPUT_SCAN_RCD structure Visual C 160 P PMSG INFO structure Visual C 158 POLARITY enumerated type in Visual Basic 185 in Visual C 138 R reading data from a communication channel 27 reading from memory 28 reading from registers 28 register constants in Visual Basic 166 in Visual C 119 registers reading from 28 writing to 30 related documents 8 returning channel information 26 returning error messages 34 returning the module name 23 returning the number of bytes in a channel buffer 27 running a DSP program 25 S Structures PDATA FILE HDR 151 DATA FILE HDR 151 structures Visual C 139 T technical support 8 TRIGGER SETUP data type Visual Basic 206 TRIGGER SETUP structure Visual C 160 TRIGGER TYPE enumerated type in Visual C 139 troubleshooting checklist 17 typical communication operations how to perform 37 W writing data to a communication channel asynchronously 29 writing data to a communication channel synchronously 29 writing to memory 30 wri
95. X SCAN SIZE NumScans pOutBlock nScansThisBlock Generate a ramp from 0 to 10 volts for i20 i lt NumScans i OutVolts i 10 0 i Convert data to raw DA values in pOutBlock Status DT VoltsToDAChanBlock OutVolts DA CHAN TO CONVERT NumScans pOutBlock DAC BIPOLAR 10 VOLT NumScans 79 Chapter 4 DT VoltsToDAScan Syntax Include File Description Parameters Name Description Name Description Name Description Notes Return Values Example 80 DTSTATUS DT VoltsToDAScan DOUBLE Volts OUTPUT SCAN RCD pOutScan DAC RANGE VoltageRange DTCommonAPI H Converts an array of voltage values into a scan of raw analog output values for use with DT_WriteDACDIO DT_ScanLoop or DT_FunctionGen Refer to the DT9840 Series DSP Library User s Manual for more information on the DT_WriteDACDIO DT_ScanLoop or DT_FunctionGen functions Volts An array of type DOUBLE that contains the voltage values to convert into raw analog output values Allocate Volts to hold NUM DAC CHANS voltage values for the DT9841 DT9841E DT9841 VIB and DT9842 2 the value of NUM DAC CHANS is 2 For the DT9842 8 the value of NUM DAC CHANS is 8 pOutScan A pointer to an array of type OUTPUT SCAN RCD described on page 160 in which the raw analog output values are returned VoltageRang
96. a rising edge low to high transition on the external gate input pin starts or stops the measurement operation The software automatically sets the gate type to EXT NORMAL GATE in this mode Name SELECTED GATE FALLS Description If you specify this element a falling edge high to low transition on the external gate input pin starts or stops the measurement operation The software automatically sets the gate type to EXT NORMAL GATE in this mode Name EXTERNAL CLOCK RISES Description If you specify this element a rising edge low to high transition on the external C T clock input pin starts or stops the measurement operation Name EXTERNAL CLOCK FALLS Description If you specify this element a falling edge high to low transition on the external C T clock input pin starts or stops the measurement operation Notes EDGE TYPE is used only in measure mode and continuous measure mode ERROR MODE SELECT Enumerated Type Definition Public Enum ERROR MODE SELECT STOP ON ERROR 0 CONTINUE ON ERROR 1 End Enum Public Interface DTCommLib BAS Members Name STOP_ON_ERROR Description If you specify this element the operation stops if the DT9840 Series module detects an error condition 181 Appendix B Name CONTINUE ON ERROR Description If you specify this element the operation continues if the DT9840 Series module detects an error condition GATE TYPE Enumerated Type Definition Public Enum
97. a the communication channel on the host computer can receive from the DT9840 Series module at one time In general the size of the channel input buffer should be at least as large as the largest single write of data from the module Note that a channel input buffer that is larger than needed has no negative performance impact on I O operations If ChanType WRITE CHAN BufSize is ignored on the host but is passed to the DT9840 Series module Therefore you could use this value to indicate to the DSP program how large to create the matching channel input buffer on the module if you wish phChan A pointer to a variable of type CHAN HANDLE described on page 116 in which the handle to the opened communication channel is returned If this function fails phChan points to a NULL value Function Reference for Visual C Programmers Name Description Notes Return Values DT ChanRead Example Syntax Include File TimeoutInMS An unsigned integer variable or constant that specifies the timeout value in milliseconds If TimeoutInMS 0 the timeout period is disabled Once the communication channel is open you can use the other channel functions to send data to receive data from and manage the communication channel A host application can open up to 32 arbitrarily named channels and write data to or read data from them The corresponding program on the DT9840 Series module can then use the channel names to
98. al operating mode If you want to specify the size of the module input and output buffers specify a variable type of BOARD OPTIONS described on page 188 If you are using multiple modules and do not know their names you can use DT BoardGetName described on page 88 to return the module names When you are finished with the module call DT BoardClose described on page 85 to close the module and release any resources that were allocated to it See Appendix A starting on page 107 Open the module DT9841 00 create internal buffers using the default buffer size BoardHandle Dim Status As DTSTATUS Dim BoardHandle As Long and return the handle in Status DT BoardOpen DT9841 00 BoardHandle NULL DT BoardReadFromMemory Syntax Public Interface Description Parameters Name Description 90 Declare Function DT BoardReadFromMemory Lib DTCommLib dll ByVal hBoard As Long ByVal SrcDSPAddress As Long ByVal NumBytes As Long ByRef DestPCBuffer As Long As DTSTATUS DTCommLib BAS Returns data from a DSP address on the DT9840 Series module to a variable on the host computer with no assistance from the DSP hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT_BoardOpen described on page 89 Function Reference for Visual Basic Programmers Name Des
99. ame Description READ CHAN The host computer reads data from the DT9840 Series module WRITE CHAN The host computer writes data to the DT9840 Series module CLOCK SRC Enumerated Type Definition Include File Elements Name Description Name Description Name Description typedef enum INTERNAL_18MHZ 0 EXTERNAL CLOCK CASCADED CLOCK CLOCK SRC DTCommonAPI H INTERNAL_18MHZ If you specify this element the internal C T clock uses a 18 MHz time base Counter timer operations start on the rising edge of the clock input signal This clock source is not generally used for event counting or up down counting mode and is automatically selected if measure mode or continuous measure mode is specified EXTERNAL_CLOCK If you specify this element an external C T clock source paces the specified counter timer channel Counter timer operations start on the rising edge of the clock input signal This clock source is not generally used for rate generation one shot or repetitive one shot mode and is not supported for measure mode or continuous measure mode CASCADED CLOCK If you specify this element the clock input signal of the specified counter timer is connected in software to the clock output signal of the proceeding counter timer For example if you specify CASCADE CLOCK for counter timer 2 the clock input of counter timer 2 is internally connected to the clock out
100. ame Description Notes Return Values 104 The most data that can be returned at one time cannot be larger than the size specified by BufSize When this function is called the available data up to the size of the Buffer variable is returned If no data is available other operations can continue If you want to block other operations from continuing while you are waiting for all the data to become available use the DT ChanRead function described on page 101 instead See Appendix A starting on page 107 Read the number of bytes available from ChannelHandle up to 20 bytes and put it in Valuel Return the actual number of bytes read in BytesRead ChannelHandle was previously opened as READ CHAN on the host Dim Status As DTSTATUS Dim ChannelHandle As Long Dim Valuel As Single Dim BytesRead As Long Status DT ChanReadAvailable ChannelHandle Valuel 20 BytesRead Declare Sub DT GetErrorString Lib DTCommLib dll ByVal Status As DTSTATUS ByVal EString As String DTCommLib BAS Returns an ASCII string that corresponds to a specific error Status A variable of type DSTATUS described on page 178 that specifies the error for which an ASCII string descriptor is returned EString A fixed length STRING variable in which the error descriptor is returned All of the functions in the DT9840 Series DSP Library return errors that you c
101. an use with this function None Function Reference for Visual Basic Programmers Example DT VoltsToDAScan Syntax Public Interface Description Parameters Name Description Name Description Name Description Notes Return Values Utility for reporting DTSTATUS errors The error description for Status is returned in ErrString Dim Status As DTSTATUS Dim ErrString As String 256 If Status DT SUCCESS Then Call DT GetErrorString Status ErrString End If Declare Function DT VoltsToDAScan Lib DTCommLib dll ByRef Volts As Double ByRef OutScan As OUTPUT SCAN RCD ByVal VoltageRange As DAC RANG As DTSTATUS Lj DTCommLib BAS Converts an array of voltage values into a scan of raw analog output values for use with DT WriteDACDIO DT ScanLoop or DT FunctionGen Refer to the DT9840 Series DSP Library User s Manual for more information on the DT WriteDACDIO DT ScanLoop or DT FunctionGen functions Volts A variable of type DOUBLE that contains the voltage values to convert into raw analog output values Allocate Volts to hold NUM DAC CHANS voltage values for the DT9841 DT9841E DT9841 VIB and DT9842 2 the value of NUM DAC CHANS is 2 For the DT9842 8 the value of NUM DAC CHANS is 8 OutScan A variable of type OUTPUT SCAN RCD described on page 205 in which the raw analog output valu
102. anTypeStr DSPBufSize Index DTSTATUS DT_ChanOpen BRD_HANDLE hBoard CHAR pChanName CHAN TYPE ChanType ULONG BufSize CHAN HANDLE phChan ULONG TimeoutInMS DTCommonAPI H 63 Chapter 4 64 Description Parameters Name Description Name Description Name Description Name Description Name Description Opens a unidirectional stream based communication channel by name creates an input buffer for the channel if it was opened for reading and returns a handle to that channel This handle is then used by all subsequent channel communication functions to identify the channel hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 pChanName A pointer to a NULL terminated CHAR array that specifies the name of the communication channel to open The maximum length of this array is determined by CHAN NAME MAX LEN described on page 116 ChanType A variable of type CHAN TYPE described on page 124 that specifies the type of operation to perform on the communication channel BufSize An unsigned integer variable or constant that specifies the size in bytes of the input buffer for a communication channel that was opened for reading If ChanType READ CHAN BufSize determines how much dat
103. ange A variable of type ADC RANGE described on page 123 that specifies the analog input voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 DOUBLE Volts LONG ADValue Convert ADValue into a voltage in the 10 V range and store in Volts Status DT ADValueToVolts ADValue ADC BIPOLAR 10 VOLTS amp Volts DTSTATUS DT BoardClose BRD HANDLE hBoard 5 Closes a previously opened module and releases all allocated resources that were associated with it DTCommLib H hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 None See Appendix A starting on page 107 49 Chapter 4 50 Example DT BoardDownload Syntax Include File Description Parameters Name Description Name Description Name Description Notes Return Values Close the module with handle hBoard Status DT BoardClose hBoard DTSTATUS DT BoardDownload BRD HANDLE hBoard CHAR pFilename BOOL bVerifyFlag DTCommLib H Downloads a compiled DSP program over the USB bus to the DSP processor of the DT9840 Series module This function supports the standard output form
104. annel using the DT ChanAsyncWrite or DT ChanSyncWrite function and the DTEVENT OUT BUFFER SPACE AVAILABLE event described on page 213 The host application should wait until it receives a DTEVENT OUT BUFFER SPACE AVAILABLE event before attempting to write additional data to the DT9840 Series module Note You can write data directly to a specified DSP address on an opened DT9840 Series module instead of writing the data to a communication channel using the DT BoardWriteToMemory function DT BoardWriteToMemory does not require that a DSP program is running on the module This function operates synchronously and take precedence over all other communication operations For example if you use DT BoardWriteToMemory to write 2 MBytes of data to the module all other messaging between the host computer and the module is suspended until all 2 MBytes has been transferred If you want to write to a specific register on the DT9840 Series module from your host application you can use the DT BoardWriteRegister function CAUTION Although you can write to any DSP address using DT BoardWriteToMemory it is highly recommended that you write to a known DSP address Writing to an arbitrary DSP address can cause major system problems To avoid cache coherency problems the DSP and the host programs should not write to the same block of memory Anytime the DSP application reads data that the host wrote the cache should be emptied first CACHE C
105. anslation s web site www datatranslation com Overview TOTO UCA e pi AA IA A AA ee re oe eee 10 Installing the SOMETE cocoa ee sie aa CERES E A ELSE n E as 15 Building Host Applications Using the DT9840 Series Host Communication Library 16 ju Product Support Chapter 1 Introduction The DT9840 Series Host Communication Library allows the host computer to communicate with and control a DSP application on a DT9840 Series module The software architecture is shown in Figure 1 Embedded Code Composer Program DT9840 Series Windows Host DSP Library on a DT9840 Series Program m EE Module DT9840 Series Host Communication yo Communication Functions Functions Library Host Computer DT9840 Series Module Figure 1 DT9840 Series Software Architecture To communicate between the host computer and a DT9840 Series module you need to write an application program for the host computer that calls the communication functions in the DT9840 Series Host Communication Library In addition you need to write a Code Composer program for the DSP on the DT9840 Series module that calls the matching communication functions in the DT9840 Series DSP Library Refer to the DT9840 Series DSP Library User s Manual for more information about writing a DSP program for a D19840 Series module The DT9840 Series Host Communication Library simplifies the details of the USB communication channel that allows a host applica
106. arn from this Manual 0 00 c cece cee eese 7 Conventions Used in this Manual o oooccoccooccocccoc ree 8 Related Documents oo roerei E hae A SUC VE ee E ee ien 8 Where to Get Hel pied nti cote etus ett eoe THEME mue e eel se hd tit fa 8 Chapter 1 Overview oocooooccccon Rh Rh hh hm 9 Introduction ter A RU a e e e pi b e pg RR 10 Board Lbevel F nctions eee ebur REEL E ee te Do ee 11 Channel Level Functions ssiri Tese a cece cece een een hee 12 Conversion FUNCHONS 6 6 xev ER Ux Wes he pi ua au e p EE e E ei 13 Installing the SoftWare eet rete ee e Cae tee e e de 15 Building Host Applications Using the DT9840 Series Host Communication Library 16 Product Supports iecore ce e ete E ete ar aae baee M hes doe ate de ph 17 General Checklist ui y ERR SEP PRU EISE OE ete un 17 Service and Supports iscsi os ae SSE Ee Re exce Rer e ye ete Ree Red se 17 Chapter 2 Using the DT9840 Series Host Communication Library 19 COVER VIC m 20 Opening and Closing a Module 0000 e eee 23 Downloading and Running a DSP Program 0 000 25 Opening and Closing a Communication Channel 0 0 00 e eee eee eee 26 Reading Data from a Communication Channel 0 0 00000 e eee eee eee 27 Writing Data to a Communication Channel 00 0 000 29 Handling Channel Communication Events eese 31 Converting Data Saee ta ee uber pae edant ebd tee Seed bte a 32 Handling E
107. at COFF file Common Object File Format with a OUT extension of Code Composer Studio for compiled programs hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 pFilename A pointer to a variable of type CHAR that specifies the name of the COFF file Common Object File Format with a OUT extension to download to the DT9840 Series module bVerifyFlag A Boolean variable that specifies whether or not to verify the download operation Set bVerifyFlag to TRUE if you want each segment that is downloaded to the module to be read back from DSP memory and verified Setting this parameter to TRUE slows down the download significantly but ensures that the DSP program is not loaded into a non existent memory location Set bVerifyFlag to FALSE if you do not want to verify the download operation This function resets the DSP processor before downloading the program After the program is downloaded call DT_BoardRun described on page 56 to run the program See Appendix A starting on page 107 Function Reference for Visual C Programmers Example DT BoardGetlnfo Syntax Include File Description Parameters Name Description Name Description Notes Return Values Example DT BoardGetName Syntax Include File Description BRD HANDLE hBoard
108. aw analog output values for use with DT WriteDACDIO DT ScanLoop or DT FunctionGen Refer to the DT9840 Series DSP Library User s Manual for more information on the DT WriteDACDIO DT ScanLoop or DT FunctionGen functions DT VoltsToDABlock For all analog output channels in a block converts an array of voltage values into a block of raw analog output values for use by DT BlockLoop or DT ListLoop Refer to the DT9840 Series DSP Library User s Manual for more information on the DT BlockLoop or DT ListLoop functions Note This function is not supported in Visual Basic DT VoltsToDAChanBlock For a specified analog output channel in a block converts an array of voltage values into a block of raw analog output values for use by DT BlockLoop or DT ListLoop Refer to the DT9840 Series DSP Library User s Manual for more information on the DT BlockLoop or DT ListLoop functions Note This function is not supported in Visual Basic 33 Chapter 2 Handling Errors Each function in the DT9840 Series Host Communication Library returns a code that represents its status or error condition Refer to Appendix A starting on page 107 for more information on each of these error codes We recommend that you check the error code of each function to ensure that it was successful If you want to return an ASCII descriptor for a specific error code call the DT GetErrorString function in your host application program 34
109. be filled with raw DA values before being sent to the hardware NumScans must be less than MAX SCAN SIZE NumScans pOutBlock nScansThisBlock Generate a ramp from 0 to 10 volts on Chan 0 Generate a ramp from 10 to 0 volts on Chan 1 for i20 i lt NumScans i OutVolts i 0 10 0 i NumScans OutVolts i 1 10 0 10 0 i NumScans Status DT_VoltsToDABlock OutVolts NumScans pOutBlock DAC_BIPOLAR_10_VOLT DTSTATUS DT_VoltsToDAChanBlock DOUBLE Volts ULONG DAChan ULONG NumScans OUTPUT SCAN BLOCK pOutBlock DAC RANGE VoltageRange DTCommonAPI H For a specified analog output channel in a block converts an array of voltage values into a block of raw analog output values for use by DT_BlockLoop or DT_ListLoop Refer to the DT 9840 Series DSP Library User s Manual for more information on the DT_BlockLoop or DT_ListLoop functions Volts An array of type DOUBLE that contains the voltage values to convert into raw analog output values Allocate Volts to hold NUM_DAC_CHANS values For the DT9841 DT9841E DT9841 VIB and DT9842 2 the value of NUM_DAC_CHANS is 2 For the DT9842 8 the value of NUM_DAC_CHANS is 8 Function Reference for Visual C Programmers Name Description Name Description Name Description Name Description Notes
110. bed on page 63 DTEVENT SYNC DATA RECEIVED DTEVENT SYNC DATA RECEIVED Paraml Param2 For an open communication channel indicates that new data was received synchronously Param1 The handle of communication channel that received the new data Param2 The number of bytes received 215 Appendix C 216 Notes In response to this event the Windows message DTMSG SYNC DATA RECEIVED is sent to the host application I The host application should do the following 1 Read the data by calling DT ChanReadAvailable described on page 67 or with DT ChanRead described on page 65 2 Process the data 3 Signal the DSP program on the DT9840 Series module that the data has been processed by calling DT ChanAcknowledge described on page 59 Symbols PDATA FILE HDR structure 151 Numerics 32 bit library 16 64 bit library 16 A acknowledging a synchronous write request 29 AD DA CLK SRC enumerated type in Visual Basic 170 in Visual C 124 ADC RANGE enumerated type in Visual Basic 170 in Visual C 123 ADC SETUP data type Visual Basic 187 ADC SETUP structure Visual C 140 ARM SELECT enumerated type in Visual Basic 185 B BOARD OPTIONS data type Visual Basic 188 BOARD OPTIONS structure Visual C 141 143 board level functions DT BoardClose 11 24 38 41 49 85 DT BoardDownload 11 25 37 39 50 86 DT BoardGetInfo 11 51 87 DT BoardGetName 1
111. bes the global constants enumerated types and data types that are used when calling the DT9840 Series host communication functions in Visual Basic Callback functions for the DT9840 Series modules are not supported in Visual Basic Constants The following constants are provided for the DT9840 Series Host Communication Library in Visual Basic Global constants described on this page Conversion constants described on page 165 Register constants described on page 166 Error constants described on page 169 Counter timer constants described on page 169 Flash memory constants described on page 169 Global Constants The following global constants are defined in the DTCommLib BAS file DTCommLibBasVer The current version of the DTCommLib BAS file DT BOARD TYPE The specific DT9840 Series module this value is 9841 to identify the DT9841 and DT9841 VIB 98412 to identify the DT9841E module 9842 to identify the DT9842 2 or 9848 to identify the DT9842 8 NUM ADC REGS The number of analog input registers All DT9840 Series modules have 8 analog input registers For the DT9841E the first two analog input registers correspond to analog input channels 0 and 1 the data in the remaining analog input registers should be ignored NUM ADC CHANS The number of analog input channels For the DT9841 DT9841 VIB DT9842 2 and DT9842 8 NUM ADC CHAN is 8 For the DT9841E NUM ADC CHAN is 2 NUM COUNTERS The number of counte
112. ble that contains the Scalable Bus address of the module If the module is the master a bus address of 0 is returned If the module is a slave a bus address of 1 through 3 is returned Refer to the DT 9840 Series Getting Started Manual for more information on assigning addresses to modules using the DT9840 Series Control Panel applet SBTerminated A Boolean variable that indicates whether the Scalable Bus is terminated for the module If TRUE the Scalable Bus is terminated for the module If FALSE the Scalable Bus is not terminated for the module Refer to the DT 9840 Series Getting Started Manual for more information on terminating the Scalable Bus using the DT9840 Series Control Panel applet Reserved An unsigned integer array of 15 elements that is reserved for future use Data Types Constants Enumerated Types Structures and Callback Functions Definition Include File Elements Name Description Name Description Name Description CLOCK_SETUP Structure Definition Include File Elements Name Description Name Description CHAN_OPEN_INFO Structure typedef struct CHAN NAME ChanName CHAN TYPE RemoteChanType ULONG RemoteBufSize CHAN OPEN INFO DTCommonAPI H ChanName A variable of type CHAN_NAME described on page 116 that represents the name of the communication channel on the host RemoteChanType A variable of type CHAN_TYPE described on page 124
113. cal operations due to the overhead required See Appendix A starting on page 107 DOUBLE Volts LONG Value Convert the voltage in Volts which is in the store in Value Status DT_VoltsToDAValue DAC BIPOLAR 10 VOLT 10 V range into a raw value and Volts amp Value 81 Chapter 4 82 Function Reference for Visual Basic Programmers DT ADSemlsWele dl a a a ec ete a EP 84 PT ADA TO VOS 52er xe oe eee ee ce me Pee edd ceo eds 85 DI Boardi OE TORO TIE T TTE 85 DT Baeardbownlosd 2 Ai EE ed EDS a howe ew bok 86 PIT DORE nio senes ta eoe botte d pce e baee we eed s d pd cdd woe 87 DTI BoardGeMNamie SA 88 DI Bo OPEL dario ke eb a Bee deh EAE c ker Ee EEA 89 DT BoardEeadPrombMietmory sc reete pee to ee IUe e ese era ec de ees 90 DI Board edie enis edere tetto e mnes een eR eate dap e etd dd 91 DT APY ame edad A ERE T RU ECLPEURMMDCOHE ewok 92 DT Board WrlteRegister A ee eee tene ree dte dg 93 DE pun JU nur P 94 DI thanAsyn We sa a a MR e RR E E EEE PA EE EEEE cee Res 95 e A esep deiten repe pee Nee Nee etre Sede epe gs 96 DI Chat Ea eoe Mem vete edet ite dietis ent atte ecd a e meena E Ee tw lted 97 DI bBbAantsetln a DEEE GR esc bib arene deme ee Shoe vua 98 DT CADO e raset repetar drae duke eT eos qu ee Mad ee eel dite Oe ici donee og 99 DI CARER AAA 101 DT tbhanheadAwulble ee aa ciao 103 I ATEOS oo A A A li sete 104 DT Velle Iob ASESf eer RR eere serbe t
114. can occur on either the host or DSP In response to this event on the host the Windows message DTMSG MODULE UNPLUGGED is sent to the host application When this event occurs the host should close all its communication channels and then close the DT9840 Series module with DT BoardClose the host application does not have to be closed The DSP program should then respond by closing its communication channels Note Itis imperative that the host application calls DT_BoardClose when the DTEVENT_MODULE_UNPLUGGED event occurs to prevent board open failures Communication Events and Messages Notes cont To reestablish communication after the USB cable is disconnected do the following 1 Reconnect the USB cable 2 Call DT BoardOpen from the host application If you want to reestablish communication with a running DSP program call DT BoardGetInfo to verify that the DSP program is running 3 Open the communication channels from the host application 4 Open the communication channels from the DSP program 5 Download a COFF file to the DT9840 Series module and run it DTEVENT OUT BUFFER SPACE AVAILABLE Syntax Description Parameters Name Description Name Description Notes DTEVENT OUT BUFFER SPACE AVAILABLE Paraml Param2 Indicates that a previously full module output buffer was emptied data was transmitted from the module output buffer across the co
115. ck the module name Specify a another program name for a module that is not already in use 1030 DT INVALID BOARD BoardOptions structure contains Check the values for the OPTIONS illegal values BoardOptions structure described on page 141 for Visual C users and on page 188 for Visual Basic users 1031 DT BOARD NOT DT9841 is not responding Check that the USB cable is still RESPONDING plugged into the module and that the power switch of the module is turned on If you still get this error contact Technical Support see page 17 1032 DT BOARD WAS SHUTDOWN DT9841 error occurred board Close the module using must be closed then reopened DT BoardClose and then reopen the module using DT BoardOpen 1033 DT PROGRAM TOO LARGE Program is too large to be This error is used internally by the loaded into DT9840 s flash DT9840 Series Flash Programmer memory Utility It is returned to this utility when you attempt to download a program that is bigger than the available flash memory 3000 DT HOST CHAN ALREADY An OPEN CHAN message The specified communication channel OPEN received from DT9841 for an is already open Check the channel already open channel name You need only open a communication channel once in both the DSP program and host application 3001 DT HOST CHAN ALREADY A CLOSE CHAN message Check the channel name You need CLOSED received from DT9841 for a only close a communication channel channel that s already closed once in both t
116. conceptual information to describe the how to use the functions in the DT9840 Series Host Communication Library to write a host application program Use this information with the reference information provided in Chapter 4 starting on page 43 for Visual C programmers and in Chapter 5 starting on page 83 for Visual Basic programmers Refer to the DT9840 Series DSP Library User s Manual for more information on using channel communication functions in your DSP program Using the DT9840 Series Host Communication Library Opening and Closing a Module Before you can communicate with a DT9840 Series module that is connected to the host computer you first need to open the DT9840 Series module by calling DT BoardOpen in your host application Note For each module ensure that only one host application opens and communicates with the module You can either specify a valid module name or specify NULL for the module name If you specify NULL for the module name the first DT9840 Series module that is connected to the host computer is opened This is the simplest method of opening a module in systems where only one DT9840 Series module is installed If you are using multiple modules and do not know their names you can use DT BoardGetName to return the module names You assign the module name when you configure the device driver Refer to the DT9840 Series Getting Started Manual for more information on configuring the device driver For
117. cribed on page 138 that defines the polarity of the output pulse for the specified counter timer In measure mode if POLARITY is ACTIVE_HIGH when you call DT_TriggerCTR the counter output is low while the measurement is in progress and high when the measurement is complete If POLARITY is ACTIVE_LOW when you call DT_TriggerCTR the counter output is high while the measurement is in progress and low when the measurement is complete GateType A variable of type GATE_TYPE described on page 135 that defines the type of gate to use for the specified counter timer For measure or continuous measure mode this value is automatically set to EXT NORMAL GATE if you specify the EDGE TYPE is SELCTED GATE RISES or SELECTED GATE FALLS MeasureModeStartEdge Used for measure mode and continuous measure mode operations only a variable of type EDGE TYPE described on page 134 that specifies what edge of the signal connected to the external gate or external clock input pin starts the measurement In continuous measure mode the counter increments from the first start edge to the next start edge the stop edge is ignored This variable is ignored for all other counter timer operations MeasureModeStopEdge Used for measure operations only a variable of type EDGE TYPE described on page 134 that specifies what edge of the signal connected to the external gate or external clock input pin stops the measurement This variable is ignored for
118. cription AD CLOCK If you specify this element the clock that paces analog input operations is selected DA CLOCK If you specify this element the clock that paces analog output operations is selected COUNT MODE Enumerated Type Definition Public Interface Members Name Description Name Description Public Enum COUNT MODE STD COUNTING 0 ONE SHOT 1 REPETITIVE ONE SHOT 2 MEASURE 3 UP_DOWN 4 CONTINUOUS_MEASURE 5 End Enum DTCommLib BAS STD_COUNTING If you specify this element the counter timer performs an event counting or rate generation pulse output operation For event counting operations specify an external C T clock source For rate generation operations specify an internal C T clock source Specify either a software gate normal external gate or inverted external gate signal to enable the operation When the operation is enabled the counter increments to the value specified by PulseWidthCount described on page 148 and activates the pulse output The pulse output stays active until the counter rolls over to 0 the terminal count The pulse output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 195 The active polarity of the pulse output pulse is determined by OutputPolarity described on page 196 This sequence repeats as long as the counter is enabled by the gate Yo
119. cription Name Description Name Description Notes Return Values Example DT BoardReadRegister Syntax Public Interface SrcDSPAddress A variable of type LONG that specifies the DSP address on the DT9840 Series module that you want to read NumBytes A variable of type LONG that specifies the number of bytes to read from the DSP on the DT9840 Series module DestPCBuffer A variable of type LONG in which the data from the DSP on the DT9840 Series module is returned to the host Although you can read from any DSP address using this function it is highly recommended that you read from a known DSP address Reading from an arbitrary DSP address can cause major system problems This function operates synchronously and take precedence over all other communication operations For example if you use this function to read 2 MBytes of data from the DT9840 Series module all other messaging between the host computer and the module is suspended until all 2 MBytes has been transferred Unlike most other functions in this library DT BoardReadFromMemory does not require that a DSP program is running on the module To read specific registers on the DT9840 Series module use DT BoardReadRegister described on page 91 See Appendix A starting on page 107 Dim Status As DTSTATUS Dim DSPAdd As Long Dim HostValue As Long Read 4 bytes from the memory location specified by DSPAdd and store it in HostVal
120. cture to STOP ON ERROR In this case if either an A D overrun or D A underrun error occurs both operations stop and the user defined callbacks are NOT invoked Unused1 An unsigned integer variable that is currently not used specify 0 for this member Unused2 An unsigned integer variable that is currently not used specify 0 for this member Unused3 An unsigned integer variable that is currently not used specify 0 for this member Unused4 An unsigned integer variable that is currently not used specify 0 for this member Unused5 An unsigned integer variable that is currently not used specify 0 for this member BOARD OPTIONS Data Type Definition Public Interface 188 Type BOARD OPTIONS SizeThisStructure As Long ReadBufSizelnKb As Long WriteBufSizelnKb As Long DbgFlag As Long End Type DTCommLib BAS Data Types Constants Enumerated Types Structures and Callback Functions Members Name Description Name Description Name Description Name Description SizeThisStructure A variable of type Long that specifies the size of the BOARD OPTIONS data type This element is provided for future compatibility ReadBufSizeInKb A variable of type Long that specifies the size of the module input buffer in kilobytes If you specify 0 for ReadBufSizelnKb the default size 64 kBytes is used At a minimum the size of the module input buffer must be at
121. d You specify this name when you configure the device driver Refer to the DT9840 Series Getting Started Manual for more information on configuring the device driver MB RAM An unsigned integer variable that represents the size of the SDRAM on the module in megabytes MB Flash An unsigned integer variable that represents the size of the flash on the module in megabytes ProgramIsRunning A Boolean variable that indicates whether a DSP program is currently running on the DT9840 Series module If TRUE a DSP program is currently running on the specified DT9840 Series module If FALSE a DSP program is not currently running on the specified DT9840 Series module 143 Appendix B 144 Name Description Name Description Name Description Name Description Name Description Name Description FPGAVersion An unsigned integer variable in which the version of the FPGA code on the module is returned USBPortType An unsigned integer variable in which the version of the USB port that is used is returned SBEnabled A Boolean variable that indicates whether the Scalable Bus is enabled for the module If TRUE the Scalable Bus is enabled for the module If FALSE the Scalable Bus is not enabled for the module Refer to the DT 9840 Series Getting Started Manual for more information on enabling the Scalable Bus using the DT9840 Series Control Panel applet SBAddress An integer varia
122. d analog output channel in a block converts an array of voltage values into a block of raw analog output values for use by DT BlockLoop or DT ListLoop DT VoltsSToDABlock For all analog output channels in a block converts an array of voltage values into a block of raw analog output values for use by DT BlockLoop or DT ListLoop a For more information on DT ReadADC DT ReadADCDIO DT CaptureBuffer DT ScanLoop DT BlockLoop DT ListLoop DT WriteDAC DT WriteDACDIO or DT FunctionGen refer to the DT9840 Series DSP Library User s Manual b This function is not supported in Visual Basic Overview Installing the Software The DT9840 Series Host Communication Library is installed when you install the DT9840 Series software Refer to the DT9840 Series Getting Started Manual for information on installing the DT9840 Series software 15 Chapter 1 Building Host Applications Using the DT9840 Series Host Communication Library To build a host application program using the 32 bit DT9840 Host Communication Library reference the file dtcommlib lib located in the following directory if you using the default installation path Program Files Data Translation DT9840 Series NLIBSNdtcommlib lib To build a host application program using the 64 bit DT9840 Host Communication Library reference the x64 file dtcommlib lib located in the following directory if you using the default installation path Program Files x86
123. d on page 55 or DT BoardReadFromMemory described onpage 54 or write to the registers of a DT9840 Series module using DT BoardWriteRegister described on page 57 or DT BoardWriteToMemory described on page 58 Note Refer to the DT9840 Series User s Manual for more information on these registers DEVICE REG BASE The Hardware Control and Status register of the DT9840 Series module address 0xB0000000 HDW CTRL REG The Hardware Control and Status register DEVICE REG BASE e HDW CALIBRATION REG A calibration register DEVICE REG BASE 0x0004 DT9842 CLOCK REC The clock divider register for the DT9842 2 and DT9842 8 modules DEVICE REG BASE 0x0008 e USB CALIBRATION REG A USB writable calibration register DEVICE REG BASE 0x000C ID REG The model ID and FPGA register DEVICE REG BASE 0x1000 ADO IN REG The data register for analog input channel 0 DEVICE REG BASE 0x4000 ADI IN REG The data register for analog input channel 1 DEVICE REG BASE 0x4004 AD IN REG The data register for analog input channel 2 DEVICE REG BASE 0x4008 Ignore this register for DI9841E modules e AD3 IN REG The data register for analog input channel 3 DEVICE REG BASE 0x400C Ignore this register for DT9841E modules e AD4 IN REG The data register for analog input channel 4 DEVICE REG BASE 0x4010 Ignore this register for DT9841E modules e AD5 IN REG The data register fo
124. d repetitive one shot operations you can use this value to determine when to stop counting in event counting applications This variable is automatically set to 0 if measure mode or continuous measure mode is specified Use the following equations to determine the value for PulseWidthCount e PulseWidthCount COUNTER RESOLUTION 1 duty cycle x clock frequency output frequency For example if the clock input frequency is 18 MHz the frequency of the output pulse is 6 0 MHz and the desired duty cycle is 66 6676 then the required PulseWidthCount is FFFFFFFEh e clks per output pulse COUNTER RESOLUTION 1 PulseWidthCount For example if PulseWidthCount FFFFFFFEh two clocks occur for each output pulse In this example the output is active for counts FFFFFFFFh and 0 Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Name Description Name Description output pulse width clks per output pulse x COUNTER CLOCK PERIOD For example if the clock period is 55 55 ns and two clock occur for each output pulse then the output pulse width is 111 11 ns output duty cycle output pulse width output period For example if the output pulse width is 222 2 ns and the output pulse period is 333 3 ns then the output duty cycle is 66 66 OutputPolarity A variable of type POLARITY des
125. dRun Lib DTCommLib dll ByVal hBoard As Long ByRef Args As String As DTSTATUS DTCommLib BAS Runs a DSP program that was downloaded previously using DT BoardDownload described on page 86 hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 Function Reference for Visual Basic Programmers Name Description Notes Return Values Example DT BoardWriteRegister Syntax Public Interface Description Parameters Name Description Name Description Args Support for this argument is currently not implemented specify NULL for Args A fixed length STRING variable that contains new arguments for the DSP program This string is parsed and passed to the main procedure of the DSP program Specify NULL for Args if you have no new arguments for the DSP program When a DSP program is downloaded using DT BoardDownload described on page 86 the program is loaded into DSP memory but is not started DT BoardRun starts program execution If a DSP program is already running when this function is called DT BoardRun resets the DSP passes new arguments to the program and re runs the program See Appendix A starting on page 107 On the module specified by BoardHandle run the previously downloaded program changing none of the program arguments Dim Status As DTSTATUS
126. dler pCallback A pointer to a callback function of type CALLBACKPROC described on page 162 that is called whenever an event occurs on the DT9840 Series module EventTraps An unsigned integer variable that specifies the type of event about which to be notified The following constants are defined e DTEVENT REMOTE CHAN OPENED described on page 215 e DTEVENT REMOTE CHAN CLOSED described on page 214 DTEVENT ASYNC DATA RECEIVED described on page 208 DTEVENT SYNC DATA RECEIVED described on page 215 e DTEVENT CHAN IN BUFFER FULL described on page 209 DTEVENT OUT BUFFER SPACE AVAILABLE described on page 213 DTEVENT ERROR described on page 210 e DTEVENT AD OVERRUN described on page 208 this event occurs in the DSP program on the DT9840 Series module only e DTEVENT DA UNDERRUN described on page 210 this event occurs in the DSP program on the DT9840 Series module only e DIEVENT MODULE UNPLUGCGED described on page 212 this event can occur in the DSP or host program Chapter 4 Description cont Name Description Notes Return Values Example 72 DTEVENT MODULE PLUGGED described on page 211 this event can occur in a DSP program only DTEVENT ALL COMM EVENTS Specify this constant to monitor all of the host communication events To register for multiple events OR the appropriate constants together pContext A pointer to a variable of type V
127. e Typical Communication Operations cont Read the number of bytes from the module with DT ChanRead Read the currently available data from the module with DT ChanReadAvailable Did the module send a synchronous write command Yes Convert raw analog data to voltage Yes y Close the communication channel on Acknowledge receipt of the data with DT_ChanAcknowledge To convert a single value call DT_ADValueToVolts to convert a scan of values call DT_ADScanToVolts to convert values for a single channel within a block call DT_ADChanBlockToVolts to convert a block of values call DT_ADBlockToVolts p the host with DT ChanClose i Close the DT9840 Series module with DT BoardClose DT VoltsToDAChanBlock DT VoltsToDABlock DT ADChanBlockToVolts DT ADBlockToVolts and DT ChanAcknowledge are not supported in Visual Basic Event driven programming is not supported in Visual Basic therefore do not use DT ChanSyncWrrite in your DSP program if you intend to write your host program using Visual Basic Programming Flowcharts Typical Event Driven Communication Operations Note Event driven operations are not supported in Visual Basic Open the DT9840 Series module from the host application with DT BoardOpen Y Register a callback function that handles communication events wit
128. e A variable of type DAC RANGE described on page 131 that specifies the analog output voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 OUTPUT SCAN RCD OutScan DOUBLE OutVolts NUM DAC CHANS Convert the voltage values in the 10 V range for the scan OutVolts into raw values and put in OutScan Status DT VoltsToDAScan OutVolts amp OutScan DAC BIPOLAR 10 VOLT Function Reference for Visual C Programmers DT VoltsToDAValue Syntax Include File Description Parameters Name Description Name Description Name Description Notes Return Values Example DTSTATUS DT VoltsToDAValue DOUBLE Volts LONG pDAValue DAC RANGE VoltageRange DTCommonAPI H Converts a single voltage value into a raw analog output value that is used by DT_WriteDAC Refer to the DT9840 Series DSP Library User s Manual for more information on the DT_WriteDAC function Volts A constant or variable of type DOUBLE that contains the voltage value to convert into a raw analog output value pDAValue A pointer to an integer variable in which the converted raw analog output value is returned VoltageRange A variable of type DAC_RANGE described on page 131 that specifies the analog output voltage range Avoid this function during time criti
129. e the resulting signal from the oscillator is then divided by 2 to provide a clock signal to the A D and D A converters that is oversampled 256 times and has a 50 duty cycle For example if you specify an internal clock frequency of 100 KHz internally the DT9841 DT9841E and DT9841 VIB modules set the oscillator to 51 2 MHz then divides the resulting signal by 2 to provide a 25 6 MHz signal with a 5076 duty cycle to the A D and D A converters MaxSampleRate A variable of type Double that indicates the maximum frequency in Hz of the internal sample clock This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual For all DT9840 Series modules this value is 100 000 Hz MinSampleRate A variable of type Double that indicates the minimum frequency in Hz of the internal sample clock This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual For the DT9841 DT9841E and DT9841 VIB this value is 200 Hz For the DT9842 2 and DT9842 8 this value is 0 Hz ActualSampleRate A variable of type Double that indicates the actual sample frequency in Hz that the DT9840 Series module could achieve This value is returned by DT SetupClock described in the DT9840 Series DSP Library User s Manual ClockType A variable of type CLOCK_TYPE described on page 172 that indicates the clock to use 193 Appendix B 194 Name Description Name
130. e File Elements Name Description Name Description Name Description Name Description Name Description Name Description Name Description MODEL ID Enumerated Type typedef enum 984 28 0 20 9841 64 2 1 9842 128 0 2 9842 64 2 3 OB4A8 128 0 4 BA8 64 2 5 9841 128 2 6713 6 9842 128 2 6713 7 9848 128 2 6713 8 9841E 128 2 6713 9 9841 128 2 VIB 10 UNKNOWN MODEL 1 MODEL ID YgUUUBURUBEUUUOY DTCommLib H DT9841_128_0 This element indicates that you have a DT9841 R module with 128 MBytes of SDRAM and 0 MBytes of flash RAM DT9841 64 2 This element indicates that you have a DT9841 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9842_128_0 This element indicates that you have a DT9842 2 R module with 128 MBytes of SDRAM and 0 MBytes of flash RAM DT9842_64_2 This element indicates that you have a DT9842 2 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9848_128_0 This element indicates that you have a DT9842 8 R module with 128 MBytes of SDRAM and 0 MBytes of flash RAM DT9848_64_2 This element indicates that you have a DT9842 8 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9841_128_2_6713 This element indicates that you have a DT9841 module that contains the 6713 chip with 128 MBy
131. e finished with the module call DT BoardClose described on page 49 to close the module and release any resources that were allocated to it See Appendix A starting on page 107 CHAR BdName BRD HANDLE hBoard BOARD OPTIONS BrdOptions BrdOptions SizeThisStructure sizeof BOARD OPTIONS Specify a module input buffer size of 64 kBytes BrdOptions ReadSizeInKb 64 Specify a module output buffer size of 200 kBytes BrdOptions WriteBufSizeInKb 200 53 Chapter 4 Example cont DT BoardReadFromMemory Syntax Include File Description Parameters Name Description Name Description Name Description Name Description 54 Open module BdName set the internal buffer sizes and return the handle in hBoard Status DT BoardOpen BdName amp hBoard amp BrdOptions DTSTATUS DT BoardReadFromMemory BRD HANDLE hBoard ULONG SrcDSPAddress ULONG NumBytes VOID pDestPCBuffer DTCommLib H Returns data from a DSP address on the specified DT9840 Series module into a variable on the host computer with no assistance from the DSP hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 SrcDSPAddress
132. e handler window that was previously registered using the DT RegisterMsgHandler function described on page 73 Parameters Name hBoard Description A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 Name hWindow Description A variable of type HWND that specifies the message window that you want to unregister Notes None Return Values See Appendix A starting on page 107 Example HWND hWinHandle Unregister the message handler for the specified window hWinHandle and module hBoard Status DT UnregisterMsgHandler hBoard hWinHandle 76 Function Reference for Visual C Programmers DT VoltsToDABlock Syntax Include File Description Parameters Name Description Name Description Name Description Name Description Notes Return Values Example DTSTATUS DT VoltsTOoDABlock DOUBLE Volts ULONG NumScans OUTPUT SCAN BLOCK pOutBlock DAC RANGE VoltageRange DTCommonAPI H For all analog output channels in a block converts an array of voltage values into a block of raw analog output values for use by DT_BlockLoop or DT_ListLoop Refer to the DT 9840 Series DSP Library User s Manual for more information on the DT_BlockLoop or DT_ListLoop functions Volts An array of ty
133. e scan loop Ignore these events the first time through the loop subsequent events however should be addressed DTEVENT ASYNC DATA RECEIVED Syntax Description Parameters Name Description Name Description 208 DTEVENT ASYNC DATA RECEIVED Paraml Param2 For an open communication channel indicates that new data was received asynchronously Param1 The handle of communication channel that received the new data Param2 The number of bytes received Communication Events and Messages Notes In response to this event the Windows message DTMSG ASYNC DATA RECEIVED is sent to the host application The host application should read the data by calling DT ChanReadAvailable described on page 67 or with DT ChanRead described on page 65 DTEVENT CHAN IN BUFFER FULL Syntax Description Parameters Name Description Name Description Notes DTEVENT CHAN IN BUFFER FULL Paraml Param2 For a channel that was opened for reading indicates that the channel input buffer is full The system cannot process any incoming data on any channel until some data has been read from the full buffer Param1 The handle of the communication channel whose input buffer is full Param2 The number of bytes of available buffer space In response to this event the Windows message DTMSG CHAN IN BUFFER FULL is sent to the host
134. eS 63 DIsChanheadouA ia ctr smt eae ect Venta QUA Re Fr Kel odo Ded io LE ta dd 65 Dr chanReadaAvailable eei es pie eek ee ae fl ok oe APRIRE 67 DT ChanSynceWrite accessio uen Re n umb yale pigs seats em d e t cus s 68 DT GetError teI Se ea e Ta retta retail teat rit este ets 69 DI RegisterCallback 5 ecc A a een a cec reed 70 DTzRegisterMsg Handler ences piene the bete tn ote idl easly te e Lasley ae 73 DT ntegisterCallback eerte Este retomar d cd dec ec eae done 75 DT UnregisterMsgHandler o s cossir esre tonse utere DESNE nn 76 DL VOltSTODA BlOCK EE ENEA E E E E E id EEA deitas 77 DT_VoltsToDAChanBlock 0 0 0 0 ccc ccc estonet RR RR RI e us 78 DT VoltstoDASc an eR Lem LL ore o I ELM IM IA ca A o UE 80 DE VoltsToDAValte na D sce He eae E EE A ape Bea 81 Chapter 5 Function Reference for Visual Basic Programmers 83 TI SAJScanToVolts 5er a cosh teer rst On ase Ret Ert eere RAE arde Ao 84 DI AADValueloVolts keen RP ER E a ME ERE E iR Ys 85 DTzBoardClose teat uty LEM ID D o ted Moratti iid A be pode t re 85 DT Boardbownload9i cate eo cette tato a 86 DI BoardGetlnfos m Le End Ies iet aee ume eee o ete pied 87 DT BoardGetlN me o e En o o er c dis o Ma aoi ea td oti per 88 DEI Board Opens ns xe eter tete C A ete ite te aite e Re E o 89 DT BoardReadFromMemory issssssssss n 90 DT BoardReadRegister sssess ene 91 DI BoardRud esc E a I eae ee ea 92 DT Board WriteRegisters oe ear tee er ea quei
135. eem y Ee ER CER RE cess 54 DT DoardReadRBegiBEpk eerie te entree pee doce Nee tense Ha em tese gs 55 Rud d PERCENT EK O E A E E E 56 DI BoardWriteRegister 2l lle d hee e e Rr Er RD E Re RR EE a eh 57 DT Board WTO MSDS Le aea 58 DT Chao DE DE A ens EE AREE ire nti ecu a 59 DI ChanAsyvec We ii Rd eere e Ib E Ru RE E anette beeen Sa 60 DT ChanBytesAxaabl coeepeetep oe RPE a Fee ad eese s 61 EXT 4 hant AAA 61 IMD A cl cs deer exe acess date GR RUE E RE p as 62 TX Chan pen oue tree here DS perdes Ree Poe oe eese er eio eene os 63 EXT 4 Dasnbeasl 2 2 eed te ee Rede sev ede eR 65 DT tbhanheadA amp wvalabl amp a CE RE ido os 67 DT Ei ra AAA UR o eoe i ce eee tege eee dene os 68 EI GetBnort g s eei nete ER ete RDHeIHRRRRU ERR E I EP Dr LOS RE NUR pe 69 DI BegiierCallack in a a Eee RE RR RE PER REDE RE Kiet dees 70 DT RegisterMse Handler Dirt 6E Ie oe he esee He eat ate ciet 73 DI Uniegister Callback esos meme Re RR he e tee te 75 ET DENS acdsee hares Gate este eee estela eerie 76 IST WoltsTol Block rios eR bet tb gcd Cb RE EE e DERE CCP ER PER wae ee ees Fi 43 Chapter 4 DT WoltsToD AC ianBl ck ias 78 DI Volts Tob Satis dois ea dd DE nue ten tr eed 80 DT yoat TOA SM 2 i seriea di E e e RM ER ELE 81 This chapter provides detailed information about each of the functions in the DT9840 Series Host Communication Library for Visual C programmers Functions are documented in alphabetical order Function Refer
136. ementing When the counter increments to the value of PulseWidthCount described on page 196 the value of the counter is output The output stays active until the counter rolls over to 0 the terminal count The output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 195 The user output then stays inactive and the counter stays disabled until the next active gate occurs All gates that occur while the counter is incrementing are ignored The active polarity of the pulse output pulse is determined by OutputPolarity described on page 196 MEASURE If you specify this element the counter timer measures the interval of a signal between a selected measurement start edge and a selected measurement stop edge Connect the signal that you want to measure to either the clock input pin or the gate input pin of the counter timer that you want to use Then specify the measurement start edge and the measurement stop edge Refer to page 181 for more information on the start and stop edges Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description When you trigger the operation with DT TriggerCTR the counter increments from the time it detects the selected start edge until it detects the stop edge When it detects the selected stop edge the counter stops counting You can determine whether the
137. ence for Visual C Programmers DT ADBlockToVolts Syntax Include File Description Parameters Name Description Name Description Name Description Name Description Notes Return Values DTSTATUS DT ADBlockToVolts INPUT SCAN BLOCK pInBlock ULONG NumScans DOUBLE Volts A DC RANGE VoltageRange DTCommonAPI H For all the analog input channels in a block converts the raw analog input values returned by DT_BlockLoop or DT_ListLoop into an array of voltage values Refer to the DT 9840 Series DSP Library User s Manual for more information on the DT_BlockLoop and DT_ListLoop functions pInBlock A pointer to an array of type INPUT_SCAN_BLOCK described on page 155 that contains the raw analog input values to convert NumScans An unsigned integer variable or constant that specifies the number of scans in the block to convert If you want to convert all of the analog input values in the block set NumScans to the value of ScansThisBlock in the INPUT SCAN BLOCK structure described on page 155 Volts An array of type DOUBLE in which the converted voltage values are returned Allocate Volts to hold NumScans NUM_ADC_REGS values Refer to page 117 for more information on NUM_ADC_REGS VoltageRange A variable of type ADC RANGE described on page 123 that specifies the range of the A D converter Avoid this functi
138. ent indicates that you have a newer module type than what is defined in the version of DTCommLib DLL on your computer Contact Data Translation for the most up to date files Non 6713 modules require customized TCF files If you are using one of these modules and do not have the TCF file you need contact Technical Support for help Data Types Constants Enumerated Types Structures and Callback Functions POLARITY Enumerated Type Definition Public Interface Members Name Description Name Description Notes Public Enum POLARITY ACTIVE HIGH 0 ACTIVE LOW 1 End Enum DTCommLib BAS ACTIVE HIGH If you specify this element the high portion of the total pulse output period is the active portion of the counter timer clock output signal on the DT9840 Series module ACTIVE LOW If you specify this element the low portion of the total pulse output period is the active portion of the counter timer clock output signal on the DT9840 Series module In measure mode if POLARITY is ACTIVE HIGH when you call DT TriggerCTR the counter output is low while the measurement is in progress and high when the measurement is complete If POLARITY is ACTIVE LOW when you call DT TriggerCTR the counter output is high while the measurement is in progress and low when the measurement is complete TRIGGER TYPE Enumerated Type Definition Public Interface Members Name Description Name Descriptio
139. er all other communication operations For example if you use this function to write 2 MBytes of data from the host computer to the DSP of the module all other messaging between the host computer and the module is suspended until all 2 MBytes has been transferred Unlike most other functions in this library DT_BoardWriteToMemory does not require that a DSP program is running on the module To write to specific registers on the DT9840 Series module use DT_BoardWriteRegister described on page 93 See Appendix A starting on page 107 Dim Status As DTSTATUS Dim HostValue As Long Dim DSPAdd As Long Write the contents of HostValue to the memory location specified by DSPAdd Status DT BoardWriteToMemory BoardHandle HostValue 4 DSPAdd Declare Function DT_ChanAsyncWrite Lib DTCommLib dll ByVal hChan As Long ByRef Buffer As Any ByVal NumBytes As Long As DTSTATUS DTCommLib BAS 95 Chapter 5 Description Parameters Name Description Name Description Name Description Notes Return Values Example DT ChanBytesAvailable Syntax Public Interface 96 Asynchronously writes a specified number of bytes from an open communication channel on the host to the DT9840 Series module hChan A variable of type LONG that specifies the handle to the open communication channel This value is returned by DT ChanOpen desc
140. er of characters for the module name is 256 ERR STRING MAX LEN The maximum number of characters for the error string is 256 BRD HANDLE A pointer of type VOID FIND HANDLE A pointer of type VOID BOARD NAME BOARD NAME MAX LEN An array of type CHAR that contains 256 elements ERROR STRING ERR STRING MAX LEN An array of type CHAR that contains 256 elements MAX BOARD OPTION SIZE The maximum number of elements for the BOARD OPTIONS structure is 200 The following data types are defined in the DTCommonAPI H file which is referenced in the DTCommLib H file CHAN NAME MAX LEN The maximum number of characters for the channel name is 200 CHAN HANDLE A pointer of type VOID CHAN NAME CHAN NAME MAX LEN An array of type CHAR that contains 200 elements Constants The following constants are provided for Visual C General purpose constants described on this page Conversion constants described on page 118 Register constants described on page 119 Error constants described on page 121 Event constants described on page 122 Message constants described on page 122 Data Types Constants Enumerated Types Structures and Callback Functions Counter timer constants described on page 122 Flash memory constants described on page 123 General Purpose Constants The following constants are defined in the DICommonAPI H file which is referenced in the DTCommLib H file for general use MIN SA
141. es are returned VoltageRange A variable of type DAC RANGE described on page 177 that specifies the analog output voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 105 Chapter 5 Example DT VoltsToDAValue Syntax Public Interface Description Parameters Name Description Name Description Name Description Notes Return Values Example 106 Convert the voltage values in the array OutVolts which are in the 10 V range into raw values and store them in OutScans Dim OutVolts NUM DAC CHANS 1 As Double Dim OutScans As OUTPUT SCAN RCD Status DT VoltsToDAScan OutVolts 0 OutScans BIP10 VOLTS SPAN Declare Function DT VoltsToDAValue Lib DTCommLib dll ByVal Volts As Double ByRef DAValue As Long ByVal VoltageRange As DAC RANG As DTSTATUS E DTCommLib BAS Converts a single voltage value into a raw analog output value that is used by DT_WriteDAC Refer to the DT9840 Series DSP Library User s Manual for more information on the DT WriteDAC function Volts A variable of type DOUBLE that specifies the voltage value to convert into a raw analog output value DAValue A variable of type LONG in which the converted raw analog output value is returned VoltageRange A variable of type DAC RANGE d
142. es that an A D overrun error occurred in an block or list loop operation Parameters Name Paraml Description This parameter is not used NULL Name Param2 Description This parameter is not used NULL Notes You can use this event with DT RegisterCallback in your DSP program to detect A D overrun errors in block loop or list loop operations This event never occurs on the host system If this event occurs in your DSP program ensure that the host program reads analog input data from the DT9840 Series module as fast as it is being acquired DTEVENT MODULE PLUGGED Syntax DTEVENT MODULE PLUGGED Paraml Param2 Description Indicates that the USB cable between the host computer and the DT9840 Series module was plugged in after being unplugged 211 Appendix C 212 Parameters Name Description Name Description Notes Syntax Description Parameters Name Description Name Description Notes Param1 This parameter is not used NULL Param2 This parameter is not used NULL This event occurs on the DSP only This event is generated each time you run the COFF file DTEVENT MODULE UNPLUGGED DTEVENT MODULE UNPLUGGED Paraml Param2 Indicates that the USB cable between the host computer and the DT9840 Series module was unplugged Param1 The handle of the module that generated the error Param2 This parameter is not used NULL This event
143. escribed on page 177 that specifies the analog output voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 Convert the voltage in Volts which is in the 10 V range into a raw value and store in Value DIM Status As DTSTATUS Dim Volts As Double Dim Value As Long Status DT VoltsToDAValue Volts Value BIP10 VOLTS SPAN A Error Codes 107 Appendix A 108 Table 4 lists the error codes that can be returned or detected by the DT9840 Series Host Communication Library Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect Error Code Error Message ASCII Text Solution 0 DT SUCCESS Success No error the function executed successfully 1 DT NO MEMORY Not enough memory availableto Request smaller buffers or increase create internal buffer the amount of system memory 2 DT BUFFER TOO SMALL Incoming message is too big for Increase the size of the buffer so that caller s buffer itis as least as large as the largest message that you will receive from the DT9840 Series module 3 DT INVALID CHAN NAME The pChanName argument is Check the channel name and ensure not valid that the specified channel exists 4 DT INVALID CHAN HANDLE The channel handle argumentis Check that the channel handle is a not
144. escription Name Description Name Description Name Description Notes In this case if either a D A underrun or A D overrun error occurs the user defined callback functions for both operations are still invoked e If ErrorOption in the ADC SETUP structure is set to STOP ON ERROR set ErrorOption in the DAC SETUP structure to STOP ON ERROR In this case if either a D A underrun or A D overrun error occurs both operations stop and the user defined callbacks are NOT invoked DacRange A variable of type DAC RANGE described on page 177 that specifies the output range for the analog output channels Unused1 An unsigned integer variable that is currently unused specify 0 for this member Unused2 An unsigned integer variable that is currently unused specify 0 for this member Unused3 An unsigned integer variable that is currently unused specify 0 for this member Unused4 An unsigned integer variable that is currently unused specify 0 for this member Unused5 An unsigned integer variable that is currently unused specify 0 for this member On the DT9842 2 the two analog output channels are 180 degrees out of phase with each other On the DT9842 8 each analog output channel is 45 degrees out of phase with the previous channel To convert a voltage to a raw initial value use DT VoltsToD AValue described on page 106 We recommend that you turn on the 20 kHz filter whenever you
145. ese e 213 DTEVENT OUTPUT SCAN BLOCK UNDERRUN sese esses 214 Contents DTEVENT REMOTE CHAN CLOSED 0 00 0 0000 0c eR e es 214 DTEVENT REMOTE CHAN OPENED eee es 215 DTEVENT SYNC DATA RECEIVED 0 000000 ccc RR RR es 215 Index i Be ILE NN ne es ee tee Wed Dau Mas 217 About this Manual This manual describes how to use the functions included in the DT9840 Series Host Communication Library to create a Windows based application that runs on the host computer and communicates with a DSP program running on a DT9840 Series module Intended Audience This document is intended for Visual C or Visual Basic programmers who are responsible for writing a host application program that communicates with the DSP on a DT9840 Series module The DT9840 Series Host Communication Library is supported in Microsoft Windows XP Windows Vista or Windows 7 using Microsoft Visual Studio 6 0 or greater What You Should Learn from this Manual This manual provides detailed information about the functions and messages provided in the DT9840 Series Host Communication Library This manual is organized as follows Chapter 1 Overview provides an introduction to the DT9840 Series Host Communication Library Chapter 2 Using the DT9840 Series Host Communication Library provides conceptual information to help you use the functions in the DT9840 Series Host Communication Library Chapter 3 Progra
146. f you specify this element the internal sample clock on the DT9840 Series module is used You specify the frequency of the internal clock source using the CLOCK SETUP structure described on page 145 AD DA CLK SRC EXTERNAL If you specify this element the signal that is connected to the Ext Clk BNC on the DT9840 Series module is used as the sample clock For the DT9841 DT9841E and DT9841 VIB modules use an external clock source with a 50 duty cycle Conversions start on a high to low transition of the external clock signal after a rising edge of the internal calibration signal The resulting frequency of the external clock is always equal to the frequency of the external clock signal that you connected to the module divided by 256 this division is done internally by the module For example if you need a sampling frequency of 100 kHz use an external clock source with a frequency of 25 6 MHz AD DA CLK SRC SB MASTER If you specify this element the sample clock is derived from the master DT9840 Series module through the Scalable Bus This is the recommended setting for all slave DT9840 Series modules when you want to synchronize the acquisition of data on all modules CHAN TYPE Enumerated Type Definition Include File typedef enum READ CHAN O0 WRITE CHAN CHAN TYPE DTCommonAPI H Data Types Constants Enumerated Types Structures and Callback Functions Elements Name Description N
147. fSize not all of the data from the DT9840 Series module is available but the data that is available is returned to the host application When the number that is returned is equal to BufSize more than the requested data from the DT9840 Series module is available but only the portion of data that fits in pBuffer is returned The most data that can be returned at one time cannot be larger than BufSize When this function is called the available data up to the size of pBuffer is returned If no data is available other operations can continue If you want to block other operations from continuing while you are waiting for all the data to become available use the DT_ChanRead function described on page 65 instead 67 Chapter 4 Return Values Example DT_ChanSyncWrite Syntax Include File Description Parameters Name Description Name Description Name Description 68 See Appendix A starting on page 107 CHAN_HANDLE hChan VOID HostBuff ULONG BytesRead Read the number of bytes available from the module up to 100 bytes HostBuff Return the actual number of bytes read in BytesRead Status DT ChanReadAvailable hChan amp HostBuff 100 amp BytesRead and put it in DTSTATUS DT ChanSyncWrite CHAN HANDLE hChan VOID pBuffer ULONG NumBytes ULONG TimeoutInMS Y DTCommonAPI H Sy
148. for digital port 0 Note that if you are using the interrupt on change feature when deglitching is enabled the maximum frequency that any change can be detected is 500 Hz if deglitching is disabled the maximum frequency that any change can be detected is is 100 kHz This parameter is ignored if PortOOut is TRUE Initial DOValue An unsigned integer variable that specifies the initial value to output to the digital output lines when DT_SetupDIO described in the DT9840 Series DSP Library User s Manual is called Unused 5 An unsigned integer array of five elements that is currently unused typedef struct BOOL CurrentSourceEnabled BOOL FilterEnabled BOOL ACCoupling IEPE CHAN INFO DTCommonAPI H 153 Appendix B Elements Name Description Name Description Name Description Notes IEPE SETUP Structure Definition Include File Elements Name Description Notes 154 CurrentSourceEnabled A Boolean variable that indicates whether the 4 mA current source is enabled or disabled for the analog input channel If the value is TRUE the 4 mA current source is enabled If the value is FALSE the 4 mA current source is disabled FilterEnabled A Boolean variable that indicates whether the 10 kHz filter is enabled or disabled for the analog input channel If the value is TRUE the 10 kHz filter is enabled If the value is FALSE the 10 kHz filter is disabled
149. formation on wiring analog inputs to use bias return termination resistance Setting a bit to 1 enables the termination resistor for the associated analog input channel Setting a bit to 0 disables the termination resistor for the associated analog input channel The bit values are as follows e Bit 1 0x01 Corresponds to analog input channel 0 e Bit 2 0x02 Corresponds to analog input channel 1 e Bit 4 0x04 Corresponds to analog input channel 2 j j j Bit 8 0x08 Corresponds to analog input channel 3 e Bit 16 0x10 Corresponds to analog input channel 4 e Bit 32 0x20 Corresponds to analog input channel 5 Bit 64 0x40 Corresponds to analog input channel 6 e Bit 128 0x80 Corresponds to analog input channel 7 Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Notes BOARD OPTIONS Structure Definition Include File Elements Name Description ErrorOption A variable of type ERROR MODE SELECT described on page 135 that specifies whether to continue or stop the operation when an A D overrun error condition is detected If you are performing an input operation and an output operation simultaneously using DT ScanLoop DT BlockLoop or DT ListLoop the following restrictions apply to ErrorOption e If ErrorOption in the DAC SETUP structure is set to CONTINUE ON ERROR set ErrorOption in t
150. h DT RegisterCallback Download a DSP application COFF format to the module with DT BoardDownload Run the downloaded DSP application on the module with DT BoardRun y Open the communication channel on the host with DT_ChanOpen i Go to the next page P 39 Chapter 3 Typical Event Driven Communication Operations cont C Continued from previous page To convert a single value call DT VoltsToDAValue to convert a scan of values call DT VoltsToDAScan to convert values for a single channel within a block call DT VoltsToDAChanBlock to convert a block of values call DT_VoltsToDABlock Convert voltage data to raw analog data Write Yes data to the module Write a specified number of bytes to the module asynchronously with DT ChanAsyncWrite Write asynchronously Write data to the module synchronously with DT ChanSyncWrite y Wait for the module to acknowledge that the data was received y C Go to the next page 2 40 Programming Flowcharts Typical Event Driven Communication Operations cont C Continued from previous page Reada Read data from the module specified number of bytes at one Yes Read the number of bytes from the module with DT ChanRead
151. h RAM 183 Appendix B 184 Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description Notes DT9842 64 2 This element indicates that you have a DT9842 2 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9848_128_0 This element indicates that you have a DT9842 8 R module with 128 MBytes of SDRAM and 0 MBytes of flash RAM DT9848_64_2 This element indicates that you have a DT9842 8 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9841 128 2 6713 This element indicates that you have a DT9841 module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9842 128 2 6713 This element indicates that you have a DT9842 module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9848 128 2 6713 This element indicates that you have a DT9848 module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9841E 128 2 6713 This element indicates that you have a DT9841E module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9841 128 2 VIB This element indicates that you have a DT9841 VIB module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM UNKNOWN MODEL This elem
152. hanAcknowledge to acknowledge that it received the request DT ChanAcknowledge and DT ChanSyncWrite are not supported in Visual Basic Note that the following issues may arise when the host application writes data to a communication channel Remote Channel Buffer Full If the channel input buffer on the DT9840 Series module is small or if the DSP program does not read data from the communication channel fast enough the host can overfill the channel input buffer on the module causing the data to back up on the communication channel Note The DSP program cannot process any incoming data on any communication channel until it has read some data from the full channel input buffer To deal with this issue either increase the size of the channel input buffer on module by calling DT ChanOpen in the DSP program or increase the rate at which the DSP program reads data from the communication channel 29 Chapter 2 30 Fast Large Writes When the host application writes data to a communication channel the data is first copied into the module output buffer If the host application writes large amounts of data very quickly the module output buffer may be filled faster than the data can be transmitted across the USB bus to the DT9840 Series module To deal with this issue either decrease the rate at which the host application program fills the module output buffer or be prepared to control how fast data is written to the ch
153. hane t Rs 105 DT VolsIob VAI A RE ua RC UE ade woke ORE ek wen 106 This chapter provides detailed information about each of the functions in the DT9840 Series Host Communication Library for Visual Basic programmers The functions are documented in alphabetical order Chapter 5 DT ADScanToVolts Syntax Public Interface Description Parameters Name Description Name Description Name Description Notes Return Values Example 84 Declare Function DT ADScanToVolts Lib DTCommLib dll ByRef InScan As INPUT SCAN RCD ByRef Volts As Double ByVal VoltageRange As ADC RANG As DTSTATUS E DTCommLib BAS Converts a scan of analog input values that is returned by DT_ReadADCDIO or DT_CaptureBuffer into an array of voltage values Refer to the DT9840 Series DSP Library User s Manual for more information on the DT ReadADCDIO and DT CaptureBuffer functions InScan A variable of type INPUT SCAN RCD described on page 204 that contains the raw analog input values to convert to voltage values Volts A variable of type DOUBLE in which the converted voltage values are returned for each analog input channel in the scan Allocate the Volts array to hold NUM ADC RECS values Refer to page 164 for more information on NUM ADC REGS VoltageRange A variable of type ADC RANGE described on page 170 that specifies the analog input voltage ra
154. he ADC SETUP structure to CONTINUE ON ERROR In this case if either an A D overrun or D A underrun error occurs the user defined callback functions for both operations are still invoked e If ErrorOption in the DAC SETUP structure is set to STOP ON ERROR set ErrorOption in the ADC SETUP structure to STOP ON ERROR In this case if either an A D overrun or D A underrun error occurs both operations stop and the user defined callbacks are NOT invoked Unused An unsigned integer array of five elements that is currently unused In Visual C the expression 1 lt lt ADChan generates the appropriate bit value for a given channel typedef struct ULONG SizeThisStructure ULONG DSPToHostBufSizeInKb ULONG HostToDSPBufSizeInKb ULONG DbgFlag BOARD OPTIONS DTCommonAPI H SizeThisStructure An unsigned integer variable that specifies the size of the BOARD_OPTIONS structure This element is provided for future compatibility 141 Appendix B 142 Name Description Name Description Name Description Notes DSPToHostBufSizeInKb An unsigned integer variable that specifies the size of the module input buffer in kilobytes on the host If you specify 0 for DSPToHostBufSizeInKb the default size is used 64 kBytes At a minimum the size of the module input buffer must be at least as large as the largest message that the DT9840 Series module will send to the ho
155. he DSP program and host application 3002 DT HOST BUFFER EMPTY Host buffer is empty and Ensure that the host application fills shouldn t be the output buffer in a timely manner 113 Appendix A 114 Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 3003 DT HOST RCV BUFFER FULL Host s board s receive buffer is full To avoid this error either increase the size of the module input buffer on the host by changing the DSPToHostBufSizelnKb parameter of the BOARD OPTIONS structure that is passed to DT BoardOpen or read data more quickly from the host If this problem still persists ensure that all of the input channel buffers on the host are being read in a timely manner so that data does not back up 3004 DT HOST MSG UNKNOWN TYPE Message received from DT9841 has an unknown message ID This error indicates that an internal communication error occurred This error should never occur in a properly installed and running system Contact Technical Support see page 17 3005 DT HOST MSG INVALID LENGTH Message received from DT9841 had invalid length This error indicates an internal communication error This error should never occur in a properly installed and running system Contact Technical Support see page 17 3006 DT HOST CHAN BUFFER FULL Host
156. he external C T clock input pin starts or stops the measurement operation EXTERNAL CLOCK FALLS If you specify this element a falling edge high to low transition on the external C T clock input pin starts or stops the measurement operation EDGE TYPE is used only in measure mode and continuous measure mode ERROR MODE SELECT Enumerated Type Definition Include File Elements Name Description Name Description typedef enum STOP_ON_ERROR CONTINUE_ON_ERROR ERROR MODE SELECT DTCommonAPI H STOP_ON_ERROR If you specify this element the operation stops if the DT9840 Series module detects an error condition CONTINUE_ON_ERROR If you specify this element the operation continues if the DT9840 Series module detects an error condition GATE_TYPE Enumerated Type Definition Include File typedef enum GATED OFF GATED ON EXT NORMAL GATE EXT INVERTED GATE GATE TYPE DTCommonAPI H 135 Appendix B Elements Name Description Name Description Name Description Name Description 136 GATED OFF If you specify this element the gate is disabled GATED ON If you specify this element a software command enables the counter timer operation immediately after execution This gate type is not supported for up down counting measure mode continuous measure mode one shot or repetitive one shot operations EXT NORMAL GATE For standard counti
157. he following enumerated types are defined in the DTCommonAPI H file which is referenced in the DICommLib H file ADC RANGE described on page 123 AD DA CLK SRC described on page 124 CHAN TYPE described on page 124 CLOCK SRC described on page 125 e CLOCK TYPE described on page 126 COUNT MODE described on page 126 DAC FILTER TYPE described on page 130 DAC RANGE described on page 131 e EDGE TYPE described on page 134 ERROR MODE SELECT described on page 135 GATE TYPE described on page 135 e POLARITY described on page 138 TRIGGER TYPE described on page 139 The MODEL ID enumerated type described on page 137 is defined in the DTCommLib H file In addition the DISTATUS enumerated type described on page 131 is defined in the DTErrors H file which is referenced in the DTCommLib H file ADC RANGE Enumerated Type Definition typedef enum ADC BIPOLAR 10 VOLTS O0 ADC RANGE Include File DTCommonAPI H Elements Name ADC_BIPOLAR_10_VOLTS Description If you specify this element the analog input range is 10 V 123 Appendix B 124 AD DA CLK SRC Enumerated Type Definition Include File Elements Name Description Name Description Name Description typedef enum Al Al Al Al DA CLK SRC INTERNAL 0 DA CLK SRC EXTERNAL DA CLK SRC SB MASTER DA CLK SRC D D D D DTCommonAPI H AD DA CLK SRC INTERNAL I
158. hen you are finished with it ensure that you close the communication channel using DT ChanClose described on page 97 to release any resources that were associated with it See Appendix A starting on page 107 Open CHAN1 on the host for writing and return the handle to the channel in ChannelHandle If the DSP program does not open its side of the channel in 10000 ms time out Dim Status As DTSTATUS Dim BoardHandle As Long Dim ChannelHandle As Long Status DT ChanOpen BoardHandle CHAN1 WRITE CHAN 0 ChannelHandle 10000 Declare Function DT ChanRead Lib DTCommLib dll ByVal hChan As Long ByRef Buffer As Any ByVal NumBytes As Long ByVal TimeoutInMS As Long As DTSTATUS DTCommLib BAS Returns a specified number of bytes from a previously opened communication channel 101 Chapter 5 102 Parameters Name Description Name Description Name Description Name Description Notes Return Values Example hChan A variable of type LONG that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 99 Buffer A variable of type ANY in which the data from the DT9840 Series module is returned You can read from any data type structure or array NumBytes A variable of type LONG that specifies the number of bytes to
159. hould never be modified programmatically BlockNum An unsigned integer variable that specifies the number of blocks in the INPUT SCAN BLOCK structure For block loop operations the value of this variable is always 1 For list loop operations the value of BlockNum is passed to this structure when DT_MallocInputBlockList described in the DT9840 Series DSP Library User s Manual is called BlockComplete A Boolean variable that indicates when the current block is filled If the value is TRUE the current block is filled If the value is FALSE the current block is not filled Once the block is processed you must set this variable to FALSE Scans 1 An array of type INPUT SCAN RCD described on page 156 in which the analog input digital input and counter timer data is returned Each scan is an element in the array The number of elements in the array is specified by nScansThisBlock INPUT SCAN RCD Structure Definition Include File typedef struct LONG ADCValues NUM_ADC_REGS ULONG FlagsAndDin ULONG CounterValues NUM_COUNTERS INPUT_SCAN_RCD DTCommonAPI H Data Types Constants Enumerated Types Structures and Callback Functions Elements Name Description Name Description ADCValues NUM_ADC_REGS An integer array in which the acquired value of all the analog input channels is returned The array is defined to be as large as the number of analog i
160. ht hardware flags is returned Bits 0 to 7 represent port 0 bits 8 to 15 represent port 1 bits 9 to 23 represent port 2 and bits 24 to 31 represent the following hardware flags e Bit 24 1 Temperature is 65 C or over 0 Temperature is under 65 C e Bit 25 1 Counter timer 2 has overflowed 0 Counter timer 2 has not overflowed e Bit 26 1 Counter timer 1 has overflowed 0 Counter timer 1 has not overflowed e Bit 27 1 Counter timer 0 has overflowed 0 Counter timer 0 has not overflowed Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Bit 28 1 A FIFO Full error occurred on the Scalable Bus 0 2 A FIFO Full error did not occur on the Scalable Bus e Bit 29 1 Ananalog output trigger occurred 0 An analog output trigger did not occur e Bit 30 1 An analog input trigger error occurred 0 An analog input trigger error did not occur e Bit 31 1 An analog input trigger occurred 0 An analog input trigger did not occur CounterValues INUM COUNTERS A LONG array in which the acquired value of all the counter timer channels is returned The array is defined to be as large as the number of counter timer channels The DT9840 Series modules support three counter timer channels 0 to 2 OUTPUT SCAN RCD Data Type Definition Public Interface Members Name Description Name Desc
161. ibrary User s Manual for more information on the DT ReadADCDIO DT ScanLoop and DT CaptureBuffer functions DT ADBlockToVolts For all the analog input channels in a block converts the raw analog input values returned by DT BlockLoop or DT ListLoop into an array of voltage values Refer to the DT9840 Series DSP Library User s Manual for more information on the DT BlockLoop and DT ListLoop functions Note This function is not supported in Visual Basic DT ADChanBlockToVolts For a specified analog input channel in a block converts the raw analog values returned by DT BlockLoop or DT ListLoop into an array of voltage values Refer to the DT9840 Series DSP Library User s Manual for more information on the DT BlockLoop and DT ListLoop functions Note This function is not supported in Visual Basic The DT9840 Series Host Communication Library provides the following conversion functions for converting voltage values to raw analog data Note These functions are not recommended in time critical operations due to the error checking that is performed in the background 32 Using the DT9840 Series Host Communication Library DT VoltsToDAValue Converts a single voltage value into a raw analog output value that is used by DT WriteDAC Refer to the DT9840 Series DSP Library User s Manual for more information on the DT WriteDAC function DT VoltsToDAScan Converts an array of voltage values into a scan of r
162. ies module with no assistance from the DSP hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 pSrcPCBuffer A pointer to a variable of type VOID that contains the data from the host to write to the DSP on a DT9840 Series module NumBytes An unsigned integer variable or constant that specifies the number of bytes to write to the DSP on a DT9840 Series module DestDSPAddress An unsigned integer variable or constant that specifies the address of DSP memory on the DT9840 Series module to write to Although you can write to any DSP address using this function it is highly recommended that you write to a known DSP address Writing to an arbitrary DSP address can cause major system problems This function operates synchronously and take precedence over all other communication operations For example if you use this function to write 2 MBytes of data from the host computer to the DSP of a DT9840 Series module all other messaging between the host computer and the module is suspended until all 2 MBytes has been transferred Unlike most other functions in this library DT_BoardWriteToMemory does not require that a DSP program is running on the DT9840 Series module To write to specific registers on the DT9840 Series module use DT_BoardWriteRegister described on page 57 Function Reference f
163. ion Library DT9840 Series Host Program DSP Program The DT9840 Series module opens a communication channel with a specified name In response the host program opens a communication channel with the same name DT ChanOpen P DT ChanOpen The DT9840 Series module writes data asynchronously to the open channel In response the host reads data from the open channel DT ChanRead p DT_ChanAsyncWrite Figure 3 Typical Communication Programming DSP Initiated Event Driven Communication Programming Host Initiated Write your host program to open communication channels and write your DSP program to respond to channel open events by opening its side of communication channels as shown in Figure 4 Event driven programming provides more flexibility but is not as easy to use as typical communication programming DT9840 Series Host Program DSP Program Register a callback function in the DT_RegisterCallback DSP program to handle events DT ChanOpen DT ChanOpen The host opens a communication channel with a specified name and the DTEVENT REMOTE CHAN OPENED event occurs in the DSP program In response the DT9840 Series module opens a communication channel with the same name DT ChanAsyncWrite DT ChanRead The host writes data asynchronously to the open channel and the DTEVENT ASYNC DATA RECEIVED event is generated in the DSP program In response the DT9840 Series modu
164. is 166 666 ns output frequency 1 output period For example if the output period is 166 666 ns then the output frequency is 6 0 MHz The maximum output frequency is 9 MHz The minimum output frequency is 0 0042 Hz 195 Appendix B 196 Name Description Name Description PulseWidthCount A variable of type Long that determines when the output pulse of the counter timer is activated this variable determines the duty cycle of the pulse output signal Values range from 1 to FFFFFFFFh In addition to rate generation one shot and repetitive one shot operations you can use this value to determine when to stop counting in event counting applications This variable is automatically set to 0 if measure mode or continuous measure mode is specified Use the following equations to determine the value for PulseWidthCount refer to page 169 for more information on the constants used in these equations e PulseWidthCount COUNTER RESOLUTION 1 duty cycle x clock frequency output frequency For example if the clock input frequency is 18 MHZ the frequency of the output pulse is 6 0 MHz and the desired duty cycle is 66 66 then the required PulseWidthCount is FFFFFFFEh clks per output pulse COUNTER RESOLUTION 1 PulseWidthCount For example if PulseWidthCount FFFFFFFEh two clocks occur for each output pulse In this example the output is active for counts FFFFFFFFh and 0
165. is structure when DT_MallocInputBlockList described in the DT9840 Series DSP Library User s Manual is called If the list was allocated for a continuous list loop operation the last block s pNext pointer points to the first block in the list If the list was allocated for a one pass list loop operation the last block s pNext pointer is NULL and the input list operation stops when the last block has been acquired nScansThisBlock An unsigned integer variable that specifies the number of scans to perform for each block For example if nScansThisBlock is 1 the block of data that is acquired represents one scan of all the analog input channels and digital input lines If nScansThisBlock is 100 the block of data that is acquired represents 100 scans of all the analog input channels and digital input lines For block loop operations the value of nScansThisBlock is passed to this structure when DT_BlockLoop described in the DT9840 Series DSP Library User s Manual is called For list loop operations the value of nScansThisBlock is passed to this structure when DT_MallocInputBlockList described in the DT9840 Series DSP Library User s Manual is called 155 Appendix B 156 Name Description Name Description Name Description Name Description AllocSize An unsigned integer variable in which the size of the input scan block in bytes is returned Note The value of this parameter s
166. is variable Unused1 An unsigned integer variable that is currently unused specify 0 for this member Unused2 An unsigned integer variable that is currently unused specify 0 for this member Unused3 An unsigned integer variable that is currently unused specify 0 for this member Unused4 An unsigned integer variable that is currently unused specify 0 for this member Unused5 An unsigned integer variable that is currently unused specify 0 for this member Data Types Constants Enumerated Types Structures and Callback Functions IEPE CHAN INFO DataType Definition Type IEPE CHAN INFO CurrentSourceEnabled As Boolean FilterEnabled As Boolean ACCoupling As Boolean End Type Include File D TCommLib BAS Elements Name CurrentSourceEnabled Description A Boolean variable that indicates whether the 4 mA current source is enabled or disabled for the analog input channel If the value is TRUE the 4 mA current source is enabled If the value is FALSE the 4 mA current source is disabled Name FilterEnabled Description A Boolean variable that indicates whether the 10 kHz filter is enabled or disabled for the analog input channel If the value is TRUE the 10 kHz filter is enabled If the value is FALSE the 10 kHz filter is disabled Name ACCoupling Description A Boolean variable that indicates whether AC coupling is enabled or disabled for the analog input channel If the
167. ish For example you can use this flag on the host to control whether to print debug messages to the serial port on the DT9840 Series module using the DT Printf function of the DT9840 Series DSP Library 189 Appendix B 190 Description cont Notes BRD INFO Data Type Definition Include File Elements Name Description Name Description Name Description You can read the value of this flag in the DSP program on the module using the DT GetDebugFlag function of the DT9840 Series DSP Library To turn debugging off specify 0 for this value Ensure that the combined size of ReadBufSizeInKb and WriteBufSizeInKb does not exceed 48 MBytes In addition ensure that you have enough host memory and free RAM on the DT9840 Series module to accommodate the sizes specified in ReadBufSizeInKb and WriteBufSizeInKb If you specify NULL for the BoardOptions parameter of the DT BoardOpen function the module input and output buffers are set to their default sizes 64 kBytes Type BRD INFO Model As MODEL ID NotUsed As Long MB RAM As Long MB Flash As Long ProgramIsRunning As Boolean Dummy1 As Integer FPGAVersion As Long USBPortType As Long SBEnabled As Boolean Dummy2 As Integer SBAddress As Long SBTerminated As Boolean Dummy3 As Integer Reserved 15 As Long End Type DTCommLib BAS Model A variable of type MODEL ID desc
168. ites a specified number of bytes from an open communication channel on the host to the DT9840 Series module This function writes the data and returns immediately It does not wait for an acknowledgement from the DSP program running on the DT9840 Series module If the communication channel is busy or backed up with data the actual transfer to the module continues in the background this function does not block Typically DT ChanAsyncWrite is easier to use and has higher performance than DT ChanSyncWrite DT ChanSyncWrite Synchronously writes a specified number of bytes from an open communication channel on the host to the DT9840 Series module and waits for a response from the DSP program This function is useful if you want to synchronize the operation of the host application with the DSP program running on the module When this function is called the data is written immediately The function blocks all operations until the DSP application receives all the data and responds by calling DT ChanAcknowledge If the channel input buffer on the DT9840 Series module is full the DSP program must read the specified amount of data from the channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application program to detect the timeout error and recover if possible Note If the DSP program sends a DT ChanSyncWrite request to the host application program the host application program must call DT C
169. l Basic 84 in Visual C 47 DT ADValueToVolts 13 32 38 41 in Visual Basic 85 in Visual C 48 DT BOARD ALREADY OPEN 113 DT BOARD NOT RESPONDING 113 DT BOARD WAS SHUTDOWN 113 DT BoardClose 11 24 38 41 in Visual Basic 85 in Visual C 49 DT_BoardDownload 11 25 37 39 in Visual Basic 86 in Visual C 50 DT_BoardGetInfo 11 in Visual Basic 87 in Visual C 51 DT_BoardGetName 11 23 in Visual Basic 88 in Visual C 51 DT_BoardOpen 11 23 37 39 in Visual Basic 89 in Visual C 52 DT_BoardReadFromMemory 11 28 in Visual Basic 90 in Visual C 54 DT_BoardReadRegister 11 28 in Visual Basic 91 in Visual C 55 DT_BoardRun 11 25 37 39 in Visual Basic 92 in Visual C 56 DT_BoardWriteRegister 11 30 in Visual Basic 93 in Visual C 57 DT_BoardWriteToMemory 11 30 in Visual Basic 94 in Visual C 58 DT_BUFFER_TOO_SMALL 108 DT CALLBACK NOT FOUND 108 DT CANT FIND BOARD 111 DT CANT OPEN DRIVER 111 DT CHAN ALREADY CLOSED 109 DT CHAN ALREADY OPEN 109 DT CHAN DISCONNECTED 109 DT CHAN OPENED FOR READ 110 DT CHAN OPENED FOR WRITE 110 DT ChanAcknowledge 12 29 38 41 59 DT ChanAsyncWrite 12 29 37 40 in Visual Basic 95 in Visual C 60 DT ChanBytesAvailable 13 27 in Visual Basic 96 in Visual C 61 DT ChanClose 12 26 38 41 in Visual Basic 97 in Visual C 61 DT ChanGetInfo 13 26 in Visual Basic 98 in Visual C 62 Index DT ChanOpen 12 26 37 39 in Visual Basic 9
170. le reads data from the open channel Figure 4 Event Driven Communication Programming Host Initiated 21 Chapter 2 22 Event Driven Communication Programming DSP Initiated Write your DSP program to open communication channels and write your host program to respond to channel open events by opening its side of communication channels as shown in Figure 5 Event driven programming provides more flexibility but is not as easy to use as typical communication programming Host Program DT BoardOpen DT RegisterCallback DT BoardDownload DT BoardRun DT ChanOpen DT ChanRead Open a DT9840 Series module and return a handle to it Register a callback function on the host to handle events Download a DSP program to the DT9840 Series module DT9840 Series Module DT9840 Series DSP Program Run the downloaded program The module opens a communication channel with a specified name and the DTEVENT REMOTE CHAN OPENED event occurs on the host As a result the host opens a communication channel with the same name Y re The module writes data asynchronously to the open channel and the DTEVENT ASYNC DATA RECEIVED event is generated on the host As a result the host reads data from the open channel re DT ChanOpen DT ChanAsyncWrrite Figure 5 Event Driven Communication Programming DSP Initiated This chapter provides
171. le to the module This handle is then used by all subsequent communication functions to identify the module Function Reference for Visual C Programmers Parameters Name Description Name Description Name Description Notes Return Values Example BoardName A pointer to a variable of type CHAR that specifies the name of the DT9840 Series module You assign this name when you configure the device driver If you are using a single DT9840 Series module you can specify NULL for BoardName to open the module If you are using multiple DT9840 Series modules you must specify the actual name of the module Refer to the DT9840 Series Getting Started Manual for more information on assigning a module name phBoard A pointer to a variable of type BRD HANDLE described on page 116 in which the handle to the open DT9840 Series module is returned If the module cannot be opened NULL is returned pBoardOptions A pointer to a variable of type BOARD OPTIONS described on page 141 that specifies the size of the module input and output buffers Specify NULL for pBoardOptions to set the module input and output buffers to their default sizes 64 kBytes This is the normal operating mode Only one host application should be communicating with a module If you are using multiple modules and do not know their names you can use DT BoardGetName described on page 51 to return the module names When you ar
172. lines NUM DOUT in the output scan record for the specified module type For example for the DT9841 NUM INPUTS IN RCD is 3 2 analog output channels and 1 24 bit digital output port NUM INPUTS USED The number of inputs defined in the input scan record NUM INPUTS IN RCD NUM OUTPUTS USED The number of outputs defined in the output scan record NUM OUTPUTS IN RCD Conversion Constants The following conversion constants are defined in the DTCommonAPI H file which is referenced in the DTCommLib H file these constants are provided if you choose to write your own conversion routines instead of using the conversions routines provided in the DT9840 Series Host Communication Library BIP10 VOLTS SPAN An input or output range of 10 V this is 20L LONG BIP2PT5 VOLIS SPAN An input or output range of 2 5 V this is 5L LONG BIP10 COUNTS PER VOLT The number of counts per volt for the 10 V range This is defined as follows DOUBLE 0x10000 0x10000 BIPI0 VOLTS SPAN BIP2PT5 COUNTS PER VOLT The number of counts per volt for the 2 5 V range This is defined as follows DOUBLE 0x10000 0x10000 BIP2PT5 VOLTS SPAN BIP10 VOLTS PER COUNT The number of volts per count for the 10 V range of the specified module This is defined as follows 1 BIP10 COUNTS PER VOLT BIP2PT5 VOLIS PER COUNT The number of volts per count for the 2 5 V range of the specified module This is defined as follows 1 BIP
173. lock in the list If the list was allocated for a one pass list loop operation the last block s pNext pointer is NULL and the list output operation stops when the last block has been output nScansThisBlock An unsigned integer variable that specifies the number of scans in each block For example if nScansThisBlock is 1 the block of data that is output represents one scan of all the analog output channels and digital output lines If nScansPerBlock is 100 the block of data that is output represents 100 scans of all the analog output channels and digital output lines For block loop operations the value of nScansThisBlock is passed to this structure when DT BlockLoop described in the DT9840 Series DSP Library User s Manual is called For list loop operations the value of nScansThisBlock is passed to this structure when DT MallocOutputBlockList described in the DT9840 Series DSP Library User s Manual is called AllocSize An unsigned integer variable in which the size of the output scan block in bytes is returned Note The value of this parameter should never be modified programmatically BlockNum A unsigned integer variable that specifies the number of blocks in the OUTPUT SCAN BLOCK structure For block loop operations the value of this variable is always 1 For list loop operations the value of BlockNum is passed to this structure when DT_MallocOutputBlockList described in the DT9840 Series DSP Libra
174. lterType As DAC FILTER TYPE DAInitialValue NUM DAC CHANS 1 As Long ErrorOption As ERROR MODE SELECT DacRange As DAC RANGE Unusedl As Long Unused2 As Long Unused3 As Long Unused4 As Long Unused5 As Long End Type DTCommLib BAS FilterType A variable of type DAC FILTER TYPE described on page 176 that specifies the reconstruction filter to apply to the analog output channels on the DT9840 Series module DAlInitialValue For clocked analog output operations an array of type Long that specifies the initial value to output to the analog output channels when DT SetupDAC described in the DT9840 Series DSP Library User s Manual is called The size of the array is specified by NUM DAC CHANS described on page 164 minus 1 ErrorOption A variable of type ERROR MODE SELECT described on page 181 that specifies whether to continue or stop the operation when a D A underrun error condition is detected If you are performing an output operation and an input operation simultaneously using DT ScanLoop DT BlockLoop or DT ListLoop the following restrictions apply to ErrorOption e If ErrorOption in the ADC SETUP structure is set to CONTINUE ON ERROR set ErrorOption in the DAC SETUP structure to CONTINUE ON ERROR Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Name D
175. lue 2 5 is available on DT9841 DT9841E and DT9841 VIB modules Register Constants The following register constants are defined in the DTCommLib BAS file These constants are provided if you want to read the registers of the DT9840 Series modules using DT BoardReadRegister described on page 91 or DT BoardReadFrom Memory described on page 90 or write to the registers of the DT9840 Series modules using DT BoardWriteRegister described on page 93 or DT BoardWriteToMemory described on page 94 Note Refer to the DT9840 Series User s Manual for more information on these registers DEVICE REG BASE The Hardware Control and Status register of the DT9840 Series module address amp HB0000000 HDW CTRL REG The Hardware Control and Status register DEVICE REG BASE HDW CALIBRATION REG A calibration register DEVICE REG BASE amp H4 DT19842 CLOCK REC The clock divider register for the DT9842 2 and DT9842 8 modules DEVICE REG BASE amp H8 e USB CALIBRATION REG A USB writable calibration register DEVICE REG BASE amp HC ID REG The model ID and FPGA register DEVICE REG BASE amp H1000 ADO IN REG The data register for analog input channel 0 DEVICE REG BASE amp H4000 ADI IN REG The data register for analog input channel 1 DEVICE REG BASE amp H4004 AD2 IN REG The data register for analog input channel 2 DEVICE REG BASE amp H4008 Ignore this register for DT984
176. ly Use DT RegisterCallback to register the callback function When you are finished with the callback function use DT UnregisterCallback to unregister the callback function Note DT RegisterCallback and DT UnregisterCallback are not supported in Visual Basic Windows messaging functions Typically GUI based programs use Windows messaging functions to monitor asynchronous events Use DT RegisterMsgHandler to register the window in which all future Windows messages that are associated with specific events are received When you are finished monitoring these events use DT UnregisterMsgHandler to unregister the message handling function Note DT RegisterMsgHandler and DT UnregisterMsgHandler are not supported in Visual Basic 31 Chapter 2 Converting Data The DT9840 Series Host Communication Library provides the following conversion functions for converting raw analog data to voltage values Note Avoid these functions during time critical operations due to the extra overhead that is required e DT ADValueToVolts Converts a single raw analog input value that is returned by DT ReadADC into a voltage value Refer to the DT9840 Series DSP Library User s Manual for more information on the DT ReadADC function DT ADScanToVolts Converts a scan of analog input values that is returned by DT ReadADCDIO DT ScanLoop or DT CaptureBuffer into an array of voltage values Refer to the DT9840 Series DSP L
177. mming Flowcharts provides flow diagrams that show how to use the functions together to write a host application program that communicates with a DSP program on a DT9840 Series module Chapter 4 Function Reference for Visual C Programmers describes each of the host communication functions in detail for Visual C programmers Chapter 5 Function Reference for Visual Basic Programmers describes each of the host communication functions in detail for Visual C programmers Appendix A Error Codes lists the errors that can be returned or detected by the DT9840 Series Host Communication Library Appendix B Data Types Constants Enumerated Types Structures and Callback Functions describes the data types constants enumerated types structures and callback functions that are used by the DT9840 Series Host Communication Library Appendix C Communication Events and Messages describes the messages that can be returned when communication events occur in the system An index completes this manual About this Manual Conventions Used in this Manual The following conventions are used in this manual Notes provide useful information or information that requires special emphasis cautions provide information to help you avoid losing data or damaging your equipment and warnings provide information to help you avoid catastrophic damage to yourself or your equipment Items that you select or type are shown in bold
178. mmunication link Param1 The handle of the communication channel that generated the DT_HOST_RCV_BUFFER_FULL error described on page 114 Param2 The number of bytes of available buffer space This event is fired on the host only after a write operation DT_ChanAsyncWrite described on page 60 or DT_ChanSyncWrite described on page 68 generates a DT_HOST_RCV_BUFFER_FULL error and data is taken out of the channel input buffer In response to this event the Windows message DTMSG_OUT_BUFFER_SPACE_AVAILABLE is sent to the host application The host application should retry the write operation 213 Appendix C 214 Syntax Description Parameters Name Description Name Description Notes Syntax Description Parameters Name Description Name Description Notes DTEVENT OUTPUT SCAN BLOCK UNDERRUN DTEVENT OUTPUT SCAN BLOCK UNDERRUN Paraml Param2 Indicates that an D A underrun error occurred in a block loop or list loop operation Param1 This parameter is not used NULL Param2 This parameter is not used NULL You can use this event with DT RegisterCallback in your DSP program to detect D A overrun errors in a block loop or list loop operation This event never occurs on the host system If this event occurs in your DSP program ensure that the host computer provides analog output data to the DT9840 Series module faster than the DACs are converting the da
179. n Public Enum TRIGGER TYPE MMEDIATE 0 EXT_TRIGGER 2 End Enum DTCommLib BAS IMMEDIATE If you specify this element the operation on the DT9840 Series module starts immediately when an input or output operation function is called EXT_TRIGGER If you specify this element a trigger event occurs when the DT9840 Series module detects a low to high transition on the TTL level signal connected to the Ext Trig BNC on the module This trigger asserts EXT_INT4 for processing 185 Appendix B Data Types The following data types are defined in the DTCommLib BAS file e LONG A 32 bit integer DOUBLE A double which is always 64 bits IEE format BOARD NAME MAX LEN The maximum number of characters for the module name is 256 ERR STRING MAX LEN The maximum number of characters for the error string is 256 BRD HANDLE A pointer of type VOID FIND HANDLE A pointer of type VOID e BOARD NAME BOARD NAME MAX LEN An array of type CHAR that contains 256 elements ERROR STRING ERR STRING MAX LEN An array of type CHAR that contains 256 elements MAX BOARD OPTION SIZE The maximum number of elements for the BOARD OPTIONS structure is 200 e CHAN NAME MAX LEN The maximum number of characters for the channel name is 200 CHAN HANDLE A pointer of type VOID e CHAN NAME CHAN NAME MAX LEN An array of type CHAR that contains 200 elements e ADC SETUP described
180. n Ane dires dior BR eee ge 93 DT BoardWriteTOMemory o 94 DT ChanAsyncWitite 5 da ep as e 95 DI ChanBytesAvallable ect ER THREE e e xe rie 96 DT ChanClose decns Rp vale aa aia E NIS eA 97 DI Ehnen o d Eo oe es e ko Le Eas a AM cap UM a ot e AO A 98 DI Chan PE 0 ee is rentre ee eed eee oen ite aes 99 DIGCh anReaddus t rectas ne che Proust e ble e rtt al edere n Bites este cues 101 DI ChanReadAvallable ois rc e re ERA REDEEM EX 103 Contents DI GetErrorString satan PERRA Te Ves a ab ew qoe aC Fave Ren 104 DEN TODAS sc eas sors alate ette e detenti ue MI Verte ARIS eee EA 105 I2T VoltsIoDAValiu e eR ERE eee iR REN 106 Appendix A Error Codes oooococoococo e n n nnn 107 Appendix B Data Types Constants Enumerated Types Structures and Callback Functions oooooooccor I I n nn 115 For Visual C Programmers 116 Data Types ET 116 Constants 323 20 See es eee ee ii dum Oe OE e SOME EAR UNA 116 General Purpose Constants 0 6 6 cee eens 117 Conversion Constants 2 cece cece cnet n 118 Register Constants qu tuens Rep e REY Une PAN e epe ee es 119 Error Constante eR eae es eet cete QURE Tete teet ales moet 121 Event Constants iere et began Pad EEUU Rep ub ur Palen Sa 122 Message Constants esse ridice aa a a nen 122 Counter Timer Constants sec islas woe edie oR UE Ar NATE RENARE EREE N 122 Flash Memory Constants sssss en 123 Enumerated Types sin e oe Ere E Re e bes
181. n DT ChanGetInfo Lib DTCommLib dll ByVal hBoard As Long ByVal ChanIndex As Integer ByVal ChanName As String ByRef ChanType As CHAN TYPE ByRef HostBufSize As Long ByRef DSPBufSize As Long As DTSTATUS DTCommLib BAS Returns information about the channel that is associated with the specified ChanIndex hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 ChanIndex A variable of type INTEGER that specifies the index of the communication channel The first open communication channel has a ChanIndex of 0 ChanName A fixed length STRING variable in which the ASCII name of the active communication channel is returned ChanType A variable of CHAN_TYPE described on page 171 in which the type of operation for the communication channel is returned HostBufSize A variable of type LONG in which the size of the channel input buffer on the host computer is returned DSPBufSize A variable of type LONG in which the size of the channel input buffer on the DT9840 Series module is returned Function Reference for Visual Basic Programmers Notes This function is rarely needed It is used only in very generalized cases where for example an application requires the names of all active channels at runtime More typical programs deal with specific channels with
182. n of the total pulse output period is the active portion of the counter timer clock output signal on the DT9840 Series module ACTIVE_LOW If you specify this element the low portion of the total pulse output period is the active portion of the counter timer clock output signal on the DT9840 Series module Data Types Constants Enumerated Types Structures and Callback Functions Notes In measure mode if POLARITY is ACTIVE HIGH when you call DT TriggerCTR the counter output is low while the measurement is in progress and high when the measurement is complete If POLARITY is ACTIVE LOW when you call DT TriggerCTR the counter output is high while the measurement is in progress and low when the measurement is complete TRIGGER TYPE Enumerated Type Definition Include File Elements Name Description Name Description Structures typedef enum MMEDIATE 0 EXT_TRIGGER 2 TRIGGER TYPE DTCommonAPI H IMMEDIATE If you specify this element the operation on the DT9840 Series module starts immediately when an input or output operation function is called EXT_TRIGGER If you specify this element a trigger event occurs when the DT9840 Series module detects a low to high transition on the TTL level signal connected to the Ext Trig BNC on the module This trigger asserts EXT_INT4 for processing The following structures are defined in the DTCommonAPLH file which is referenced in
183. n page 124 in which the type of operation for the communication channel is returned pHostBufSize A pointer to an integer variable in which the size of the channel input buffer on the host computer is returned pDSPBufSize A pointer to an integer variable in which the size of the channel input buffer on the DT9840 Series module is returned Function Reference for Visual C Programmers Notes Return Values Example DT ChanOpen Syntax Include File This function is rarely needed It is used only in very generalized cases where for example an application requires the names of all active channels at runtime More typical programs deal with specific channels with well known names In these cases the application can open the channel directly by name using DT ChanOpen described on page 63 See Appendix A starting on page 107 Get the information for all communication channels on the host and print it BRD HANDLE hBoard CHAN NAME ChanName CHAN TYPE ChanType ULONG HostBufSize ULONG DSPBufSize WORD Index CHAR ChanTypeStr Index 0 While DT ChanGetInfo hBoard Index ChanName amp ChanType amp HostBufSize amp DSPBufSize DT SUCCESS if ChanType READ CHAN ChanTypeStr READ else ChanTypeStr WRITE Printf Channel d name s Type s DSPBufSize d n Index ChanName Ch
184. nchronously writes a specified number of bytes from an open communication channel on the host computer to the DT9840 Series module and waits for a response from the module hChan A variable of type CHAN HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 63 pBuffer A pointer to a variable of type VOID that contains the data to write to the DT9840 Series module NumBytes An unsigned integer variable or constant that specifies the number of bytes to write to the DT9840 Series module Function Reference for Visual C Programmers Name Description Notes Return Values Example DT GetErrorString Syntax Include File Description TimeoutInMS An unsigned integer variable or constant that specifies the timeout value in milliseconds If TimeoutInMS 0 the timeout period is disabled Typically DT ChanSyncWrite executes immediately with no delay The TimeoutInMS parameter is useful in the unlikely event that the channel input buffer on the DT9840 Series module becomes full and the function blocks operations while waiting for room to be available in the channel input buffer This function blocks all operations until the DT9840 Series module receives all the data and responds by calling DT ChanAcknowledge described on page 59 When this function is called the data is written immediately If the channel
185. nd click on the Support link When requesting technical support be prepared to provide the following information Your product serial number e The hardware software product you need help on The version of the CD you are using Your contract number if applicable If you are located outside the USA contact your local distributor see our web site www datatranslation com for the name and telephone number of your nearest distributor 17 Chapter 1 18 2 Using the DT9840 Series Host Communication Library 4L A eaaa Ea E e E E EE EEEE DEE 20 pena and Closing a Module recrei terenie A E eika ve ERE Se ND ee Roe Hon ced 23 Downloading and Running a DSP Program 2 0 6 25 Opening and Closing a Communication Channel 0 00000 c eee eee eee 26 Reading Data from a Communication Channel 0066 eese re er ere ys 27 Writing Data to a Communication Channel escenes snepi ei iae e eee 29 Handling Channel Communication Events 6 66 easi a a a al Convertog DAL s eee tre Pee pete Eee ben D T Eee tnt ees adi pee tees oie 32 E l ERIM E 34 19 Chapter 2 20 Overview To communicate between the host computer and a DT9840 Series module you need to write a host application program that calls the communication functions in the DT9840 Series Host Communication Library In addition you need to write a Code Composer program for the DT9840 Series module that calls the corresponding communication
186. ng operations enables the operation when the external gate signal is high and disables the operation when the external gate signal is low For one shot and repetitive one shot operations enables the operation on the transition from the low level to the high level rising edge and disables the operation on the transition from the high level to the low level falling edge For up down counting mode increments the counter when the external gate signal is high and decrements the counter when the external gate signal is low For measure mode or continuous measure mode this value is automatically set to EXT NORMAL GATE if you specify the EDGE TYPE is SELCTED GATE RISES or SELECTED GATE FALLS EXT INVERTED GATE For standard counting operations enables the operation when the external gate signal is low and disables the operation when the external gate signal is high For one shot and repetitive one shot operations enables the operation on the transition from the high level to the low level falling edge and disables the operation on the transition from the low level to the high level rising edge For up down counting mode increments the counter when the external gate signal is low and decrements the counter when the external gate signal is high This gate type is not supported for measure mode or continuous measure mode Data Types Constants Enumerated Types Structures and Callback Functions Definition Includ
187. nge Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 Convert the raw AD values for all the analog input channels in the scan InScan into voltages in the 10 V range and put in InVoltsArray Dim Status As DTSTATUS Dim InScan As INPUT SCAN RCD Dim InVoltsArray NUM ADC REGS As Double Status DT ADScanToVolts InScan InVoltsArray 0 BIP10 VOLTS SPAN Function Reference for Visual Basic Programmers DT ADValueToVolts Syntax Public Interface Description Parameters Name Description Name Description Name Description Notes Return Values Example DT BoardClose Syntax Description Declare Function DT ADValueToVolts Lib DTCommLib dll ByVal ADValue As Long ByRef Volts As Double ByVal VoltageRange As ADC RANGE As DTSTATUS DTCommLib BAS Converts a single raw analog input value that is returned by DT ReadADC into a voltage value Refer to the DT9840 Series DSP Library User s Manual for more information on the DT ReadADC function ADValue A variable of type LONG that specifies the raw analog input value to convert into a voltage value Volts A variable of type DOUBLE in which the converted voltage value is returned VoltageRange A variable of type ADC RANGE described on page
188. nnel The EventCode is DTEVENT REMOTE CHAN OPENED pContext is context information passed in DT RegisterCallback Paraml is not used Param2 is a pointer to the CHAN OPEN INFO structure the return value is ignored Function Reference for Visual C Programmers Example cont DT RegisterMsgHandler Syntax Include File Description Parameters Name Description BOOL RemoteChanOpenProc IN PARAM ULONG EventCode IN PARAM VOID pContext IN PARAM LONG Paraml IN PARAM LONG Param2 CHAN OPEN INFO pChanInfo CHAN OPEN INFO Param2 switch pChanInfo RemoteChanType case WRITE_CHAN open a channel to read data DT_ChanOpen NULL pChanInfo gt ChanName READ CHAN pChanInfo gt RemoteBufSize amp g hChanRead TIMEOUT OPEN break case READ CHAN open a channel to write data DT_ChanOpen NULL pChanInfo gt ChanName WRITE_CHAN pChanInfo gt RemoteBufSize amp g_hChanwrite TIMEOUT_OPEN break when all the channels have been opened this callback can be unregistered j DTSTATUS DT RegisterMsgHandler BRD HANDLE hBoard HWND hWindow ULONG EventTraps DTCommLib H Registers the window in which future Windows messages that are associated with a DT9840 Series module are displayed hBoard A variable of type BRD HA
189. nput registers Refer to page 117 for more information on NUM_ADC_REGS FlagsandDin An unsigned integer value in which the state of the digital input ports and the eight hardware flags is returned Bits 0 to 7 represent port 0 bits 8 to 15 represent port 1 bits 9 to 23 represent port 2 and bits 24 to 31 represent the following hardware flags e Bit 24 1 Temperature is 65 C or over 0 Temperature is under 65 C e Bit 25 1 Counter timer 2 has overflowed 0 Counter timer 2 has not overflowed e Bit 26 1 Counter timer 1 has overflowed 0 Counter timer 1 has not overflowed e Bit 27 1 Counter timer 0 has overflowed 0 Counter timer 0 has not overflowed e Bit 28 1 A FIFO Full error occurred on the Scalable Bus 0 A FIFO Full error did not occur on the Scalable Bus e Bit 29 1 Ananalog output trigger occurred 0 An analog output trigger did not occur e Bit 30 1 An analog input trigger error occurred 0 An analog input trigger error did not occur e Bit 31 1 An analog input trigger occurred 0 An analog input trigger did not occur 157 Appendix B Name Description CounterValues INUM COUNTERS An unsigned integer array in which the acquired value of all the counter timer channels is returned The array is defined to be as large as the number of counter timer channels The DT9840 Series modules support three counter timer channels 0 to 2 MSG
190. nsion that you can download to the module using the DT BoardDownload function DT BoardDownload resets the DSP processor on the opened DT9840 Series module and downloads the compiled DSP program over the USB bus to the DSP on the module You can specify whether or not you want each segment that is downloaded to the DT9840 Series module to be read back from DSP memory and verified If you choose to verify the download operation the download rate is reduced significantly however verifying the download operation ensures that the program is not loaded into a non existent memory location After the program is downloaded call DT BoardRun to run the DSP program on the opened DT9840 Series module 25 Chapter 2 Opening and Closing a Communication Channel Before you can perform any channel communication operation from the host application such as reading from or writing to a communication channel you first need to open the communication channel by calling DT ChanOpen in your host application with a valid channel name DT ChanOpen opens a unidirectional stream based communication channel for either reading or writing creates an input buffer if the channel was opened for reading the size of which is user specified and returns a handle to the channel that is used by all subsequent communication functions to identify the channel Note In general the input buffer size should be at least as large as the largest single write of data from
191. nstead of DT ChanReadAvailable ensure that it is reading as many bytes as are being written by the DSP program on the module 27 Chapter 2 28 Note In applications where you want to minimize the communication code in your DSP program you can read data directly from a specified DSP address on an opened DT9840 Series module instead of reading the data from a communication channel using the DT BoardReadFromMemory function DT BoardReadFromMemory does not require that a DSP program is running on the module This function operates synchronously and take precedence over all other communication operations For example if you use DT BoardReadFromMemory to read 2 MBytes of data from the module all other messaging between the host computer and the DSP program is suspended until all 2 MBytes has been transferred If you want to read a specific register on the DT9840 Series module from the host program you can use the DT BoardReadRegister function CAUTION Although you can read from any DSP address using DT BoardReadFromMemory it is highly recommended that you read from a known DSP address Reading from an arbitrary DSP address can cause major system problems Using the DT9840 Series Host Communication Library Writing Data to a Communication Channel To write data to an opened communication channel the DT9840 Series Host Communication Library provides the following functions DT ChanAsyncWrite Asynchronously wr
192. nt voltage values in the 10 V range The converted values are stored in InVolts This example assumes that pInBlock points to an input block that has already been filled with raw AD values by the hardware NumScans must be less than MAX SCAN SIZE NumScans pInBlock nScansThisBlock Status DT ADChanBlockToVolts pInBlock AD CHAN TO CONVERT NumScans ADC BIPOLAR 10 VOLTS DTSTATUS DT ADScanToVolts INPUT SCAN RCD pInScan DOUBLE Volts ADC RANGE VoltageRange t DTCommonAPI H 47 Chapter 4 48 Description Parameters Name Description Name Description Name Description Notes Return Values Example DT ADValueToVolts Syntax Include File Converts a scan of analog input values that is returned by DT ReadADCDIO or DT CaptureBuffer into an array of voltage values Refer to the DT9840 Series DSP Library User s Manual for more information on the DT ReadADCDIO and DT CaptureBuffer functions pInScan A pointer to an array of type INPUT SCAN RCD described on page 156 that contains the raw analog input values to convert to voltage values Volts An array of type DOUBLE in which the converted voltage values are returned for each analog input channel in the scan Allocate the Volts array to hold NUM ADC RECS values Refer to page 117 for more inf
193. num DAC RANGE DAC BIPOLAR 10 VOLTS 0 DAC BIPOLAR 2 PT 5 VOLTS 1 End Enum DTCommLib BAS DAC BIPOLAR 10 VOLTS If you specify this element the analog output range is 10 V DAC BIPOLAR 2 PT 5 VOLTS If you specify this element the analog output range is 2 5 V 177 Appendix B 178 DTSTATUS Enumerated Type Definition Public Enum DTSTATUS DT SUCCESS DT COMMON BASE ERR 0 DT_NO_MEMORY DT BUFFER TOO SMALL DT INVALID CHAN NAME DT INVALID CHAN HANDLE DT INVALID PHCHAN DT NOT IMPLEMENTED DT INVALID CALLBACK PTR DT INVALID BUFFER PTR DT INVALID NUM BYTES DT INVALID BYTES READ PTR 10 DT TIMEOUT DT INVALID CHAN TYPE DT INVALID POINTER DT CALLBACK NOT FOUND DT CHAN DISCONNECTED DT INCOMPATIBLE CHAN TYPE DT CHAN ALREADY OPEN DT CHAN ALREADY CLOSED DT TOO BIG FOR CHAN BUFFER DT TOO BIG FOR BOARD BUFFER 20 DT VOLTAGE OUT OF RANGE DT AD VALUE OUT OF RANGE DT NO SYNC DATA RECEIVED
194. o the communication channel as described on page 29 When you are finished with the communication channel call DT ChanClose to close the communication channel and release any resources that were allocated to it 26 Using the DT9840 Series Host Communication Library Reading Data from a Communication Channel To read data from an opened communication channel the DT9840 Series Host Communication Library provides the following functions DT ChanRead Returns a specified number of bytes from a communication channel that was previously opened for reading If the requested number of bytes is not yet available from the DSP program on the DT9840 Series module this function blocks all operations until either the data is available or the function times out When the host application program calls DT ChanRead the DSP program must write the specified number of bytes of data to a communication channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible DT ChanReadAvailable Returns the data that is available from a communication channel that was previously opened for reading up to the size of the input channel buffer on the host The buffer size is the maximum number of bytes that the host can read at one time If no data is available from the DSP program on the DT9840 Series module other Operations can continue When the number
195. oardHandle BoardInfo Declare Function DT BoardGetName Lib DTCommLib dll ByVal BoardIndex As Long ByVal BoardName As String As DTSTATUS DTCommLib BAS Returns the name of a connected DT9840 Series module BoardIndex A variable of type LONG the specifies the index of the DT9840 Series module whose name you want to return The first DT9840 Series module installed in the system has a BoardIndex of 0 BoardName A fixed length STRING variable in which the ASCII name of the DT9840 Series module is returned This function is rarely needed It is used only in very generalized cases where for example a host based application requires the names of all connected DT9840 Series modules at runtime More typical programs deal with a single module with a well known name In these cases the host application can open the module directly by name with DT BoardOpen described on page 89 See Appendix A starting on page 107 Function Reference for Visual Basic Programmers Example DT BoardOpen Syntax Public Interface Description Parameters Name Description Name Description Get the name of the first DT9840 Series module installed in the system and store it in the string BoardName Dim Status As DTSTATUS Dim BoardIndex As Long Dim BoardName As String 256 BoardIndex 0
196. ock signal that you connected to the module divided by 256 this division is done internally by the module For example if you need a sampling frequency of 100 KHz use an external clock source with a frequency of 25 6 MHz AD DA CLK SRC SB MASTER If you specify this element the sample clock is derived from the master DT9840 Series module through the Scalable Bus This is the recommended setting for all slave DT9840 Series modules when you want to synchronize the acquisition of data on all modules CHAN TYPE Enumerated Type Definition Public Interface Members Name Description Name Description Public Enum CHAN TYPE READ CHAN 0 WRITE CHAN 1 End Enum DTCommLib BAS READ CHAN If 0 the channel on the host is opened for reading WRITE CHAN If 1 the channel on the host is opened for writing CLOCK SRC Enumerated Type Definition Public Interface Public Enum CLOCK SRC INTERNAL 18MHZ 0 EXTERNAL_CLOCK 1 CASCADED_CLOCK 2 End Enum DTCommLib BAS 171 Appendix B Members Name Description Name Description Name Description INTERNAL 18MHZ If you specify this element the internal C T clock uses a 18 MHz time base Counter timer operations start on the rising edge of the clock input signal This clock source is not generally used for event counting or up down counting mode and is automatically selected if measure mode or continuous measure mode is
197. on Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 15 DT CHAN DISCONNECTED Remote end of communication Reconnect the USB cable between channel has disconnected the host computer and the DT9840 Series module 16 DT INCOMPATIBLE CHAN Remote end of channel was If the host application opened the TYPE opened as incompatible type R communication channel for a write vs W operation open the communication channel on the module for a read operation If the host application opened the communication channel for a read operation open the communication channel on the module for a write operation 17 DT CHAN ALREADY OPEN The specified channel is already The specified communication channel open is already open Check the channel name You need only open a communication channel once in both the host application and DSP program 18 DT CHAN ALREADY CLOSED The specified channel is already The specified communication channel closed is already closed Check the channel name You need only close a communication channel once in both the host application and DSP program 19 DT TOO BIG FOR CHAN The requested size of write is Ensure that the channel input buffer BUFFER bigger than receiver s chan on the module is large enough to hold buffer the data that is being written by the host 20 DT TOO BIG FOR BOARD The requested size of a write is Ensure that the module
198. on during time critical operations due to the overhead required Appendix A starting on page 107 45 Chapter 4 46 Example DT ADChanBlockToVolts Syntax Include File Description Parameters Name Description Name Description INPUT SCAN BLOCK pInBlock DOUBLE InVolts MAX SCAN SIZE NUM ADC REGS ULONG NumScans Convert the raw AD values for all channels in a block into their equivalent voltage values in the 10 V range The converted values are stored in InVolts as an array This example assumes that pInBlock points to an input block that has already been filled with raw AD values by the hardware NumScans must be less than MAX SCAN SIZE NumScans pInBlock nScansThisBlock Status DT ADBlockToVolts pInBlock NumScans InVolts ADC BIPOLAR 10 VOLTS DTSTATUS DT ADChanBlockToVolts INPUT SCAN BLOCK pInBlock ULONG ADChan ULONG NumScans DOUBLE Volts ADC RANGE VoltageRange n DTCommonAPI H For a specified analog input channel in a block converts the raw analog values returned by DT_BlockLoop or DT_ListLoop into an array of voltage values Refer to the DT 9840 Series DSP Library User s Manual for more information on the DT_BlockLoop and DT_ListLoop functions pInBlock A pointe
199. on page 187 BOARD OPTIONS described on page 188 BRD INFO described on page 190 CLOCK_SETUP described page 192 CTR SETUD described on page 194 e DAC SETUP described on page 198 DATA FILE HDR described on page 186 DIO SETUD described on page 200 EPE CHAN INFO described on page 203 e JEPE_SETUP described on page 203 e INPUT SCAN RCD described on page 204 OUTPUT SCAN RCD described on page 205 e TRIGGER SETUD described on page 206 186 Data Types Constants Enumerated Types Structures and Callback Functions ADC_SETUP Data Type Definition Public Interface Members Name Description Name Description Type ADC_SETUP Termination As Long ErrorOption As ERROR_MODE_SELECT Unusedl As Long Unused2 As Long Unused3 As Long Unused4 As Long Unused5 As Long End Type DTCommLib BAS Termination An unsigned integer variable that enables or disables 1 kQ bias return termination resistors for the analog input channels on the DT9841 and DT9841E modules Since the DT9841 VIB DT9842 2 and D19842 8 modules have single ended inputs only this element is ignored for these modules This feature is particularly useful with floating signal sources on the DT9841 and DT9841E Refer to the DT9840 Series Getting Started Manual for more information on wiring analog inputs to use bias return termination resistance Setting a bit to 0 disables the termination resistor for the a
200. on page 19 For detailed syntax information in Visual C refer to Chapter 4 starting on page 43 For detailed syntax information in Visual Basic refer to Chapter 5 starting on page 83 Table 3 Conversion Functions Function Type Function Name Description Conversion to Voltage Functions DT ADValueToVolts Converts a single raw analog input value that is returned by DT ReadADC into a voltage value DT ADScanToVolts DT ADChanBlockToVoltsP Converts a scan of analog input values that is returned by DT ReadADCDIO DT CaptureBuffer or DT ScanLoop into an array of voltage values For a specified analog input channel in a block converts the raw analog values returned by DT BlockLoop or DT ListLoop into an array of voltage values DT ADBlockToVoltsP For all the analog input channels in a block converts the raw analog input values returned by DT BlockLoop or DT ListLoop into an array of voltage values 13 Chapter 1 14 Table 3 Conversion Functions cont Function Type Function Name Description Conversion to Raw Data Functions DT_Volts ToDAValue Converts a single voltage value into a raw analog output value that is used by DT_WriteDAC DT VoltsToDAScan Converts an array of voltage values into a scan of raw analog output values for use with DT WriteDACDIO DT ScanLoop or DT FunctionGen DT VoltsToDAChanBlock For a specifie
201. open communication channel on the host to a DT9840 Series module Channel Write Functions cont 12 DT ChanSyncWrite Synchronously writes a specified number of bytes from an open communication channel on the host to a DT9840 Series module and waits for a response from the module DT ChanAcknowledge Acknowledges that the host received a synchronous write command from a DT9840 Series module Overview Table 2 Channel Level Communication Functions cont Function Type Function Name Description Channel Read DT ChanRead Reads a specified number of bytes from a previously Functions opened communication channel DT ChanReadAvailable Returns the data that is currently available from an open communication channel on the DT9840 Series module up to the size of the channel input buffer Channel DT ChanGetlnfo Returns information about a specified channel in a Communication list of channels Support Functions DT ChanBytesAvailable Returns the number of bytes that are currently available in the specified channel buffer a This function is not supported in Visual Basic Conversion Functions Conversion functions allow you to convert raw analog data into voltage values and to convert voltage values into raw analog data Table 3 summarizes the conversion functions To better understand how to use these functions refer to Chapter 2 starting
202. or Visual C Programmers Return Values Example DT ChanAcknowledge Syntax Include File Description Parameters Name Description Notes Return Values Example See Appendix A starting on page 107 BRD HANDLE hBoard ULONG DSPAdd VOID HostVars Write all the values in HostVars on the host computer to DSPAdd on the module Status DT BoardWriteToMemory hBoard amp HostVars sizeof HostVars DSPAdd DTSTATUS DT ChanAcknowledge CHAN HANDLE hChan DTCommonAPI H Acknowledges that the host application received a synchronous write command from a DT9840 Series module hChan A variable of type CHAN_HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT_ChanOpen described on page 63 When the DT9840 Series module writes data synchronously to the host application the module writes a specified number of bytes to an opened communication channel and waits for a response from the host application When all the data has been received by the host the host application should respond by calling this function This function is useful if you want to synchronize the operation of the host application and the DSP program on the module See Appendix A starting on page 107 Acknowledge a synchronous write command from the module on the open communication channel hChan Status
203. or the DT9841 DT9841E and DT9841 VIB this value ranges from 1 to 24 for the DT9842 2 and DT9842 8 this value ranges from 1 to 16 ADC COUNTS PER STEPS The number of count changes for each step of the A D converter For the DT9841 DT9841E and DT9841 VIB this value ranges from 1 to 8 for the DT9842 2 and DT9842 8 this value ranges from 1 to 16 NUM DAC CHANS The number of analog output channels for the DT9841 DT9841E DT9841 VIB and DT9842 2 this value is 2 for the DT9842 8 this value is 8 NUM DAC STEPS The number of steps for the D A converter on the module For the DT9841 DT9841E and DT9841 VIB this value ranges from 1 to 24 for the DT9842 2 and DT9842 8 this value ranges from 1 to 16 DAC COUNTS PER STEPS The number of count changes for each step of the D A converter For the DT9841 DT9841E and DT9841 VIB this value ranges from 1 to 8 for the DT9842 2 and DT9842 8 this value ranges from 1 to 16 117 Appendix B 118 NUM INPUTS IN RCD The number of analog input registers NUM ADC REGS number of counter timer channels NUM COUNTERS and number of 24 bit digital input lines NUM DIN in the input scan record for the specified module type For example for the DT9841 NUM INPUTS IN RCD is 12 8 analog input registers 3 counter timer channels and 1 24 bit digital input port NUM OUTPUTS IN RCD The number of analog output channels NUM DAC CHANS and number of 24 bit digital output
204. ormation on NUM ADC RECS VoltageRange A variable of type ADC RANGE described on page 123 that specifies the analog input voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 INPUT SCAN RCD InScan DOUBLE InVolts NUM ADC REGS Convert the raw AD values for the analog input channels in the scan InScan into voltages in the 10 V range and put in InVolts Status DT ADScanToVolts amp InScan InVolts ADC BIPOLAR 10 VOLTS DTSTATUS DT ADValueToVolts LONG ADValue DOUBLE pVolts ADC RANGE VoltageRange DTCommonAPI H Function Reference for Visual C Programmers Description Parameters Name Description Name Description Name Description Notes Return Values Example DT BoardClose Syntax Description Include File Parameters Name Description Notes Return Values Converts a single raw analog input value that is returned by DT ReadADC into a voltage value Refer to the DT9840 Series DSP Library User s Manual for more information on the DT ReadADC function ADValue An integer variable or constant that specifies the raw analog input value to convert into a voltage value pVolts A pointer to a variable of type DOUBLE in which the converted voltage value is returned VoltageR
205. ounter timer increments when the specified external gate is enabled and decrements when the specified external gate is disabled The counter timer increments or decrements on the rising edge of the external clock input signal Use UP DOWN mode only when the position of the object being monitored stays within the range of the counter as the operation is not be reliable if the counter increments above FFFFFFFh or decrements below 0 Specify an external C T clock source this mode does not support a cascaded C T source Specify either a normal external gate or inverted external gate signal When the operation is enabled the counter increments to the value specified by PulseWidthCount described on page 148 and activates the pulse output The pulse output stays active until the counter rolls over to 0 the terminal count The pulse output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 147 The active polarity of the pulse output pulse is determined by OutputPolarity described on page 149 This sequence repeats as long as the counter is enabled by the gate You can read the value of the counter at any time using DT ReadCTR CONTINUOUS MEASURE If you specify this element the counter starts incrementing when it detects a specified start edge and stops incrementing when it detects the next start edge the stop edge is ignored in this mode When the ope
206. pArgStr DTCommLib H Runs a DSP program that was downloaded previously using DT BoardDownload described on page 50 hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 pArgStr Support for this argument is currently not implemented specify NULL for pArgStr A pointer to a variable of type CHAR that contains new arguments for the program This string is parsed and passed to the main procedure of the DSP program Specify NULL for pArgStr if you have no new arguments for the DSP program When a DSP program is downloaded using DT BoardDownload described on page 50 the program is loaded into DSP memory but is not started DT BoardRun starts program execution If a DSP program is already running when this function is called DT BoardRun resets the DSP passes new arguments to the program and re runs the program Function Reference for Visual C Programmers Return Values Example DT BoardWriteRegister Syntax Include File Description Parameters Name Description Name Description Name Description Notes Return Values Example See Appendix A starting on page 107 On module hBoard downloaded program run the previously changing none of the program arguments Status DT BoardRun hBoard NULL
207. pe DOUBLE that contains the voltage values to convert into raw analog output values Allocate Volts to hold NumScans NUM DAC CHANS values For the DT9841 DT9841E DT9841 VIB and DT9842 2 the value of NUM DAC CHANS is 2 For the DT9842 8 the value of NUM DAC CHANS is 8 NumScans An unsigned integer variable or constant that represents the number of scans for each block If you want to convert all of the analog output values in the block set NumScans to the value of ScansThisBlock in the OUTPUT SCAN BLOCK structure described on page 158 pOutBlock A pointer an array of type OUTPUT SCAN BLOCK described on page 158 in which the raw analog output values are returned VoltageRange A variable of type DAC RANGE described on page 131 that specifies the analog output voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 INPUT SCAN BLOCK pOutBlock DOUBLE OutVolts MAX SCAN SIZE NUM DAC CHANS ULONG NumScans 77 Chapter 4 Example cont DT VoltsToDAChanBlock Syntax Include File Description Parameters Name Description 78 Converts an array of output voltages in the 10 V range to equivalent raw DA values and stores them in an Output Block as the values for both DA channels This example assumes that pOutBlock points to an output block that needs to
208. ption Name Description Notes Return Values Example Returns a specified number of bytes from a previously opened communication channel hChan A variable of type CHAN HANDLE described on page 116 that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 63 pBuffer A pointer to a variable of type VOID in which the data from the DT9840 Series module is returned NumBytes An unsigned integer variable or constant that specifies the number of bytes to read from the DT9840 Series module TimeoutInMS An unsigned integer variable or constant that specifies the timeout value in milliseconds If TimeoutInMS 0 the timeout period is disabled If the requested number of bytes is not yet available from the DT9840 Series module this function blocks all operations until either the data is available or the function times out If you prefer a non blocking operation use DT_ChanRead Available described on page 67 When the host application calls DT_ChanRead the DSP application on the module must write NumBytes bytes of data to the communication channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible See Appendix A starting on page 107 CHAN HANDLE hChan VOID HostBuff Read 100 bytes from the module and put it in HostBuff If the
209. put of counter timer 1 Note that you cannot specify CASCADED_CLOCK for counter timer 0 since there is no lower counter timer with which to cascade 125 Appendix B Description cont The rising edge of the clock input signal is active This clock source is not supported for up down counting measure mode or continuous measure mode CLOCK TYPE Enumerated Type Definition Include File Elements Name Description Name Description Name Description typedef enum AD DA CLOCK AD CLOCK DA CLOCK CLOCK TYPE DTCommonAPI H AD_DA_CLOCK If you specify this element the clock that paces both analog input and analog output operations is selected AD_CLOCK If you specify this element the clock that paces analog input operations is selected DA_CLOCK If you specify this element the clock that paces analog output operations is selected COUNT_MODE Enumerated Type Definition Include File 126 typedef enum STD_COUNTING ONE_SHOT REPETITIVE ONE SHOT MEASURE UP DOWN CONTINUOUS MEASURE COUNT MODE DTCommonAPI H Data Types Constants Enumerated Types Structures and Callback Functions Elements Name Description Name Description STD COUNTING If you specify this element the counter timer performs an event counting or rate generation pulse output operation For event counting operations specify an e
210. r timer channels for all DT9840 Series modules this value is 3 NUM DIN The number of 24 bit digital input lines for all DT9840 Series modules this value is 1 For the DT9841 VIB only the first 16 bits are accessible the 8 remaining bits should be ignored NUM DOUT The number of 24 bit digital output lines for all DT9840 Series modules this value is 1 For the DT9841 VIB only the first 16 bits are accessible the 8 remaining bits should be ignored NUM DAC CHANS The number of analog output channels for the DT9841 DT9841E DT9841 VIB and DT9842 2 this value is 2 for the DT9842 8 this value is 8 Data Types Constants Enumerated Types Structures and Callback Functions NUM STEPS The number of steps for the A D converter on the module For the DT9841 DT9841E and DT9841 VIB this value is 22 for the DT9842 2 and DT9842 8 this value is 2 6 COUNTS PER STEPS The number of count changes for each step of the A D converter For the DT9841 DT9841E and DT9841 VIB this value is 28 for the DT9842 2 and DT9842 8 this value is 216 CLOCK SETUP LEN The size of the CLOCK SETUP data type in bytes 8 4 4 8 TRIGGER SETUP LEN The size of the TRIGGER SETUP data type in bytes 3 4 ADC SETUP LEN The size of the ADC SETUP data type in bytes 7 4 DAC SETUP LEN The size of the DAC SETUP data type in bytes 8 NUM_DAC_CHANS 4 DIO SETUP LEN The size of the DIO SETUP data type in byte
211. r analog input channel 5 DEVICE REG BASE 0x4014 Ignore this register for DI9841E modules e AD6 IN REG The data register for analog input channel 6 DEVICE REG BASE 0x4018 Ignore this register for DI9841E modules 119 Appendix B 120 AD7 IN REG The data register for analog input channel 7 DEVICE REG BASE 0x401C Ignore this register for DI9841E modules DIG IN REG The input register for digital input ports 0 1 and 2 and the flag bits DEVICE REG BASE 0x4020 Port 2 is not used for the DT9841 VIB module CTRO IN REG The input register for counter timer 0 DEVICE REG BASE 0x4024 CTR1 IN REG The input register for counter timer 1 DEVICE REG BASE 0x4028 CTR2 IN REG The input register for counter timer 2 DEVICE REG BASE 0x402C LED REC The register for the diagnostic LEDs DEVICE REG BASE 0x4030 The following constants are provided for controlling individual LEDs LED D0 LED CR 0x01 LED D1 LED CR10 0x02 LED D2 LED CR11 0x04 LED D3 LED CR8 0x08 LED D4 LED CR14 0x10 LED D5 LED CR7 0x20 LED D6 LED CR12 0x40 LED D7 LED CR13 0x80 LED ALL LEDs CR7 to CR14 0xFE LED HBEAT LED CR7 0x20 LED RED LED CR7 0x20 This LED turns red LED GREEN LED CR14 0x10 This LED turns green DACO REG The data register for analog output channel 0 DEVICE REG BASE 0x8000 DACI1 REG
212. r to an array of type INPUT_SCAN_BLOCK described on page 155 that contains a block of raw analog input values to convert to voltage values ADChan An unsigned integer variable or constant that specifies on which analog input channel within the block to perform the conversion For all DT9840 Series modules valid values range from 0 to 7 Function Reference for Visual C Programmers Name Description Name Description Name Description Notes Return Values Example DT ADScanToVolts Syntax Include File NumScans An unsigned integer variable or constant that specifies the number of scans in the block to convert If you want to convert all of the values corresponding to a specified analog input channel within the block set NumScans to the value of ScansThisBlock in the INPUT SCAN BLOCK structure described on page 155 Volts An array of type DOUBLE in which the converted voltage values are returned Allocate Volts to hold NumScans values VoltageRange A variable of type ADC RANGE described on page 123 that specifies the analog input voltage range Avoid this function during time critical operations due to the overhead required See Appendix A starting on page 107 INPUT SCAN BLOCK pInBlock DOUBLE InVolts MAX SCAN SIZE ULONG NumScans Convert all of the raw AD values in a block for a single AD channel into their equivale
213. ration completes the counter remains idle until it is next read On the next read the current value of the counter from the previous edge to edge measurement operation is returned and the next edge to edge measurement operation is started automatically 129 Appendix B 130 Description cont Connect the signal that you want to measure to either the clock input pin or the gate input pin of the counter timer that you want to use Then specify the measurement start edge Refer to page 134 for more information on the start edge Read the value of the counter using DT ReadCTR If you read the counter before the measurement is complete 0 is returned Note Incontinuous measure mode the internal C T clock is used to calculate the interval of the signal between the specified start and stop edges The pulse width and period count are automatically set to 0 You can use the following equations to determine the frequency and period of the signal based on the value of the counter e Frequency 18 MHz Number of Counts e Period 1 Frequency DAC_FILTER_TYPE Enumerated Type Definition Include File Elements Name Description Name Description typedef enum NONE 0 FIVE_KHZ TWENTY_KHZ DAC FILTER TYPE DTCommonAPI H NONE If you specify this element no filter will be applied to the analog output channels Use this setting for DT9842 2 and DT9842 8 modules FIVE KHZ If yo
214. read from the DT9840 Series module TimeoutInMS A variable of type LONG that specifies the timeout value in milliseconds If TimeoutInMS 0 the timeout period is disabled If the requested number of bytes is not yet available for the channel this function blocks all operations until either the data is available or the function times out If you prefer a non blocking operation use DT_ChanRead Available described on page 103 When the host application calls DT_ChanRead the DSP application must write NumBytes bytes of data to the communication channel within the specified timeout period or a DT TIMEOUT error is returned You can write the host application to detect the timeout error and recover if possible See Appendix A starting on page 107 Read 4 bytes from ChannelHandle and put it in Valuel If the module does not write the specified number of bytes in 1000 ms a timeout occurs Dim Status As DTSTATUS Dim ChannelHandle As Long Dim Valuel As Single Status DT ChanRead ChannelHandle Valuel 4 1000 Function Reference for Visual Basic Programmers DT ChanReadAvailable Syntax Public Interface Description Parameters Name Description Name Description Name Description Name Description Declare Function DT ChanReadAvailable Lib DTCommLib dll ByVal hChan As Long ByRef Buffer As Any ByVal BufSize As Long ByRef BytesRead As Long
215. rently available in the specified channel buffer hChan A variable of type LONG that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 99 BytesAvailable A variable of type LONG in which the number of bytes is returned See Appendix A starting on page 107 Read the number of bytes available in the channel specified by the handle hChan and store it in AvailableBytes Dim Status As DTSTATUS Dim hChan As Long Dim AvailableBytes As Long Status DT ChanBytesAvailable hChan AvailableBytes Declare Function DT ChanClose Lib DTCommLib dll ByVal hChan As Long As DTSTATUS DTCommLib BAS Closes a previously opened communication channel on the host and releases all allocated resources that were associated with it hChan A variable of type LONG that specifies the handle to the open communication channel This value is returned by DT ChanOpen described on page 99 None See Appendix A starting on page 107 Close channel ChannelHandle on the host Dim Status As DTSTATUS Status DT ChanClose ChannelHandle 97 Chapter 5 DT ChanGetlnfo Syntax Public Interface Description Parameters Name Description Name Description Name Description Name Description Name Description Name Description 98 Declare Functio
216. ribed on page 183 that represents the module type NotUsed A variable of type Long that is used internally by the system but is not meaningful to Visual Basic programmers MB RAM A variable of type Long that represents the size of the SDRAM on the module in megabytes Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description Name Description Name Description Name Description Name Description Name Description Name Description MB Flash A variable of type Long that represents the size of the flash on the module in megabytes ProgramIsRunning A Boolean variable that indicates whether a DSP program is currently running on the specified DT9840 Series module If TRUE a DSP program is currently running on the specified DT9840 Series module If FALSE a DSP program is not currently running on the specified DT9840 Series module Dummy1 A variable of type Integer that is used internally by the system for padding Do not use this variable FPGAVersion An unsigned integer variable in which the version of the FPGA code on the module is returned USBPortType An unsigned integer variable in which the version of the USB port that is used is returned SBEnabled A Boolean variable that indicates whether the Scalable Bus is enabled for the module If TRUE the Scalable Bus is enabled for the module If FALSE
217. ribed on page 185 TRIGGER TYPE described on page 185 ADC RANGE Enumerated Type Definition Include File Members Name Description Public Enum ADC RANGE ADC BIPOLAR 10 VOLTS 0 End Enum DTCommLib BAS ADC BIPOLAR 10 VOLTS If you specify this element the analog input range is 10 V AD DA CLK SRC Enumerated Type Definition Public Interface Members Name Description 170 Public Enum AD DA CLK SRC AD DA CLK SRC INTERNAL 0 AD DA CLK SRC EXTERNAL 1 AD DA CLK SRC SB MASTER 2 End Enum DTCommLib BAS AD DA CLK SRC INTERNAL If you specify this element the internal sample clock on the DT9840 Series module is used You specify the frequency of the internal clock source using the CLOCK SETUP structure described on page 192 Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Description AD DA CLK SRC EXTERNAL If you specify this element the signal that is connected to the Ext CIk BNC on the DT9840 Series module is used as the sample clock For the DT9841 DT9841E and DT9841 VIB modules use an external clock source with a 50 duty cycle Conversions start on a high to low transition of the external clock signal after a rising edge of the internal calibration signal The resulting frequency of the external clock input is always equal to the frequency of the external cl
218. ribed on page 99 Buffer A variable of type ANY that contains the data to write to the DT9840 Series module You can write into any data type structure or array NumBytes A variable of type LONG that specifies the number of bytes to write to the DT9840 Series module This function writes the data and returns immediately It does not wait for an acknowledgement from the module If the communication channel is busy or backed up with data the actual transfer to the module continues in the background this function does not block See Appendix A starting on page 107 Asynchronously write the contents of the 2 Byte variable Valuel to ChannelHandle which was previously opened as WRITE CHAN on the host Dim Status As DTSTATUS Dim ChannelHandle As Long Dim Valuel As Integer Dim NumBytes As Long Valuel 255 NumBytes 2 Status DT ChanAsyncWrite ChannelHandle Valuel NumBytes Declare Function DT ChanBytesAvailable Lib DTCommLib dll ByVal hChan As Long ByRef BytesAvailable As Long As DTSTATUS DTCommLib BAS Function Reference for Visual Basic Programmers Description Parameters Name Description Name Description Return Values Example DT ChanClose Syntax Public Interface Description Parameters Name Description Notes Return Values Example Returns the number of bytes that are cur
219. ription Notes Type OUTPUT SCAN RCD DACValues NUM DAC CHANS 1 As Long DoutValues As Long End Type DTCommLib BAS DACValues NUM DAC CHANS 1 An Long array to output to the analog output channels The array is defined to be as large as the number of analog output channels on the module DoutValues A variable of type Long that contains a 24 bit value to output to the digital output lines Bits 0 to 7 represent port 0 bits 8 to 15 represent port 1 and bits 9 to 23 represent port 2 You must specify this elements of this structure appropriately before calling DT ScanLoop DT BlockLoop DT ListLoop or DT FunctionGen described in the DT9840 Series DSP Library User s Manual 205 Appendix B TRIGGER SETUP Data Type Definition Public Interface Members Name Description Name Description Name Description 206 Type TRIGGER SETUP TrigType As TRIGGER TYPE Unusedl As Long Unused2 As Long End Type DTCommLib BAS TrigType A variable of type TRIGGER_TYPE described on page 185 that specifies the trigger mode Unused1 An unsigned integer variable that is currently used specify 0 for this member Unused2 An unsigned integer variable that is currently used specify 0 for this member Communication Events and Messages D EIEVENT AD OVERRUN erresire rette Pene led le e tete 208 DTEVENT ASYNC DATA RECEIVED seeee eh eh 208 TEV ENT CHA
220. ruct TRIGGER_TYPE TrigType ULONG Unused1 ULONG Unused2 TRIGGER SETUP DTCommonAPI H TrigType A variable of type TRIGGER TYPE described on page 139 that specifies the trigger mode on the DT9840 Series module Unused1 An unsigned integer variable that is currently unused specify 0 for this element Data Types Constants Enumerated Types Structures and Callback Functions Name Unused2 Description An unsigned integer variable that is currently unused specify 0 for this element 161 Appendix B Callback Functions The CALLBACKPRCC callback function is defined in the DTCommonAPI H file as follows CALLBACKPROC CallBack Function Definition BOOL CALLBACKPROC ULONG EventCode VOID pContext LONG Paraml LONG Param2 Include File DTCommonAPI H Parameters Name EventCode Description An unsigned integer variable returned by this function that represents the type of event that occurred The following constants are defined for each event type e DTEVENT REMOTE CHAN OPENED described on page 215 e DTEVENT REMOTE CHAN CLOSED described on page 214 DTEVENT ASYNC DATA RECEIVED described on page 208 e DTEVENT SYNC DATA RECEIVED described on page 215 DTEVENT CHAN IN BUFFER FULL described on page 209 DTEVENT OUT BUFFER SPACE AVAILABLE described on page 213 DTEVENT ERROR described on page 210 DTEVENT MODULE UNPLUGGED
221. rval of a signal between a selected measurement start edge and a selected measurement stop edge Connect the signal that you want to measure to either the clock input pin or the gate input pin of the counter timer that you want to use Then specify the measurement start edge and the measurement stop edge Refer to page 134 for more information on the start and stop edges When you trigger the operation with DT TriggerCTR the counter increments from the time it detects the selected start edge until it detects the stop edge When it detects the selected stop edge the counter stops counting You can determine whether the measure mode operation is complete or not using DT ReadCTRStatus When the operation is complete read the value of the counter using DT ReadCTR Use the following equations to determine the frequency period and pulse width of the signal e Frequency 18 MHz Number of Counts e Period 1 Frequency Pulse width Number of Counts 18 MHz Data Types Constants Enumerated Types Structures and Callback Functions Description cont Name Description Name Description Note In measure mode the internal C T clock is used to calculate the interval of the signal between the specified start and stop edges The pulse width and period count are automatically set to 0 You can specify the polarity of the output signal during and after the measurement UP DOWN If you specify this element the c
222. ry User s Manual is called BlockComplete A Boolean variable that indicates when the current block is empty If the value is TRUE the current block is empty If the value is FALSE the current block is not empty Once the block has been processed you must set this variable to FALSE 159 Appendix B Name Description Scans 1 An array of type OUTPUT SCAN RCD described on page 160 that contains the analog output and digital data to output for each scan Each scan is an element in the array The number of elements in the array is specified by nScansThisBlock OUTPUT SCAN RCD Structure Definition Include File Elements Name Description Name Description TRIGGER SETUP Structure Definition Include File Elements Name Description Name Description 160 typedef struct LONG DACValues NUM_DAC_CHANS ULONG DoutValues OUTPUT SCAN RCD DTCommonAPI H DACValues NUM DAC CHANS An integer array of analog values to output to the analog output channels The array is defined to be as large as the number of analog output channels on the module DoutValues An unsigned integer variable that contains a 24 bit value to output to the digital output lines Bits 0 to 7 represent port 0 bits 8 to 15 represent port 1 and bits 9 to 23 represent port 2 Note that for this value to be output you first need to call DT SetupDIO and set ClockDout to TRUE typedef st
223. s 5 4 12 2 CTR SETUP LEN The size of the CTR SETUP data type in bytes 13 4 INPUT SCAN RCD LEN The size of the INPUT SCAN RCD data type in bytes 12 4 OUTPUT SCAN RCD LEN The size of the OUTPUT SCAN RCD data type in bytes NUM_DAC_CHANS 1 4 NUM INPUTS IN RCD The number of analog input registers NUM_ADC_REGS number of counter timer channels NUM COUNTERS and number of 24 bit digital input lines NUM DIN in the input scan record for the specified module type For example for the DT9841 NUM INPUTS IN RCD is 12 8 analog input registers 3 counter timer channels and 1 24 bit digital input port NUM OUTPUTS IN RCD The number of analog output channels NUM DAC CHANS and number of 24 bit digital output lines NUM DOUT in the output scan record for the specified module type For example for the DT9841 NUM INPUTS IN RCD is 3 2 analog output channels and 1 24 bit digital output port Conversion Constants The following conversion constants are defined in the DTCommLib BAS file BIP10 VOLIS SPAN An input or output range of 10 V this is 208 LONG BIP2PT5 VOLIS SPAN An input or output range of 2 5 V this is 5 LONG NUM STEPS The number of discrete steps possible with the A D or D A converter For the DT9841 DT9841E and DT9841 VIB this number is 22 For the DT9842 2and DT9842 8 this number is 216 COUNTS PER STEP The number of count changes for one step of the A D converter
224. s channel buffer is full Either increase the size of the channel input buffer on the host by calling DT ChanOpen in the host program or increase the rate at which the module reads data from the communication channel 3007 DT HOST SEND BUFFER FULL Host s board s send buffer is full To avoid this error either increase the size of the module output buffer on the host by changing the HostToDSPBufSizelnKb parameter of the BOARD OPTIONS structure that is passed to DT BoardOpen or read data more quickly from the module If this problem still persists ensure that all of the channel buffers on the module are being read in a timely manner so that data does not back up Data Types Constants Enumerated Types Structures and Callback Functions Por Visual Ct Programmers scissor iets He eb e Ge ier C Ed p ee For Visual Basic Progcamtmer iie cee a sien ook tsk eae nied tears se e e hopes ie eder cea 115 Appendix B 116 For Visual C Programmers This section describes the data types constants enumerated types structures and callback functions that are used when calling the DT9840 Series host communication functions in Visual C Refer to Chapter 4 starting on page 43 for more information Data Types The following data types are defined in the DTCommLib H file LONG A 32 bit integer DOUBLE A double which is always 64 bits IEE format BOARD NAME MAX LEN The maximum numb
225. specified EXTERNAL CLOCK If you specify this element an external C T clock source paces the specified counter timer channel Counter timer operations start on the rising edge of the clock input signal This clock source is not generally used for rate generation one shot or repetitive one shot mode and is not supported for measure mode or continuous measure mode CASCADED CLOCK If you specify this element the clock input signal of the specified counter timer is connected in software to the clock output signal of the proceeding counter timer For example if you specify CASCADE CLOCK for counter timer 2 the clock input of counter timer 2 is internally connected to the clock output of counter timer 1 Note that you cannot specify CASCADED CLOCK for counter timer 0 since there is no lower counter timer with which to cascade The rising edge of the clock input signal is active This clock source is not supported for up down counting measure mode or continuous measure mode CLOCK TYPE Enumerated Type Definition Include File Elements Name Description 172 Public Enum CLOCK TYPE AD DA CLOCK 0 AD CLOCK 1 DA CLOCK 2 End Enum DTCommLib BAS AD DA CLOCK If you specify this element the clock that paces both analog input and analog output operations is selected Data Types Constants Enumerated Types Structures and Callback Functions Name Description Name Des
226. specified channel index Check the board index If the index exists open a communication channel for that module with DT ChanOpen 1015 DT NO MESSAGING Messaging system is not yet running This error should never occur in a a properly installed and running System It indicates that the messaging system was not started properly when the module was opened with DT BoardOpen Contact Technical Support see page 17 1016 DT WINDOW NOT FOUND An attempt was made to unregister a window that wasn t registered Check the name of the message handler to unregister You can unregister message handlers functions only if they have been registered 1017 DT FILE NOT FOUND The specified file does not exist Specify an appropriate filename for the Code Composer COFF file 1018 DT DRIVER VERSION The currently installed Windows driver is the wrong version This version of the library is not compatible with the DT9840 Series Device Driver that is installed on the host computer This error should never occur in a properly installed and running system Typically this error indicates that a software installation problem occurred with the module Contact Technical Support see page 17 111 Appendix A Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 1019 DT FIRMWA
227. specified events occur DT UnregisterCallback Unregisters a previously registered callback function a This function is not supported in Visual Basic Channel Level Functions Channel level functions perform various operations on a single communication channel which connects a program running on the host computer with a DSP program running on a DT9840 Series module Operations include opening and closing a channel getting information about a channel reading data from a channel and writing data to a channel Table 2 summarizes the channel level communication functions To better understand how to use these functions refer to Chapter 2 starting on page 19 For detailed syntax information in Visual C refer to Chapter 4 starting on page 43 For detailed syntax information in Visual Basic refer to Chapter 5 starting on page 83 Function Type Table 2 Channel Level Communication Functions Function Name Description Channel Open and Close Functions DT ChanOpen Opens a unidirectional stream based communication channel by name specifies the size of the channel input buffer if the channel was opened for reading and returns a handle to the channel DT ChanClose Closes a previously opened communication channel on the host and releases all allocated resources that were associated with it Channel Write Functions DT ChanAsyncWrite Asynchronously writes a specified number of bytes from an
228. ss argument does not reference a valid buffer Specify a valid DSP address Refer to the DT9840 Series User s Manual for DSP addresses 1025 DT ERROR MEMORY MISMATCH Mismatch in value written to and read back from memory A COFF file was downloaded to the DT9840 Series and the DSP memory was verified against the original memory image on the host At least one byte was incorrect This indicates that either the COFF file attempted to load data at addresses that do not refer to memory on the DT9840 Series or a hardware communication problem exists with the module Contact Technical Support see page 17 1026 DT USB ERROR An unknown type of USB error occurred indicates a system problem This error should never occur in a properly installed and running system Contact Technical Support see page 17 112 Error Codes Table 4 Errors that the DT9840 Series Host Communication Library Can Return or Detect cont Error Code Error Message ASCII Text Solution 1027 DT INVALID DSP ADDRESS An invalid pointer was passed Pass a valid pointer for pDSPAdaress PTR as the pDSPAdaress argument 1028 DT INVALID REGISTER An invalid address was passed Specify the address of the as the Register argument appropriate register Refer to the DT9840 Series User s Manual for more information on available registers 1029 DT BOARD ALREADY OPEN Board is already opened by Che
229. ssociated analog input channel The bit values are as follows e Bit 1 0x01 Corresponds to analog input channel 0 e Bit 4 0x04 e Bit 2 0x02 Corresponds to analog input channel 1 Corresponds to analog input channel 2 e Bit 8 0x08 Corresponds to analog input channel 3 e Bit 16 0x10 Corresponds to analog input channel 4 e Bit 32 0x20 Corresponds to analog input channel 5 e Bit 64 0x40 Corresponds to analog input channel 6 Bit 128 0x80 Corresponds to analog input channel 7 ErrorOption A variable of type ERROR MODE SELECT described on page 181 that specifies whether to continue or stop the operation when an A D overrun error condition is detected 187 Appendix B Description cont Name Description Name Description Name Description Name Description Name Description If you are performing an input operation and an output operation simultaneously using DT ScanLoop DT BlockLoop or DT ListLoop the following restrictions apply to ErrorOption e If ErrorOption in the DAC SETUP structure is set to CONTINUE ON ERROR set ErrorOption in the ADC SETUP structure to CONTINUE ON ERROR In this case if either an A D overrun or D A underrun error occurs the user defined callback functions for both operations are still invoked e If ErrorOption in the DAC SETUP structure is set to STOP ON ERROR set ErrorOption in the ADC SETUP stru
230. st using the DT ChanSyncWrite or DT ChanAsyncWrite function in the DSP program on the module If the amount of memory used by your host application is not a concern we recommend that you set the size of the module input buffer to a multiple of the largest message DT ChanSyncWrite or DT ChanAsyncWirite that the DT9840 Series module will send to the host HostToDSPBufSizeInKb An unsigned integer variable that specifies the size of the module output buffer in kilobytes on the host If you specify 0 for Host ToDSPBufSizeInKb the default size 64 kBytes is used Ata minimum the size of the module output buffer must be at least as large as the largest message that the host will send to the DT9840 Series module using the DT ChanSyncWrite or DT_ChanAsyncWrite function in the host application If the amount of memory used by your host application is not a concern we recommend that you set the size of the module output buffer to a multiple of the largest message DT_ChanSyncWrite or DT_ChanAsyncWrite that the host will send to the DT9840 Series module DbgFlag An unsigned integer that is passed from the DT9840 Series Host Communication Library to the DT9840 Series DSP Library and is used to control serial debugging on the module The DT9840 Series DSP Library uses the lowest 16 bits of this value The upper 16 bits is available to your host program to define as you wish For example you can use this flag on the host to control
231. t copied All of the functions in the DT9840 Series DSP Library return error codes that you can use with this function A pointer to an variable of type CHAR in which the ASCII string is returned See Appendix A starting on page 107 for more information on the error codes that can be returned or detected by the DT9840 Series Host Communication Library Utility for reporting DTSTATUS errors DTSTATUS CheckErr DTSTATUS Status CHAR pErrStr if Status pErrstr NULL LOG printf amp trace SYS exit 1 DT GetErrorString Status pErrStr else return Status DTSTATUS DT_RegisterCallback BRD_HANDLE hBoard CALLBACKPROC pCallback ULONG EventTraps VOID pContext DTCommonAPI H Registers a callback function that is called whenever an event occurs on the DT9840 Series module Function Reference for Visual C Programmers Parameters Name Description Name Description Name Description hBoard A variable of type BRD HANDLE described on page 116 that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 52 If you specify a valid value for hBoard the registered event handler is called for events that occur on the associated DT9840 Series module If you specify NULL for hBoard all events regardless of the module are sent to the registered event han
232. ta DTEVENT REMOTE CHAN CLOSED DTEVENT REMOTE CHAN CLOSED Paraml Param2 Indicates that the DT9840 Series DSP program has closed its side of the communication channel Param1 The handle of the communication channel that was closed by the DSP program on the DT9840 Series module Param2 This parameter is not used NULL In response to this event the Windows message DTMSG REMOTE CHAN CLOSED is sent to the host application The host application should close its side of the communication channel by calling DT ChanClose described on page 61 Communication Events and Messages Syntax Description Parameters Name Description Name Description Notes Syntax Description Parameters Name Description Name Description DTEVENT REMOTE CHAN OPENED DTEVENT REMOTE CHAN OPENED Paraml Param2 Indicates that the DSP program on the DT9840 Series module has opened its side of the communication channel Param1 The handle of the module whose communication channel was opened by the DT9840 Series module Param2 A pointer to a CHAN OPEN INFO structure described on page 145 that contains information about the communication channel on the DT9840 Series module In response to this event the Windows message DTMSG REMOTE CHAN OPENED is sent to the host application The host application should open its side of the communication channel by calling DT ChanOpen descri
233. ter constants are defined in the DTCommLIB BAS file COUNTER RESOLUTION A value of FFFFFFFFh 232 1 when using the internal clock source for counter timer operations COUNTER CLOCK FREQ A value of 18 MHz the time base for the internal clock for counter timer operations COUNTER CLOCK PERIOD A value of 55 ns 1 COUNTER CLOCK FREQ CTRO ONE SHOT IN PROGRESS A value of amp H1 CTR1 ONE SHOT IN PROGRESS A value of amp H2 CTR2 ONE SHOT IN PROGRESS A value of amp H4 CTRO0 MEASURE IN PROGRESS A value of amp H10 CTR1 MEASURE IN PROGRESS A value of amp H20 CTR2 MEASURE IN PROGRESS A value of amp H40 Flash Memory Constants The following flash memory constants are defined in the DTCommLib BAS file USER DATA MEM SIZE A value of amp H10000 DATA FILE MAGIC NUMBER A value of amp H9191956 Enumerated Types The following enumerated types are defined in the DTCommLib BAS file ADC RANGE described on page 170 AD DA CLK SRC described on page 170 CHAN TYPE described on page 171 CLOCK SRC described on page 171 CLOCK TYPE described on page 172 COUNT MODE described on page 173 169 Appendix B DAC FILTER TYPE described on page 176 DAC RANGE described on page 177 e DISTATUS described on page 178 EDGE TYPE described on page 181 ERROR MODE SELECT described on page 181 GATE TYPE described on page 182 MODEL ID described on page 183 e POLARITY desc
234. tes of SDRAM and 2 MBytes of flash RAM 137 Appendix B Name Description Name Description Name Description Name Description Name Description Notes DT9842 128 2 6713 This element indicates that you have a DT9842 module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9848 128 2 6713 This element indicates that you have a DT9848 module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9841E 128 2 6713 This element indicates that you have a DT9841E module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM DT9841 128 2 VIB This element indicates that you have a DT9841 VIB module that contains the 6713 chip with 128 MBytes of SDRAM and 2 MBytes of flash RAM UNKNOWN MODEL This element indicates that you have a newer module type than what is defined in the version of DTCommLib DLL on your computer Contact Data Translation for the most up to date files Non 6713 modules require customized TCF files If you are using one of these modules and do not have the TCF file you need contact Technical Support for help POLARITY Enumerated Type Definition Include File Elements Name Description Name Description 138 typedef enum ACTIVE_HIGH ACTIVE_LOW POLARITY DTCommonAPI H ACTIVE_HIGH If you specify this element the high portio
235. that determines the whether the communication channel on the host was opened for reading or for writing RemoteBufSize An unsigned integer variable that represents the size of the channel input buffer on the host typedef struct AD DA CLK SRC ClockSource DOUBLE SampleRate DOUBLE MaxSampleRate DOUBLE MinSampleRate DOUBLE ActualSampleRate CLOCK TYPE ClockType ULONG Unused 5 CLOCK SETUP DTCommonAPI H ClockSource A variable of type AD_DA_CLK_SRC described on page 124 that specifies the clock source for the input output operation SampleRate A variable of type DOUBLE that specifies the frequency in Hz for the internal sample clock For the DT9841 DT9841E and DT9841 VIB modules values range from 200 Hz to 100 000 Hz For the DT9842 2 and DT9842 8 modules values range from 0 Hz to 100 000 Hz 145 Appendix B 146 Description cont Name Description Name Description Name Description Name Description Name Description The actual frequency that the module can achieve may be slightly different than the frequency you specified due to the accuracy of the clock frequency 0 0176 The actual clock frequency is returned in ActualSampleRate For the DT9841 DT9841E and DT9841 VIB modules the value that you specify for the internal clock frequency is multiplied by 512 internally to set the oscillator on the module
236. tically sets this value to INTERNAL_18MHz PeriodCount A variable of type Long that defines the initial value that is loaded into the specified counter timer Values range from 1 to FFFFFFFFh The counter timer counts from PeriodCount to FFFFFFFFh rolls over to 0 the terminal count and then reloads PeriodCount In event counting operations this variable determines the value at which to start counting In pulse output operations this variable determines the frequency of the pulse output signal This variable is automatically set to 0 if measure mode or continuous measure mode is specified Use the following equations to determine the value for PeriodCount when performing pulse output operations refer to page 169 for more information on the constants used in these equations e PeriodCount COUNTER RESOLUTION 2 COUNTER_CLOCK_FREQ output frequency For example if the clock input frequency is 18 MHz and the desired pulse output frequency is 6 0 MHz the required PeriodCount is FFFFFFFEh clks per output period COUNTER RESOLUTION 2 PeriodCount For example if PeriodCount FFFFFFFEh three clocks occur for each output period In this example the counter counts FFFFFFFEh FFFFFFFFh 0 FFFFFFFEh FFFFFFFFh 0 and so on e output period clks per output period x COUNTER CLOCK PERIOD For example if three clocks occur for each output period and the clock period is 55 555 ns then the output period
237. ting to registers 30 221 Index 222
238. tion Name Description EXT INVERTED GATE For standard counting operations enables the operation when the external gate signal is low and disables the operation when the external gate signal is high For one shot and repetitive one shot operations enables the operation on the transition from the high level to the low level falling edge and disables the operation on the transition from the low level to the high level rising edge For up down counting mode increments the counter when the external gate signal is low and decrements the counter when the external gate signal is high This gate type is not supported for measure mode or continuous measure mode MODEL ID Enumerated Type typedef enum DT9841 128 0 O DT9841 64 2 1 DT9842 128 0 2 DT9842 64 2 3 DT9848 128 0 2 4 DT9848 64 2 5 DT9841 128 2 6713 6 DT9842 128 2 6713 7 DT9848 128 2 6713 8 DT9841E 128 2 6713 9 DT9841 128 2 VIB 10 UNKNOWN MODEL 1 MODEL ID DTCommLib BAS DT9841 128 0 This element indicates that you have a DT9841 R module with 128 MBytes of SDRAM and 0 MBytes of flash RAM DT9841 64 2 This element indicates that you have a DT9841 F module with 64 MBytes of SDRAM and 2 MBytes of flash RAM DT9842 128 0 This element indicates that you have a DT9842 2 R module with 128 MBytes of SDRAM and 0 MBytes of flas
239. tion program to communicate with a DSP program on a DT9840 Series module The communication model is stream based The DT9840 Series Host Communication Library provides three types of API functions e Board level functions described on this page Channel level functions described on page 12 Conversion functions described on page 13 10 Overview Board Level Functions Board level communication functions allow you to open and a close a DT9840 Series module get information about a module get information about error status codes that are returned download and run programs on a module read data from and write to DSP memory on a module and handle communication events Table 1 summarizes the board level communication functions To better understand how to use these functions refer to Chapter 2 starting on page 19 For detailed syntax information in Visual C refer to Chapter 4 starting on page 43 For detailed syntax information in Visual Basic refer to Chapter 5 starting on page 83 Table 1 Board Level Functions Function Type Function Name Description Open and Close DT BoardOpen Opens a DT9840 Series module by name specifies the Functions size of the internal messaging buffers for the module and returns a handle to the module DT BoardClose Closes a previously opened module and releases all allocated resources that were associated with it Download and Run DT BoardDownload Downloads a compiled DSP
240. u can read the value of the counter at any time using DT_ReadCTR ONE_SHOT If you specify this element the counter timer outputs a single pulse when the external gate is active 173 Appendix B 174 Description cont Name Description Name Description Specify an internal C T clock source and either a normal external gate or inverted external gate type to enable the operation When the operation is enabled the counter begins incrementing When the counter increments to the value of PulseWidthCount described on page 196 the value of the counter is output The output stays active until the counter rolls over to 0 the terminal count When the counter reaches the terminal count the module clears the one shot trigger enable bit The output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 195 The pulse output then stays inactive and the counter stays disabled until the one shot trigger enable bit is set The active polarity of the pulse output pulse is determined by OutputPolarity described on page 196 REPETITIVE ONE SHOT If you specify this element the counter timer outputs a single pulse when the specified external gate signal is active Specify an internal C T clock source and either a normal external gate or an inverted external gate When the operation is enabled with an external gate the counter begins incr
241. u specify this element a 5 KHz Bessel reconstruction filter is applied to each analog output channel on the DT9841 DT9841E and DT9841 VIB This setting is recommended for slow clock rates This element is ignored for the DT9842 and DT9842 8 modules Data Types Constants Enumerated Types Structures and Callback Functions Name Description TWENTY KHZ If you specify this element a 20 KHz Bessel reconstruction filter is applied to each analog output channel on the DT9841 DT9841E and DT9841 VIB This setting is recommended for fast clock rates This element is ignored for the DT9842 and DT9842 8 modules DAC RANGE Enumerated Type Definition Include File Elements Name Description Name Description typedef enum DAC BIPOLAR 10 VOLTS 0 DAC BIPOLAR 2 PT 5 VOLTS DAC RANGE DTCommonAPI H DAC_BIPOLAR_10_VOLTS If you specify this element the analog output range is 10 V DAC_BIPOLAR_2_PT_5_VOLTS If you specify this element the analog output range is 2 5 V DTSTATUS Enumerated Type Definition typedef enum DT_SUCCESS DT_COMMON_BASE_ERR DT NO MEMORY DT BUFFER TOO SMALL DT INVALID CHAN NAME DT INVALID CHAN HANDLE DT INVALID PHCHAN DT NOT IMPLEMENTED DT INVALID CALLBACK PTR D D D D D D D DT INVALID BUFFER PTR DT INVALID NUM BYTES DT INVALID BYTES READ PTR
242. ue Status DT BoardReadFromMemory BoardHandle DSPAdd 4 HostValue Declare Function DT BoardReadRegister Lib DTCommLib dll ByVal hBoard As Long ByVal Register As Long ByRef Value As Long As DTSTATUS DTCommLib BAS 91 Chapter 5 92 DT BoardRun Description Parameters Name Description Name Description Name Description Notes Return Values Example Syntax Public Interface Description Parameters Name Description Reads the value of a specific register on a DT9840 Series module hBoard A variable of type LONG that specifies the handle to the opened DT9840 Series module This value is returned by DT BoardOpen described on page 89 Register A variable of type LONG that specifies the register on the DT9840 Series module to read Value A variable of type LONG in which the value of the specified register on the DT9840 Series module is returned The DICommAPI BAS file defines constants that you can use for Register Refer to page 164 for more information on these constants See Appendix A starting on page 107 Read the raw value of the register for analog input channel 0 and store it in Value Dim Status As DTSTATUS Dim BoardHandle As Long Dim Value As Long Status DT BoardReadRegister BoardHandle ADO IN REG Value Declare Function DT Boar
243. uous measure mode is specified Use the following equations to determine the value for PeriodCount when performing pulse output operations refer to page 122 for more information on the constants used in these equations e PeriodCount COUNTER RESOLUTION 2 COUNTER CLOCK FREO output frequency For example if the clock input frequency is 18 MHz and the desired pulse output frequency is 6 0 MHz the required PeriodCount is FFFFFFFEh 147 Appendix B 148 Description cont Name Description e clks per output period COUNTER RESOLUTION 2 PeriodCount For example if PeriodCount FFFFFFFEh three clocks occur for each output period In this example the counter counts FFFFFFFEh FFFFFFFFh 0 FFFFFFFEh FFFFFFFFh 0 and so on e output period clks per output period x COUNTER CLOCK PERIOD For example if three clocks occur for each output period and the clock period is 55 555 ns then the output period is 166 666 ns output frequency 1 output period For example if the output period is 166 666 ns then the output frequency is 6 0 MHz The maximum output frequency is 9 MHz The minimum output frequency is 0 0042 Hz PulseWidthCount An unsigned integer variable that determines when the output pulse of the counter timer is activated this variable determines the duty cycle of the pulse output signal Values range from 1 to FFFFFFFFh In addition to rate generation one shot an
244. valid valid handle that was returned by DT ChanOpen 5 DT INVALID PHCHAN The phChan argument is not Pass a valid pointer valid 6 DT NOT IMPLEMENTED This function is not yet Do not call this function at this time implemented 7 DT INVALID CALLBACK PTR The pCallback argument is not Pass a valid pointer for pCallback valid pointer 8 DT INVALID BUFFER PTR The pBuffer argument is not Pass a valid pointer for pBuffer valid 9 DT INVALID NUM BYTES The NumBytes argument is not Specify a value for NumBytes that is valid greatOer than O If you are using DT BoardWriteTo Memory also ensure that NumBytes is divisible by 4 10 DT INVALID BYTES READ The pBytesHead argumentis an Pass a valid pointer for pBytesRead PTR invalid pointer 11 DT TIMEOUT The operation timed out Ensure that the DSP application responds to the host within the specified timeout period 12 DT INVALID CHAN TYPE The ChanType argument is not Specify READ CHAN to read data valid from the channel or WRITE CHAN to write data to the channel 13 DT INVALID POINTER An invalid pointer was passed Pass a valid pointer to an appropriate as an argument variable 14 DT CALLBACK NOT FOUND An attempt was made to Check the name of the callback unregister a callback that wasn t registered function to unregister You can unregister callback functions only if they have been registered Error Codes Table 4 Errors that the DT9840 Series Host Communicati
245. well known names In these cases the application can open the channel directly by name using DT ChanOpen described on page 99 Return Values Example See Appendix A starting on page 107 Get the information for the first communication channel on the host and print va Dim to the immediate debug window Status As DTSTATUS Dim Dim Dim Dim Dim Status ChanName BoardHandle As Long ChanName As String 200 ChanType As CHAN TYPE HostB DSP ufSize As Long BufSize As Long DT ChanGet nfo ChanType DT ChanOpen Syntax DSPI Debug Debug Debug Debug If ChanType BufSize 0 Channel Name Host DSP Buffer Size READ C Print Index Print Print Buffer Size Print Channel Type READ CHAN Else Debug Print End Declare Function BoardHandle HostBufSize 0 ChanName HostBufSize DSP BufSize HAN Then Debug Print Channel Type WRIT E CHAN If DT ChanOpen Lib DTCommLib dll ByVal hBoard As Long ByVal ChanName As String ByVal ChanType As CHAN TYPE ByVal BufSize As Long ByRef hChan As Long ByVal TimeoutInMS As Long As DTSTATUS Public Interface DTCommLib BAS 99 Chapter 5 100 Description Parameters Name Description Name Description Name
246. whether to print messages to the serial port on the module using the DT Printf function of the DT9840 Series DSP Library You can read the value of this flag in the DSP program on the module using the DT GetDebugFlag function in the DT9840 Series DSP Library Ensure that the combined size of DSPToHostBufSizelnKb and HostToDSPBufSizelnKb does not exceed 48 MBytes In addition ensure that you have enough host memory and free RAM on the DT9840 Series module to accommodate the sizes specified in DSPToHostBufSizelnKb and HostToDSPBufSizeInKb Data Types Constants Enumerated Types Structures and Callback Functions Notes cont BRD INFO Structure Definition Include File Elements Name Description Name Description Name Description Name Description Name Description If you specify NULL for the pBoardOptions parameter of the DT BoardOpen function the module input and output buffers are set to their default sizes 64 kBytes typedef struct MODEL ID Model CHAR pModelNameStr ULONG MB RAM ULONG MB Flash BOOL ProgramIsRunning ULONG FPGAVersion ULONG USBPortType BOOL SBEnabled LONG SBAddress BOOL SBTerminated ULONG Reserved 15 BRD INFO DTCommLib H Model A variable of type MODEL ID described on page 137 that represents the module type pModelNameStr A pointer to a variable of type CHAR in which the name of the module is returne
247. xternal C T clock source For rate generation operations specify an internal C T clock source Specify either a software gate normal external gate or inverted external gate signal to enable the operation When the operation is enabled the counter increments to the value specified by PulseWidthCount described on page 148 and activates the pulse output The pulse output stays active until the counter rolls over to 0 the terminal count The pulse output is then deactivated and the counter is automatically reloaded with the initial count specified by PeriodCount described on page 147 The active polarity of the pulse output pulse is determined by OutputPolarity described on page 149 This sequence repeats as long as the counter is enabled by the gate You can read the value of the counter at any time using DT ReadCTR ONE SHOT If you specify this element the counter timer outputs a single pulse when the external gate is active Specify an internal C T clock source and either a normal external gate or an inverted external gate signal to enable the operation When the operation is enabled the counter begins incrementing When the counter increments to the value of PulseWidthCount described on page 148 the value of the counter is output The output stays active until the counter rolls over to 0 the terminal count When the counter reaches the terminal count the module clears the one shot trigger enable bit The output

Download Pdf Manuals

image

Related Search

Related Contents

ETERNUS SX300, SX300S ディスクアレイ ホストポート拡張 取扱説明書  株式会社アクロディアとの資本・業務提携に関するお知らせ  Lavorare in sicurezza con la decespugliatrice e il  Manual Central Dosagem  Super Détergent    Appendix A - AutomationDirect  Aetertek AT-211SW User`s manual  High Resolution 37X Zoom Color Camera SCZ  Samsung GT-I5500 Керівництво користувача(Froyo)  

Copyright © All rights reserved.
Failed to retrieve file