ECODE DTFUN::ConfigAD( UINT ChanType, UINT ListSize, DBL Gain, int ClockSource, DBL Freq, DWORD BufSize ) { int status; ECODE result= 0; BufferSize= (int)BufSize; result+= SetChanType( ChanType ); result+= SetChanList( ListSize, Gain ); Freq= SetClock(ClockSource, Freq ); // ClockSource=0 ... internal, 1=external result+= SetWndHandle(); result+= SetBuffers( BufSize ); ClockHz= Freq; // do we want to output the sample clock onto the user counter pin? // (this user counter pin can then be used as an A/D sample clock input for another board // and is also used to drive this particular board // NOTE that the user counter pin has to be wired externally to the A/D Sample Clock In pin if (outputclockonusercounter) { // set the cascade mode status= olDaSetCascadeMode(lphDassCT, OL_CT_SINGLE); // set up the clocks and gates // use an internal clock status= olDaSetClockSource(lphDassCT, OL_CLK_INTERNAL); // set the clock frequency status= olDaSetClockFrequency(lphDassCT, ClockHz); // specify the gate to enable the C/T operation status= olDaSetGateType(lphDassCT, OL_GATE_NONE); // status= olDaSetGateType(lphDassCT, OL_GATE_HIGH_LEVEL); // specify the mode for continuous output status= olDaSetCTMode(lphDassCT, OL_CTMODE_RATE); // as opposed to OL_CTMODE_ONESHOT // specify the output pulse type status= olDaSetPulseType(lphDassCT, OL_PLS_HIGH2LOW); // specify the duty cycle or pulse width status= olDaSetPulseWidth(lphDassCT, 100); // configure the subsystem status= olDaConfig( lphDassCT ); // if we use a self-generated clock, then pre-start the A/D conversion here // start of sampling will be triggered when counter/clock is started status= olDaStart( lphDass ); } return( result ); }
DBL DTFUN::SetClock(int ClockSource, DBL Freq ) { ECODE status; if(ClockSource == 0) { status= olDaSetClockSource( lphDass, OL_CLK_INTERNAL ); } else { status= olDaSetClockSource( lphDass, OL_CLK_EXTERNAL ); } status= olDaSetClockFrequency( lphDass, Freq ); status= olDaConfig( lphDass ); status= olDaGetClockFrequency( lphDass, &Freq ); return( Freq ); }
ECODE DTFUN::SetBuffers( DWORD BufSize ) { int i; ECODE retval= 0; status= olDaSetWrapMode( lphDass, OL_WRP_MULTIPLE ); dwSize= BufSize; for(i=0; i<BUFNUM; i++) { retval+= olDmAllocBuffer( 0, dwSize, &hbuf[i] ); retval+= olDaPutBuffer( lphDass, hbuf[i] ); } retval+= olDaConfig( lphDass ); d_count= 0; // initialize data counter BufferCount= 0; BufferPtr= 0; return( status ); }
void COctopusAOTF::Start( void ) { olDaSetClockFrequency( hdass_9834, 0.25 * freq * outbuffersize ); olDmAllocBuffer( 0, outbuffersize, &hBuf_DAC ); if( hBuf_DAC == NULL ) { AfxMessageBox(_T("Error Allocating buffer.")); return; } GenerateSignal(); olDaPutBuffer( hdass_9834, hBuf_DAC ); olDaConfig( hdass_9834 ); olDaStart( hdass_9834 ); B.AOTF_running = true; m_status_AOTF.SetBitmap( m_bmp_yes ); }
BOOL OctopusLaser::OnInitDialog() { CDialog::OnInitDialog(); ECODE status = NULL; TRACE("Initializing OctopusLaser\n"); hdrvr_9812 = NULL; hdass_9812_DAC = NULL; status = olDaInitialize(PTSTR("DT9812(00)"), &hdrvr_9812 ); if (status != OLNOERROR) { TRACE("Error: %lu\n ",status); AfxMessageBox(_T("Connect to DT9812 board failed.\nHave you plugged it in and turned it on?")); } status = olDaGetDASS( hdrvr_9812, OLSS_DA, 1, &hdass_9812_DAC ); status = olDaSetDataFlow( hdass_9812_DAC, OL_DF_SINGLEVALUE ); status = olDaConfig( hdass_9812_DAC ); if( status != OLNOERROR ) { TRACE("Error: %lu\n ",status); AfxMessageBox(_T("Error at Subsystem DAC")); } return TRUE; }