Home
DB4getmud(int din)
Contents
1. AD2npts 1 500000 This call will set up AD2 1 to perform 500 000 conversions AD 2clkin din scode Op Code Prototype Description Arguments AD2 CLKIN 0x16 void AD2dkin int din int scode Selects the source of the sampling dock for the specified AD2 Thisis useful for synchronizing A D2 conversions with other devices din Deviceindex number scode Clock source 1 4 INTERNAL 1 Internal sample clock 1610 XBDRV Software Reference Example EXTERNAL 2 Front panel BNC XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line AD2clkin 1 EXTERNAL This call will set up AD2 1 to use its front panel BNC for the sampling clock AD 2clkout din dcode Op Code Prototype Description Arguments Example AD2_CLKOUT 0x17 void AD2clkout int din int dcode Asserts the AD2 s internal sampling clock onto an XBUS internal patch line This is useful for synchronizing other devices with AD2 conversions din Deviceindex number dcode Patch line code 3 5 XCLK1 3 XBUS patch line XCLK2 4 XBUSpatch line NONE 5 Nodo patch AD2clkin 1 INTERNAL AD2clkout 1 XCLK1 This call will set up AD2 1 to use its internal sampling clock and assert it to the XCLK1 line on the XBUS where it can be used to synchronize other devices on the bus AD 2status din Op Code Prototype Description Arguments Example AD2 STATUS 0x1B int AD2status int din Returns the status of
2. WG2ton 1 WG2ton 2 XBlgtrig Global trigger This will cause WG2 1 and WG2 2 to turn ON at precisely the same time WG 2clear din Op Code Prototype Description Arguments Example WG2 CLEAR 0x13 void WG2cdlear int din Clears the specified WG2 and resets it to the factory default setup din Deviceindex number WG2clear 1 This clears WG2 1 and resets it WG2 Waveform Generator 1203 WG 2amp din amp Op Code Prototype Description Note Arguments Example WG2 AMP 0x14 void WG2amp int din float amp Sets the output waveform amplitude With WG2 hardware versions lower than 4 0 when the WG2 is generating Gaussian noise at its max level the amplitude display will read 9 99 on the display Decreasing the amplitude to 5 0 will not reduce the level of the noise by 6 0dB This is corrected with WG2 hardware versions 4 0 and higher din Deviceindex number amp Amplitude in volts 0 00 9 99 WG2amp 1 5 00 This sets WG2_ 1 output amplitude to 5 00 Vp WG 2freq din freq Op Code Prototype Description Arguments Example WG2 FREQ 0x15 void WG2freq int din float freq Sets the sine wave frequency din Deviceindex number freq Frequency in Hz 1 20 000 WG2shape 1 SINE WG2freq 1 5000 WG2on 1 This programs WG2 1 to produce a sine wave output with a frequency of 5kHz WG 2swrt din swrt Op Code Prototype Descri
3. DB4setfilt 1 CH1 F NT 60 2304 XBDRV Software Reference D B4selfilt int din int chan int ftype int fs Op Code DB4 FILTER 0x13 Prototype float DB4selfilt int din int chan int ftype int fs Description Sets filter frequency on the specified channel of specified DB4 to the selected filter index see table below for programmable filter settings and frequencies Returns actual filter frequency Similar to DB4setfilt but uses an index to specify the frequency Arguments din Device index number chan CH1 CH2 CH3 CH4 or CHALL ftype Filter type F HP high pass F LP low pass F NT notch fs corner frequency setting Example This code sets the following filter frequencies for channel 1 High pass 10 Hz Low pass 12 000 Hz Notch 60 Hz DB4selfilt 1 CH1 F HP 8 DB4selfilt 1 CH1 F LP 33 DB4selfilt 1 CH1 F NT 2 High Pass 8 Low Filter Freguency Notch Filter Notch Filter Freguency Pass Filter Index Hz Index Hz 0 0 0 0 1 5 5 9 1 50 6 14 10 90 2 60 15 23 100 900 3 100 24 32 1000 10000 4 120 33 37 low pass only 11000 15000 5 150 o 180 DB4 Digital Biological Amplifier 2305 D B4userfilt int din int chan int fn float coef Op Code DB4 USERCOEF 0x14 Prototype void DB4userfilt int din int chan int fn float coef Description Downloads 2 order Bi quad IIR filter coefficients to specified filter bank in PD1 Arguments din Device index number chan CH1 CH2 CH3 CH
4. k Jwhile i lt 0 amp amp k lt xbtimeout if i SLAVE ACK processerr i j Jwhile i SLAVE ACK amp amp j lt XB MAX TRYS amp amp xb_eflag void standform unsigned char bufp qint n gint i j x cs long k if xb_eflag if n gt 63 14 XBDRV Software Reference showerr Too many datum being moved with Standard Form else j cs 0 iosend xln amp 0x7f iosend 0x40 n for x 0 x lt n 1 x iosend bufp x cs qint bufp x iosend cs 0 i iorec k Jwhile i lt 0 amp amp k lt xbtimeout if i SLAVE ACK processerr i j Jwhile i SLAVE ACK amp amp j lt XB MAX TRYS amp amp xb eflag XBDRV Nuts amp Bolts 15 Error Handling XBDRV uses two procedures for handling communication errors The processerr procedure is called when the SLAVE ACK response is not received after a command is sent Processerr attempts to decode the error If a data integrity error flag ARB_ERR is detected the procedure returns after checking the number of errors ne counter If this count exceeds NUM_TRYS a transmission error message will be displayed and the program will abort If a SLAVE ERR flag is detected the processerr procedure will receive the error message from the slave device and display it on the video monitor using the showerr procedure void processerr qint li gint ne long x qint i j char
5. Op Code Prototype Description Arguments Example WG1 DUR 0x1A void WG1Idurf int din float dur Sets enables the WG1 s saf timing feature When the self timer is enabled the signal will gate on when a valid trigger is detected and gate off after the specified duration Specify a duration of zero for continuous output din Deviceindex number dur Duration of gatein ms 1 30 000 WGltrig 1 POS_EDGE WGlrf 1 0 0 WGlshape 1 SINE WGlfreq 1 1000 WGlphase 1 90 0 WGldur 1 2 WGlon 1 This program will produce the output shown below Tigger Input WG Irf din rf Op Code Prototype Description WG1 RF 0x1B void WGlrf intdin float rf Sets the rise and fall time of the built in gating feature WG1 Waveform Generator 807 NOTE The WG1 has limited gating abilities Only the following gate rise fall times will give guaranteed results 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 20 30 40 50 60 70 80 90 Arguments din Deviceindex number rf Rise and fall time of gate in ms 0 1 90 0 Example WG1rf 1 3 0 This sets a 3 0 ms rise and fall time to WG1 1 WG ltrig din tcode Op Code WG1 TRIG 0x1C Prototype void WGltrig int din int tcode Description Programs the ENABLE TRIGGER input of the WG1 The valid trigger types are listed below NOTE The duration feature works only with EDGE ty
6. val Bit pattern to set 0 63 Ox3f dec hex TG6baserate 1 _1ms TG6new 1 3 200 0x05 TG6value 1 3 50 150 0x0a This defines a new timing sequence 3 and sets outputs 1 and 3 set default high by TG 6new and outputs 2 and 4 set default low by TG6new to produce the timing sequence shown below TG6 Outputs 2 and 4 0 50 150 199 TG6 Outputs 1 and 3 1110 XBDRV Software Reference TG 6dup din snum s beg s end Op Code Prototype Description Arguments Example 1 500kHz clock Example 2 Arbitrary seqs d beg ndup dmask TG6 DUP 0x1B void TG dup intdin intsnum ints beg ints end int d_beg int ndup int dmask Duplicates a section of a timing sequence throughout the rest of the sequence memory on specified outputs This feature simplifies creation of long repetitive master timing sequences on certain TG6 outputs Arbitrary sequences can then be specified on other outputs using TG6high and TG6low din Deviceindex number snum Sequence number 0 7 s beg Begin of section to dup 0 seq Igth 1 s end End of section to dup s_beg 1 seq Igth 1 d_beg Position to begin dup s_end 1 seq Igth 1 ndup No of duplications 0 32000 dmask Bit positions to dup 0 63 Ox3f dec hex The following example illustrates the creation of a 500kH z clock on channel 1 of the TG6 TG6baserate 1 _lus TG6new 1 2 100 0x00
7. 100 count seq TG6high 1 2 0 1 0x01 one clock pulse TG6dup 1 2 0 2 2 50 0x01 make 50 copies TG6reps 1 CONTIN REPS 0 play continuously TG6baserate 1 _1ms TG6new 1 3 200 0x00 TG6high 1 3 5 10 0x01 TG6high 1 3 15 25 0x01 TG6dup 1 3 0 40 40 4 0x01 TG6high 1 3 30 125 0x02 TG6high 1 3 80 150 0x04 This creates a master timing sequence on output 1 and two other seguences on outputs 2 and 3 as shown below TG6 Timing Generator 1111 TG6 Output 1 0 40 80 120 160 199 TG6 Output 2 0 30 125 199 TG6 Output 3 0 80 150 199 TG 6status din Op Code Prototype Description Arguments Example TG6 STATUS 0x1D int TG 6status int din Returns the output status of the specified TG6 din Deviceindex number Return Values IDLE 0 TG6 stopped ARM 1 TG6 armed ready for trigger ACTIVE 2 Timing sequence in progress LAST 3 Last rep of timing sequence in progress TG6arm 1 0 TG6go 1 do if kbhit TG6stop 1 while TG6status 1 IDLE The do loop waits until TG6 1 stops returns IDLE If a key is pressed during the loop the TG6 1 will stop upon completion of the present sequence repetition 1112 XBDRV Software Reference this page intentionally left blank WG2 Waveform Generator 1201 WG2 Waveform Generator Note The WG2 must be installed in a caddie that is communicating with the host comput
8. Op Code Prototype Description Arguments Example RTE INTERPDEL 0x0111 void PD1interpDEL int din int ifact Calling PD linterpD EL enables the delay interpolator and sets the interpolation factor Refer to PD 1 User s Guide for more information on the DP2 s delay interpolator din Device index number ifact Interpolation factor 1 32767 ifact 32767 number of samples PDlinterpDEL 1 int 32767 0 100 0 The above call will enable the DP2 dday interpolator and set the delay interpolation speed to approximately 100 samples PD1 Delay Processor Calls 2125 PD 1setD EL din tapn dly Op Code Prototype Description Arguments Example RTE SETDEL 0x0104 void PD1setDEL int din int tapn int dly This procedure is used to specify the amount of delay to be used for the indicated delay tap output din Device index number tapn Delay tap specifier Use TAP 0 31 0 3 dly Number of samples to delay 0 32767 Assume a sample rate of 50KHz or 50 samples per millisecond PD1lclrDEL 1 0 0 4 0 PDlsetDEL 1 TAP 0 2 50 0 PD1lsetDEL 1 TAP 1 2 50 12 PD1lsetDEL 1 TAP 2 2 50 24 PD1lsetDEL 1 TAP 3 2 50 36 PD1llatchDEL 1 The code listed above will clear the DP2 and set the first four delay taps of channel 2 to 0 12 24 and 36 milliseconds See baow for explanation of PD llatchDEL PD llatchD EL din Op Code Prototype De
9. Op Code Prototype Description Arguments Example SW2_OFF 0x12 void SW2off int din When gating is controlled from software SW 2off tells the specified SW2 to start gating its input signal OFF with the specified shape SW 2off has no effect when the SW2 is programmed for external enable gating control see SW 2trig din Deviceindex number SW2off 1 This will turn off SW2 1 302 XBDRV Software Reference SW 2ton din Op Code Prototype Description Arguments Example SW2 TON 0x13 void SW2ton int din Similar to SW2on but causes the specified SW2 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number SW2trig 1 COMPUTER SW2ton 1 SW2ton 2 XBlgtrig Global trigger This will cause SW2 1 and SW2 2 to begin gating ON at precisely the same time SW 2toff din Op Code Prototype Description Arguments Example SW2_TOFF 0x14 void SW 2toff int din Similar to SW2off but causes the specified SW2 to wait for a global or local XBUS trigger before taking action see XB1gtrig and XBIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher
10. PFltype din type n Op Code Prototype Description Arguments Example PFL TYPE 0x11 void PFltype intdin int type intn Selects filter type algorithm and commences filtering din Deviceindex number n Number of delay line taps Number of biquad stages for BIQ16 32 type Filter type code 16 32 16 or 32 bit prec Coeff Max Code Type Fmt Taps Order FIR16 1 FIR 1 15 160 159 FIR32 2 FIR 2 30 64 63 IIR32 3 IIR 8 24 8 7 BIO16 4 bi guad IIR 2 14 57 38 BIQ32 5 bi guad IIR 2 30 21 14 PFlbegin 1 load filter coefficients PFltype 1 FIR16 32 This will tell the PF1 1 to start filtering using a 16 bit precision FIR algorithm The filter s 32 tap coefficients must be loaded first PF1Programmable Filter 909 PFibegin din Op Code Prototype Description Arguments Example PFL BEGIN 0x14 void PFlbegin int din Sets mode for downloading tap coefficients Current filtering process continues until PF 1type is called din Deviceindex number See PF l1type PF1b16 din coeff Op Code Prototype Description Arguments Example PF1 b16 0x15 void PF1b16 int din int coeff Downloads a 16 bit feed forward numerator tap coefficient NOTE Floating point to integer scale value depends on coefficient format required by desired filter type see PF 1type code constants din Deviceindex number coeff Filter coefficient PFlbegin din set PF1 to load mode
11. din Deviceindex number SW2toff 1 SW2toff 2 XBlgtrig Global trigger This will cause SW2 1 and SW2 2 to begin gating OFF at precisely the same time SW2 Cosine Switch 303 SW 2shape din scode Op Code Prototype Description Arguments Example SW2 SHAPE 0x16 void SW2shapef int din int scode Selects the SW2 ON OFF gating shape The valid shape types are listed below din Device index number scode Shape type code 0 7 ONOFF ON OFF Switch COS2 Cos function COS4 Cos function COS6 Cos function RAMP Linear ramp function RAMP2 Ramp2 function RAMP4 Ramp function RAMP6 Ramp function SW2shape 1 COS2 SW2on 1 delay 1000 SW2off 1 This will program SW2 1 to gate its input ON with a cos shape and then OFF after about one second with the same shape SW 2rftime din rftime Op Code Prototype Description Arguments Example SW2 RFTIME 0x15 void SW2rftimef int din float rftime Sets the rise and fall time of the gate shape The time is taken between the 10 and 90 points of minimum and maximum gate amplitude din Deviceindex number rftime Rise and fall time of gatein ms 0 5 99 9 See SW 2dur 304 XBDRV Software Reference SW 2trig din tcode Op Code Prototype Description Arguments Example SW2 TRIG 0x17 void SW2trig int din int tcode Programs the gating control mode of the SW2 The valid enable types a
12. 25 rtn str printf Displacement s n rtn_str while kbhit HTIstop 1 2210 XBDRV Software Reference HTlisiSO din Op Code Prototype Description Arguments Example HTI ISISO 0x20 void HTlis SO int din Switches the HTI from FASTRAK mode to ISOTRAK II mode din Device index number Following statements will set HTI to ISOTRAK II mode and run it HTIclear 1 HTIisISO 1 HTIgo 1 DB4 Digital Biological Amplifier 2301 DB4 Digital Biological Amplifier Overview This section describes the commands used to program the DB4 from a computer See the DB4 User s Guide for information on the operation of the amplifier D B4clear int din Op Code DB4 CLEAR 0x11 Prototype void DB4clear int din Description Clears the specified DB4 and resets it to last EEPROM settings Gain filter and impedance threshold settings will not be reset Arguments din Device index number D B4setgain int din int chan float Op Code Prototype Description Arguments Example gain DB4 GAIN 0x12 float DB4setgain int din int chan float gain Sets gain on the specified channel of specified DB4 to nearest programmable gain setting Returns actual gain value din Device index number chan CH1 CH2 CH3 CH4 or CHALL gain gain x100 to x1 000 000 The following sets gain on channel 2 to 10 000x DB4setgain 1 CH2 10000 0 2302 XBDRV Software Reference D B4selgain int din
13. DD Israte will pass the specified sample period to the nearest tenth of a microsecond So if you make a call such as DD Israte 1 6 98 it will be rounded and sent to the DD1 as 7 0us and the DD1 will truncate it down to the nearest integer number of 0 08us which is 6 96us XBDRV versions 2 01 and higher has provided the DD Isperiod call to set sample period and return the actual sample period to correct this problem DD Isperiod din sper Op Code Prototype Description Arguments Example DD1 SPERIOD 0x22 float DD1speriod int din float sper Sets the sampling period microseconds per sample of the specified DD1 It returns the actual sample period din Deviceindex number sper Sampling period 5 4us 2000us 2us 2000us for FASTDAC mode printf Sf DDisperiod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of DD1 1 to 1 5 04us 198 413kHz N ote DD1 Stereo Analog Interface 1507 DDIsperiod corrects the round off problem associated with DD Israte call while the base clock limitation still apply See note under DD Israte DD Isperiod call is available for DD1 of hardware versions 5 0 and above and XBDRV versions 2 01 and above DD 1npts din npts Op Code Prototype Description Arguments Example DD1 NPTS 0x18 void DD1npts int din long npts Sets the number of samples the specified DD1 will convert after it is triggered din Deviceindex number np
14. Resets the specified DSP s into basic convolution mode In this mode the each DSP can be controlled by data records sent to its COEF input port After being properly loaded with coefficients DSPs running in this mode will convolve data at their input ports with coefficient data and write the result to the output ports din Device index number dmask DSP specification mask See above PDiresetDSP 1 Ox0fffffff Resets all DSPs installed in system PD llockD SP din dmask Op Code Prototype Description Arguments Example RTE_LOCKDSP void PD1lockDSP int din long dmask Locks the specified DSP so that it will not respond to global sync commands din Device index number dmask DSP specification mask See above PD1lockDSP 1 0x3 This call will lock DSPs O and 1 PD1 DSP Calls 2119 PD linterpD SP din ifact dmask Op Code Prototype Description Arguments Example RTE_INTERPDSP void PD1lockDSP int din int ifact long dmask Turns interpolation on Interpolation is used to provide a smooth transition from one set of filter coefficients to another din Device index number ifact Interpolation factor usu 500 1000 dmask DSP specification mask See above PDlinterpDSP 1 1000 0x1 Turns on coefficient interpolation for DSP 0 and sets the interpolation factor to 1000 PD 1checkD SPS din Op Code Prototype Description Arguments Example PD1 CHECKDSP 0x24 long PD1ch
15. See the table at the end of this section for interpreting bit patterns See the BioAmp User s Guide for information on Digital and Analog clipping Digital Clip Analog Clip Channel 4 3 2 1 4 3 2 1 The following example reads the clip bitmask from the DB4 If bitpattern 238 then channels 2 3 and 4 show both analog and digital clipping on all channels int bitpattern bitpattern DB4getclip 1 D B4getstat int din Op Code Prototype Description Arguments Example DB4 GETSTAT 0x1d int DB4getstat int din Returns 0if headstage is not on Returns 3 for low impedance headstage Returns 65 for high impedance headstage din Device index number The following example reads the status of the DB4 int status status DB4getstat 1 2312 XBDRV Software Reference D B4powdown int din Op Code DB4 POWDOWN Oxle Prototype void DB4powdown int din Description Turns off the H S4 headstage Arguments din Device index number Example The following example powers down the HS4 headstage DB4powdown 1 D B4getgain int din int chan int sel Op Code DB4 GETGAIN 0x20 Prototype float DB4getgain int din int chan int sel Description Returns the gain from the specified channel and loads sel with index of gain setting Arguments din Device index number chan CH1 CH2 CH3 CH4 sel Pointer to int variable to hold gain index Notes To just read the gain and not l
16. This four channel delay is capable of generating multiple arbitrary delay taps from each of four delay channels The following calls are used to program the delay processor hardware Refer to PD 1 U ser s Guide for more information on using the DP2 PD 1clrD EL din nO n1 n2 n3 Op Code Prototype Description Arguments Example RTE_CLRDEL 0x0103 void PD1clrDEL int din int nO intn1 intn2 intn3 Clears the delay processor and specifies the number of taps to be processed on each channel PD1clrDEL will flush the delay history see PD 1flushD EL clear all delay time specifications to zero and turn off interpolation see below In addition the n0 n3 arguments are used to indicate the number of delay taps each channel should process Refer to PD1 User s Guide for limitations associated with delay tap processing din Device index number n0 n1 n2 n3 Processing specifiers for each delay channel 0 through 3 PD CLLDET CL A3 80 D3 This call will clear the delay processor and tell it to process delay taps 0 12 on channel 0 and 0 7 on channel 1 2124 XBDRV Software Reference PD 1flushD EL din Op Code Prototype Description Arguments Example RTE FLUSHDEL 0x010f void PD1flushDEL int din Clears all delay history buffers to zero Should be used each time the PDT is rearmed for operation using the delay processor din Device index number None PD linterpD EL din ifact
17. din Deviceindex number amp Amplitude in volts 0 00 9 99 WGlamp 1 5 00 This call sets WG1 1 output amplitude to 5 00 Vp WG lfreq din freq Op Code Prototype Description Arguments Example WG1 FREQ 0x15 void WGlfreq int din float freq Sets the sine wave frequency din Deviceindex number freq Frequency in Hz 1 20 000 WGlshape 1 SINE WGlfreq 1 5000 WGlon 1 This programs WG1 1 to produce a sine wave output with a frequency of 5kH z 804 XBDRV Software Reference WG Iswrt din swrt Op Code Prototype Description Arguments Example WG1 SWRT 0x16 void WGliswrt int din float swrt Sweeps the sine wave frequency for chirp tones din Deviceindex number swrt Frequency sweep ratein Hz s 10 9 999 WGlshape 1 SINE WGlfreq 1 200 WGlswrt 1 1000 WGlon 1 This code programs WG1 1 to produce a swept frequency sine wave starting at 200Hz After one second the frequency will be 1 2 kHz NOTE The frequency will continue increasing until the WG1 is gated off or until WG loff is issued WG Iphase din phase Op Code Prototype Description Arguments Example WG1 PHASE 0x17 void WGlphase int din float phase Sets the onset phase of the WGT Ss sine wave generator as well as the seed value for the WGI s internal random number generator Using the phase call the WG1 can be made to generate frozen noise signals each tim
18. port Pl 2writeX din pnum bitcode Op Code Prototype Description Arguments Example PI2 WRITEX 0x1F void Pl2write int din int pnum int bitcode Writes the specified bit code to an auxiliary port specified as output din Deviceindex number pnum Port number 1 4 bitcode Output bit code 0 0xff PI2clear 1 Pl2outsX 1 2 Pl2writeX 1 2 Oxff This will set all bits on auxiliary port 2 high 1016 XBDRV Software Reference PI 2readX din pnum Op Code Prototype Description Arguments Example PI2 READX 0x20 int Pl 2readX int din int pnum Reads the current input lines Note that any inputs designated to have negative logic will read as 1 when the input is low and 0 when the input is high din Deviceindex number pnum Port number PI2clear 1 i PI2readx 1 1 This will read the 8 bit pattern on auxiliary port 1 TG6 Timing Generator 1101 TG6 Timing Generator Overview The TG6 is a timing generator utilizing a dedicated microprocessor and high speed static RAM to produce up to six arbitrary timing sequences The TG6 programming procedures make extensive use of mask type arguments whereby each bit in a 6 bit number or mask is used to set specific output high or low for a specific interval Since the TG6is a TTL device when a channel is set high it will produce a voltage between 2 8V and 5V When a channel is set low its voltage will be between OV and 0 8V
19. synchronizing other devices with DA 1 conversions din Deviceindex number dcode Patch line code 3 5 XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line NONE 5 Nodock patch DAlclkin 1 INTERNAL DAlclkout 1 XCLK1 This call will set up DA1 1 to use its internal sampling clock and assert it to the XCLK1 line on the XBUS where it can be used to synchronize other devices on the bus DA1 Dual D A Converter 1309 DA lclipon din Op Code Prototype Description Arguments Example DA1 CLIPON 0x1F void DA1dipon int din Enables the DAC clip detection feature If the D A conversion data ever reach their maximum absolute value 7FFF the front panel Clip light will trip and stay on until a D A larm is issued NOTE If this feature is enabled the maximum sampling rate is limited to 100kH z din Deviceindex number See example under DA Iclip D A 1status din Op Code Prototype Description Arguments Example DA1 STATUS 0x1B int DA Istatus int din Returns the status of the specified DA1 Return Values IDLE O DALidle no conversion in progress ARM 1 DAlarmed ready for trigger ACTIVE 2 DAt1conversion in progress din Deviceindex number do while DAlstatus 1 ACTIVE This will cause the program to pause while DA1 1 finishes converting the present sample buffer DA lclip din Op Code Prototype Description Arguments Example DA1 CLIP 0x1D int DA
20. to 1 5 04us 198 413kH z AD2speriod corrects the round off problem associated with AD 2srate call while the base clock limitation still apply See note under AD 2srate AD 2speriod call is available for AD2 of hardware versions 5 0 and above and XBDRV versions 2 01 and above AD 2sampsep din sampsep Op Code Prototype Description AD2_SAMPSEP 0x21 void AD2sampsep int din float sampsep Sets the separation time between individual channel samples for the specified A D2 Arguments Example AD2 Instrumentation A D Converter 1609 NOTE Care must be taken not to set the sampling rate too fast or the AD2 will not be able to finish sampling all specified channels in time The period specified by AD 2srate must satisfy the following period gt channe s 1 sample separation din Deviceindex number sampsep Sample separation 2 1us 1000us AD2xchans 1 30 AD2sampsep 1 5 0 AD2srate 1 155 0 This call will set up AD2 1 to use 30 external channels and set the time between the samples taken on each channel to 5us The sampling rate has been selected with a period which allows completion of all 30 channel samples AD 2npts din npts Op Code Prototype Description Arguments Example AD2 NPTS 0x18 void AD2npts int din long npts Sets the number of samples the specified AD2 will convert after it is triggered din Deviceindex number npts Number of conversions 1 2
21. void DA3dkin int din int scode Selects the source of the sampling clock for the specified DA3 This is useful for synchronizing DA3 conversions with other devices din Deviceindex number scode Clock source 1 4 INTERNAL 1 Internal sample clock EXTERNAL 2 Front panel BNC XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line DA3clkin 1 EXTERNAL This call will set up DA3 1 to use its front panel BNC for the sampling clock 1708 XBDRV Software Reference D A 3clkout din dcode Op Code Prototype Description Arguments Example DA3 CLKOUT 0x17 void DA3dkout int din int dcode Asserts the DA3 s internal sampling clock onto an XBUS internal patch line This is useful for synchronizing other devices with DA3 conversions din Deviceindex number dcode Patch line code 3 5 XCLK1 3 XBUS patch line XCLK2 4 XBUSpatch line NONE 5 Nodock patch DA3clkin 1 INTERNAL DA3clkout 1 XCLK1 This call will set up DA3 1 to use its internal sampling clock and assert it to the XCLK1 line on the XBUS where it can be used to synchronize other devices on the bus D A 3clipon din Op Code Prototype Description Arguments Example DA3 CLIPON 0x1F void DA3clipon int din Enables the DAC clip detection feature If the D A conversion data ever reach their maximum absolute value 7 FFF the front panel clip light will trip and stay on until a DA 3arm is issued NOTE If this featur
22. 1 COMMON 0 PMlclear 1 PMiconfig 1 PM1_STEREO PMlmode 1 COMMON This set of calls will setup the PM 1 for two channel operation in common mode PM Ispkon din sn Op Code Prototype Description Arguments Example PM1 SPKON 0x14 void PM 1spkon int din intsn Turns the specified speaker on din Deviceindex number sn Speaker number 1 16 Thefollowing constants can also be used to specify a PM1 speaker SN 1 SN2 SN 16 for speakers 1 16 CHAN A 0 CHAN B 8 PMlclear 1 PMiconfig 1 PM1_STEREO PM1 Power Multiplexer 2003 PMispkon 1 CHAN A SN3 PMlspkon 1 CHAN B SN7 Turns on the 3rd speaker of Channel A and the 7th speaker 17 of Channel B Note the device is programmed to operate in STEREO mode PM Ispkoff din sn Op Code Prototype Description Arguments Example PM1 SPKOFF 0x15 void PM 1spkoff int din int sn Turns the specified speaker off din Deviceindex number sn Speaker number 1 16 See above PMispkoff 1 3 PMlspkoff 1 15 Turns off the speakers turned on in the above example 2004 XBDRV Software Reference this page intentionally left blank PD1 Overview 2101 PD1 Power SDAC Overview Unlike other XBUS devices the PD1 not only contains a controlling DSP processor but it also includes a secondary controlling processor that handles the PD1 auto routing function This secondary processor is resp
23. ADimode 1 ADC1 This call will set up AD1 1 to useA D channe 1 AD Istrig din Op Code Prototype Description Arguments Example AD1 STRIG x14 void ADiIstrig intdin Sets up the specified A D1 for single triggering of a conversion buffer AD 1strig can be issued while the AD1is active see example under AD Imtrig din Deviceindex number ADistrig 1 ADlarm 1 This will cause AD1 1 to begin converting on an external trigger or AD 1go but will not retrigger unless AD larm is issued again 1404 XBDRV Software Reference AD 1mtrig din Op Code Prototype Description Arguments Example AD1 MTRIG 0x19 void ADImtrig int din Sets up the specified AD1 for multiple external triggering of a conversion buffer NOTE AD 1strig can be issued while the AD1 is in multiple triggering mode to place it back into single triggering mode This provides a way to stop the A D1 from software after the next buffer conversion is complete without disabling the external triggering source din Deviceindex number ADimtrig 1 ADlarm 1 This will cause AD1 1 to begin converting at each external trigger The AD1 will not retrigger until conversion of the present buffer is complete AD 1reps din nreps Op Code Prototype Description Arguments Example AD1 REPS 0x1C void ADzt1reps int din unsigned int nreps Sets the number of times the AD1 can be re triggered after an AD larm is issued
24. Bi quad IIR to PF1 1 and begin the filtering process Each array contains 3 x 4 12 coefficients PF1Programmable Filter 907 PF 1biq32 din bcoefs acoefs Prototype Description Arguments Example nbigs void PF1biq32 int din float bcoefs float acoefs int nbigs Downloads two floating point arrays containing feedforward and feedback tap coefficients for a Cascaded Bi quad IIR filter and starts the filtering process all in asingle call Floating point to integer conversion is done by the routine Precision is 32 bit The coefficients in the two arrays must be ordered appropriately for the bi quad architecture and lie within the 230 format range 2 0 lt b a lt 2 0 din Deviceindex number bcoefs Array of feed forward numerator coeff s bio by bp by by ba bno bri biol acoefs Array of feed back denominator coeff s a gt Ais Bios Boos Bais a amos Anis Gaol N 2m filter order Notethat the a s are always sent but not actually used nbigs Number of 2nd order 3 tap bi quad stages m PFlbigq32 1 bcoefs acoefs 4 This will download an amp th order Bi quad IIR to PF1 1 and begin the filtering process Each array contains 3 x 4 12 coefficients 908 XBDRV Software Reference The remaining functions are the basic calls used by the filter functions to upload coefficients to the PF1 In general use the preceeding functions since they accept floating point coefficient arrays
25. Code Prototype Description Arguments Pl2map 0x1D void Pl2map int din int bitn int mmask Programs the PI2 s Auto Mapping feature to set specific output bits when a specific input pattern is present at the device s inputs Note that this feature only sets output bits the actual level at the device output can be inverted using the Pl2logic call The mmask argument specifies the input bits that must be true for a valid match other bits are ignored If a match is detected the PI2 will set the bitn specified din Deviceindex number bitn Bit number of output to set mmask Input map mask Pl2 Parallel Interface 1007 Example Suppose the PI2 is going to be used to interface a user response box to the host computer through the XBUS The box will be connected to the PI2 as shown in thefollowing diagram Subject Response Box Buttons O O 6 L E D s S o 6 Typical Subject Response Box The subject response box shown above has four momentary normally open push button switches and four LEDs The switches are connected with one terminal to ground and the other to the PI21 O line shown above LEDs are wired with the cathode lead going to ground and the anode lead going through a 4700 resistor to the PI2 I O line shown Let s suppose we want the response box to operate in the following way e Whenever a single button is pressed the corresponding LED should light up
26. D3 CODE A3 CODE I o ol A W N F o A D D AD2 CODE A D P D1 CODE XBDRV Nuts amp Bolts 9 Miscellaneous Communication Constants The XBDRV H header file contains a number of constants used for miscellaneous communication procedures These include a series of constants used to specify the communication port to be used and the standard XBUS communications constants BORK RK KK kk kk kk kk k k k k k K A A K AA AA AXA RRR I kk Global communication control constants oko ok oko ok oko oko ok oko oko oko oko oko oko oko oko oko ok ok ok kok kok kok kok kok kok kok kok kok fine COM1 fine COM2 fine COM3 fine COM4 fine COM AP2x fine COM APa fine COM APb Li 2 3 4 fine COM AP2 5 6 9 6 0 fine USE DOS COMlbase 0x3f8 COM2base 0x2f8 COM3base 0x3e8 COM4base 0x2e8 APabase 0x230 Pbbase 0x250 NOP s VER RE x TRIG IDENT_RE HOST_RT ARB_ERR HOST_ERR ERR_ACK SLAVE_ACK HARD_RST 10 XBDRV Software Reference SLAVE_ERR BAUD_LOCK ARB_ACK ARB_ID ARB_RST GTRIG LTRIG Physical Drivers Because XBDRV is written in standard C it can be easily ported to other hardware and software platforms However when an IBM PC or compatible is not being used a few short procedures must be written that are specific to that computer hardware These Physical Driver
27. DA1 from software after the next buffer conversion is complete without disabling the external triggering source din Deviceindex number DAlmtrig 1 DAlarm 1 This will cause DA1 1 to begin converting at each external trigger The DA1 will not retrigger until the present conversion cycle is complete DA1 Dual D A Converter 1305 DA lreps din nreps Op Code Prototype Description Arguments Example DA1 REPS 0x1C void DAtreps int din unsigned int nreps Sets the number of times the DA1 can be re triggered after a DA larm is issued Valid only in multiple trigger mode din Deviceindex number nreos Repeat triggers before rearming 0 60 000 DAlreps 1 100 If this line is added to the previous example DA1 1 will respond only to the first 100 triggers received D A Israte din sper Op Code Prototype Description Arguments Example N ote DA1 SRATE 0x15 void DAlsratef int din float sper Sets the sampling rate of the specified DA1 by assigning the sampling period Use only when compatibility with older hardware is required see N ote below din Deviceindex number sper Sampling period 5us 2000us 2us 2000us for FASTDAC mode DAlsrate 1 20 0 Sets the sampling period of DA1 1 to 20us which corresponds to a sampling frequency of 50kH z DA1 derives the programmed sampling period from a 12 5 MHz base clock This means that realizable sample periods are qua
28. Example DD1 CLIPON 0x1F void DD1clipon int din Enables the DD1 clip detection feature If the A D or D A conversion data ever reach their maximum absolute value 7FFF the front panel Clip light will trip and stay on until the next DD larm is issued NOTE If this feature is enabled the maximum sampling rate is limited to 100kH z din Deviceindex number See example under DD clip DD1 Stereo Analog Interface 1509 D DIstatus din Op Code Prototype Description Arguments Example DD1 STATUS 0x1B int DD 1status int din Returns the status of the specified DD1 Return Values IDLE O0 DDzLidle no conversion in progress ARM 1 DD1 armed ready for trigger ACTIVE 2 DD1 conversion in progress din Deviceindex number do while DDIstatus 1 ACTIVE This will cause the program to pause while DD1 1 finishes converting the present sample buffer DD Iclip din Op Code Prototype Description Arguments Example DD1 CLIP 0x1D int DDIdip int din Returns the status of the clip detector Return Values O If no clip has occurred 1 If aclip has occurred din Deviceindex number DDiclipon 1 DDlarm 1 DD1go 1 do if DDiclip 1 DDistop 1 while DD1status 1 ACTIVE This example will stop DD1 1 D A clip at any time lt if either the A D or 1510 XBDRV Software Reference this page intentionally left blank AD2 Instrumentation A D Converte
29. M C1 Arguments din Device index number M Clpos int din int pos Prototype void MC1pos int din int pos Description Sets the position to which the motor will move when the MC 1move command is issued Arguments din Device index number pos Position M Clvel int din int vel int perm Prototype void MCilvel int din int vel int perm Description Setsthemaximum velocity of the motor Arguments din Device index number vel velocity in units s perm 2402 XBDRV Software Reference M C lacc int din int acc int perm Prototype void MClacc int din int acc int perm Description Sets the acceleration of the motor The motor will accelerate until it reaches the maximum velocity set by the MC1vel command Arguments din Device index number acc acceleration in units s s perm M C1imove int din Prototype void MC1movetint din Description Initiates movement of the motor to the position set by the MC 1pos command Arguments din Device index number Example The following example sets a new position to which to move 20 degrees and then intiates movement MClpos 1 20 MClimove 1 M C1syncmove int din Prototype void MCilsyncmovetint din Description Arguments din Device index number Example M Clgear int din float gratio Prototype void MClgear int din float gratio Description Sets the gear ratio of the motor Arguments din Device index number gratio Gear ratio Example Thefollow
30. Prepares the specified DA3 for D A conversion DA3arm must be issued before the DA3 can be triggered from software or externally to start conversion din Deviceindex number See example for D A 3go 1702 XBDRV Software Reference D A3go din Op Code Prototype Description Arguments Example DA3 GO 0x11 void DA3go int din Triggers the specified DA3 from software to begin D A conversion DA3arm must be issued first to prime the DA3 din Deviceindex number DA3clear 1 DA3arm 1 DA3go 1 This example will reset DA3 1 to its default setting and begin conversion D A3stop din Op Code Prototype Description Arguments Example DA3 STOP 0x12 void DA3stop int din Forces the specified DA3 to stop D A conversion immediately NOTE DA3stop will not zero the DAC outputs a D A 3clear must be issued to re zero if necessary din Deviceindex number delay 1000 DA3stop 1 These lines added to the example given for DA3go will cause the DA3 1 to stop after a short delay period DA3 2 4 8 Multi Channel Instrumentation D A 1703 D A 3tgo din Op Code Prototype Description Arguments Example DA3 TGO 0x21 void DA3tgo int din Similar to DA3go but causes the specified DA3 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggeri
31. REPS 0x1C void DD1reps int din unsigned int nreps Sets the number of times the DD1 can be re triggered after a DD larm is issued Valid only in multiple trigger mode din Deviceindex number nreps Repeat triggers before re arming 0 60 000 DDireps 1 100 If this line is added to the example given for DD1mtrig DD1 1 will respond only to the first 100 triggers received DD Israte din sper Op Code Prototype Description Arguments Example Note DD1 SRATE 0x15 void DDisratef int din float sper Sets the sampling rate microseconds per sample of the specified DD1 Use only when compatibility with older hardware is required see N ote below din Deviceindex number sper Sampling period 5 4us 2000us 2Qus 2000us for FASTDAC mode DDisrate 1 20 00 Sets the sampling rate of DD1 1 to 1 20us BOkH z DD1 derives the programmed sampling period from a 125 MHz base dock This means that realizable sample periods are quantized to 0 08us For example calling D D Israte 1 7 0 will actually cause 1506 XBDRV Software Reference the device to sample every 6 96us because the rate must be derived from an integer number of cycles of the base dock 0 08us Also the rate will be truncated down to the nearest integer number of 12 5MHz clock cycles so calling D D 1srate 1 5 9 will result in a 5 84us sampling period not a 5 92us as might be expected With XBDRV versions 2 00 or lower
32. V 20us 50kHz AD2 derives the programmed sampling period from a 125 MHz base clock This means that realizable sample periods are quantized to 0 08us For example calling AD 2srate 1 7 0 will actually cause the device to sample every 6 96us because the rate must be derived from an integer number of cycles of the base clock 0 08us Also the rate will be truncated down to the nearest integer number of 12 5MHz clock cycles so calling AD 2srate 1 5 1 will result in a 5 04us sampling period not a 5 12us as might be expected 1608 XBDRV Software Reference With XBDRV versions 2 00 or lower AD 2srate will pass the specified sample period to the nearest tenth of a microsecond So if you make a call such as AD 2srate 1 6 98 it will be rounded and sent to the AD2 as 7 0us and the AD2 will truncate it down to the nearest integer number of 0 0815 which is 6 96us XBDRV versions 2 01 and higher has provided the AD 2speriod call to set sample period and return the actual sample period to correct this problem AD 2speriod din sper Op Code Prototype Description Arguments Example Note AD2 SPERIOD 0x24 float AD2speriod int din float sper Sets the sampling period microseconds per sample of the specified AD2 It returns the actual sample period din Deviceindex number spe Sampling period 5us 2000us printf Sf AD2speriod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of A D2 1
33. Valid only in multiple trigger mode din Deviceindex number nreos Repeat triggers before rearming 0 60 000 ADlreps 1 100 If this line is added to example given for AD 1Imtrig AD1 1 will respond only to the first 100 triggers received AD1 Dual A D Converter 1405 AD Israte din sper Op Code Prototype Description Arguments Example Note AD1 SRATE 0x15 void AD Israte int din float sper Sets the sampling rate in microseconds per sample of the specified AD1 Use only when compatibility with older hardware is required see N ote below din Deviceindex number spe Sampling period 5us 2000us ADlsrate 1 20 0 Sets the sampling rate of AD1 1 to 1 20us 50kH z AD1 derives the programmed sampling period from a 125 MHz base clock This means that realizable sample periods are quantized to 0 08us For example calling AD 1srate 1 7 0 will actually cause the device to sample every 6 96us because the rate must be derived from an integer number of cycles of the base clock 0 08us Also the rate will be truncated down to the nearest integer number of 12 5MHz clock cycles so calling AD 1srate 1 5 1 will result in a 5 04us sampling period not a 5 12us as might be expected With XBDRV versions 2 00 or lower AD Israte will pass the specified sample period to the nearest tenth of a microsecond So if you make a call such as AD Israte 1 6 98 it will be rounded and sent to the AD1as 7 0us
34. and the AD1 will truncate it down to the nearest integer number of 0 08us which is 6 96us XBDRV versions 2 01 and higher has provided the AD Isperiod call to set sample period and return the actual sample period to correct this problem 1406 XBDRV Software Reference AD Isperiod din sper Op Code Prototype Description Arguments Example N ote AD1 SPERIOD 0x22 float A Dlsperiod int din float sper Sets the sampling period microseconds per sample of the specified AD1 It returns the actual sample period din Deviceindex number spe Sampling period 5us 2000us printf Sf AD1lsperiod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of AD1 1 to 1 5 04us 198 413kH z AD 1speriod corrects the round off problem associated with AD Israte call while the base clock limitation still apply See note under AD Israte AD Asperiod call is available for AD1 of hardware versions 5 0 and above and XBDRV versions 2 01 and above AD 1npts din npts Op Code Prototype Description Arguments Example AD1 NPTS 0x18 void ADlInpts int din long npts Sets the number of samples the specified AD1 will convert after it is triggered din Deviceindex number npts Number of conversions 1 23 ADlnpts 1 500000 This call will set up AD1 1 to perform 500 000 conversions which corresponds to 10 seconds at 50kH z sampling rate AD1 Dual A D Converter 1407 AD 1clkin d
35. another level of ease and versatility The XBDRV software is a complete library of driver routines ready to use with Turbo C and Microsoft C compilers The XBDRV software is provided in source code format for easy compilation and for advanced programmers who may wish to customize or create new drivers The source code listing also makes it possible to port XBDRV to non PC computers and other compiler platforms Once you have installed and configured your System II hardware the Softw are Setup section has a simple C example to help you get started in programming your XBUS devices right away The XBDRV Nuts amp Bolts section contains advanced programming information which is necessary only if you wish to modify or write your own driver routines The Procedure Descriptions section outlines the driver routines and associated parameters for each XBUS device As new devices and their drivers become available document updates will be provided on a per device basis The driver source code is also listed with each device driver description The basic format of all the XBUS device driver routines is similar Once you get familiar with a few of them writing programs to control your XBUS devices will be easy and fast Software Setup 3 Software Setup Before proceeding be certain that you have completed all the steps outlined in the System II Installation Guide and have verified that your hardware is working properly Turbo and Microso
36. are accessed using the following three command calls e Pl2outsX e Pl2writeX e Pl2readX All other commands apply only to the eight main smart I O lines Pl2 Parallel Interface 1003 Pl 2clear din Op Code Prototype Description Arguments Example PI2 CLEAR 0x11 void Pl2clear int din Resets the specified PI2 to the factory default configuration The PI2 default configuration is as follows e Auxilliary ports All inputs e Smart Ports a All inputs with Positive Logic b No Mapping or Auto Timing c Noinput Debouncing or Latching din Deviceindex number PI2clear 1 Resets PI2 1 Pi2outs din omask Op Code Prototype Description Arguments Example PI2 OUTS 0x12 void Pl2outs int din int omask Specifies certain I O bits to be outputs A set bit within omask will make the corresponding I O line an output while all reset bits will indicate input lines din Deviceindex number omask Designation Mask 1 Output OS nput PI2outs 1 0xf0 This call will program PI2 1 to make I O lines 1 through 4 inputs and lines 5 through 8 outputs 1004 XBDRV Software Reference Pl2logic din logout login Op Code Prototype Description Arguments Example PI2 LOGIC 0x13 void Pl2logic int din int logout int login Specifies a logic mask applied to PI2 inputs and outputs All operations within the PI2 are assumed to be operating with positive logic i e 1 gt high g
37. be called directly in user source code PD1 Referencing Variables XBDRV includes a number of constants macros to be used when programming the PD1 These constants are used to bracket and identify data records placed on data streams being sent to the PD1 from the AP2 The defined constants include MONO STEREO _START STOP LSYNC and GSYNC Refer to PD1 User s Guide for more information on the use of these constants Also included in XBDRV are a number of global variables used to identify various PD1 resources and their ports Variable arrays are used instead of constants macros to allow for indexed referencing of various PD1 resources For example to program the first eight delay taps of delay channel 0 to 0 10 20 70 millisecond delays respectively a for next loop can be used PDisrate 1 20 0 PDiclrDEL 1 8 0 0 0 for i 0 i lt 8 i PDisetDEL 1 TAP i 0 i 10 N ote that resource variables and thus resources and their ports are always numbered starting from zero instead of one At first this may seem awkward however after writing a few code loops such as the one shown above the advantages of zero based referencing become apparent The following variables are included in XBDRV s PD1 section DSPid 0 27 DSPin 0 27 DSPinL 0 27 DSPinR 0 27 DSPout 0 27 DSPoutL 0 27 DSPoutR 0 27 COEF O 27 DELin 0 3 DELoutl0 31 0 3 TAP 0 31 0 3 DAC O 3 AD
38. e The LED should remain illuminated while the button is pressed and for 100 milliseconds after it is released e If more than one button is pressed at the same time the software should indicate an error 1008 XBDRV Software Reference e Button activity should be latched to avoid missed subject responses e PI2 debouncing should be used to avoid false button reads e Response times should be measured The following program shows how the PI2 should be programmed to realize the system behavior described above In this example the name of the button pressed is displayed on the screen as long as the button is pressed include lt dos h gt include lt stdio h gt include lt stdlib h gt include lt conio h gt include xbdrv h define YES 0x01 define NO 0x02 define PANIC 0x04 void main int op ytl clrscr XBlinit USE_DOS printf PI2 Subject Response Box Demonstration printf n n Press any key to quit PI2clear 1 Clear to factory default KA PI2outs 1 0xf8 Make lines 4 8 outputs Ey PI2logic 1 0x00 0x07 Neg logic for button inputs PI2latch 1 0x07 Latch all of the input lines PI2debounce 1 10 Enable input debouncing 10ms Autotime output lines 5 7 bits 4 6 ae for i 4 i lt 7 i PI2autotime 1 i 100 Now send maps for LED activity PI2map 1 4 YES bit 4 output 5 on for YES PI2map 1 5 NO bit 5 output 6
39. going to be used to interface a user response box to the host computer through XBUS The box will be connected to the PI1 as shown in the following diagram PI Parallel Interface 707 Subject Response Box Panic Typical subject response box The typical subject response box shown here has three momentary normally open push button switches and three LEDs The switches are connected with one terminal to ground and the other to the PI1 I O line LEDs are wired with the cathode lead going to ground and the anode lead going through a 4700 resistor to the PI1 I O line shown Let s suppose we want the response box to operate in the following way e Whenever a single button is pressed the corresponding LED should light up e The LED should remain illuminated while the button is pressed and for 100 milliseconds after it is released e If more than one button is pressed at the same time all LEDs should light up to indicate an error e Button activity should be latched to avoid missed subject responses 708 XBDRV Software Reference e PI1 debouncing should be used to avoid false button reads The following program shows how the PI1 should be programmed to realize the system behavior described above In this example the name of the button pressed is displayed on the screen for as long as the button is pressed include lt stdlib h gt include lt conio h gt incl
40. if itis on SW 2clear din Op Code Prototype Description Arguments Example SW2 CLEAR 0x20 void SW2clear int din Clears the specified SW2 and resets it to the factory default setup Triggering MANUAL COMPUTER Gate Shape Cos2 function Rise Fall time 10 0 ms Gate duration Continuous din Deviceindex number SW2clear 1 306 XBDRV Software Reference This will reset SW2 1 to factory default CG1 Clock Generator 401 CG1 Clock Generator CG1go din Op Code Prototype Description Arguments Example CG1 GO 0x11 void CG1 intdin Tells the specified CG1 to begin producing the programmed output din Deviceindex number CGltrig 1 POS_EDGE CG1go 1 This issues a manual trigger on CG1 1 CG 1tgo din Op Code Prototype Description Arguments Example CG1 TGO 0x19 void CGltgo int din Similar to CG 1go but causes the specified CG1 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number CGltrig 1 NONE CG1tgo 1 CG1tgo 2 XBlgtrig Global trigger This will cause CG1 1 and CG1 2 to begin clocking at precisely the same time 402 XBDRV Software Reference CG Istop din Op Code CG1 STOP 0x12 Pro
41. int chan int Op Code Prototype Description Arguments Example gs DB4 GAIN 0x12 float DB4selgain int din int chan int gs Sets gain on the specified channel of specified DB4 to the selected gain index Returns actual gain value Similar to DB4setgain but uses an index to specify the gain din Device index number chan CH1 CH2 CH3 CH4 or CHALL gs gain setting index 0 36 The following sets gain on all channels to gain setting 5 which corresponds to 600x DB4selgain 1 CHALL 5 Table of gain settings Gain Index Gain 0 8 9 17 18 26 27 36 100 900 in 100x steps 1 000 9 000 in 1 000x steps 10 000 90 000 in 10 000x steps 100 000 1 000 000 in 100 000x steps DB4 Digital Biological Amplifier 2303 D B4setfilt int din int chan int ftype float ffreg Op Code DB4 FILTER 0x13 Prototype float DB4setfilt int din int chan int ftype float ffreq Description Sets filter frequency on the specified channel of specified DB4 to nearest programmable filter frequency see table below for programmable filter frequencies Returns actual filter frequency Arguments din Device index number chan CH1 CH2 CH3 CH4 or CHALL ftype F HP high pass F LP low pass F NT notch ffreg corner frequency Example This code sets the following filter frequencies for channel 1 High pass 10 Hz Low pass 12 000 Hz Notch 60 Hz DB4setfilt 1 CH1 F HP 10 DB4setfilt 1 CH1 F LP 12000
42. int tochan Op Code Prototype Description Arguments Notes Example DB4 IMPSCAN Oxif int DB4impscan int din int tochan Scans impedance of multiple channels on HS4 headstage and returns bitmask for which channels are above the impedance threshold din Device index number tochan channel number to scan through starting from channel 1 CH1 CH2 CH3 or CH4 The bit pattern is set by which channels exceed the impedance threshold 1 in bit pattern Channels that are less than the impedance threshold have a 0 in the bit pattern See the table at the end of this section for interpreting bit patterns See the BioAmp User s Guide for information on impedance measurement N egative Positive Channel 4 3 2 1 4 3 2 1 The following example scans impedance from channel 1 through channa 3 If impmask 33 corresponding to a bit pattern of 0010 0001 Channel 2 Negative edectrode exceeds the impedance threshold and Channel 1 Positive electrode exceeds the impedance threshold impmask DB4impscan 1 CH3 DB4 Digital Biological Amplifier 2311 D B4getclip int din Op Code Prototype Description Arguments Notes Example DB4 GETCLIP O0x1c int DB4getclip int din Returns bit pattern for channel clip status din Device index number The bit pattern is set by which channels are clipping 1 in bit pattern Channels that are not clipping have a Oin the bit pattern
43. number pcode Patch selection code 1 5 XTRG1 XBUSTrig Sync 1 XTRG2 XBUSTrig Sync 2 XCLK1 XBUS Clock 1 XCLK2 XBUS Clock 2 EXT Front Panel BNC only Example CGlpatch 1 XCLK1 This call will program CG1 1 to assert its output to XBUS clock line 1 CG1 Clock Generator 405 CG lactive din Op Code CG1 ACTIVE 0x17 Prototype char CGlactive int din Description Returns false if the selected CG1 is in idle mode or is waiting for a trigger otherwise CGlactive returns true Arguments din Deviceindex number Example The CGlactive call can be used to check if a pulse sequence has finished so response data can be collected as illustrated below if CGlactive 1 read in spike times 406 XBDRV Software Reference this page intentionally left blank SD1 Spike Discriminator 501 SD1 Spike Discriminator SD 1go din Op Code Prototype Description Arguments Example SD1 GO 0x11 void SD1go int din Tells the SD1 to begin spike discrimination i e takes the device out of IDLE mode Note that this is the default state of the SD1 din Deviceindex number SDlgo 1 Programs SD1 to begin looking for spikes SD Istop din Op Code Prototype Description Arguments Example SD1 STOP 0x12 void SDI1stop int din Places the SD1 in IDLE mode In this mode no pulses are sent from the First or Last outputs Use the SD1 s IDLE mode if your TimeStamper Counter does not have a
44. of three filter architectures e PF1fir16 e PF1fir32 e PFliir32 e PFlbiq16 e PF1biq32 The remaining commands are the basic functions that download user specified filter coefficients to the PF1 In general you should use the preceding routines since they accept floating point coefficient arrays e PFitype e PFibegin e PF1b16 e PF1al6 e PF1b32 e PF1a32 Filter coefficients can be obtained from a variety of signal processing software packages Refer to PF1 supplemental documentation for further information 902 XBDRV Software Reference PFlfreq din Ipfreg hpfreq Op Code Prototype Description Arguments Example PF1 FREQ 0x19 void PFlfreq int din int pfreg int hpfreg Selects corner frequencies of built in lowpass and highpass filters and commences filtering din Deviceindex number Ipfreg lowpass corner freq 50 15 000 0 OFF hpfreq highpass corner freq 50 15 000 0 OFF PFifreg 1 600 1400 This call tells the PF1 1 to start filtering with a lowpass corner frequency of 600Hz and highpass corner frequency of 1 4kHz which is equivalent to a notch filter with 800H z bandwidth and centered at about 1kH z PFlgain din Ipgain hpgain Op Code Prototype Description Arguments Example PF1 GAIN 0x1A void PFilgain int din intlpgain inthpgain Select gains of built in lowpass and highpass filters din Deviceindex number Ipgain lowpass filter gain hpgain highpas
45. returned Because only 16 bits are sent from the ET1 the ETilread16 procedure is faster than ET1read32 however the upper 16 bits of data are lost and short rollover times can be a problem din Deviceindex number i 0 ETlgo 1 do tbuf i ETlreadl6 1 if tbuf i 1 i while i lt 100 ETlstop 1 This program block will record 100 event times in the PC buffer tbuf ET1 Event Timer 603 ET 1lread32 din Op Code Prototype Description Arguments Example ET1 READ32 0x21 unsigned long ET 1read32 int din Reads a 32 bit timer counter value from ET1 FIFO If the FIFO is empty a value of 1 is returned din Deviceindex number See example for ET Lread16 ET ldrop din Op Code Prototype Description Arguments Example ET1 DROP 0x18 void ET1drop int din Clears the ETT s FIFO memory din Deviceindex number ETlgo 1 delay 100 ET1stop 1 for i 0 i lt 10 i tbuf i ETlread32 1 ETidrop 1 This program will record events for about 100 milliseconds and then read the first 10 times into the PC array tbuf ET1drop is then called to dear any remaining event times ET lreport din Op Code Prototype Description Arguments Example ET1 REPORT 0x20 int ET 1report int din Returns the number of timer counter values stored inthe ET1 s FIFO din Deviceindex number ET1go 1 do while ETlreport 1 lt 100 604 XBDRV S
46. sper Op Code Prototype Description Arguments Example DA3 SRATE 0x15 void DA3srate int din float sper Sets the per channel sampling rate of the specified DA3 Use only when compatibility with older hardware is required see N ote below din Deviceindex number spe Sampling period 2us 2000us NOTE The aggregate sampling rate of channels x per channel sampling rate cannot exceed 500kH z DA3srate 1 20 0 This call will set the sampling rate of DA3 1 to 1 20us 50kHz 1706 XBDRV Software Reference Note DA3 derives the programmed sampling period from a 125 MHz base dock This means that realizable sample periods are quantized to 0 08us For example calling DA3srate 1 7 0 will actually cause the device to sample every 6 96us because the rate must be derived from an integer number of cycles of the base clock 0 08us Also the rate will be truncated down to the nearest integer number of 12 5MHz clock cycles so calling DA3srate 1 5 1 will result in a 5 04us sampling period not a 5 12us as might be expected With XBDRV versions 2 00 or lower DA 3srate will pass the specified sample period to the nearest tenth of a microsecond So if you make a call such as D A 3srate 1 6 98 it will be rounded and sent to the DA3 as 7 0us and the DA3 will truncate it down to the nearest integer number of 0 08us which is 6 96us XBDRV versions 2 01 and higher has provided the D A3speriod call to set sample
47. sss 100 switch li case ARB_ERR if ne gt XB_MAX_TRYS XBlflush showerr Communication errors break else XBlflush break case SLAVE_ERR tdtdisab j 0 x 0 do i iorec if i gt 0 sss j 1 j x 0 X 16 XBDRV Software Reference O amp amp j lt 200 ss x lt xbtimeout Ss break default if ne gt XB MAX TRYS showerr No XBUS device responding at XBL accessed break void showerr char eee qint rn pn i enable rn xin gt gt 2 pn xln amp 3 1 sprintf xb_err 0 sprintf xb_err 1 XBUS Error Rack d Position d rn pn sprintf xb_err 2 s xcaller sprintf xb_err 3 s eee sprintf xb_err 4 sprintf xb_err 5 xb_eflag 1 if xb_emode printf 3s n xb_err i i Jwhile xb err i 0 0 exit 0 Version 2 of XBDRV allows you to trap XBDRV errors in your program You can then terminate the program or take action to correct the error Consult the APOS XBDRV Release Notes for further details XBDRV Nuts amp Bolts 17 Receiving Data Across XBUS XBDRV has three procedures used for receiving device data The get8 procedure receives a single byte from the host device while get16 and get32 handle integer and long values respectively Any timean XBUS device responds with data the amount and type of data are al
48. the front panel Clip light will trip and stay on until the next AD larm is issued NOTE If this feature is enabled the maximum sampling rate is limited to 100kH z din Deviceindex number See example under AD Iclip AD Istatusf din Op Code Prototype Description Arguments Example AD1 STATUS 0x1B int A Dlstatus int din Returns the status of the specified A D1 Return Values IDLE O ADlLidle no conversion in progress ARM 1 ADlarmed ready for trigger ACTIVE 2 AD1lconversion in progress din Deviceindex number do while ADlstatus 1 ACTIVE This will cause the program to pause while AD1 1 finishes converting the present sample buffer AD1 Dual A D Converter AD 1clip din Op Code Prototype Description Arguments Example AD1 CLIP 0x1D int ADldip intdin Returns the status of the clip detector Return Values O If no clip has occurred 1 If aclip has occurred din Deviceindex number AD1iclipon 1 ADlarm 1 AD1go 1 do if ADlclip 1 AD1stop 1 while ADlstatus 1 ACTIVE 1409 This example will stop AD1 1 if the A D clips at any time 1410 XBDRV Software Reference this page intentionally left blank DD1 Stereo Analog Interface 1501 DD1 Stereo Analog Interface DD 1clear din Op Code Prototype Description Arguments Defaults Example DD1 CLEAR 0x1E void DD1clear intdin Clears the specified DD1 and resets it
49. the host and then set again as soon as any input line in Imask is detected true on the next strobe cycle Arguments din Deviceindex number Imask Input bits to latch 1 Latch 0 No Latch Example See example under PI 2map P 2autotime din bitn dur Op Code PI2 AUTOTIME 0x17 Prototype void Pl2autotime int din int bitn float dur Description Enables and programs the PI2 s Auto Time feature When this feature is enabled the Pl2 will automatically reset a specified output line after a period of time Each output line has its own timer which is started each time it is written to by the host computer or the Auto M apping feature Arguments din Deviceindex number bitn Bit number 0 7 dur Duration in ms 0 32 000 Example See example under Pl2map 1006 XBDRV Software Reference P 2toggle din tmask Op Code Prototype Description Arguments Example PI2 LATCH 0x21 void Pl2toggle int din int tmask Programs the PI2 s Output Toggling feature used with Pl2autotime This feature will cause selected tmask output bits to toggle back on set after the same duration specified in PI 2autotime din Deviceindex number tmask Output bits to toggle PI2clear 1 PI2outs 1 Ox0f PI2autotime 1 0 500 PI2autotime 1 1 250 PI2toggle 1 0x03 After the above program is run LEDs 1 and 2 bits O and 1 will go on and off at 1Hz and 0 5Hz respectively PI 2map din bitn mmask Op
50. timer so times can be zeroed independently din Device index number bitmask Bit mask of input timers to zero See example under PI 2gettime P 2gettime din bitn Op Code Prototype Description Arguments Example PI2 GETTIME 0x1A int P 2gettime int din int bitn Returns the time in ms an input line became true from the time PI 2zerotime was last called Each line has a timer so times can be read individually Input event times are latched so they can be read any time before another zeroing Maximum time is 32 seconds WARNING The time for a particular input will read zero for 2 milliseconds after that input is read true using Pl2read To avoid possible false readings always wait at least 2 milliseconds after a bit reads true before trying to read its time din Deviceindex number bitn Bit number of input to read PI2clear 1 getch wait for key hit V PI2zerotime 1 0x03 zero timers on bits 0 and 1 x delay 2000 wait 2 seconds t0 PI2gettime 1 0 get time of bit 0 ti PI2gettime 1 1 get time of bit 1 Pl2 Parallel Interface 1011 This program waits for a keyboard hit then zeros the input timers on bits 0 and 1 Inputs 1 and 2 and then waits 2 seconds for a response before getting the times Pl2gettime returns 0 if the input bit has not gone true 1012 XBDRV Software Reference Pl 2write din bitcode Op Code Prototype Description Argumen
51. to factory default settings din Deviceindex number Sampling rate 1 20us 50kHz of conversions 1000 Channel mode DAC1 Single triggering Clip feature disabled See example for DD 1go DD larm din Op Code Prototype Description Arguments Example DD1 ARM 0x13 void DD1iarm int din Prepares the specified DD1 for A D D A conversion DD larm must be issued before the DD1 can be triggered from software or externally to start conversion din Deviceindex number See example for DD 1go DD 1go din Op Code Prototype Description Arguments Example DD1 GO 0x11 void DD1go intdin Triggers the specified DD1 from software to begin A D D A conversion DD larm must be issued first to prime the DD1 din Deviceindex number DDiclear 1 DDlarm 1 1502 XBDRV Software Reference DD1go 1 This example will reset DD1 1 to its default setting and begin conversion DD 1stop din Op Code Prototype Description Arguments Example DD1 STOP 0x12 void DD1stop int din Forces the specified DD1 to stop A D D A conversion immediately NOTE DD istop will not zero the DAC outputs a DD Iclear must be issued to re zero if necessary din Deviceindex number delay 1000 DD1stop 1 These lines added to the example above will cause the DD1 1 to stop after a short delay period DD 1tgo din Op Code Prototype Description Arguments D
52. which of the specified AD2 s four channels will be used for conversion The combination of A D channels to be used is specified by bits 2 5 of the mcode parameter din Deviceindex number mcode Mode code 0x04 0x3C ADC1 0x04 A D channel 1 ADC2 0x08 A D channad 2 ADC3 0x10 A D channel 3 ADC4 0x20 A D channa 4 DUALADC 0x0C A D channels 1 amp 2 Other combinations are achieved by directly setting bits 2 5 of mcode bit 5 bit 4 bit3 bit 2 bit1 bit 0 ADC4 ADC3 ADC2 ADC1 0 0 or by adding the above defined constants as in the following example AD2mode 1 ADC1 ADC3 This call will set up AD2_ 1 to use A D channels 1 and 3 AD 2xchans din nchans Op Code Prototype Description Arguments Example AD2 XCHANS 0x22 void AD2xchans int din int nchans Instructs the A D2 to use external multiplexer input channels of the MX1 or MXISH If used AD 2xchans is issued instead of AD 2mode and the A D2Ssfour front panel BNC inputs cannot be used din Deviceindex number nchans Number of external channels to use 1 128 AD2xchans 1 16 Note AD2 Instrumentation A D Converter 1605 This call will set up AD2_ 1 to use 16 multiplexed external channels Two external multiplexer modules 8 channels each must be installed in the XBUS Call this function after A D 2clear and before mrecord Otherwise channels will be shifted AD 2gain din chan gain Op Code Prototype Description Arguments Example AD2
53. 0x11 void DA1go int din Triggers the specified DA1 from software to begin D A conversion DAlarm must be issued first to prime the DA1 din Deviceindex number DAlclear 1 DAlarm 1 DAlgo 1 This example will reset DA 1 1 to its default setting and begin conversion D A Istop din Op Code Prototype Description Arguments Example DA1 STOP 0x12 void DAlstop int din Forces the specified DA1 to stop D A conversion immediately NOTE DAlstop will not zero the DAC outputs a DA lclear must be issued to re zero if necessary din Deviceindex number delay 1000 DAlstop 1 These lines added to the example under DA 1go will cause the DA1 1 to stop conversion after a short delay period D Altgo din Op Code Prototype Description DA1 TGO 0x21 void DAltgo intdin Similar to DA1go but causes the specified DA1 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices Arguments Example DA1 Dual D A Converter 1303 NOTE Global and local triggering features are available only on XBUS hardware versions 3 0 or higher din Deviceindex number DAlarm 1 r DAlarm r 2 DAltgo 1 DAltgo 2 XBlgtrig Global trigger This will first prepare both DA1 1 and DA1 2 to wait for a same trigger and begin conversion at precisely the same time DA 1mode d
54. 203 Takes PA4 out of MUTE mode If the PA4 was not in MUTE mode the call will have no effect din Deviceindex number PA4nomute 1 PA 4ac din Op Code Prototype Description Arguments Example PA4 AC 0x11 void PA4ac int din Places the specified PA4 in AC coupling mode din Deviceindex number PA4ac 1 This places PA4 1 in AC coupling mode PA 4dc din Op Code Prototype Description Arguments Example PA4 DC 0x12 void PA4dc int din Places the specified PA4in DC coupling mode din Deviceindex number PA4dc 1 This places PA4 1 in DC coupling mode PA 4read din Op Code Prototype Description Arguments Example PA4 READ 0x18 float PA4read int din Returns the current attenuation setting from the specified PA 4 din Deviceindex number printf Current attenuation f n PA4read 1 204 XBDRV Software Reference This displays the current attenuation setting of PA 4 1 SW2 Cosine Switch 301 SW2 Cosine Switch SW 2on din Op Code Prototype Description Arguments Example SW2 ON 0x11 void SW2onf intdin When gating is controlled from software SW2on tells the specified SW2 to start gating its input signal ON with the specified shape SW2on has no effect when the SW2 is programmed for external enable gating control see SW2trig din Deviceindex number SW2trig 1 COMPUTER SW2on 1 This will turn on SW2 1 SW 2off din
55. 2111 PD Istatus din Op Code Prototype Description Arguments Example PD1 STATUS 0x1B int PD 1status int din Returns the status of the specified PD1 Return Values IDLE O PDl1idle no conversion in progress ARM 1 PD1larmed ready for trigger ACTIVE 2 PD1conversion in progress din Device index number See DD Istatus PD 1syncall din Op Code Prototype Description Arguments Example RTE_SYNCALL 0x0110 void PD 1syncall int din Sends a global sync command to all PD1 resources causing them to latch any previously loaded filter coefficients and or delay constants Calling PD1syncall is equivalent to sending the value GSYNC to the PD1 on a data stream din Device index number PDisrate 1 20 0 PDlclrDEL 1 3 0 0 0 PDlsetDEL 1 TAP 0 0 50 PD1lselDEL 1 TAP 0O 1 100 PD1lselDEL 1 TAP 0 2 150 possibly load some filter coefs PDlsyncall 1 The code shown above will program channed 0 of the delay processor to generate Ims 2ms and 3ms delays from its first three tap outputs It then alludes to filter coef loading The PD1syncall call is then used to synchronously latch all parameters 2112 XBDRV Software Reference Route Scheduling Calls The PD1 s Real Time Router RTR is programmed to run a specified routing schedule on each tick of the sampling clock The routing schedule is programmed using the following set of XBDRV calls Route order within ea
56. 4 or CHALL fn filter number 0 1 2 corresponding to F_HP F_LP F_NT respectively coef filter coefficients BO B1 B2 A1 A2 Notes Thefilter number represents one of three cascaded filter banks User coefficients may be downloaded to any of these banks i e one could download coefficients for a notch filter to filter number 0 See the end of this section for instructions on how to generate filter coefficients with Matlab DB4getfilt will not return an indication that user specified coefficients have been loaded Example This example downloads filter coefficients for a 5 kHz notch filter to filter bank number 1 float coef 5J 0 9845 1 3925 0 9845 1 3925 0 9691 DB4userfilt 1 CH2 1 coef 2306 XBDRV Software Reference D B4setiT int din int chan int it Op Code Prototype Description Arguments Example DB4 SETIT 0x15 void DB4setlT int din int chan int it Sets the impedance threshold for specified channel This threshold controls the behavior of the impedance LEDs on the headstage din Device index number chan CH1 CH2 CH3 CH4 or CHALL it impedance threshold 1 99 kOhms This example sets the impedance threshold on channel 1 to 5000 ohms 5k ohms and channel 2 to 6000 ohms 6 kohms DB4setIT 1 CH1 5 DB4setIT 1 CH2 6 D B4nchan int din int nc Op Code Prototype Description Arguments Example DB4 NCHAN 0x16 void DB4nchan int din int nc Set to the
57. 6 XBDRV Software Reference this page intentionally left blank ET1 Event Timer 601 ET1 Event Timer ET 1clear din Op Code Prototype Description Arguments Example ET1 CLEAR 0x11 void ET i1clear intdin Resets the ET1 to the default factory configuration The ET1 default configuration is as follows Event Timing from Single Input No Block Counting Normal Enable FIFO Cleared din Deviceindex number ETlclear 1 Resets ET1 1 ET1go din Op Code Prototype Description Arguments Example ET1 GO 0x15 void ET1go int din Takes the ET1 out of IDLE mode and tells it to begin recording counting events NOTE The ETTS timer counter is automatically reset and a block marker zero is placed in the FIFO memory din Deviceindex number ETlgo 1 delay 100 ETlstop 1 This block of code will program the ET1 to record events for approximately 100 milliseconds 602 XBDRV Software Reference ET Istop din Op Code Prototype Description Arguments Example ET1 STOP 0x16 void ET 1stop int din Places the ET1 in idle mode In this mode the ET1 timer counter is halted and no data is written to the FIFO memory din Deviceindex number See ET 1go ET lread16 din Op Code Prototype Description Arguments Example ET1 READ 0x22 int ET 1read16 int din Reads a 16 bit value from the ET1 s FIFO memory If the FIFO is empty the value of 1 is
58. B4 GETIT 0x22 Prototype int DB4getlT int din int chan Description Returns the impedance threshold setting from the specified channel Arguments din Device index number chan CH1 CH2 CH3 CH4 Example The following example reads the impedance threshold from the DB4 channel 1 Ine BI IT DB4getIT 1 CH1 D B4getchmode int din Op Code DB4 GETCHMODE 0x23 Prototype int DB4getchmode int din Description Returns the channel mode from the specified DB4 Arguments din Device index number DB4 Digital Biological Amplifier 2315 D B4getmud int din Op Code DB4 GETCHMODE 0x24 Prototype int DB4getchmode int din Description Returns the last manual update made to DB4 The number returned consists of the the channel changed upper 4 bits and the function changed lower 4 bits Returns 0 if no manual update has been made Value is reset to 0 after DB4getmud is run Channel Constants CH1 0x0 CH2 0x1 CH3 0x2 CH4 0x3 CHALL Oxa Function Constants MUD_GAIN Ox2 MUD_HP 0x3 MUD LP 0x4 MUD NT 0x5 MUD IT 0x6 MUD ALL Oxf Arguments din Device index number Example The following code checks for the last change made manually to the DB4 The return value will be 0x12 decimal 18 if the channel 2 gain has been changed int mud mud DB4getmud 1 2316 XBDRV Software Reference Binary D ecimal Conversion Chart This chart can assist you in decoding the bit pattern returned by DB4getclip and DB4impsc
59. C O 3 IB 0 15 OB 0 15 PD1 Referencing Variables 2103 Convolving DSP selector DSP mono input port DSP left channel input port DSP right channel input port DSP mono output port DSP left channel output port DSP right channel output port DSP coefficient input port Delay Processor input port Delay tap output port 0 31 selects tap Delay tap specification input port D A Converter input port A D Converter output port Inbound data stream Outbound data stream The variables shown above are initialized when PD 1clear is called These variables will NOT be valid until PD 1clear has been called 2104 XBDRV Software Reference PD1 Basic Calls The PD1 Power SDAC can be programmed and operated much like other TDT D A A D converters The PD1 XBUS drivers described here include a PD1mode call to make the PD1 compatible with the DD1 thus allowing the use of standard DA and AD auto detecting calls PD 1clear din Op Code PD1 CLEAR 0x1E Prototype void PD 1clear int din Description Clears the specified PD1 and resets it to factory default settings Also resets the RTR Analog Interface and Router Schedule by calling PD lresetRTE PD 1ciriO and PD 1cirsched Refer to specifications on these calls for more information Arguments din Device index number Defaults Sampling rate 1 20us 50kHz of conversions 1000 Single triggering Unlike other D A A D devices PD 1mode must be called to enab
60. D1 TGO 0x21 void DDltgof int din Similar to DD 1go but causes the specified DD1 to wait for a global or local XBUS trigger before taking action see XB1gtrig and XBIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number Example DD1 Stereo Analog Interface 1503 r DDlarm r 1 DDlarm 2 DD1tgo 1 DD1tgo 2 XBlgtrig Global trigger This will cause DD1 1 and DD1 2 to begin conversion at precisely the same time DD lmode din mcode Op Code Prototype Description Arguments DD1 MODE 0x14 void DD1mode int din int mcode Selects which of the specified DD1 s four channels will be used for conversion The combination of A D and D A channels to be used is specified by the lower four bits of mcode din Deviceindex number mcode Mode code 0x00 0x0F DAC1 0x01 D A channel 1 DAC2 0x02 D A channel 2 DUALDAC 0x03 Both D A channels ADC1 0x04 A D channel 1 ADC2 0x08 A D channad 2 DUALADC O0x0C Both A D channels FASTDAC 0x10 Fast single channel D A ALL OxOF All channels converting Other combinations are achieved by directly setting bits 0 3 of mcode bit 3 bit2 bitl bit ADC2 ADC1 DAC2 DAC1 or by adding the above defined constants as in the following example NOTE FASTDAC places the DD1 into a special D A channel 1 only mode with 500kHz sampli
61. D1mode assumes your PD 1 has two DAC and two ADC channels similar to the DD1 PD Imode creates the routing schedule necessary to use the specified channels For example calling PD Imode 1 DAC2 DUALADC will result in the following commands being sent to the PD1 PDiclrsched 1 PDinstrms 1 1 2 PDispecIB 1 IB 0 DAC 1 PDispecOB 1 OB 0 ADC 0 PDIlspecOB 1 OB 1 ADC 1 din Device index number mcode Any combination of the DACY 2 and ADCY 2 constants see D D lmode for a description You must use the PD 1 function calls nstrms speciB specOB etc to make use of the third and fourth channels FASTDAC modeis not available on the PD1 PD 1clear 1 PDimode 1 DAC1 required AP2 play call PDlarm 1 PDlgo 1 This example will reset PD1 1 to its default setting and begin conversion from DAC channel 1 PD1 Basic Calls 2107 PD Instrmsf din nIB nOB Op Code PD1 NSTRMS 0x14 Prototype void PD1nstrms int din intnIB intnOB Description ThePD1Instrms call is used to tell the PD1 how many Inbound AP2 gt PD1 and Outbound PD1 gt A P2 data streams it should process Be careful to match the number specified here with the play and record specifications made on the AP2 For example if two Inbound streams are specified with PD 1nstrms then dplay should be used setup the A P2 to feed the proper number of data streams Note this procedure also calls PD InstrmsRTE Arguments d
62. Example PM1 CLEAR 0x11 void PM 1clear int din Clears the PM 1 to its factory default settings All speakers off Exclusive mode Mono configuration din Deviceindex number PMiclear 3 Resets PM 1 3 to factory default mode see above PM lconfig din ccode Op Code Prototype Description Arguments Example PM1 CONFIG 0x12 void PM 1config int din int ccode Sets the PM 1 configuration to either mono or stereo This call has no affect when deviceis running in common switching mode see below Also the manual MON O STEREO switch should be set to the desired operating mode din Deviceindex number ccode Deviceconfiguration code use PM1 MONO 1 PM1 STEREO 0 see below 2002 XBDRV Software Reference PM 1lmode din mcode Op Code Prototype Description Arguments Example PM1 MODE 0x13 void PM1mode int din int mcode Programs the PM 1 to run in either Exclusive or Common mode In common mode any number of speakers can be switched on at the same time In exclusive mode only one speaker per channel will be allowed on at any given time The PM 1 will automatically turn off other speakers before turning on the specified speaker Warning damage to amplifiers etc may result if more than one speaker load is placed in parallel across its outputs Refer to your amplifier documentation for pertinent information din Deviceindex number mcode Device mode code use EXCLUSIVE
63. GAIN 0x1F void AD2gain int din int chan int gain Sets the gain factor which the AD2 will use on a specific input channel Unless specified with AD 2gain channel gains default to x1 NOTE If used AD 2gain must follow an AD2mode or AD 2xchans command NOTE Gain factors x16 through x128 are disabled with factory default Use of these gains may degrade system performance and is discouraged These gains can be enabled by singling the jumper on the lower left of the back of A D2 din Deviceindex number chan Channel to set gain on 1 128 gain Channd gain factor 0 7 x1 0 x16 4 x2 1 x32 5 x4 2 x64 6 x8 3 x128 7 for i 1 1 lt 5 it AD2gain 1 i x8 This will set the gain factor on channels 1 4 of AD2 1 to x8 AD 2strig din Op Code Prototype AD2 STRIG x1A void AD2strig int din 1606 XBDRV Software Reference Description Arguments Example Sets up the specified AD2 for single triggering of a conversion buffer AD 2strig can be issued while the A D2is active see example under AD 2mtrig din Deviceindex number AD2strig 1 AD2arm 1 This will cause AD2 1 to begin converting on an external trigger or AD2go but will not re trigger unless an AD 2arm isissued again AD 2mtrig din Op Code Prototype Description Arguments Example AD2 MTRIG 0x19 void AD2mtrig int din Sets up the specified AD2 for multiple external triggering of a conversion buffer NOTE AD2s
64. Iclip int din Returns the status of the clip detector Return Values O If no clip has occurred 1 If aclip has occurred din Deviceindex number DAlclipon 1 DAlarm 1 1310 XBDRV Software Reference DAlgo 1 do if DAlclip 1 DAlstop 1 while DAlstatus 1 ACTIVE This example will stop DA1 1 if the D A dips at any time AD1 Dual A D Converter 1401 AD1 Dual A D Converter AD 1clear din Op Code Prototype Description Arguments Defaults Example AD1 CLEAR 0x1E void AD 1clear int din Clears the specified AD1 and resets it to factory default settings din Deviceindex number Sampling rate 1 20us 50kHz of conversions 1000 Channel mode ADC1 Single triggering Clip feature disabled See example for AD 1go AD larm din Op Code Prototype Description Arguments Example AD1 ARM 0x13 void ADlIarm int din Prepares the specified AD1 for A D conversion AD larm must be issued before the AD1 can be triggered from software or externally to start conversion din Deviceindex number See example for AD 1go AD 1go din Op Code Prototype Description Arguments Example AD1 GO 0x11 void AD1go int din Triggers the specified AD1 from software to begin A D conversion AD larm must be issued first to prime theAD1 din Deviceindex number ADliclear 1 ADlarm 1 1402 XBDRV Software Reference AD1go 1 This examp
65. RTE_SPECIB 0x0109 void PD1specl B int din int ibn int des Use this call to specify the destination resource port for an Inbound data stream AP2 gt PD1 If the stream will be dynamically assigned there is no need to call this procedure din Device index number ibn Inbound stream number Use IB 0 15 des Destination port PDlclear 1 PDinstrms 1 1 0 PDlclrsched 1 PDispecIB 1 IB 0 DAC 1 This program segment will program the PD1 as a single channel D A converter Data will be converted from DAC 1 second D A channel 2116 XBDRV Software Reference PD 1specO B din obn src Op Code Prototype Description Arguments Example RTE SPECOB 0x0112 void PD1specOB int din int obn int src Use this call to specify the source resource port for an Outbound data stream PD1 gt AP2 Outbound streams cannot be dynamically assigned and therefore must be specified using PD1specOB Refer to PD1 User s Guide for rules on specifying Outbound steams din Device index number ibn Inbound stream number Use IB 0 15 des Destination port PDlclear 1 PDinstrms 1 0 2 PDlclrsched 1 PDispecIB 1 OB 0 ADC 0 PDlspecIB 1 OB 1 ADC 1 This program segment will program the PD1 as a two channel A D converter PD1 DSP Calls 2117 DSP Calls When running in convolver mode DSPs are programmed primarily through data records sent to their coefficient inputs A DSP is reset
66. Same as 0x04 Thelower four bits in slcode select DAC output capacitance as follows 1000pF 560 220 100 ceed 1 slcodebit FSE Call DA3clear to turn slew correction off Example DA3setslew 1 0x09 Sets an output load capacitance of 1100pF on the DAC outputs of DA3 1 off on DA3 2 4 8 Multi Channel Instrumentation D A 1711 D A 3zero din Op Code Prototype Description Arguments Example DA3 ZERO 0x23 int DA 3zero int din Zeroes all DA3 outputs din Deviceindex number DA3go 1 do if kbhit DA3stop 1 DA3zero 1 Jwhile DA3status 1 ACTIVE This example will stop DA3 1 and zero all outputs if akey is pressed during D A conversion 1712 XBDRV Software Reference this page intentionally left blank Auto Detecting Calls 1801 Auto Detecting Calls XBDRV includes a series of procedures that are helpful to those writing applications for use with different TDT modules The current System II line includes three D A and three A D module options Although each device has its own special features they are programmed using nearly identical XBUS calls To make an application program automatically detect and control the installed A D and D A module one might include a conditional block such as the one shown below implements D A stop command if XBldevice DD1_CODE 1 DD1stop 1 else if XBldevice DA1 CODE 1 DAlstop 1 else if
67. The following diagram illustrates the relation between mask bits and the TG6S front panel BNCs Thus bit mask position O corresponds to channel 1 of the TG6 and bit mask position 4 corresponds to channel 5 of the TG6 Bit mask positions 6 and 7 are not used in setting the TG6 msb BIT MASK sb 7 6 5 4 3 2 1 0 TRIG CLOCK o 1102 XBDRV Software Reference Binary Hexadecimal Conversion Chart This chart can assist you in determining the appropriate hexadecimal code for selecting different combinations of channels In C hexadecimal numbers are preceded by Ox In Pascal hexadecimal numbers are preceded by S a Peme ile hex Examples To set a mask for channels 2 4 and 6 00101010 in binary you would use a mask number of 2A in hex This can be easily determined from the chart above because 0010 the left hand four digits of the binary code is 2 in hex and 1010 the right hand four digits of the binary code isA in hex Thus put together 00101010 equals 2A in hex To set a mask for channels 2 3 and 4 00001110 in binary you would use a mask number of 14 decimal or OE in hex In C you would write 0x0E in Pascal you would write SOE TG6 Timing Generator 1103 TG 6clear din Op Code Prototype Description Arguments Example TG6 CLEAR 0x11 void TG6dear int din Clears all timing sequences and sets all outputs low Default co
68. XBDRV Software Reference for System II XBUS Devices Software version 2 20 Printed 10 1 98 Device Index AD1 Dual A D Converter 1401 AD2 Instrumentation A D Converter 1601 Auto detecting calls 1801 CG1 Clock Generator 401 DA1 Dual D A Converter 1301 DA3 2 4 8 Multi Channel Instrumentation D A 1701 DB4 Digital Biological Amplifier 2301 DD1 Stereo Analog Interface 1501 ET1 Event Timer 601 HTI Head Tracker Interface 2201 PA4 Programmable Attenuator 201 PD1 Power SDAC 2101 PF1 Programmable Filter 901 PI1 Parallel Interface 701 PI2 Parallel Interface 1001 PM1 Power Multiplexer 2001 SD 1 Spike Discriminator 501 SS1 Programmable Signal Switcher 1901 SW 2 Cosine Switch 301 TG6 Timing Generator 1101 WG1 Waveform Generator 801 WG2 Waveform Generator 1201 XB1 Device Caddie 101 XBDRV Software Reference this page intentionally left blank Table of Contents XBDRV Software Reference Table of Contents XBDRV Software Reference Table of Contents XBDRV Software Reference Table of Contents XBDRV Software Reference Table of Contents XBDRV Software Reference Table of Contents XBDRV Software Reference THIS PAGE INTENTIONALLY LEFT BLANK Introduction 1 Introduction The XBUS driver software package XBDRV is a complete high level language interface for the XBUS product line Although direct programming of XBUS devices is a straightforward task the XBDRV package adds
69. XBldevice DA3 CODE 1 DA3stop 1 Obviously this implementation would be difficult to manage To address this problem XBDRV includes a set of auto detecting calls that implement this functionality using the more efficient switch case statement The auto detecting calls set up two global variables dadev and addev when the DAclear and ADclear calls are made These variables are then used in subseguent DA and AD calls to select the installed hardware device and to call the appropriate procedure Thefollowing example illustrates this implementation 1802 XBDRV Software Reference DAstop call void DAstop gint din switch dadev case DD1 CODE DDistop din break case DA1 CODE DAlstop din lt lt break case DA3 CODE DA3stop din break case PD1 CODE PD1stop din break default xcaller char e DAstop dn showerr No D A device IDed When using the auto detecting calls a few points must be noted First the DAclear and AD clear calls are not optional they must be called so that the dadev and addev variables will be set properly Secondly differences between devices must be handled by the application program For example if the DA3 s slew reduction is to be enabled when this device is present the following statements must be included in the application program if XBldevice DA3_CODE 1 DA3setslew 1 AUTOSLEW Auto Dete
70. ab The following commands show how to generate Butterworth filter coefficients from the Matlab command line The sample rate is 48 kHz for the 2 channel HS4 headstage and 24 kHz for the 4 channel H S4 headstage Prototype B A butter order Corner Frequency sample rate Low pass Example 1000 Hz low pass filter for 2 channel HS4 B A butter 2 1000 48000 Matlab returns B 0 0010 0 0020 0 0010 A 10000 1 9075 0 9116 The first A coefficient is always assumed to be 1 and is not used in the DB4userfilt command High pass Example 1200 H z high pass filter for 4 channel HS4 B A butter 2 1200 24000 high Notch Example 1000 Hz Notch with 100 Hz band for 2 channel HS4 This example generates a notch filter that can be loaded to one filter block The notch is 1 order i e 6dB per octave BA butter 1 950 1050 48000 stop Band pass Example 1000 to 5000 Hz band pass filter for 4 channel H S4 This example generates a band pass filter that can be loaded to one filter block The pass band is 1st order i e 6dB per octave B A butter 1 1000 5000 24000 MC1 Motor Controller 2401 MC1 Motor Controller Overview This section describes the commands used to program the MC1 from a computer See the MC1 Tear Sheet for information on the operation of the controller through the front panel M Ci1clear int din Prototype void MCilclear int din Description Clears the specified
71. above will cause the A D2 1 to stop after a short delay period AD 2tgo din Op Code Prototype Description Arguments Example AD2 TGO 0x23 void AD2tgo int din Similar to AD2go but causes the specified AD2 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number AD2arm 1 AD2 Instrumentation A D Converter 1603 AD2arm 2 AD2tgo 1 AD2tgo 2 XBlgtrig Global trigger This will cause AD2 1 and AD2 2 to begin conversion at precisely the same time AD 2sh din shmode Op Code Prototype Description Arguments AD2_SH 0x20 void AD2sh int din int shmode Enables or disables the individual sample hold amplifiers on the AD2 s four main channels or on the external multiplexer channels of MX1SH Disabling the sample holds results in a slight improvement of signal to noise ratio Enabling the sample holds results in simultaneous sampling of all four channels NOTE If used AD2sh must precede an AD 2mode or AD 2xchans command din Device index number shmode Sample hold mode OFF 0 ON 1 1604 XBDRV Software Reference AD 2mode din mcode Op Code Prototype Description Arguments Example AD2 MODE 0x14 void AD2modef int din int mcode Selects
72. al device however 10 dB gain is valid only when signal is applied at left 8 channels These are marked as INPUT channels 1902 XBDRV Software Reference Arguments Example WARNING When selecting 10 dB gain do not exceed 10V peak input output level Otherwise unpredectable operation will be resulted din Deviceindex number SSlgainon 3 This will turn on the gain of the SSI having din 3 SSlgainoff din Op Code Prototype Description Arguments Example SS1 GAINOFF 0x13 void SSlgainoff int din Turns off the 10 dB gain at inputs 1 2 5 and 6 See SSlgainon din Deviceindex number SSlgainoff 5 This will turn off the gain of the SS1 having din 5 SSlmode din mcode Op Code Prototype Description Arguments Example SS1 MODE 0x14 void SSIimode int din int mcode Sets the SST s switching mode din Deviceindex number mcode Device switching mode pre defined as QUAD 21 0 DUAL 41 1 SNG81 2 SSlmode 1 DUAL 4 1 This sets the SS1 as a dual 4 to 1 or 1 to 4 switch SS1 Programmable Signal Switcher 1903 SS1select din chan inpn Op Code Prototype Description SS1 SELECT 0x15 void SSiselect int din int chan intinpn Connects the specified input channel inpn to the specified output channel chan Arguments din Deviceindex number chan Device channel number 0 through 3 marked as A through B inpn Device input number In quad 2 to 1 mode inpn
73. alues that may be set by the user from the front panel of the MCT and then reset values in software Arguments din Device index number parcode velocity in units s PC VEL 1 PC ACC 2 PC GEAR 3 PC MINP 4 PC MAXP 5 PC HOME 6 PC REFMODE 7 2408 XBDRV Software Reference PC SRCHVEL 8 PC REFPOS 9 PC Kp 10 PC Ki 11 PC Kd 12 PC Ilim 13
74. ample PD1stop 1 PDiclrI0O 1 This code is typical of how the PD1 can be stopped asynchronously and then its DAC outputs forced to zero volts PD lsetlO din dt1 dt2 atl at2 Op Code Prototype Description Arguments Example RTE SETIO 0x0117 void PD1clrlO gint din float dt1 float dt2 float at1 float at2 Sets up LED indicator thresholds for the DAC and ADC channels By default the yellow LEDS will light for signals greater than 0 04 volts and the red LEDS will light when voltages are greater than 5 0 volts These defaults can be overridden using PD1setlO din Device index number dtl Yellow LED threshold for DACs 0 10 0 dt2 Red LED threshold for DACs 0 10 0 atl Yellow LED threshold for ADCs 0 10 0 at2 Red LED threshold for ADCs 0 10 0 PDlsetIO 1 0 01 9 99 0 01 9 99 2122 XBDRV Software Reference This above call will set the red LED thresholds to 9 99 volts and the yellow LED thresholds to 0 01 volts PD 1whatlO din Op Code Prototype Description Arguments Example RTE_WHATIO 0x01114 qint PD1whatlO int din This call returns micro code version and device information for the installed analog I O hardware Refer to PD 1 User s Guide for more information on decoding the returned value din Device index number See PD 1 User s Guide PD1 Delay Processor Calls 2123 Delay Processor Calls The PD Lis optionally equipped with the DP2 delay processor
75. an 224 0000 1111 1111 0000 240 Examples A decimal value of 12 corresponds to the bit pattern 0000 1100 For DB4getclip this would mean that channels 3 and 4 have analog clipping at the headstage For decoding decimal values larger than those shown in this table find the decimal value in the right hand column that is closest to but not greater than the returned value The four most significant bits i e the 4 left most bits for that decimal value form the four most significant bits of the returned value To determine the four least significant bits subtract that decimal value from the returned value The remainder decimal value which will be between 0 and 15 form the four least signficant bits i e the 4 rightmost bits of the bit pattern DB4 Digital Biological Amplifier 2317 For example the bit pattern for 238 would be the bit pattern for 224 1110 followed by the bit pattern for 14 i e 238 224 which is 1110 So the bit pattern for 238 is 1110 1110 When you are programming you should make use of the bit shifting features of your programming language e g lt lt and gt gt in C to decode bit patterns automatically 2318 XBDRV Software Reference Generating Filter Coefficients with M atlab The DB4 Controller accepts user downloaded filter coefficients for any of its three filter banks See the programming guide for more information It is quite simple to generate filter coefficients with Matl
76. at dc Sets the DC shift level in the output waveform NOTE This shift remains on the output even when the signal is gated off DC shifting is useful when generating AM modulated signals din Deviceindex number dc DC shift level in volts 9 9 9 9 WG2dc 1 1 0 This programs WG2 1 output to have a 1 0 V DC shift WG 2shape din scode Op Code Prototype Description Arguments Example WG2 SHAPE 0x19 void WG2shapef int din int scode Selects the WG2 waveform shape The valid shape types are listed below din Deviceindex number scode Shape type code 1 4 GAUSS Gaussian noise UNIFORM Uniform noise SINE Sine wave WAVE User defined shape WG2amp 1 6 00 WG2shape 1 GAUSS WG2on 1 This will program WG2 1 to produce a Gaussian noise signal with a 6 volt maximum amplitude 1206 XBDRV Software Reference WG 2dur din dur Op Code Prototype Description Arguments Example WG2 DUR 0x1A void WG2durf int din float dur Sets enables the WG2 s salf timing feature When the self timer is enabled the signal will gate on when a valid trigger is detected and gate off after the specified duration Specify a duration of zero for continuous output din Deviceindex number dur Duration of gatein ms 1 30 000 WG2trig 1 POS_EDGE WG2rf 1 0 0 WG2shape 1 SINE WG2freq 1 1000 WG2phase 1 90 0 WG2dur 1 2 WG2on 1 This program will produce th
77. b bn N filter order ntaps Number of delay line taps N 1 PFlfirl6 1 bcoefs 64 This downloads a 64 tap FIR to PF1 1 and starts the filtering process PF1fir32 din bcoefs ntaps Prototype Description Arguments void PFilfir32 int din float bcoefs int ntaps Downloads a floating point array containing the desired FIR tap coefficients and starts the filtering process Floating point to integer conversion is done by the routine Precision is 32 bit and coefficients must lie within the 2 30 format range 2 0 lt b lt 2 0 din Deviceindex number bcoefs Array containing feed forward coefficients b b b bn N filter order ntaps Number of delay line taps N 1 Example PF1Programmable Filter 905 PF1fir32 1 bcoefs 64 This downloads a 64 tap FIR to PF1 1 and starts the filtering process PF liir32 din bcoefs acoefs ntaps Prototype Description Arguments Example void PFIiir32 int din float bcoefs float acoefs int ntaps Downloads two floating point arrays containing feedforward and feedback tap coefficients for a Direct II IIR filter and starts the filtering process all in a single call Floating point to integer conversion is done by the routine Precision is 32 bit and coefficients must lie within the 8 24 format range 128 0 lt b a lt 128 0 WARNING Direct Il IIR s are inherently limited to approximately 8 th order depending on f
78. ch routing schedule is determined by simple routing rules Refer toPD1 User s Guide for more information on these rules PD 1cirsched din Op Code Prototype Description Arguments Example RTE_CLRSCHED 0x0106 void PD1drsched int din Clears the current routing schedule and readies the PD1 s RTR for receiving routing calls It is important that all PD1 route scheduling calls be made immediately following the PD 1clrsched call Do NOT intermix calls in this group with other PD1 Calls din Device index number See PD laddsimp PD1 Route Scheduling Calls 2113 PD laddsimp din src des Op Code Prototype Description Arguments Example RTE ADDSIMP 0x0107 void PDladdsimp int din int src int des Adds a simple route to the current route schedule Simple routes are used to interconnect two PD1 resources when there is a single source no mixing Be careful to follow ordering rules when scheduling routes involving DSPs see PD 1 U ser s Guide din Device index number src Route source port Use DSPout DELout or ADC des Route destination port Use DSPin COEF DELin TAP or DAC PDlclrsched 1 PDladdsimp 1 DSPout 0 DAC 0 PDladdsimp 1 ADC 0 DSPin 0 These three calls will program a routing schedule that will pass the signal from ADC O through DSP 0 and out DAC O Note the ordering of the scheduling calls whereby the DSP is read before it is written Refer to PD1 Use s Guide fo
79. constants which may be altered to better suit the user s needs These constants will be found at the top of the XBDRV H file It is recommended these constants be altered only if problems occur while using XBDRV BRK kk kk kk kk kk k k k K K k K K RR A RRR I I I User programmable control constants oko oko oko oko oko oko oko oko oko oko oko ok oko oko oko oko oko ok ok kok kok kok kok kok kok kok kok kok define XB MAX DEV TYPES 32 fine XB MAX OF EACH TYPE 16 fine XB TIMEOUT fine XB MAX TRYS X X fine XB MAX NUM RAC 120 X X X fine XB WAIT FOR ID 8 XBDRV Software Reference Device Type Identification Codes XBDRV defines a unique Device Type Identification Code for each XBUS device In the identification procedure these codes are used as the index to the xcode matrix which is where the XBUS Location Numbers XLNs are stored BRK KR kk kk kk kk k k k K k K A AK AA AAA XXX RR I IO I Device ID codes oko oko oko oko oko ok oko oko oko oko oko oko oko oko oko oko oko ok kok kok kok kok kok kok kok kok oko fine PA4 CODE 0x01 fine SW2 CODE 0x02 fine CG1 CODE 0x03 fine SD1 CODE 0x04 fine ET1 CODE 0x05 fine PI1 CODE 0x06 fine UI1 CODE 0x07 fine WG1 CODE 0x08 fine PF1 CODE 0x09 fine TG6 CODE 0x0a fine PI2 CODE 0x0b fine WG2 CODE 0x0c fine VC1 CODE 0x0d fine SS1 CODE 0x0e fine PM1 CODE Ox0f fine HTI CODE Oxla DA1_CODE D1_CODE D1 CODE A2 CODE
80. correspond to true bits 1 s in Imask other outputs are unchanged and the time period is specified by the _beg and end parameters din Deviceindex number snum Sequence number 0 7 beg Seq position to begin at 0 seq Igth 1 _end Seq position to end at beg l seq loth 1 Imask Bit locations to set low 0 63 Ox3f dec hex TG6baserate 1 _1ms TG6new 1 3 200 0x05 TG6low 1 3 25 75 0x05 TG6low 1 3 100 115 0x05 This defines a new timing sequence 3 and sets outputs 1 and 3 set default high by TG 6new to produce the timing sequence shown below TG6 Outputs 1 and 3 0 25 75 100 115 199 All other outputs remain unchanged from their default states TG6 Timing Generator 1109 TG 6value din snum beg end Op Code Prototype Description Arguments Example val TG6 VALUE xla void TG 6value int din intsnum int_beg int_end int val Sets a specific bit pattern on TG6 outputs for an interval of a timing sequence It combines the actions of TG6high and TG6low by setting all outputs to the bit pattern of val I Nigh 0How over the time period specified by the _beg and end parameters NOTE Unlike TG6high and TG6low you cannot set or clear certain bits without affecting others din Deviceindex number snum Sequence number 0 7 _beg Seq position to begin at 0 seq Igth 1 end Seq position to end at beg 1 seq Igth 1
81. cting Calls 1803 Another situation that must be handled by the application program is when the DD1 or PD1isinstalled In this case the D A and A D are the same device Although the auto detecting calls add a compatibility advantage to your programs they also add complexity TDT does not recommend using these calls unless it is essential that your application runs on multiple TDT platforms The following is a list of available auto detecting calls For more detailed information on specifications examples and notes please refer to this document for discussions on device specific driver calls Note that calls not common to all D A or A D devices are omitted D A Calls DAclear din DAarm din DAgo din DAstop din DAtgo din DAmode din mcode D Astrig din DAmtrig din DAreps din nreps D Asrate din sper D Asperiod din sper DAnpts din npts DAclkin din scode DAclkout din dcode D Astatus din A D Calls AD clear din ADarm din ADgo din ADstop din ADtgo din AD mode din mcode ADstrig din AD mtrig din ADreps din nreps ADsrate din sper ADsperiod din sper ADnpts din npts ADclkin din scode ADclkout din dcode ADstatus din 1804 XBDRV Software Reference The following are issues to keep in mind when using the auto detecting calls e DAS e DA3 e DA3 e DD1 PD1 e PD1 e PD1 The D A and A D modules do not
82. d HTI to display the indicated parameter on its LED display din Device index number pid Parameter identification number P AZ 1 AZimuth angle P EL 2 ELevation angle P ROLL 3 ROLL angle PX 4 X displacement PY 5 X displacement PZ 6 Z displacement See H TlreadXYZ HTlreadAER din amp az amp el amp roll Op Code Prototype Description Arguments Example HTI READAER 0x14 void HTlreadAER int din float az float el float roll Reads the current rotation parameters azimuth elevation and roll angles from the specified HTI The returned angles will be in degrees with about a 0 02 degree resolution Note this call reguires that about 8 bytes of information be transferred between the HTI and the FASTRAK If speed becomes an issue try HTIfastA ER and or HTIreadone din Device index number az Pointer to return azimuth el Pointer to return elevation roll Pointer to return roll See H TlreadXYZ HTI Head Tracker Interface 2205 H TifastAER din amp az Gel amp roll Op Code Prototype Description Arguments Example HTI FASTAER 0xld void HTlfastA ER int din gint az gint e gint roll Reads the current rotation parameters azimuth elevation and roll angles from the specified HTI The returned angles will be in degrees This is the fast version of HTlreadAER The returned values will be 16 bit integers The angles will only be valid between 127 degrees and will have a 1 de
83. e is enabled the maximum sampling rate is limited to 100kH z din Deviceindex number See example under DA 3clip DA3 2 4 8 Multi Channel Instrumentation D A 1709 D A 3status din Op Code Prototype Description Arguments Example DA3 STATUS 0x1B int DA 3status int din Returns the status of the specified DA3 Return Values IDLE O0 DA3idle no conversion in progress ARM 1 DA3 armed ready for trigger ACTIVE 2 DA3conversion in progress din Deviceindex number do while DA3status 1 ACTIVE This will cause the program to pause while DA3 1 finishes converting the present sample buffer D A 3clip din Op Code Prototype Description Arguments Example DA3 CLIP 0x1D int DA3dip intdin Returns the status of the clip detector Return Values O If no clip has occurred 1 If aclip has occurred din Deviceindex number DA3clipon 1 DA3arm 1 DA3go 1 do if DA3clip 1 DA3stop 1 while DA3status 1 ACTIVE This example will stop DA3 1 if the D A clips at any time 1710 XBDRV Software Reference D A 3setslew din sicode Op Code DA3 SETSLEW 0x22 Prototype void DA3setslew int din int slcode Description Sets the amount of slew distortion correction by selecting the load capacitance placed on the D A converter outputs The capacitance is selected by the bits in slcode Arguments din Deviceindex number slcode Slew correction code AUTOSLEW 0x00
84. e output shown below Tigger Input WG 2rf din rf Op Code Prototype Description WG2 RF 0x1B void WG2rf int din float rf Sets the rise and fall time of the built in gating feature NOTE The WG2 has limited gating abilities Only the following gate rise fall times will give guaranteed results WG2 Waveform Generator 1207 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 20 30 40 50 60 70 80 90 Arguments din Deviceindex number rf Rise and fall time of gate in ms 1 0 90 0 Example WG2rf 1 3 0 This call sets the rise and fall times of 3 0 ms to WG2 _ 1 s gating circuit WG 2trig din tcode Op Code WG2 TRIG 0x1C Prototype void WGZtrig int din int tcode Description Programs the ENABLE TRIGGER input of the WGz2 The valid trigger types are listed below NOTE The duration feature works only with EDGE type see WG2dur and NONE manual triggering Arguments din Deviceindex number tcode Trigger type code 1 5 POS EDGE Rising edge triggered NEG EDGE Falling edge triggered POS ENABLE _ Highleve enabled NEG ENABLE Low level enabled NONE Free running Example WG2trig 1 POS EDGE This will program WG2 1 to rising edge triggered WG 2seed din seed Op Code Prototype Description Arguments WG2 SEED 0x1D void WG2seed int din long seed Sets the random number generator seed value din D
85. e round off problem associated with PD Israte call while the base clock limitation still apply See note under PD Israte PD Isperiod call is available for PD1 of hardware versions 5 0 and above and XBDRV versions 2 01 and above 2110 XBDRV Software Reference PD 1npts din npts Op Code Prototype Description Arguments Example PD1 NPTS 0x18 void PD 1npts int din long npts Sets the number of samples the specified PD1 will convert after it is triggered din Device index number npts Number of conversions 1 23 PDinpts 1 1 This call tells the PD1 to convert the maximum number of points possible This maximum number corresponds to about 24 hours at 50KH z PD 1clkin din scode Op Code Prototype Description Arguments Example PD1 CLKIN 0x16 void PD1clkin int din int scode Selects the source of the sampling dock for the specified PD1 This is useful for synchronizing PD1 conversions with other devices din Device index number scode Clock source 1 4 See DD Iclkin See DD Iclkin PD 1clkout din dcode Op Code Prototype Description Arguments Example PD1 CLKOUT 0x17 void PD1clkout int din int dcode Asserts the PDTS internal sampling clock onto an XBUS internal patch line This is useful for synchronizing other devices with PD1 conversions din Device index number dcode Patch line code 3 5 See DD Iclkin See DD Iclkout PD1 Basic Calls
86. e the device is triggered To generate non frozen noise call WG1phase 1 1 din Deviceindex number phase Phasein degrees 0 00 360 00 Use 1 to set the phase to continuous WGltrig 1 POS ENABLE WGishape 1 SINE WGlfreq 1 200 WGlphase 1 90 WGlon 1 WG1 Waveform Generator 805 This programs WG1 1 to produce a 200Hz sine wave with a 90 degree onset phase synchronized with the Enable input WG 1dc din dc Op Code Prototype Description Arguments Example WG1 DC 0x18 void WGldc intdin float dc Sets the DC shift level in the output waveform NOTE This shift remains on the output even when the signal is gated off DC shifting is useful when generating AM modulated signals din Deviceindex number dc DC shift level in volts 9 9 9 9 WGldc 1 1 0 This call programs WG1 1 output to have a 1 0 V DC shift WG Ishapef din scode Op Code Prototype Description Arguments Example WG1 SHAPE 0x19 void WG1Ishapef int din int scode Selects the WG1 waveform shape The valid shape types are listed below din Deviceindex number scode Shape type code 1 4 GAUSS Gaussian noise UNIFORM Uniform noise SINE Sine wave WAVE User defined shape WGlamp 1 6 00 WGlshape 1 GAUSS WGlon 1 This will program WG1 1 to produce a Gaussian noise signal with a 6 volt maximum amplitude 806 XBDRV Software Reference WG 1dur din dur
87. e the source code compatible with a wider range of compilers the following directive constants can be used to customize the XBDRV source code MSC turns on Microsoft C compatibility COMP 32 support for 32 bit compilers WINDOWS removes all error display using printf The XBDRV source code includes support for compilation with a 32 bit compiler such as WATCOM Version 9 0 When using this compiler the MSC COMP32 and INTMOVE defines must be made Note that the INTMOVE define replaces the 16 bit assembly in 1IO ASM with equivalent C code Controlling Two XBUSes Under most circumstances the XBDRV software will be used to control a single XBUS connected to either the TDT AP2 card or a standard PC serial port Under this condition the setup outlined in the Startup Guide using the DOS parameter works best Call XBlinit USE DOS at the start of each application program to initialize your system using the DOS parameter 6 XBDRV Software Reference If the XBUSes are interfaced to the PC via the AP2 card two XBUSes can be controlled from a single application program When using XBDRV with two XBUSes the DOS parameter is not used Under this condition the DOS utilities such as XBCOMINI EXE must be called twice with a command line argument specifying each AP2 For example the following calls should be made in your AUTOEXEC BAT file to initialize a system with two A P2s and two XBU Ses apld APa apld APb xbcomini APa xbcom
88. e will latch selected Imask input bits which become true after optional logic inversion until they are acknowledged by the host computer The latch is automatically cleared when the PI1 inputs are read from the host and then set again as soon as any input line in Imask is detected true on the next strobe cycle din Deviceindex number Imask Selection mask 1 Latch 0 No Latch See example under Pl lmap 710 XBDRV Software Reference Pl ldebounce din Op Code Prototype Description Arguments Example PIL DEBOUNCE 0x19 void Plidebounce int din Enables PI 1 s Debouncing feature on all input lines din Deviceindex number See example under Pl lmap PI Parallel Interface 711 Pl 1lstrobe din Op Code Prototype Description Arguments Example PIT STROBE 0x1A void Plistrobe int din Enables the PI1 s External Strobe input By default the PI1 uses an internal 10KHz timer to sample the Pll inputs and update the PI1 outputs This internal rate generator can be replaced by an external TTL signal with a frequency of up to 10KHz din Deviceindex number Plistrobe 1 This enables PIT 1 External Strobe input Pl loptread din Op Code Prototype Description Arguments Example PIL OPTREAD 0x1B int Pl loptread int din Reads the PET s optically isolated input port if installed din Deviceindex number i PIloptread 1 This call reads the state of PI1 PE1 1 s optically iso
89. eckDSPS int din Returns a long bit mask specifying all functioning DSPs installed in the PD1 You MUST call PD 1bypassD SP 1 OxOFFFFFFF before calling PD 1checkD SPS or the test will fail for any non bypassed DSPs din Device index number dmask PD1icheckDSPS 1 printf Functioning DSPs X X int dmask gt gt 16 int dmask amp Oxffff In a PD1 system with six convolver blocks 12 DSPs the above code will generate the following output Functioning DSPs OOFFF 2120 XBDRV Software Reference PD lwhatD SP din dspid Op Code Prototype Description Arguments Example RTE WHATDSP 0x01115 qint PD1whatDSP int din int dspid This call returns micro code version and device identification information for the specified DSP Refer to PD 1 User s Guide for more information on decoding the returned value din Device index number dspid DSP selection ID Use DSPid 0 27 See PD 1 User s Guide PD1 Analog I O Calls 2121 Analog I O Calls The PD1 can be configured with a variety of D A A D options Ataminimum atypical PD1 will be equipped with two channels of DAC and two channels of ADC Theinstalled analog interface can be programmed using the following calls PD 1clriO din Op Code RTE CLRIO 0x0117 Prototype void PD1drlO int din Description Clears all DAC outputs to zero volts and clears the digital portion of the analog interface back to zero Arguments din Device index number Ex
90. elay timefrom Hoop 1 0 10 5 20 ms dly wid 08ms lt dly i hnum wid Time width of hoop 0 011 0 830 ms upper Upper voltage level of hoop 9 8 9 9V lower Lower voltage level of hoop 9 9 9 8V lower lt upper SDihoop 1 1 RISE 0 0 0 0 1 0 0 9 SDlhoop 1 2 FALL 0 45 0 02 3 0 0 0 SD1 Spike Discriminator 503 SD1inumhoops 1 2 The figure shown below illustrates what you should see on your scope after making the above series of SD1 calls NOTE You must connect a 5 volt 1KHz tone to the SD1 input and trigger your scope from the first output 0 02msec Width 3v 1v Rise Ov lt 45msec gt SD Inumhoops din numhoops Op Code Prototype Description Arguments Example SD1 NUMHOOPS 0x16 void SDinumhoops int din int numhoops Tells the SD1 how many hoops to use when discriminating spikes Be careful not to tell the SD1 to use more hoops than you have specified using the SD lhoop call din Device index number numhoops Number of hoops 1 5 See the example given for SD lhoop 504 XBDRV Software Reference SD lcountf din Op Code Prototype Description Arguments Example SD1 COUNT 0x17 int SD 1count int din The SD1 automatically keeps a count of the number of accepted spikes it discriminates The SD 1count call can be used to retrieve that count NOTE The count is reset to zero each time SD 1go is called SD 1count w
91. em associated with DA Israte call while the base clock limitation still apply See note under D Alsrate DA lsperiod call is available for DA1 of hardware versions 5 0 and above and XBDRV versions 2 01 and above D A Inpts din npts Op Code Prototype Description Arguments Example DA1 NPTS 0x18 void DAlnpts int din long npts Sets the number of samples the specified DA1 will convert after it is triggered din Deviceindex number npts Number of conversions 1 22 DAlnpts 1 500000 This call will set up DA1 1 to perform 500 000 conversions which corresponds to 10 seconds at 50kH z sampling rate XBDRV Software Reference D A 1clkin din scode Op Code Prototype Description Arguments Example DA1 CLKIN 0x16 void DA1dkin intdin intscode Selects the source of the sampling dock for the specified DA1 This is useful for synchronizing DA 1 conversions with other devices din Deviceindex number scode Clock source 1 4 INTERNAL 1 Internal sample clock EXTERNAL 2 Front panel BNC XCLK1 3 XBUSpatch line XCLK2 4 XBUS patch line DAlclkin 1 EXTERNAL This call will set up DA1 1 to use its front panel BNC for the sampling clock D A 1clkout din dcode Op Code Prototype Description Arguments Example DA1 CLKOUT 0x17 void DAt1clkout int din int dcode Asserts the DAI s internal sampling clock onto an XBUS internal patch line This is useful for
92. er at 38400 baud WG 2on din Op Code Prototype Description Arguments Example WG2 ON 0x11 void WG2on int din Tells the specified WG2 to begin producing the programmed wave shape When using the external trigger enable WG2on acts as an overall device enable use WG 2off to disable the WG2 When the trigger mode is set to NONE WG2on will activate the WG2 output signal din Deviceindex number WG2trig 1 NONE WG2on 1 This will turn on the WG2 1 WG2 1 will produce waveform as configured prior to this call WG 2off din Op Code Prototype Description Arguments Example WG2 OFF 0x12 void WG2off int din Places the specified WG2 in IDLE mode WG 2off will act as an overall system disabler when the external trigger enable is used When triggering is set to NONE WG 2off will turn off the device s output signal din Deviceindex number WG2off 1 This will stop WG2 1 from producing output signal 1202 XBDRV Software Reference WG 2ton din Op Code Prototype Description Arguments Example WG2 TON 0x21 void WG2ton int din Similar to WG 2on but causes the specified WG2 to wait for a global or local XBUS trigger before taking action see XB1gtrig and XBIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number WG2trig 1 NONE
93. eviceindex number seed Random number seed value 1 22 1208 XBDRV Software Reference Example WG2shape 1 UNIFORM WG2seed 1 1000000 WG2on 1 This sets WG2 1 as a uniform noise generator and seeds it with 1 000 000 WG 2delta din delta Op Code Prototype Description Arguments Example WG2 DELTA 0x1E void WG2delta int din long delta Sets a precise sine wave frequency din Deviceindex number delta 2 frequency in Hz 55854 5 Hz 76895 636 frequency in Hz WG2shape 1 SINE WG2delta 1 long 76895 636 100 0 WG2on 1 Programs WG2 1 to produce a 100HZ sine wave WG 2wave din wave npts Op Code Prototype Description Arguments Example WG2 WAVE 0x1F void WG2wavef int din int wave int npts Uploads a user defined waveform into the WG2 sample buffer from a host PC din Deviceindex number wave Pointer to waveform buffer npts number of buffer points to use 1 800 c 32767 400 for 1 400 1 lt 400 i wave i 400 i c WG2wave 1 wave 800 WG2shape 1 WAVE WG2on 1 This uploads an 800 point zero DC shift ramp function into the WG2 1 and replays the contents of the sample buffer until gated off WG2 Waveform Generator 1209 WG 2status din Op Code WG2 STATUS 0x20 Prototype int WG2statusf int din Description Returns the status of the specified WG2 WARNING Calling WG 2status while the device is generating tones or convert
94. fied PA4 with the attenuation level specified The attenuation level is rounded to the nearest tenth of a dB 5 Arguments din Device index number level Attenuation in dB 0 0 99 9 6 Example PA4atten 1 20 0 Programs PA 4 1 with an attenuation of 20 0dB Description 1 The XBDRV operation format and name Usually this procedure name will be very similar to the device Op Code Corresponding device Op Code This is the primary device operation code used to implement the reguired device function Refer to individual device information sheets for more information on device Op Codes C prototype Brief description of what the procedure does This line will also disclose any limitations or special notes associated with the procedure Procedure Descriptions 21 5 Description of argument s This description includes acceptable ranges for each argument 6 An example call sometimes with other supporting calls is given for each procedure along with a brief description of what the call will do XB1 Device Caddie 101 XB1 Device Caddie XB 1linit cprt A Op Code Prototype Description Arguments Example N int XBlinit int cprt Initializes the XBUS system and returns true if successful If the cprt parameter is passed with USE DOS 0 the procedure checks the XBCOM DOS environment variable to identify and initialize the communication method being used This DOS selection method can be over
95. for i 0 i lt ntaps i PFlb16 din int bcoes i 0x8000 0 5 PFltype din FIR16 ntaps start filter This example shows how coefficients are scaled and downloaded to the PF1 for a 16 bit precision FIR filter Values in bcoes are floating point between 1 as required for the 1 15 format for this filter type 910 XBDRV Software Reference PFlal6 din coeff Op Code PF1 al6 0x17 Prototype void PF1al6f int din int coeff Description Downloads a 16 bit feed back denominator tap coefficient NOTE Floating point to integer scale value depends on coefficient format required by desired filter type see PF 1type code constants Arguments din Deviceindex number coeff Filter coefficient Example See PF1b16 PF1b32 din coeff Op Code PF1 b32 0x16 Prototype void PF1b32 int din int coeff Description Downloads a 32 bit feed forward numerator tap coefficient NOTE Floating point to integer scale value depends on coefficient format reguired by desired filter type see PFltype code constants Arguments din Deviceindex number coeff Filter coefficient Example See PF1b16 PF1a32 din coeff Op Code PF1 a32 0x18 Prototype void PF1a32 int din int coeff Description Downloads a 32 bit feed back denominator tap coefficient NOTE Floating point to integer scale value depends on coefficient format required by desired filter tyoe see PF 1type code constants Arguments din De
96. ft C Support The XBDRV C source code is provided in a format fully compatible with Borland Turbo C If you are using the Microsoft C compiler you should define MSC either in the compile command line or at the top of the program If you are programming under Microsoft WINDOWS you should also define WINDOWS The XBDRV is also compatible with other C compilers If you are using a different C compiler please refer to the user s guide for your compiler see Support for Other Compilers below Test your software installation by writing a simple C program The program listed below initializes your XBUS hardware using the XB linit procedure and setup a PA4 attenuation if you have a PA4 module In this example we will use the Turbo C compiler 1 Invoke the Turbo C editor environment and set it up to use proper memory model and other compiler linker options 2 Create a project file and include the following files in the project xbtstl c xbdrv c 3 Clear the editor and typein the following program include lt stdlib h gt include lt stdio h gt include xbdrv h void main void 4 XBDRV Software Reference int A clrscr if XBlinit USE_DOS printf Xn Error initializing XBUS n exit 0 for i 0 i lt 1000 i PA4atten 1 float i 10 0 4 Be certain the compiler is setup properly and then compile link and run the program If this simple program co
97. ftware Reference Example 3 Once for n trigs TG6reps 1 TRIGGED REPS 10 TG6arm 1 3 TG6 ready for ext TTL trigger TG6 1 will produce timing seguence number 3 once on each external trigger for 10 triggers and then stop responding to triggers TG 6new din snum Igth dmask Op Code Prototype Description Arguments Example TG6 NEW 0x17 void TG6new int din intsnum int lgth int dmask Defines a new timing sequence in a segment of the TG6 s memory Up to eight separate sequences can be defined and accessed independently and are retained until power is turned off or a TG 6clear is issued Each sequence is 6 bits wide one bit for each output and the total length of all seven sequences cannot exceed 32 767 ticks of the base clock period is set with TG 6baserate din Deviceindex number snum Sequence number 0 7 Igth Sequence length 0 32767 ticks dmask Default data mask 0 63 Ox3f dec hex the corresponding outputs are set default high TG6baserate 1 _1ms TG6new 1 3 200 0x05 This defines an area of TG6 memory for a new timing sequence 3 which will be 200 ms long The outputs 1 and 3 bits O and 2 are set high and outputs 2 4 5 and 6 bits 1 3 4 and 5 are set low 0x05 hex 000101 binary The default mask setting facilitates active high or low logic implementation using TG 6high and TG 6low TG6 Timing Generator 1107 TG 6
98. gree resolution din Device index number az Pointer to return azimuth el Pointer to return elevation roll Pointer to return roll int az el roll HTIclear 1 HTIgo 1 dol HTIfastAER 1 amp az el amp roll printf Az 4 2f El 4 2f Ro 4 2f n az el roll Jwhile kbhit HTIstop 1 void getch 2206 XBDRV Software Reference HTlreadXYZ din amp x amp y amp Z Op Code Prototype Description Arguments Example HTI READXYZ 0x15 void HTlreadXY Z int din float x float y float z Reads the current displacement parameters X Y and Z from the specified HTI The returned displacements will be in centimeters with about a 0 03 cm resolution din Device index number X Pointer to return X y Pointer to return Y Z Pointer to return Z float x y z HTIclear 1 HTIgo 1 HTIboresight 1 HTIshowparam 1 P_EL HTIreadAER 1 az amp el amp roll HTIreadXYZ 1 8x amp y amp 2 TIstop 1 HTIfastXYZ din 6x amp y amp Z Op Code Prototype Description Arguments Example HTI FASTXYZ O0xle void HTIfastxY Z int din int x int y int z Reads the current head movement parameters X Y and Z translations from the specified HTI This is the fast read version of HTIreadXYZ The returned values will be between 127 centimeters with a 1 cm resolution din Device index number X Pointer to return X y P
99. he FIFO If IN 2 is used as an acceptance pulse for recording an event time it must go high before the next event occurs on IN 1 ET levcount din Op Code ET1 EVCOUNT 0x14 Prototype void ETlevcount int din Description Places the ET1 in Event Counter mode In this mode the ET1 will count events rather than time stamp them Use ETlclear to return the ET1 to Event Timing mode Arguments din Deviceindex number Example If the line ET1evcount 1 is added to the beginning of the program example given for ET lcompare the FIFO contents would change to 0 4 3 2 ET 1lblocks din numblocks Op Code ET1 BLOCKS 0x19 Prototype void ET 1blocks int din int numblocks 606 XBDRV Software Reference Description Arguments Enables and programs the ETT s block counting feature When enabled this feature will cause the ET1 to time count events until a specified number of blocks have been recorded to the FIFO memory Set numblocks to O to disable the block counting feature din Device index number numblocks Number of blocks to record 0 32000 Example ET1 Event Timer 607 ETiclear 1 ETlcompare 1 ETlblocks 1 100 ET1go 1 do while ETlactive 1 Read in ET1 values Running this program with the ET1 connected as shown below will cause the system to record 100 blocks of data into the ET1 s FIFO memory Note that the COMPARISON mode has been selected so spontaneous activity is rec
100. he device being programmed The following XBUS devices are currently supported by XBDRV e XB1 XBUSDeviceCaddie e PA4 Programmable Attenuator e SW2 Cosine Switch e CG1 Clock Generator e SD1 Spike Discriminator e ET1 Event Timer e PI1 Parallel Interface e WG1 Waveform Generator e PF1 Programmable Filter e TG6 Timing Generator e PI2 Parallel Interface ll V R8A8B88 LPLELLLLLLLSELLLL SLL LSLSLE SESESE e WG2 Waveform Generator II Oc e SS1 Programmable Signal Switcher 0x0e e PMI Power Multiplexer OxOf e HTI Head Tracker Interface 0x1a e DA1 Dual D A Converter 0x10 e AD1 Dual A D Converter 0x11 e DD1 Stereo Analog Interface 0x12 e AD2 500KHzlInst A D 0x14 e DA3 Inst D A Converter 0x16 e PD1 Power SDAC Convolver 0x17 e HTI Head Tracker Interface OX1a e DB4 Digital Bio A mp OX 1b NOTE The values within parentheses are the XBUS Device Type Identifiers DTI XBDRV declares constants equal to these values in the following way define dev CODE dti example define PA4 CODE 0x01 20 XBDRV Software Reference Description Format Each XBDRV procedure will be listed and described according toa specific format Following is an illustration of this format for the PA 4atten operation The significance of each line is given after this example Example a PA 4atten din level 2 Op Code PA4 ATT 0x20 3 Prototype void PA 4atten int din float level 4 Description Programs the speci
101. high din snum beg end hmask Op Code TG6 HIGH 0x18 Prototype void TG6high int din intsnum int_beg int_end int hmask Description Sets selected TG6 outputs high for an interval of a timing sequence The outputs to set high correspond to true bits 1 s in hmask other outputs are unchanged and the time period is specified by the beg and end parameters Arguments din Deviceindex number snum Seguence number 0 7 beg Seq position to begin at 0 seq Igth 1 end Seq position to end at _beg 1 seq loth 1 hmask Bit locations to set high 0 63 Ox3f dec hex Example 1 TG6high 1 1 10 11 0x01 Channel 1 will produce a one count pulse at time 10 Example 2 TG6baserate 1 _1ms TG6new 1 3 200 0x00 TG6high 1 3 25 75 0x0a TG6high 1 3 100 115 0x0a TG6high 1 3 50 130 0x20 TG6new defines a new timing sequence 3 and sets all channels default low TG 6high sets outputs 2 4 and 6 to produce the timing seguence shown below TG6 Outputs 2 and 4 0 25 75 100 115 199 TG6 Output 6 0 50 130 199 All other outputs remain unchanged from their default states 1108 XBDRV Software Reference TG 6low din snum beg end Op Code Prototype Description Arguments Example Imask TG6 LOW 0x19 void TG6low int din intsnum int beg int end intImask Sets selected TG6 outputs low for an interval of a timing seguence The outputs to set low
102. ill return zero if Hoop 1 only is used din Deviceindex number SD1igo 1 delay for 1 second SDistop 1 printf XnXnSpikes d n n SDlcount 1 The above example will print the number of accepted spikes generated in a one second period SD lup din cbuf Op Code Prototype Description Arguments Example SD1 UP 0x18 void SDlup intdin char cbuf Uploads the current configuration from the specified SD1 The configuration is sent as a binary image 32 bytes long din Deviceindex number cbuf Pointer to a character buffer at least 32 bytes long char cbhuf 32 SDlup 1 cbuf Uploads current SD1 configuration into PC memory SD1 Spike Discriminator 505 SD ldown din cbuf Op Code Prototype Description Arguments Example SD1 DOWN 0x19 void SDi1down int din char cbuf Downloads a configuration from PC memory The configuration is sent as a binary image 32 bytes long NOTE The only reasonable source of this binary image is to upload it from the SD 1 din Deviceindex number cbuf Pointer to a character buffer at least 32 bytes long char cbhuf 32 SDlup 1 cbuf save cbuf to disk three days later load cbuf from disk SDidown 1 cbuf SD lup loads SD1 1 configuration to a PC buffer cbuf which can be saved to a file Later this configuration can be retrieved and put in a PC buffer cbuf again SD 1down uses cbuf to configure SD1 1 50
103. ilter type din Deviceindex number bcoefs Array of feed forward numerator coeff s b b b 0 b N filter order acoefs Array of feed back denominator coeff s ap a a a N filter order Note that a is always sent but not actually used ntaps Number of delay line taps N 1 PFliir32 1 bcoefs acoefs 5 This downloads a 4th order IIR to PF1 1 and starts the filtering process Each array contains 5 coefficients 906 XBDRV Software Reference PF1biq16 din bcoefs acoefs Prototype Description Arguments Example nbiqs void PFlbigl6 int din float bcoefs float acoefs int nbigs Downloads two floating point arrays containing feedforward and feedback tap coefficients for a Cascaded Bi quad IIR filter and starts the filtering process all in a single call Floating point to integer conversion is done by the routine Precision is 16 bit The coefficients in the two arrays must be ordered appropriately for the bi quad architecture and lie within the 214 format range 2 0 lt b a lt 2 0 din Deviceindex number bcoefs Array of feed forward numerator coeff s b by by bg by b O Dno Baas byl acoefs Array of feed back denominator coeff s ao a ap a Bois Ay Ojos am Anal N 2m filter order Note that the a s are always sent but not actually used nbigs Number of 2nd order 3 tap bi quad stages m PFlbigql6 1 bcoefs acoefs 4 This will download an amp th order
104. ime Out on COM Port break while inportb cpa xbsel 5 amp 0x20 outportb cpa xbsel datum if 1i gt xbtimeout showerr Transmission Time Out on COM Port break while inportb cpa xbsel amp 0x02 outportb cpa xbsel 1 datum gint iorec void 12 XBDRV Software Reference if xb_eflag return 0 if cc lt COM_APa if inportb cpa xbsel 5 amp 0x01 return inportb cpa xbsel s return 1 if inportb cpa xbsel amp 0x01 return inportb cpa xbsel 1 else return 1 XBDRV Nuts amp Bolts 13 Command Form Output Procedures XBDRV uses two procedures for sending XBUS commands in the form acknowledged by XBUS The procedure shortform is used to send single byte commands and the standform procedure is employed for multi byte commands In both procedures the common variable xIn is set using the getxIn procedure and in the standform procedure a checksum is calculated and appended to the transmission Finally both procedures use the processerr procedure for error handling void getxln qint din qint dtype char descrip xIn xbcode dtype din xbsel strcpy xcaller descrip if xln amp amp xb_eflag showerr Non present device referenced void shortform qint val gint i j long k if xb_eflag cmd 0 val j iosend xln amp 0x7f iosend val k 0 do i iorec
105. in mcode Op Code Prototype Description Arguments Example DA1 MODE 0x14 void DA Imodef int din int mcode Selects which of the specified DA1 s two channels will be used for conversion The channel mode for D A conversion is specified by mcode din Deviceindex number mcode Mode code DAC1 0x01 DAC2 0x02 DUALDAC 0x03 Both D A channels FASTDAC 0x10 Fast single channel D A The FASTDAC option places the DA 1 into a special 500kH z sampling rate mode using channel 1 only DAlmode 1 DAC1 This call will set up DA1 1 to useD A channel 1 D A channel 1 D A channel 2 1304 XBDRV Software Reference D A Istrig din Op Code Prototype Description Arguments Example DA1 STRIG x14 void DAlstrig intdin Sets up the specified DA 1 for single triggering of a conversion buffer DA I1strig can be issued while the DA Lis active see example under DA 1mtrig din Deviceindex number DAlstrig 1 DAlarm 1 This will cause DA1 1 to begin converting on an external trigger or DA1lgo but will not retrigger unless the DA larm is issued again DA 1mtrig din Op Code Prototype Description Arguments Example DA1 MTRIG 0x19 void DA1lmtrig int din Sets up the specified DA1 for multiple external triggering of a conversion buffer NOTE DAlstrig can be issued while the DA1 is in multiple triggering mode to place it back into single triggering mode This provides a way to stop the
106. in scode Op Code Prototype Description Arguments Example AD1 CLKIN 0x16 void ADz1clkin int din int scode Selects the source of the sampling clock for the specified AD1 This is useful for synchronizing AD1 conversions with other devices din Deviceindex number scode Clock source 1 4 INTERNAL 1 Internal sample clock EXTERNAL 2 Front panel BNC XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line ADlclkin 1 EXTERNAL This call will set up AD1 1 to use its front panel BNC for the sampling dock AD Iclkout din dcode Op Code Prototype Description Arguments Example AD1 CLKOUT 0x17 void ADIdkout int din int dcode Asserts the ADTS internal sampling clock onto an XBUS internal patch line This is useful for synchronizing other devices with AD1 conversions din Deviceindex number dcode Patch line code 3 5 XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line NONE 5 Nodock patch ADlclkin 1 INTERNAL ADlclkout 1 XCLK1 This call will set up AD1 1 to use its internal sampling clock and assert it to the XCLK1 line on the XBUS where it can be used to synchronize other devices on the bus 1408 XBDRV Software Reference AD 1clipon din Op Code Prototype Description Arguments Example AD1 CLIPON 0x1F void ADzIclipon int din Enables the ADC clip detection feature If the A D conversion data ever reach their maximum absolute value 7FFF
107. in Device index number nlB Number of Inbound data streams 0 16 nOB Number of Outbound data streams 0 16 Example PDlinstrms 1 2 0 This call will program the PD1 to process two channels of Inbound data D A data and no Outbound data A D data PD 1tgo din Op Code PD1 TGO 0x21 Prototype void PD1tgo int din Description Similar to PD 1go but causes the specified PD1 to wait for a global or local XBUS trigger before taking action see XB1gtrig and XB1ltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher Arguments din Device index number Example See DD Itgo 2108 XBDRV Software Reference PD Istrig din Op Code Prototype Description Arguments Example PD1 STRIG 0x1A void PD 1strig int din Sets up the specified PD1 for single triggering of a conversion buffer PD 1strig can be issued while the PD1is active see example under PD 1mtrig din Device index number See DD Istrig PD 1Imtrig din Op Code Prototype Description Arguments Example PD1 MTRIG 0x19 void PD1mtrig int din Sets up the specified PD1 for multiple external triggering of a conversion buffer NOTE PD 1strig can be issued while the PD1 is in multiple triggering mode to place it back into single triggering mode This provides a way to stop the PD1 from software after the next buffer conversio
108. ines programmed as inputs have no significance din Device index number bitmask Output bit code PI2clear 1 PI2outs 1 Oxf0 PI2setbit 1 0x60 The above code segment will illuminate LEDs 2 and 30n a standard TDT response box Pl 2cirbit din bitmask Op Code Prototype Description Arguments Example PI2 CLRBIT 0x19 void Pl2drbit int din int bitmask Similar to Pl2write but clears output lines specified by a bit mask and leaves the others unchanged Note that outputs specified to have negative logic will have high output levels if cleared Also bits in the mask corresponding to I O lines programmed as inputs have no significance din Device index number bitmask Output bit code PI2clear 1 PI2outs 1 Oxf0 PI2setbit 1 Oxf0 PI2clrbit 1 0x60 1014 XBDRV Software Reference The above code segment will briefly flash all LEDs 1 4 on a standard TDT response box then will turn off LEDs 2 and 3 Pl2 Parallel Interface 1015 gt The four Auxiliary I O Ports are accessed using the following three command calls All previous commands apply only to the eight smart I O lines PI 2outsX din pnum Op Code Prototype Description Arguments Example PI2 OUTS 0x1E void Pl2outsxX int din int pnum Configures an auxiliary I O port to be an output din Deviceindex number pnum Port number 1 4 PI2outsxX 1 2 This call will make auxiliary I O port 2 an output
109. ing a user waveform will cause clicks in the WG2 output waveform Do not use WG 2status while the device is in one of these two modes Return Values OFF 0 WG2is off no output ON 1 WG2 output gated fully on RISING 2 Output gateisin rising state FALLING 3 Output gate is in falling state Arguments din Deviceindex number Example if WG2status 1 ON WG2off 1 Turns WG2 1 off if itis on 1210 XBDRV Software Reference this page intentionally left blank DA1 Dual D A Converter 1301 DA1 Dual D A Converter D A l1clear din Op Code Prototype Description Arguments Example DA1 CLEAR 0x1E void DA 1clear int din Clears the specified DA1 module and resets it to factory default settings Factory Defaults Sampling rate 1 20us 50kHz of conversions 1000 Channel mode DAC1 Single triggering Clip feature disabled Zero output din Deviceindex number See example under DA 1go D Alarm din Op Code Prototype Description Arguments Example DA1 ARM 0x13 void DAlarm int din Prepares the specified DA1 module to wait for a trigger to begin D A conversion DA larm must be issued before the DA1 can be triggered through either software or an external trigger source to start D A conversion din Deviceindex number See example under DA 1go 1302 XBDRV Software Reference DA1go din Op Code Prototype Description Arguments Example DA1 GO
110. ing example sets the gear ratio of the motor to MC1 Motor Controller 2403 M Clhome int din int home Prototype Description Arguments Example void M C1Ihomefint din int home Sets the home position of the motor This is the position the motor will return to when the MC1gohomef command is issued or the HOME button is pressed on the front of the MC1 controller din Device index number home Home position of MC1 Thefollowing example sets the home position to 90 degrees and goes there with the MClgohome command MCihome 1 90 MClgohome 1 M Clboundry int din int minp int Prototype Description Arguments Example maxp void MClboundry int din int minp int maxp Sets the boundaries of the motor to limit the movement of the arm to a particular range This is often a safety feature and prevents the arm from tangling up any cables that may be attached to it din Device index number minp Minimum position maxp Maximum position The following example sets the arm to limit movement between 90 and 90 degrees MClboundry 1 90 90 2404 XBDRV Software Reference M C1reference int din int refmode int srchvel int refpos Prototype void MClreference int din int refmode int srchvel int refpos Description References the MC1 through the use of a dick switch or manually Arguments din Device index number refmode Reference M ode RM MANUAL 1 RM REFSWITCH 2 srchvel Search veloci
111. ini APb The XBlinit call must also be made twice at the top of each application program A typical program initialization might appear as follows if XBlinit APa XBlinit APb printf Xn Error initializing XBUS n exit 0 XBU Ses are then selected for control using the XB1select call For example to select the XBUS connected to APb simply call XBlselect A Pb XBUS command calls following this call will be sent to the XBUS that is controlled by APb XBDRV Nuts amp Bolts 7 XBDRV Nuts amp Bolts This section is intended for users with advanced programming skills who wish to customize or create new driver software routines C code listings are provided on disk This section covers the portion of XBDRV C which governs communication to and from XBUS devices and error handling Code for individual device driver routines is listed in each device s section Commands and data are sent to XBUS devices using two procedures one called shortform which is used for handling short form commands and a second called standform which is used when the standard form communication protocol is needed Also an error handling procedure and a show error procedure are used globally For receiving data from devices there are three procedures to upload single byte integer and long integer values These procedures are called get amp get16 and get32 respectively Control Constants XBDRV has several control
112. int nbytes int cl int c2 H Tlsetraw HTIwriteraw and HTIreadraw provide a method for customizing the operation of the HTI HeadTracker system Note if the HTI default mode of operation does not suit your needs consider interfacing the FASTRAK directly to the host Although these three calls allow for some amount of customization they provide something short of a direct link to the FASTRAK The HTlIsetraw call provides the HTI with the basic structure of the output string programmed to be sent by the FASTRAK din Device index number nbytes Number of bytes to send cl First lockon character c2 Second lockon character See H Tlreadraw HTI Head Tracker Interface 2209 H Ti writeraw din cmdstr Op Code HTI WRITERAW 0x16 Prototype void HTIwriteraw int din char cmdstr Description Sends a command direct to the FASTRAK Arguments din Device index number cmdstr Character string buffer holding the FASTRAK command Example See H TI readraw H Tl readraw din maxchars amp buf Op Code HTI READRAW 0x17 Prototype void HTlreadraw int din int maxchars char buf Description Reads the Output command direct from the specified HTI FASTRAK Arguments din Device index number maxchars Maximum number of characters that should be read buf Pointer to character buffer Example char rtn_str 50 HTIclear 1 HTIwriteraw 1 01 2Xr HTIsetraw 1 21 O 1 2 HTIgo 1 do HTIreadraw 1
113. inter to waveform buffer npts number of buffer points to use 1 800 c 32767 400 for i1 400 1 lt 400 i wave i 1i c WGlwave 1 wave 800 WG1 Waveform Generator 809 lt WGlshape 1 WAVE WGlon 1 This uploads an 800 point zero DC shift ramp function into the WG1 1 and replays the contents of the sample buffer until gated off WG Istatus din Op Code Prototype Description Arguments Example WG1 STATUS 0x20 int WGistatus int din Returns the status of the specified WG1 WARNING Calling WG Istatus while the device is generating tones or converting a user waveform will cause clicks in the WG1 output waveform Do not use WG Istatus while the device is in one of these two modes Return Values OFF 0 WGlLis off no output ON 1 WG1 output gated fully on RISING 2 Output gate isin rising state FALLING 3 Output gate is in falling state din Deviceindex number if WGlstatus 1 0N WGloff 1 Turns WG1 1 off if itis on 810 XBDRV Software Reference this page intentionally left blank PF1Programmable Filter 901 PF1 Programmable Filter Overview The PF1 is a digital programmable filter You can use the built in filter functions or can load your own Built in filters functions include e PFlfreq e PFigain If you wish to load your own filter coefficients use one of the following functions Each function combines basic PF1 function calls to implement one
114. is Lor 2 in dual 4 to 1 mode inpn can be 1 through 4 in single 8 to 1 mode inpn can be 1 through 8 Example SSlclear 1 SSlgainon 1 SSlmode 1 DUAL 4 1 SSlselect 1 2 1 This will dear the SS1 and reset it to factory default turn on the 10 dB gain at inputs 1 2 5 and 6 set the SS1 as a dual 4 to 1 switch inputs 5 and 6 are addressed as inputs 1 and 2 and connect input 1 marked as input 5 to output 2 marked as C NOTE Theeight inputs are marked as 1 through 8 as in signal 8 to 1 mode While in dual 4 to 1 mode the actual inputs numbers are 1 2 3 and 4 inputs 5 through 8 should be addressed as inputs 1 through 4 Similarly in guad 2 to 1 mode input numbers are 1 and 2 That is inputs 3 and 4 5 and 6 and 7 and 8 should be addressed as inputs 1 and 2 respectively The four outputs marked as A through D are always addressed as 0 through 3 In dual 4 to 1 mode only 0 and 2 can be addressed since outputs 1 and 3 are disabled their addresses are 0 or 2 Similarly only output 0 can be addressed in single 8 to 1 mode since outputs 1 through 3 are disabled connected to output 0 1904 XBDRV Software Reference this page intentionally left blank PM1 Power Multiplexer 2001 PM1 Power Multiplexer Note SincePM1 connection is critical to its performance please refer to the PM 1 specification sheet for correct connection PM 1clear din Op Code Prototype Description Arguments
115. it otherwise returns zero Use the device code constants PA4 CODE SW2_CODE etc in the dev parameter position This procedure is handy for programs designed to run on different systems dev Devicetype code See header file din Deviceindex number if XBldevice PA4 CODE 1 PA4atten 1 20 0 The above code will check if PA4 1 exists and if it does the PA 4atten call will set its attenuation level to 20 0 dB XBlotrig Op Code Prototype GTRIG 0xD3 void XBlotrig void 104 XBDRV Software Reference Description Arguments Example Sends a global trigger to all XBUS devices Certain XBUS modules can be told to wait for this trigger before starting or stopping to provide precise software synchronization NOTE This command works only with XBUS hardware versions 3 0 and above None CG1tgo 1 CG1tgo 2 XBlgtrig This triggers CG1 1 and CG1 2 at the same time XB lltrig int rn Op Code Prototype Description Arguments LTRIG 0xD4 void XBlltrig intrn Sends a local trigger to all XBUS devices in the specified XB1 Caddie rack number Certain XBUS modules can be told to wait for this trigger before starting or stopping to provide precise software synchronization NOTE This command works only with XBUS hardware versions 3 0 and above rn XB1 Caddie rack number XB 1version int dev int din Op Code Prototype Description Arguments NA int XBlversion int de
116. ixlogic 1 0x0f Places ET1 1 in Multi Channel mode using the EE1 and selects negative edge triggering on inputs 1 4 and positive edge triggering on inputs 5 8 PI Parallel Interface 701 Pl1 Parallel Interface Overview The Pll is a smart parallel interface utilizing a dedicated microprocessor to drive eight smart TTL I O lines A logical diagram for the structures actually implemented in software is shown in the following diagram Auto Mapper Controller AN 1 Output Output Input U Latch Logic Output 2 Control Selector gt Input Input Latch Logic 6 Control T Auto Timer PI1 Logical Diagram The PI1 programming procedures make excessive use of mask type arguments whereby each bit in an 8 bit number is used to enable or disable a given feature on a specific I O bit The following diagram illustrates the correlation between mask bits and the PI 1 s front panel BN Cs 702 XBDRV Software Reference msb BIT MASK isb 716 5 4 3 211 0 STROBE O PI Parallel Interface 703 Pliclear din Op Code Prototype Description Arguments Example PI1 CLEAR 0x11 void Pliclear int din Resets the specified PIT to the factory default configu
117. lated input Pl loptwrite din bitcode Op Code Prototype Description Arguments Example PIL OPTWRITE 0x1C void Plloptwrite int din int bitcode Writes the value bitcode to the PETS optically isolated output port if installed din Device index number bitcode 8 bit value 0 255 Plloptwrite 1 0xff This call sets all bits on PI1 PE1 1 s optically isolated output 712 XBDRV Software Reference WG1 Waveform Generator 801 WG1 Waveform Generator WG lon din Op Code Prototype Description Arguments Example WG1 ON 0x11 void WGlon int din Tells the specified WG1 to begin producing the programmed wave shape When using the external trigger enable WG 1on acts as an overall device enable use WG loff to disable the WG1 When the trigger mode is set to NONE WG 1on will activate the WG1 output signal din Deviceindex number WGitrig 1 NONE WGlon 1 This will set no trigger free run and turn on WG1 1 output WG loff din Op Code Prototype Description Arguments Example WG1 OFF 0x12 void WGloff int din Places the specified WG1 in IDLE mode WG loff will act as an overall system disabler when the external trigger enable is used When triggering is set to NONE WGloff will turn off the device s output signal din Deviceindex number WGloff 1 This will turn off WG1 1 output 802 XBDRV Software Reference WG lton din Op Code P
118. le a particular configuration of DAC and ADC channels See PD lmode Example See PD Imode PD1 Basic Calls 2105 PD larm din Op Code Prototype Description Arguments Example PD1ARM 0x13 void PD1larm int din Prepares the specified PD1 for A D D A conversion PD larm must be issued before the PD1 can be triggered from software or externally to start conversion PD larm also calls PD 1flushRTE Refer to this call s specification for more information din Device index number See PD Imode PD 1go din Op Code Prototype Description Arguments Example PD1 GO 0x11 void PD1go int din Triggers the specified PD1 from software to begin A D D A conversion PD larm must be issued first to prime the PD1 din Device index number See PD Imode PD Istop din Op Code Prototype Description Arguments Example PD1 STOP 0x12 void PD 1stop int din Forces the specified PD1 to stop A D D A conversion immediately NOTE PD istop will not zero the DAC outputs a PD 1clear or PD1clriO must be issued to zero the outputs din Device index number PD1stop 1 This call immediately halts all A D and D A conversion on PD1 1 2106 XBDRV Software Reference PD Imodef din mcode Op Code Prototype Description Arguments Note Example NA void PD1mode int din int mcode This call has been added to make the PD1 compatible with other TDT D A A D devices P
119. le the DA 3 is active see example under D A 3mtrig din Deviceindex number DA3strig 1 DA3arm 1 This will cause DA3 1 to begin converting on an external trigger or DA3go but will not retrigger unless the D A 3arm is issued again DA3mtrig din Op Code Prototype Description Arguments DA3 MTRIG 0x19 void DA3mtrig int din Sets up the specified DA3 for multiple external triggering of a conversion buffer NOTE DA3strig can be issued while the DA3 is in multiple external triggering mode to place it back into single triggering mode This provides a way to stop the DA3 from software after the next buffer conversion is complete without disabling the external triggering source din Deviceindex number Example DA3 2 4 8 Multi Channel Instrumentation D A 1705 DA3mtrig 1 DA3arm 1 This will cause DA3 1 to begin converting at each external trigger The DA3 will not retrigger until the present conversion cycle is complete D A 3reps din nreps Op Code Prototype Description Arguments Example DA3 REPS 0x1C void DA3reps int din unsigned int nreps Sets the number of times the DA3 can be re triggered after a DA3arm is issued Valid only in multiple trigger mode din Deviceindex number nreos Repeat triggers before rearming 0 60 000 DA3reps 1 100 If this line is added to the previous example DA3 1 will respond only to the first 100 triggers received D A 3srate din
120. le will reset A D1 1 to its default setting and begin conversion AD 1stop din Op Code Prototype Description Arguments Example AD1 STOP 0x12 void AD Astop int din Forces the specified AD1 to stop A D conversion immediately din Deviceindex number delay 1000 ADistop 1 These lines added to the example given for AD 1go will cause the AD1 1 to stop after a short delay period AD ltgo din Op Code Prototype Description Arguments AD1TGO 0x21 void ADItgo int din Similar to AD 1go but causes the specified AD1 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBlIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number Example AD1 Dual A D Converter 1403 r ADlarm 1 ADlarm 2 1 r ADltgo AD1tgo 2 XBlgtrig Global trigger This will cause AD1 1 and AD1 2 to begin conversion at precisely the same time AD lmode din mcode Op Code Prototype Description Arguments Example AD1 MODE 0x14 void AD1mode int din int mcode Selects which of the specified ADT s two channels will be used for conversion The channel mode for A D conversion is specified by mcode din Deviceindex number mcode Mode code ADC1 0x04 A D channel 1 ADC2 0x08 A D channad 2 DUALADC 0x0C Both A D channels
121. mpiles links and runs the software is installed properly If you experience trouble check all of your hardware and software installation work and then call TDT Turbo Pascal Support If you are using Turbo Pascal you will have to compile the provided source file into a TPU file using the Turbo Pascal compiler Once the XBDRV TPU file has been created it should be moved to the appropriate directory and linked to your application using the Turbo Pascal USES line in your source code When compiling the drivers be certain the Range Checking compiler feature is disabled Test your software setup by writing a simple PASCAL program The program shown below initializes your XBUS hardware using the XBlinit procedure and programs the PA4 programmable attenuator to count from 00 0 to 99 9dB Invoke the Turbo compiler and type in the following lines program xbtstl uses crt xbdrv var i integer begin if not XBlinit USE DOS then begin writeln Error initializing XBUS halt Software Setup 5 end for i 0 to 999 do PA4atten 1 i 10 0 end If this program compiles links and runs the driver software is installed properly If you experience trouble check all of your hardware and software installation work and then call TDT Support for Other Compilers Because the XBDRV drivers are provided in C source code format they can be used with a variety of compilers and operating systems In an effort to mak
122. n is complete without disabling the external triggering source din Device index number See DD 1Itmtrig PD lreps din nreps Op Code Prototype Description Arguments Example PD1 REPS 0x1C void PD1reps int din unsigned int nres Sets the number of times the PD1 can be re triggered after a PD larm is issued Valid only in multiple trigger mode din Device index number nreos Repeat triggers before re arming 0 60 000 See DD lreps PD1 Basic Calls 2109 PD Isratef din sper Op Code Prototype Description Arguments Example PD1 SRATE 0x15 void PD 1srate int din float sper Sets the sampling rate of the specified PD1 U se only when compatibility with older hardware is required see N ote under D DIsrate din Device index number sper Sampling period 5us 2000us or 6 5us 2000us when A D is used PDisrate 1 20 00 Sets the sampling rate of PD1 1 to 1 20us 50kH z PD Isperiod din sper Op Code Prototype Description Arguments Example Note PD1 SPERIOD 0x26 float PD1speriod int din float sper Sets the sampling period microseconds per sample of the specified PD1 It returns the actual sample period din Device index number sper Sampling period 5us 2000us or 6 5us 2000us when A D is used printf Sf PDisperiod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of PD1 1 to 1 5 04us 198 413kHz PDisperiod corrects th
123. n enable input din Deviceindex number SDistop 1 SD luse enable din Op Code Prototype Description Arguments Example SD1 ENABLE 0x13 void SDluse enable int din Tells the specified SD1 to use its ENABLE input When active this input will enable spike discrimination whenever it is high Discrimination is disabled IDLE mode when the input is low din Deviceindex number SDluse enable 1 502 XBDRV Software Reference SD 1no_enable din Op Code Prototype Description Arguments Example SD1 NOENABLE void SD1no_enab int din Tells the SD1 to ignore its ENABLE input din Deviceindex number SDlno enable 1 SD lhoop din hnum scode dly Op Code Prototype Description Arguments Example wid upper lower SD1 HOOP 0x15 void SDlhoop int din int hnum int scode float dly float wid float upper float lower Specifies a discrimination hoop on the SD1 The dly and wid parameters have no significance when hnum 1 Hoop 1 serves as a trigger with adjustable level and slope only Set the lower level of hoop 1 to just under the upper level The values of dly and wid for Hoops 2 5 must be set so that the hoops do not overlap in time see below din Deviceindex number hnum Hoop Number 1 5 scode Slope selection code 1 5 RISE Positive Slope FALL Negative Slope PEAK Pos to Neg Transition VALLEY Neg to Pos Transition ANY Pos or Neg Slope dly D
124. nfiguration is as follows lus base clock period Single rep after trigger din Deviceindex number TG6clear 1 This resets TG6 1 TG 6arm din snum Op Code Prototype Description Arguments Example TG6 ARM 0x12 void TG6arm int din intsnum Arms the TG6 to generate the specified timing sequence when triggered to start externally or from software din Deviceindex number snum Sequence number 0 7 See TG 6go TG 6go din Op Code Prototype Description Arguments Example TG6 GO 0x13 void TG6go int din Triggers the currently armed timing sequence see TG6arm din Deviceindex number TG6arm 1 3 TG6go 1 This will arm and start timing sequence number three 1104 XBDRV Software Reference TG 6tgo din Op Code Prototype Description Arguments Example TG6 TGO 0x14 void TG6tgof int din Prepares the TG6 to receive a global or local software trigger to synchronize it with other XBUS devices see XB1gtrig and XB Iltrig din Deviceindex number TG6arm 1 3 TG6tgo 1 ready for global software trig arm and tgo other relevant devices XBlgtrig issue global software trig This will arm and start the TG6 timing sequence and other devices readied with their corresponding tgo commands simultaneously TG 6stop din Op Code Prototype Description Arguments Example TG6 STOP 0x15 void TG 6stop intdin Stops the TG6 from soft
125. ng rate and cannot be combined with other options 1504 XBDRV Software Reference Example DDimode 1 DAC1 ADC2 This call will set up DD1 1 to use D A channel 1 and A D channel 2 DD 1strig din Op Code Prototype Description Arguments Example DD1 STRIG 0x1A void DDistrig int din Sets up the specified DD1 for single triggering of a conversion buffer DD 1strig can be issued while the DD1is active see example under DD Imtrig din Deviceindex number DDistrig 1 DDlarm 1 This will cause DD1 1 to begin converting on an external trigger or DD 1go but will not retrigger unless D D larm is issued again DD 1mtrig din Op Code Prototype Description Arguments DD1 MTRIG 0x19 void DDImtrig int din Sets up the specified DD1 for multiple external triggering of a conversion buffer NOTE DD Istrig can be issued while the DD1 is in multiple external triggering mode to place it back into single triggering mode This provides a way to stop the DD1 from software after the next buffer conversion is complete without disabling the external triggering source din Deviceindex number Example DD1 Stereo Analog Interface 1505 DDimtrig 1 DDlarm 1 This will cause DD1 1 to begin converting at each external trigger The DD1 will not retrigger until conversion of the present buffer is complete DD 1reps din nreps Op Code Prototype Description Arguments Example DD1
126. ng are available only on XBUS hardware versions 3 0 or higher din Deviceindex number DA3arm 1 DA3arm 2 DA3tgo 1 DA3tgo 2 XBlgtrig Global trigger This will cause DA3 1 and DA3 2 to begin conversion at precisely the same time D A3mode din mcode Op Code Prototype Description Arguments DA3 MODE 0x14 void DA3modef int din int mcode Selects which of the specified DA3 s channels will be used for conversion The channel mode for D A conversion is specified by mcode din Deviceindex number mcode Mode code DAC1 0x01 D A channe 1 DAC2 0x02 D A channel 2 DAC3 0x04 D A channel 3 DAC4 0x08 D A channel 4 DAC5 0x10 D A channel 5 DAC6 0x20 D A channel 6 DAC7 0x40 D A channel 7 DAC8 0x80 D A channel 8 FASTDAC3 0x00 Fast D A channel 1 only 1704 XBDRV Software Reference Example NOTE FASTDAC3 mode must be used for single channe D A at the maximum 500kHz sampling rate When using multiple channels at aggregate sampling rates faster than about 200kHz the D A channels should be utilized in sequence For example with 4 channels at 50kHz per channel DA3 channels 1 4 should be specified DA3mode 1 DAC1 DAC3 Sets up DA3 1 to use D A channels 1 and 3 D A 3strig din Op Code Prototype Description Arguments Example DA3 STRIG 0x1A void DA strig int din Sets up the specified DA3 for single triggering of a conversion buffer D A 3strig can be issued whi
127. nt M Clcurpos int din Description Reads the current position of the motor Arguments din Device index number Example M Cicurvel int din Prototype int MCicurvel int din Description Reads the current velocity of the motor Arguments din Device index number Example M Clgo int din Prototype void MClgo int din Description Arguments din Device index number Example MC istop int din Prototype void MCistop int din Description StopstheMCl1 Arguments din Device index number Example M Clkill int din Prototype void MCIkill int din Description Programmable kill switch for the MC1 Arguments din Device index number Example MC1 Motor Controller 2407 M C1zero int din Prototype void MCi1zero int din Description MakestheMC1 oo to the zero position Arguments din Device index number Example Thefollowing example reads the freguency settings of the high pass low pass and notch filter banks M C1gohome int din Prototype void MCilgohome int din Description Makes the motor go to the home position the position set by MC1lhome Arguments din Device index number MC lgoref int din Prototype void M Cl1goref int din Description Makesthemotor go to the reference position Arguments din Device index number Example M C lgetparam int din int parcode Prototype int MClgetparam int din int parcode Description Reads one of several parameters from the MC1 This can be used to read v
128. ntized to 0 08us For example calling DA 1srate 1 7 0 will actually cause the device to sample every 6 96us because the rate must be derived from an integer number of cycles of the base clock 0 08us Also the rate will be truncated down to the nearest integer number of 12 5MHz clock cycles so calling DA1srate 1 5 1 1306 XBDRV Software Reference will result in a 5 04us sampling period not a 5 12us as might be expected With XBDRV versions 2 00 or lower DA Israte will pass the specified sample period to the nearest tenth of a microsecond So if you make a call such as D A Israte 1 6 98 it will be rounded and sent to the DA1 as 7 0us and the DA1 will truncate it down to the nearest integer number of 0 08us which is 6 96us XBDRV versions 2 01 and higher has provided the DA Isperiod call to set sample period and return the actual sample period to correct this problem DA lsperiod din sper Op Code Prototype Description Arguments Example DA1 SPERIOD 0x22 float DA Isperiod int din float sper Sets the sampling period microseconds per sample of the specified DA1 It returns the actual sample period din Deviceindex number spe Sampling period 5us 2000us 2us 2000us for FASTDAC mode printf Sf DAlsperiod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of DA1 1 to 1 5 04us 198 413kH z N ote DA1 Dual D A Converter 1307 DAlsperiod corrects the round off probl
129. number of channels in the headstage din Device index number nc 2or 4 This example configures the DB4 to 2 channel operation DB4nchan 1 2 DB4 Digital Biological Amplifier 2307 D B4setT S int din float amp float Op Code Prototype Description Arguments Notes Example freq DB4 SETTS 0x17 void DB4setTS int din float amp float freq Sets the amplitude and frequency of the test signal din Device index number amp voltage 0 0 1V freq frequency 1 5960 Hz The test tone is played out of a 16 bit D A The amplitude is scaled over the 16 bits so a 0 1 V signal will have the best quality highest signal to noise A 0 0001 V 0 1 mV signal will have only about a 30 dB dynamic range This example sets the test signal on the headstage to 2000 Hz and 0 01 V and then turns it on DB4setTS 1 0 01 2000 DB4onTS 1 D B4onT S int din Op Code Prototype Description Arguments Example DB4 TSOO 0x18 void DB4onTS int din Activates the test signal on the headstage connected to the specified controller din Device index number This example sets the test signal on the headstage to 2000 Hz and 0 01 V and then turns it on DB4setTS 1 0 01 2000 DB4onTS 1 2308 XBDRV Software Reference D B4offT S int din Op Code Prototype Description Arguments Example DB4 TSOO 0x18 void DB4offTS int din Turns off the test signal on the headstage connected to the specified cont
130. o float high the Pl lread function will return 0x00 Pl lautotime din atmask dur Op Code Prototype PIL AUTOTIME 0x16 void Pllautotime int din int atmask float dur 706 XBDRV Software Reference Description Arguments Example Enables and programs the PI1 s Auto Time feature When this feature is enabled the Pll will automatically reset specified output lines after a preset period of time All I O lines share the same timer which is started each time the outputs are written to by the host computer or the Auto Mapping feature Specify a duration of 0 to disable the A uto Time feature din Deviceindex number dur Duration in milliseconds 0 0 3200 0 See example under Pl lmap Pl lmap din incode mapoutmask Op Code Prototype Description Arguments Example Plimap 0x17 void Plimap int din int incode int mapoutmask Programs the PIT s Auto Mapping feature When enabled the PIT will automatically set specified output bits when a specified input pattern is present at the device s inputs Note that this feature only sets output bits However the actual level at the device output can be inverted using the Pl logic call The incode argument specifies the input pattern that must be matched exactly If a match is detected the PI1 will automatically set the bits specified in mapoutmask din Device index number incode Input match value mapoutmask Output Control M ask Suppose the PI1 is
131. oad sel with the gain index enter 0 for sel eg gain DB4getgain 1 CH2 0 Example The following example reads the gain from the DB4 channel 2 and loads the variable sel with the gain index float gain int sel gain DB4getgain 1 CH2 amp sel DB4 Digital Biological Amplifier 2313 D B4getfilt int din int chan int ft int sel Op Code DB4 GETFILT 0x21 Prototype float DB4getfilt int din int chan int ft int sel Description Returns the filter frequency from the specified channel and filter bank and loads sa with index of freguency setting Arguments din Device index number chan CH1 CH2 CH3 CH4 ft Filter type F_HP high pass F_LP low pass F_NT notch sel Pointer to int variable to hold gain index Notes To just read the freguency and not load sel with the frequency index enter 0 for sd e g frequency DB4getfilt 1 CH2 F HP 0 Example The following example reads the freguency settings of the high pass low pass and notch filter banks from the DB4 channel 1 and 2 and load the variable sel with the gain index float hp lp nt for ch 0 ch lt 1 ch hp DB4getfilt 1 ch F HP amp sel printf Ch i HP Sf Sel Si ch hp sel lp DB4getfilt 1 ch F LP amp sel printf LP Sf Sel Si lp sel nt DB4getfilt 1 ch F NT amp sel printf NT f Sel i n nt sel 2314 XBDRV Software Reference D B4getiT int din int chan Op Code D
132. oftware Reference ET1stop 1 This code segment will program the ET1 to record events until 100 values are loaded into the ET1 s FIFO ET lactive din Op Code Prototype Description Arguments Example ET1 ACTIVE 0x17 int ET lactive int din Returns 1 if the specified ET1 is recording events and returns 0if the ET1is IDLE din Deviceindex number See example under ET 1blocks ET lcompare din Op Code Prototype Description Arguments Example ET1 COMPARE 0x13 void ETlcomparef int din Places the specified ET1 in the COMPARISON mode In this mode the enable input line is used to delimit two recording intervals one when the enable line is high and a second when the enable line is low On each transition of the enable input the timer counter is reset and a block marker 0 is written to the FIFO memory See the example below for more information din Deviceindex number ETlcompare 1 ETigo 1 delay 100 ETlstop 1 H ypothetical ET1 input ET1 Event Timer 605 gt 0 gt 0 gt 0 gt 0 ENABLE Ti T2 T3 T4 T5 T6 T7 T8 T9 IN 1 IN 2 No Connection If this program is run with the hypothetical input shown the resulting FIFO contents would be 0 T1 T2 T3 T4 0 T5 T6 T7 0 T8 TY O NOTE In the above example the IN 2 input was left floating high so all event times on IN 1 were recorded in t
133. ointer to return Y Z Pointer to return Z HTIfastXYZ 1 amp x amp y amp Z y HTI Head Tracker Interface 2207 HTireadone din pid Op Code Prototype Description Arguments Example HTI READONE xic float HTlreadone int din int pid Reads the specified parameter from the indicated HTI The return value is in floating point format with the same units and resolution as the standard HTIreadA ER and HTlreadXYZ calls din Device index number pid Parameter identification number See HTIshowparam for legal constants HTIclear 1 HTIgo 1 do printf Roll 4 2f n HTIreadone 1 P_ROLL while kbhit HTIstop 1 void getch H Tl reset din pid Op Code Prototype Description Arguments Example HTI RESET 0x1b void HTireset int din Sends Y to the specified HeadTracker Note care must be taken to allow 5 seconds for the FASTRAK to run through initialization din Device index number HTIreset 1 delay 5000 2208 XBDRV Software Reference H TI getecode din Op Code Prototype Description Arguments Example HTI GETECODE 0x1f int H Tl getecode int din Returns the last error code transmitted from FASTRAK Refer to FASTRAK document for more information din Device index number lasterr HTIgetecode 1 H Tlsetraw din nbytes c1 c2 Op Code Prototype Description Arguments Example HTI SETRAW 0x18 void HTlsetraw int din
134. on for NO PI2map 1 6 PANIC bit 6 output 7 on for PANIC PI2zerotime 1 0x07 zero timers on all input lines do i PI2read 1 read inputs if i button pressed Ef Pl2 Parallel Interface 1009 switch i process response case YES t1 PI2gettime 1 0 gotoxy 10 10 printf Yes response time t d ms ssc L break case NO t1 PI2gettime 1 1 gotoxy 10 10 printf NO response time d ms WE Lae break case PANIC t1 PI2gettime 1 2 gotoxy 10 10 printf PANIC response time d ms Wot break default gotoxy 10 10 printf Error Wye end switch end if delay 1000 Delay before accept next response gotoxy 10 10 printf Ready read to clear spurious inputs latched during processing if i PI2read 1 zero the time of the inputs just pressed PI2zerotime 1 i Jwhile kbhit void getch Note that the input timers are reset individually after a button is pressed This allows each response time to be measured from the last response of that type 1010 XBDRV Software Reference P 2zerotime din bitmask Op Code Prototype Description Arguments Example PI2 ZEROTIME 0x1A void Pl2zerotime int din int bitmask Zeroes the PI2 s Input Timing feature This feature is used with Pl2gettime to determine the time any input line goes true Each line has a
135. onsible for interfacing with the PD1 and controlling all PD1 resources The PD1 s secondary processor and its associated circuits are collectively referred to as the Real Time Router or RTR Because there are numerous XBUS calls required to control the PD1 they have been broken into logical groups based on their function and or the PD1 resource they control These groups and a brief description are listed below 1 PD1 Basic Calls This group includes the PD1 calls that function in a similar manner to other D A A D calls These overlapping calls include PD1clear PD1mode PD1srate and PDlarm Basic Calls provide the PD1 with D A A D functionality and make it compatible with other TDT converter modules 2 Route Scheduling Calls Route schedules are specified using this group of calls Included are calls for scheduling simple routes and multi routes Also included are calls specifying hard wired connections for Inbound and Outbound streams 3 Convolver DSP Calls These calls send commands to the PD1 s complex of DSP processors 4 Analog I O Calls The PD1 is typically equipped with 2 or 4 channels of A D and D A The calls in this group are used to initialize and configure these hardware resources 2102 XBDRV Software Reference 5 Delay Processor Calls The PD1 delay processor optional is controlled with this group of calls 6 Utility Calls These functions are used by other PD1 calls and should NOT
136. orded in every other data block Square Wave Generator Spike Conditioning Discrimination System JUUUL Subject SA TO ET Imult din Op Code Prototype Description ET1 MULT 0x12 void ETimult int din When the optional EE1 Event Timer Expander is being used ETlmult places the ET1 in Multi Channel mode In this mode an 8 bit pattern indicating which of the EET s inputs were triggered is stored with each event time as the upper byte of the 32 bit time stamp i e the event times counts are truncated to 24 bits Bits corresponding to triggered inputs are set to 0 other bits are 1 NOTE You must read event times with ET Lread32 into an unsigned long integer variable when using multi channel mode or the bit pattern information will be lost 608 XBDRV Software Reference Arguments Example din Deviceindex number ETimult 1 Places ET1 1 in Multi Channel mode ET 1xlogic din Imask Op Code Prototype Description Arguments Example ET1 MULT 0x1A void ET1xlogic int din int mask When the optional EE1 Event Timer Expander is being used ET1xlogic selects the active triggering edge positive or negative for each of the eight inputs din Deviceindex number Imask Logic mask for inputs msb LMASK Isb BIT 7 6 5 413 2 110 B T 9 gt pos edge BIT 1 gt neg edge INPUT K 8 7 6 5 4 3 2 1 ETimult 1 ET
137. pe see WGldur and NONE manual triggering Arguments din Deviceindex number tcode Trigger type code 1 5 POS EDGE Rising edge triggered NEG EDGE Falling edge triggered POS ENABLE High leva enabled NEG ENABLE Low level enabled NONE Free running Example WGltrig 1 POS_EDGE This will program WG1 1 to rising edge triggered WG 1seed din seed Op Code Prototype Description WG1 SEED 0x1D void WGlseed int din long seed Sets the random number generator seed value 808 XBDRV Software Reference Arguments Example din Deviceindex number seed Random number seed value 1 2 32 WGlshape 1 UNIFORM WGlseed 1 1000000 WGlon 1 This programs WG1 1 to output uniform random noise with the generator seeded by 1 000 000 WG 1delta din delta Op Code Prototype Description Arguments Example WG1 DELTA 0x1E void WGldelta int din long delta Sets a very precise sine wave frequency din Deviceindex number delta 2 frequency in Hz 79277 419 Hz 54176 426 frequency in Hz WGlshape 1 SINE WGldelta 1 long 54176 426 100 0 WGlon 1 This code programs WG1 1 to produce a 100Hz sine wave WG lwave din wave npts Op Code Prototype Description Arguments Example WG1 WAVE 0x1F void WGlwave int din int wave int npts Uploads a user defined waveform into the WG1 sample buffer from a host PC din Deviceindex number wave Po
138. period and return the actual sample period to correct this problem D A 3speriod din sper Op Code Prototype Description Arguments Example DA3 SPERIOD 0x24 float DA3speriod int din float sper Sets the sampling period microseconds per sample of the specified DA3 It returns the actual sample period din Deviceindex number sper Sampling period 2us 2000us NOTE the aggregate sampling rate of channels X per channel sampling rate cannot exceed 500 kHz printf Sf DA3speriod 1 5 00 Outputs 5 04 to the screen and sets the sampling rate of DA3 1 to 1 5 04us 198 413kH z N ote DA3 2 4 8 Multi Channel Instrumentation D A 1707 DA3speriod corrects the round off problem associated with DA 3srate call while the base clock limitation still apply See note under D A3srate D A 3speriod call is available for DA3 of hardware versions 5 0 and above and XBDRV versions 2 01 and above DA3npts din npts Op Code Prototype Description Arguments Example DA3 NPTS 0x18 void DA3npts int din long npts Sets the number of samples the specified DA3 will convert after it is triggered din Deviceindex number npts Number of conversions 1 23 DA3npts 1 500000 This call will set up DA3 1 to perform 500 000 conversions which corresponds to 10 seconds at 50kH z sampling rate D A 3clkin din scode Op Code Prototype Description Arguments Example DA3 CLKIN 0x16
139. ption WG2 SWRT 0x16 void WG2swrt int din float swrt Sweeps the sine wave frequency for chirp tones 1204 XBDRV Software Reference Arguments Example din Deviceindex number swrt Frequency sweep rate in Hz s 10 9 999 WG2shape 1 SINE WG2freq 1 200 WG2swrt 1 1000 WG2on 1 This programs WG2 1 to produce a swept freguency sine wave starting at 200Hz After one second the frequency will be 1 2 kHz NOTE The frequency continues increasing until the WG2 is gated off or until WG off is issued WG 2phase din phase Op Code Prototype Description Arguments Example WG2 PHASE 0x17 void WG2phasef int din float phase Sets the onset phase of the WG2 s sine wave generator as well as the seed value for the WG2 s internal random number generator Using the phase call the WG2 can be made to generate frozen noise signals each time the device is triggered To generate non frozen noise call WG2phase 1 1 din Deviceindex number phase Phasein degrees 0 00 360 00 Use 1 to set the phase to continuous WG2trig 1 POS ENABLE WG2shape 1 SINE WG2freq 1 200 WG2phase 1 90 WG2on 1 This programs WG2 1 to produce a 200Hz sine wave with a 90 degree onset phase synchronized with the Enable input WG2 Waveform Generator 1205 WG 2dc din dc Op Code Prototype Description Arguments Example WG2_DC 0x18 void WG2dc intdin flo
140. r 1601 AD2 Instrumentation A D Converter AD 2clear din Op Code Prototype Description Arguments Example AD2 CLEAR 0x1E void AD2dear int din Clears the specified AD2 and resets it to factory default settings Factory Defaults Sampling rate V 20us 50kH z Sample separation 2 lus of conversions 1000 Sample hold mode OFF Channel mode ADC1 Single triggering din Deviceindex number See example under AD 2go AD 2arm din Op Code Prototype Description Arguments Example AD2 ARM 0x13 void AD2arm intdin Prepares the specified AD2 for A D conversion AD2arm must be issued before the AD2 can be triggered from software or externally to start conversion din Deviceindex number See example for A D 2go 1602 XBDRV Software Reference AD 2go din Op Code Prototype Description Arguments Example AD2_GO 0x11 void AD2go int din Triggers the specified AD2 from software to begin A D conversion AD2arm must be issued first to prime the A D2 din Deviceindex number AD2clear 1 AD2arm 1 AD2go 1 This example will reset A D2 1 to its default setting and begin conversion AD 2stop din Op Code Prototype Description Arguments Example AD2 STOP 0x12 void AD2stop int din Forces the specified AD2 to stop A D conversion immediately din Deviceindex number delay 1000 AD2stop 1 These lines added to the example
141. r more information on rules governing route scheduling 2114 XBDRV Software Reference PD laddmult din srclst sf Op Code Prototype Description Arguments Example nsrcs des RTE ADDMULT 0x0108 void PDladdmult int din intsrclst float sf int nsrcs int des Adds a multi route mixing route to the current route schedule Multi routes are used to connect multiple output ports to a single input port Multi routes support individual scaling for each input din Device index number srdst Integer array containing list of source ports sl Floating point array containing a list of source scale factors 1 0 lt sf lt 0 99976 nsrcs Number of sources in srdst 1 13 des Destination port int srclstL 8 int srclstR 8 float sf 8 PDlclrsched 1 for i 0 i lt 8 i srclstL i DSPoutL i srclstR i DSPoutR i sf i 0 125 PDladdmult 1 srclstL sf 8 DAC 0 PDladdmult 1 srclstR sf 8 DAC 1 The program segment shown above will program the PD1 RTR to run two multi routes The first will sum the left channel outputs from DSPs 0 through 7 and send the result to DAC O s input The second multi route will sum the right channel outputs from the same DSPs and send it to the input of DAC 1 All inputs will be scaled by 0 125 or 1 8 PD1 Route Scheduling Calls 2115 PD IspeciB din ibn des Op Code Prototype Description Arguments Example
142. rated if the CG1 is programmed with the above two calls and its trigger input is clocked from an external source Enable pigger Mm je k E owu IU mn nn CG lperiod din period Op Code Prototype Description Arguments Example CG1 PERIOD 0x15 void CGlperiod int din float period Sets the period frequency of the CG1 output with a 50 duty cycle din Device index number period Clock cycle period in us 1 20 106 CGlperiod 1 100 0 This will program the CG1 to generate a 10kHz clock signal with 50 duty cycle 404 XBDRV Software Reference CG lpuse din on t off t Op Code CG1 PULSE 0x16 Prototype void CGlpulse int din float on t float off t Description Programs the CG1 to generate a signal with a variable duty cyde The on t parameter specifies the time the output will be high while off_t indicates how long the signal will be low The overall period of the waveform ison_t off_t Arguments din Deviceindex number on_t Output high duration in useconds 2000 20 000 000 off t Output low duration in useconds 2000 20 000 000 Example CGlpulse 1 7500 0 2500 0 This call will program the CG1 to generate a 100H z signal with a 75 duty cycle CG lpatch din pcode Op Code CG1 PATCH 0x18 Prototype void CGlpatch int din int pcode Description Programs the CG1 to patch its output to one of the XBUS trigger clocking signals Arguments din Deviceindex
143. ration The PI1 default configuration is as follows All inputs with Positive Logic No Mapping or Auto Timing No input Debouncing or Latching Internal Strobe din Deviceindex number Pllclear 1 Resets PI1 1 Pl louts din omask Op Code Prototype Description Arguments Example PIT OUTS 0x12 void Pl louts int din int omask Specifies certain I O bits to be outputs A set bit within omask will make the corresponding I O line an output while all reset bits will indicate input lines din Deviceindex number omask Designation Mask 1 Output OS nput PIlouts 1 0xf0 This call will program PI1 1 to make I O lines 1 through 4 inputs and lines 5 through 8 outputs 704 XBDRV Software Reference PI Llogic din logout login Op Code Prototype Description Arguments Example PIL LOGIC 0x13 void Plllogic int din int logout int login Specifies a logic mask applied to PI1 inputs and outputs All operations within the PI1 are assumed to be operating with positive logic i e 1 gt high gt true gt on 0 gt low false gt off The logic of any I O line can be inverted by calling Pl llogic with a Lin the proper bit mask position NOTE Bits of logout which correspond to I O lines programmed as inputs will have no significance The same is true of login din Deviceindex number logout Ouput Logic Designation Mask O Positive 1 N egative login Input Logic Designa
144. re listed below din Deviceindex number tcode Trigger type code 0 4 0 MANUAL Manual or software COMPUTER Control of gating POS EDGE Rising edge external trigger NEG EDGE Falling edge external trigger POS ENABLE High level external enable NEG ENABLE Low level external enable See SW 2dur DUNE SW 2dur din dur Op Code Prototype Description Arguments Example SW2_DUR 0x18 void SW2dur int din float dur Sets enables the SW2 s self timing feature When the self timer is enabled the SW2 will gate ON when a valid trigger is detected and gate OFF after the specified duration Specify a duration of zero for continuous output after triggering NOTE SW2dur does not work when using POS ENABLE or NEG ENABLE gating control din Deviceindex number dur Duration of gatein ms 1 9999 SW2trig 1 POS_EDGE SW2dur 1 100 0 SW2rftime 1 10 0 SW2shape 1 RAMP SW2on 1 This example will produce the gate shown below in response to an external trigger SW2 Cosine Switch 305 ENABLE Input SW 2status din Op Code Prototype Description Arguments Example SW2 STATUS 0x19 int SW 2status int din Returns the status of the specified SW2 Return Values OFF 0 SW 2 is off no output ON 1 SW 2 gate fully on RISING 2 Gateisin rising state FALLING 3 Gateisin falling state din Deviceindex number if SW2status 1 ON SW2off 1 Turns SW2 1 off
145. ridden by specifying a communications port code in the cprt parameter This override method is only recommended if you intend to control two XBU Ses from a single PC Once the port is identified and initialized the procedure then begins identifying XBUS modules until it finds an XB1 device caddie with NO programmable modules Each time XBlinit detects a device it sets the variable xbcode equal to the device s XBUS Location Number XLN cprt XBUS Port USE DOS Use DOS environment variable XBCOM typical APa Initialize XBUS on APa APb Initialize XBUS on APb XBlinit cprt If a single XB1 caddie contained two PA4s and two SW 2s the xbcode variable would be set as follows xbcode PA4 CODE 1 XBN 4 xbcode PA4 CODE 2 XBN 5 xbcode SW2_CODE 1 XBN 6 xbcode SW2_CODE 2 XBN 7 All other xbcode values would be 0 Also see description for the XB 1ldevice command 102 XBDRV Software Reference NOTE XLNS range from 4 127 and XBN is the XBUS number 0 or 1 try 0 XB1 Device Caddie 103 XB1flush Op Code Prototype Description Arguments Example SNOP 0x00 void XB1flush void Flushes the communications data stream by sending 40 SN OPs zeros None XBlflush This will send 40 SNOPs to the communication stream XB 1device dev din NA Op Code Prototype Description Arguments Example int XBldevicef int dev int din Returns the XLN of the specified device if it was detected by XB lin
146. ription Clears the specified HTI and resets it to factory default settings In this mode information will be handled in the Polhemus 16 bit format Arguments din Device index number Defaults Data format 16 bit integer Display azimuth rotation angle HTI in ready mode Translation unit centimeter Rotation unit degree Mode Fastrak Example See HTIreadXYZ TheHTI does not support Isotrak which was discontinued in 1993 HTI Head Tracker Interface 2203 H TI go din Op Code HTI GO 0x12 Prototype void HTIgo int din Description Places the FASTRAK in continuous transmit mode Once in this mode the current positional information can be accessed using the following HTI calls HTireadAER HTIfastAER HTireadXYZ HTIfastXYZ and HTIreadone Arguments din Device index number Example See HTIreadXYZ HTistop din Op Code HTI_STOP 0x13 Prototype void HTIstop int din Description Takes the FASTRAK out of continuos transmit mode Arguments din Device index number Example See HT lreadXYZ H TI boresight din Op Code HTI BORESIGHT 0x19 Prototype void HTIboresight int din Description Issues boresight B1 command to the FASTRAK Arguments din Device index number Example See H TlreadXYZ 2204 XBDRV Software Reference H TI showparam din pid Op Code Prototype Description Arguments Example HTI SHOWPARAM Oxia void HTlshowparam int din int pid Tells the specifie
147. roller din Device index number This example sets the test signal on the headstage to 2000 Hz and 0 01 V and then turns it on The test signal is turned off when the user presses a key DB4setTS 1 0 01 2000 DB4onTS 1 do while kbhit DB4o0ffTS 1 D B4starti M int din int chan Op Code Prototype Description Arguments Example DB4 STARTIM 0x19 void DB4startl M int din int chan Starts impedance monitoring by the headstage on the specified channel din Device index number chan CH1 CH2 CH3 CH4 see example under DB4read M D B4stopIM int din Op Code Prototype Description Arguments Example DB4 STOPIM Oxla void DB4stop M int din int chan Stops impedance monitoring by the headstage din Device index number see example under DB4readiM DB4 Digital Biological Amplifier 2309 D B4readiM int din int pc Op Code Prototype Description Arguments Example DB4 READIM Oxilb int DB4readiM int din int pc Returns impedance from the specified channel din Device index number pc impedance of POS or NEG electrode and ground The following example continuously monitors the impedance on headstage channel 1 until the user presses a key DB4startIM 1 1 int imp imn do imp DB4readIM 1 POS imn DB4readIM 1 NEG printf Impedance Positive i Imp Neg i n imp imn Jwhile kbhit 2310 XBDRV Software Reference D B4impscan int din
148. rototype Description Arguments Example WG1 TON 0x21 void WGlton int din Similar to WG 1on but causes the specified WG1 to wait for a global or local XBUS trigger before taking action see XBlgtrig and XBIltrig Useful for synchronized triggering of multiple XBUS devices NOTE Global and local triggering are available only on XBUS hardware versions 3 0 or higher din Deviceindex number WGitrig 1 NONE WGlton 1 WGlton 2 XBlgtrig Global trigger This will cause WG1 1 and WG1 2 to turn ON at precisely the same time WG Iclear din Op Code Prototype Description Arguments Example WG1 CLEAR 0x13 void WGlclear int din Clears the specified WG1 and resets it to the factory default setup Gaussian noise 9 99V amplitude 0 0V DC shift continuous phase free run 1 0 ms rise fall time output off din Deviceindex number WGiclear 1 This clears WG1 1 and sets factory defaults WG1 Waveform Generator 803 WG lamp din amp Op Code Prototype Description Note Arguments Example WGI AMP 0x14 void WGlamp int din float amp Sets the output waveform amplitude With WG1 hardware versions lower than 4 0 when the WG1 is generating Gaussian noise at its max level the amplitude display will read 9 99 on the display Decreasing the amplitude to 5 0 will not reduce the level of the noise by 6 0dB This is corrected with WG1 hardware versions 4 0 and higher
149. s are responsible for driving the RS232 port of the host computer Two physical drivers are used by XBDRV to drive the PC s RS232 interface iosend and iorec These procedures handle the sending and receiving of single byte data to and from the RS232 port In addition to these procedures code must be written that initializes the port to the required protocol Brief descriptions of the iosend and iorec procedures are given below losend The iosend procedure sends a single byte of data out the RS232 serial port The procedure first checks if the serial port hardware is ready to send the byte of data If after a TIME OUT period the port does not become ready the procedure fails and sends an error message to the video monitor XBDRV Nuts amp Bolts 11 iorec This procedure checks the serial port hardware for any received data If data is available it is returned otherwise the value of 1 is returned NOTE The iosend and iorec procedures provided with XBDRV can drive all COM ports on the PC as well as the RS232 port on TDT s AP2 This versatility is typically not needed in user written physical drivers BRK KK k k kk kk kk kk kk kk kk kk kk k k k k K ARR RR AXA AXA AA A I I I Physical Drivers FER RR k kA XX XX XX X kk k kk kk kk k k K K K A AAA AXA AA AX AXA AXA AXA AAA AXA AXA Z K void iosend gint datum long ii if xb_eflag if cc lt COM_APa if ii gt xbtimeout showerr Transmission T
150. s filter gain ODB _6DB _12DB _18DB _24DB PFlgain 1 _ODB _6DB This call will tell the PF1 1 to set the lowpass filter gain to 0 dB and the highpass filter gain to 6 dB U RUN HE PF1Programmable Filter 903 PF lbypass din Op Code Prototype Description Arguments Example PF1 BYPASS 0x12 void PFlbypass int din Bypasses the main digital filter oversampling circuit remains active so bandwidth is 20KH 2 din Deviceindex number PFlbypass 1 This call lets the input signal bypass the digital filtering process on PF1 1 PF lnopass din Op Code Prototype Description Arguments Example PF1 NOPASS 0x13 void PFinopass int din Switches PF1 output off din Deviceindex number PFlnopass 1 This call will turn off the PF1 1 output 904 XBDRV Software Reference gt The following five functions simplify PF1 programming by combining basic PF1 calls to load and run a filter in a single call PFl1fir16 din bcoefs ntaps Prototype Description Arguments Example void PFifirl6 int din float bcoefs int ntaps Downloads a floating point array containing the desired FIR tap coefficients and starts the filtering process Floating point to integer conversion is done by the routine Precision is 16 bit and coefficients must lie within the 1 15 format range 1 0 lt b lt 1 0 din Deviceindex number bcoefs Array containing feed forward coefficients b b
151. scription Arguments Example RTE_LATCHDEL 0x010e void PD llatchDEL int din This call is used to latch any previously specified delay times into the DP2 Refer toPD1 User s Guide for more information din Device index number See previous example 2126 XBDRV Software Reference PD lwhatD EL din Op Code Prototype Description Arguments Example RTE_WHATDEL 0x0113 qint PD1whatDEL int din This call returns micro code version and device information for the installed delay hardware Refer to PD1 User s Guide for more information on decoding the returned value din Device index number See PD 1 User s Guide HTI Head Tracker Interface 2201 HTI Head Tracker Interface Overview HTI is an XBUS compatible interface to the Polhemus FASTRAK and ISOTRAK II head trackers The HTI relieves the host PC from the tasks associated with receiving and decoding FASTRAK information By default the Head Tracker Interface will program the FASTRAK to run in 16 bit mode whereby azimuth elevation and roll as well as X Y and Z information is available at a rate of up to 120 Hz In this default mode angles will be passed with a 0 02 degree accuracy and displacement information is available with a 0 03 cm accuracy The HTI also allows the host to communicate directly with the FASTRAK and provides a means for sending and receiving raw commands For more information on using the Polhemus FASTRAK refer to the FASTRAK user s man
152. se step Op Code Prototype Description Arguments Example PA4 SETUP 0x17 void PA4setup int din float base float step Configures the STEP mode on the PA4 The base parameter sets a base attenuation calibration level and step specifies the attenuation step size din Deviceindex number base Base attenuation in dB 0 0 99 9 steo Attenuation step sizein dB 0 1 10 0 PA4setup 1 20 0 3 0 This call would set the PA4 STEP mode to have 20 0 dB of base attenuation and step sizes of 3 0 dB 202 XBDRV Software Reference PA 4auto din Op Code Prototype Description Arguments Example PA4 AUTO 0x13 void PA4auto int din Programs the specified PA4 in AUTO mode to update attenuation dynamically while you dial in din Deviceindex number PA4auto 2 This sets PA4 1 in AUTO mode PA 4man din Op Code Prototype Description Arguments Example PA4 MAN 0x14 void PA4man int din Programs the PA4 to operate in MANUAL update mode enter the attenuation to take effect din Deviceindex number PA4man 1 This sets PA4 1 in MANUAL mode PA 4mute din Op Code Prototype Description Arguments Example PA4 MUTE 0x15 void PA4mute int din M utes the specified PA 4 din Deviceindex number PA4mute 1 PA 4nomute din Op Code Prototype PA4 NOMUTE 0x16 void PA4nomutef int din Description Arguments Example PA4 Programmable Attenuator
153. share all of the same mode codes For example an error will result if aDAmode 1 DAC4 call is made to a system having DA1 module DA zero is not available Uses the FASTDAC3 constant instead of FASTDAC Call either DA mode or AD mode but not both Include both the A D and D A constants in the function call eg DAmode 1 ADC2 DAC1 You cannot use A D or D A channels 3 and 4 with the DA mode or PD Imode functions The PD1 does not have FASTDAC mode SS1 Programmable Signal Switcher 1901 SS1 Programmable Signal Switcher Overview The SS1 is a versatile signal switcher utilizing a dedicated microprocessor and solid state switches to provide bi directional multi channel switching The SS1 can be configured as a quad 2 to 1 dual 4 to 1 or single 8 to 1 switch A 10 dB gain also can be applied at inputs 1 2 5 and 6 SSi1clear din Op Code Prototype Description Arguments Example SS1 CLEAR 0x11 void SSiclear int din Clears the current switching mode and sets the SS1 to the following factory default configuration All switches off OdB gain on all channels Quad 2 to 1 switching mode din Deviceindex number SSlclear 1 Resets SS1 1 to factory default mode guad 2 to 1 mode no gain all channels are off SSigainon din Op Code Prototype Description SS1 GAINON 0x12 void SSigainon int din Turns on the 10 dB gain at inputs 1 2 5 and 6 NOTE The SSl is a bi direction
154. t true gt on 0 gt low false gt off The logic of any I O line can be inverted by calling PI2logic with a lin the proper bit mask position NOTE Bits of logout which correspond to I O lines programmed as inputs will have no significance The same is true of login din Deviceindex number logout Ouput Logic Designation Mask O Positive 1 N egative login Input Logic Designation M ask 0 Positive 1 N egative Suppose the PI2 is interfaced to a subject response switch that pulls I O line 1 low false in positive logic each time the button is pressed The PI2 can be programmed to reverse the logic of this line with the following procedure call PI2logic 1 0x00 0x01 So pressing the button will be interpreted as true Pl 2debounce din dbtime Op Code Prototype Description Arguments Example PI2 DEBOUNCE 0x16 void Pl2debounce int din int dbtime Enables PI2 s Debouncing feature on all input lines din Deviceindex number dbtime Debounce time in ms 0 255 See example under PI2map Pl2 Parallel Interface 1005 Pl2latch din Imask Op Code PI2 LATCH 0x18 Prototype void Pl2latch int din int Imask Description Programs the Pl2 s Input Latching feature This feature will latch selected Imask input bits which become true after optional logic inversion until they are acknowledged by the host computer The latch is automatically cleared when the PI2 inputs are read from
155. the specified A D2 Return Values IDLE O AD2idle no conversion in progress ARM 1 AD2armed ready for trigger ACTIVE 2 AD2conversion in progress din Deviceindex number do while AD2status 1 ACTIVE lt AD2 Instrumentation A D Converter 1611 This will cause the program to pause while AD2 1 finishes converting the present sample buffer AD 2clip din Op Code Prototype Description Arguments Example AD2 CLIP 0x1D int AD2dip intdin Returns the status of the clip detector Return Values number of clips that have occurred din Deviceindex number AD2arm 1 AD2go 1 do if AD2clip 1 gt 4 AD2stop 1 while AD2status 1 ACTIVE This example will stop AD2 1 if the A D clips more than four times 1612 XBDRV Software Reference this page intentionally left blank DA3 2 4 8 Multi Channel Instrumentation D A 1701 DA3 2 4 8 Multi Channel Instrumentation D A D A 3clear din Op Code Prototype Description Arguments Example DA3 CLEAR 0x1E void DA3clear int din Clears the specified DA3 and resets it to factory default settings Defaults Sampling rate V 20us 50kHz of conversions 1000 Channel mode DAC1 Single triggering Clip feature disabled Slew Correction Off no load cap din Deviceindex number See example for D A 3go D A3arm din Op Code Prototype Description Arguments Example DA3 ARM 0x13 void DA3arm int din
156. tion M ask 0 Positive 1 N egative Suppose the PIT is interfaced to a subject response switch that pulls I O line 1 low false in positive logic each time the button is pressed The PI1 can be programmed to reverse the logic of this line with the following procedure call PIllogic 1 0x00 0x01 So pressing the button will be interpreted as true Pl lwrite din bitcode Op Code Prototype Description PIL WRITE 0x14 void Plwrite int din int bitcode Writes the specified bit code to PI1 output lines Note that any outputs specified to have negative logic will have output levels inverted from the bitcode specified for that line Also bits corresponding to I O lines programmed as inputs have no significance Arguments Example PI Parallel Interface 705 din Device index number bitcode Output bit code Pllclear 1 PIlouts 1 Oxff Plilogic 1 0x0f 0x00 PIlwrite 1 Oxff After the above program is run LEDs 1 through 4 will be off while LEDs 5 through 8 will be on Pl lread din Op Code Prototype Description Arguments Example PIL READ 0x15 int Pllread int din Reads the current inputs lines Note that any inputs designated to have negative logic will read as 1 when the input is low and 0 when the input is high din Deviceindex number PI1clear 1 PIllogic 1 0x00 Oxfe i PIlread 1 If input 1 is held low while inputs 2 through 7 are allowed t
157. to this basic mode with the PD lresetD SP call see below Each DSP can be made to run in either bypassed or no pass mode using the PD lbypass and PD lidle calls explained below The following calls make extensive use of a bit mask to specify DSPs within the PD1 In a specification bit mask bit position zero LSBit corresponds to DSP 0 and bit 1 to DSP 1 etc Specifying 1 in amask bit position sends the command to the appropriate DSP PD lidleD SP din dmask Op Code RTE_IDLEDSP 0x0116 Prototype void PD1lidleDSP int din long dmask Description Places the specified DSP s in IDLE mode In this mode output ports will always read zero and all input ports are ignored Arguments din Device index number dmask DSP specification mask see above Example PDlidleDSP 1 0x3 This call will place DSPs 0 and lin idle mode PD lbypassD SP din dmask Op Code RTE BYPASSDSP 0x010c Prototype void PD1bypassDSP int din long dmask Description Places the specified DSP s in BYPASS mode In this mode DSPinL gt DSPoutL and DSPinR gt DSPoutR The COEF input port will be ignored Arguments din Device index number dmask DSP specification mask see above Example PDlbypassDSP 1 0x30 This call will place DSPs 4 and 5in bypass mode 2118 XBDRV Software Reference PD lresetD SP din dmask Op Code Prototype Description Arguments Example RTE RESETDSP 0x010b void PD 1resetDSP int din long dmask
158. totype void CGIlstop int din Description Places the specified CG1 in IDLE mode Arguments din Deviceindex number Example CGlstop 1 This will stop CG1 1 from producing output CG ltrig din tcode Op Code CG1 TRIG 0x14 Prototype void CGltrig int din int tcode Description Programs the trigger enable input of the CG1 The valid trigger types are listed below NOTE When using an enable type triggering the CG1 repetition counter is disabled see CG lreps Arguments din Deviceindex number tcode Trigger type code 1 5 POS EDGE Rising edge triggered NEG EDGE Falling edge triggered POS ENABLE High leva enabled NEG ENABLE Low level enabled NONE Free running Example CGltrig 1 POS_EDGE This will program CG1 1 to rising edge triggered If no input is applied to the CG1 ENABLE input a following CG1go call will manually trigger the device CG1 Clock Generator 403 CG lreps din nreps Op Code Prototype Description Arguments Example CG1 REPS 0x13 void CGlreps int din int nreps Programs the number of periods of the specified waveform the CG1 will output each time it is triggered Remember that this feature is disabled when the trigger enable input is programmed to POS ENABLE or NEG ENABLE see CG ltrig din Deviceindex number nreos Number of periods to output 0 30000 Use nreps 0 for continuous output CGltrig 1 POS_EDGE CGlreps 1 3 The following output will be gene
159. trig can be issued while the AD2 is in multiple external triggering mode to place it back into single triggering mode This provides a way to stop the AD2 from software after the next buffer conversion is complete without disabling the external triggering source din Deviceindex number AD2mtrig 1 AD2arm 1 This will cause AD2 1 to begin converting at each external trigger The AD2 will not retrigger until conversion of the present buffer is complete AD 2reps din nreps Op Code Prototype Description Arguments AD2_REPS 0x1C void AD2reps int din unsigned int nreps Sets the number of times the AD2 can be re triggered after an AD 2arm is issued Valid only in multiple trigger mode din Deviceindex number nreos Repeat triggers before rearming 0 60 000 Example AD2 Instrumentation A D Converter 1607 AD2reps 1 100 If this line is added to the example given for AD 2mtrig AD2 1 will respond only to the first 100 triggers received AD 2srate din sper Op Code Prototype Description Arguments Example Note AD2 SRATE 0x15 void AD2srate int din float sper Sets the per channel sampling rate in terms of microseconds per sample of the specified AD2 Use only when compatibility with older hardware is required see Note below See also AD 2sampsep din Deviceindex number sper Sampling period 2us 2000us AD2srate 1 20 0 Sets the per channel sampling rate of AD2 1 to
160. ts Example PI2 WRITE 0x14 void Pl2write int din int bitcode Writes a specific bit pattern to the main output lines Note that any outputs specified to have negative logic will have output levels inverted from the bitcode specified for that line Also bits corresponding to I O lines programmed as inputs have no significance din Device index number bitcode Output bit code PI2clear 1 PI2outs 1 Oxff PI2logic 1 0x0f 0x00 PI2write 1 Oxff After the above program is run LEDs 1 through 4 will be off while LEDs 5 through 8 will be on Pl 2read din Op Code Prototype Description Arguments Example PI2 READ 0x15 int Pl2read int din Reads the bit pattern on the main input lines Note that any inputs designated to have negative logic will read as 1 when the input is low and 0 when the input is high din Deviceindex number PI2clear 1 Pl2logic 1 0x00 Oxfe i PI2read 1 If input 1 is held low while inputs 2 through 7 are allowed to float high PI2read will return 0x00 Pl2 Parallel Interface 1013 Pl 2setbit din bitmask Op Code Prototype Description Arguments Example PI2 SETBIT 0x18 void Pl2setbit int din int bitmask Similar to Pl 2write but sets output lines specified in a bit mask and leaves the others unchanged logical OR Note that outputs specified for negative logic will have low output levels if set Also bits corresponding to Smart Port l
161. ts Number of conversions 1 2 DDinpts 1 500000 This call will set up DD1 1 to perform 500 000 conversions which corresponds to 10 seconds at 50kH z sampling rate DD 1clkin din scode Op Code Prototype Description Arguments Example DD1 CLKIN 0x16 void DDIcikin int din int scode Selects the source of the sampling dock for the specified DD1 This is useful for synchronizing DD1 conversions with other devices din Deviceindex number scode Clock source 1 4 INTERNAL 1 Internal sample clock EXTERNAL 2 Front panel BNC XCLK1 3 XBUS patch line XCLK2 4 XBUS patch line DD1iclkin 1 EXTERNAL This call will set up DD1 1 to use its front panel BNC for the sampling clock 1508 XBDRV Software Reference DD 1clkout din dcode Op Code Prototype Description Arguments Example DD1 CLKOUT 0x17 void DD1clkout int din int dcode Asserts the DDTS internal sampling clock onto an XBUS internal patch line This is useful for synchronizing other devices with DD1 conversions din Deviceindex number dcode Patch line code 3 5 XCLK1 3 XBUSpatch line XCLK2 4 XBUSpatch line NONE 5 Nodo patch DDiclkin 1 INTERNAL DDiclkout 1 XCLK1 This call will set up DD1 1 to use its internal sampling dock and assert it to the XCLK1 line on the XBUS where it can be used to synchronize other devices on the bus DD Iclipon din Op Code Prototype Description Arguments
162. ty refpos Reference position Example To reference the motor to zero degrees manually through the front panel Press the REFERENCE button then turn the dial until the motor is positioned to zero degrees Press ENTER To reference manually through programming move to the position you want to reference using MC1pos and MC1move then call M Clreference with the value of this reference position This will rereference the last position set by MC1pos to the value refpos MC1 Motor Controller 2405 M Clfilter int din int par int v Prototype void MCifilter int din int par int v Description Sets the filter coefficients for the motor Arguments din Device index number par Parameter FP Kp 0x08 FP Ki 0x04 FP Kd 0x02 FP Ilim 0x01 V Value Notes These coefficients are specific to the motor you are using and the load that is on the motor They should be set to provide smooth motion See the motor catalog for approximate values that should work for your motor Example M C1status int din Prototype int M Cistatus int din Description Checks the status of the motor controller Arguments din Device index number STAT OFF 0 STAT STATIC 1 STAT MOVE 2 STAT_ERROR 3 Example The following example waits for the motor to finish moving before playing a sound MCipos 1 20 MClimove 1 do while MClstatus 1 STAT_MOVE lt code to play sound 2406 XBDRV Software Reference M Clcurpos int din Prototype i
163. ual When HTI is used to interface Polhemus FASTRAK different baud rates can be selected by setting the I O SELECT switches on the back of FASTRAK and the jumpers on the back of HTI We highly recommend use of 38 400 baud rate The available HTI jumper settings and corresponding FASTRAK switch settings are illustrated on the following diagram Baud Rate HTI FASTRAK 49006 oo 12345678 Fon coo NN NUNNU gorr od od 1 674 naje 38 400 ojo ojo CE o o NOT USED DODO ood m o NOT USED ooo ooo 2202 XBDRV Software Reference The HTI does not require a NULL modem cable The cable used to connect FASTRAK and PC is aNULL modem cable which cannot be used to interface H TI and FASTRAK HTI version 3 0 and earlier supports only FASTRAK HTI versions 4 0 and later support both FASTRAK and ISOTRAK I The HTI power up mode is always FASTRAK mode Calling HTlisiSO 1 will put the HTI in ISOTRAK II mode and calling HTIclear 1 will put it back to FASTRAK mode To manually switch the HTI from the FASTRAK mode to ISOTRAK II mode or vice versa press and hold the START STOP button at the top left of the HTI panel until the LED next to this button stops blinking When the button is released the display on the front panel will indicate the present mode HTIclear din Op Code HTI CLEAR 0x11 Prototype void HTIclear int din Desc
164. ude xbdrv h define YES 0x01 define NO 0x02 define PANIC 0x04 void main int i clrscr XBlinit USE_DOS i PIlread 1 if i switch i printf PI1 Subject Response Box Demonstration printf n n Press any key to quit Clear to factory default PIlclear 1 Make lines 4 thru 8 outputs Note unused made outputs to simplify input ecoding PIlouts 1 0xf8 Flip the logic for the buttons inputs RY PIllogic 1 0x00 0x07 Latch all of the input lines A PIllatch 1 0x07 Enable input debouncing PI1debounce 1 Autotime all output lines x PIlautotime 1 0x70 500 0 Send logic table for LED activity Hh PIlmap 1 0x01 0x10 PIlmap 1 0x02 0x20 PIlmap 1 0x03 0x70 PIlmap 1 0x04 0x40 PIlmap 1 0x05 0x70 PIlmap 1 0x06 0x70 PIlmap 1 0x07 0x70 lines are PI Parallel Interface 709 case YES gotoxy 10 10 printf Yes hi break case NO gotoxy 10 10 printf NO break case PANIC gotoxy 10 10 printf PANIC a break default gotoxy 10 10 printf Error ae else gotoxy 10 10 printf a delay 1000 Dummy delay Jwhile kbhit void getch Plllatch din Imask Op Code Prototype Description Arguments Example PIL LATCH 0x18 void Pl llatch int din int Imask Programs the PI1 s Input Latching feature This featur
165. v int din Returns the hardware version of the specified XB1 Caddie or XBUS device module If dev lt 0 returns the version of caddie arbiter din NOTE This command works only with XBUS hardware versions 3 0 and above dev DevicetypelD code XB1 Device Caddie 105 din Device index number or caddie number Example XBlversion 0x11 1 This returns version number of AD1 1 106 XBDRV Software Reference XB lselect int cprt Op Code Prototype Description Arguments Example NA void XBiselect int cprt When controlling a systen with two AP2s and two XBUSes XBlselect is used to toggle control between the XBUSes Do not use this call unless you have two AP2s and two XBUSes in a single computer cprt XBUS Command Port APa Select XBUS connected to APa APb Select XBUS connected to A Pb XBlselect APa This call selects the XBUS connected to APa Commands following this call will take effect in this selected XBUS PA4 Programmable Attenuator 201 PA4 Programmable Attenuator PA 4atten din level Op Code Prototype Description Arguments Example PA4 ATT 0x20 void PA 4atten int din float level Programs the specified PA4 with the attenuation level specified The attenuation level is rounded to the nearest tenth of a dB din Deviceindex number level Attenuation in dB 0 0 99 9 PA4atten 1 20 0 Programs PA4 1 with an attenuation of 20 0 dB PA 4setup din ba
166. viceindex number Example coeff Filter coefficient See PF1b16 Pl2 Parallel Interface 1001 Pl2 Parallel Interface Overview The PI2 is a smart parallel interface utilizing a dedicated microprocessor to drive eight smart TTL I O lines and four auxiliary 8 bit ports for general purpose digital I O A logical diagram for the structures actually implemented in software is shown in the following diagram Controller Auto gt DB9 Connector Mapper KX we Output Output Input mE Latch Logic Output LIT 2 gt Control gt Selector i jm L M E D43 D44 s Input Input Latch Logic iP 6 Control E e S I E CI Fer T Bu D48 Aux I O ports 1 4 PI2 Logical Diagram The PI2 programming procedures make extensive use of mask type arguments whereby each bit in an 8 bit number is used to enable or disable a given feature on a specific I O bit The following diagram illustrates the relation between mask bits and the PI2 s front panel BN Cs 1002 XBDRV Software Reference The four Auxiliary I O Ports are accessed using the last three command calls in this section All other commands apply only to the eight main smart I O lines msb BIT MASK isb 7 6 5 4 3 2 10 AUX PORTS 3 4 gt The four Auxiliary I O Ports
167. ware after completion of the current sequence repetition din Deviceindex number See TG 6status TG 6baserate din brcode Op Code Prototype Description TG6 BASERATE 0x16 void TG6baseratef int din int brcode Sets the TG6 s base clock rate for output timing sequences Sequence patterns are specified in terms of integers ticks of this clock Arguments Example TG6 Timing Generator 1105 din Deviceindex number brcode Base rate time period _100ns 0 _lus 1 _10us 2 _100us 3 _ims 4 EXT 7 See example under TG 6new TG 6reps din rmode rcount Op Code Prototype Description Arguments Example 1 Continuous Example 2 Repeat n times TG6 REPS 0x1C void TG6reps int din int rmode int rcount Sets the seguence repetition mode and count The timing sequence can be made to run 1 continuously after triggering 2 for a set number of repetitions after a trigger or 3 once each trigger for a set number of repeat triggers din Deviceindex number rmode Repetition mode CONTIN REPS 0 TRIGGED_REPS 1 rcount Repetition count 0 32 000 0 infinite repetitions TG6reps 1 CONTIN REPS 0 TG6arm 1 3 TG6go 1 TG6 1 will produce timing sequence number 3 until TG 6stop is called TG6reps 1 CONTIN_REPS 10 TG6arm 1 3 TG6go 1 TG6 1 will produce timing sequence number 3 for 10 repetitions It must be armed before triggering again 1106 XBDRV So
168. ways known by both the XBUS device and the HOST computer When an XBUS command requires a device response the response data is always sent immediately after the SLAVE_ACK Therefore on computer platforms where incoming serial data is NOT buffered automatically it is necessary to hold system interrupts until the XBUS communication is complete unsigned char get8 void qint i long k if xb_eflag return 0 i iorec k Jwhile i lt 0 amp amp k lt xbtimeout if i lt 0 showerr Device not responding with byte value after SLAVE_ACK i 0 turn unsigned char i gint get16 void qint i bn long k gint rv unsigned char x 2 if xb_eflag return 0 r for bn 0 bn lt 2 bn k Jwhile i lt 0 amp amp k lt xbtimeout 18 XBDRV Software Reference else showerr Device not responding with integer valu E ACK ETN rv 0 turn rv gt unsigned long get32 void gint i bn unsigned long k unsigned long rv unsigned char x 4 if xb_eflag return 0 rv unsigned long x k 0 for bn 0 bn lt 4 bn do i iorec k Jwhile i lt 0 amp amp k lt xbtimeout if i gt 0 else showerr Device not responding with long value SLAVE_ACK rv 0 return rv Procedure Descriptions 19 Procedure Descriptions XBUS procedures are divided into groups based on t
Download Pdf Manuals
Related Search
Related Contents
Ficha técnica Samsung ME732KR-X Инструкция по использованию Outlook Express User Manual Bedienungsanleitung DVD-550SD (LOSA0805) Manual EVBUM2131 - NCP1230 90 Watt, Universal Input Adapter Power XF 5a - FITRE SpA - Website Les Courriers de Fab et Coco #1 – Partie1 Copyright © All rights reserved.
Failed to retrieve file