Innovative Integration
 
Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
sampling more than 50000 per second

 
Post new topic   Reply to topic    II Support Forum Index -> Delfin
View previous topic :: View next topic  
Author Message
trides



Joined: 13 Dec 2008
Posts: 19
Location: Indonesia

PostPosted: Thu Jun 25, 2009 5:18 am    Post subject: sampling more than 50000 per second Reply with quote

Dear sir,
With the help from the available examples, I try to input analog data as in this code below :

Code:

#include "HdwLib.h"
#include "UtilLib.h"
#include "DspLib.h"
#include "..\HdwLib\UserData.h"
#include "..\HdwLib\DigitalIo.h"
#include <ctype>
#include <cstdlib>

using namespace II;

IntBuffer varku;

class LoopThread : public Thread
{           
public:
   LoopThread(AdcStream & ain, UserData & digio, IIPriority priority)
         : Ain(ain), Thread(priority), Looping(false), FCount(0), DigIO(digio)  { }

   // Methods         
   void       Start()
      {  Looping = true;  Starting.Release();  }      
   
   void       Stop()
      {  Looping = false;  Stopping.Acquire();  }
      
   // Properties
   int         Count() const
      {  return FCount;  }      
   
protected:   
   // Data
    AdcStream & Ain;
   UserData & DigIO;
   Semaphore    Starting;
   Semaphore    Stopping;
   bool      Looping;
   // Fields
   int       FCount;
   
   // Methods
   void Execute()
      { 
      while (!Terminated())
         {
         FCount = 0;
         Starting.Acquire();
         // echo input to output   
         while(Looping)
            {
            Ain.Get();
            varku = Ain.Buffer();
            ++FCount;
            DigIO.Data(varku[2]);
            }
         Stopping.Release();            
         //            
         }
      }
};


//---------------------------------------------------------------------------
//  IIMain() --  Loop analog input to output
//---------------------------------------------------------------------------

void IIMain()
{
    AdcStream Ain;
   UserData DigIO;
   DigIO.Config(15);
   LoopThread Loop(Ain, DigIO, tpNormal);
   Loop.Resume();
   
   volatile bool status;
   float SampleRate;

    SampleRate = 50000;

   BasicTmb Timebase;
   Timebase.Rate(SampleRate);
   Ain.Device().Attach(Timebase);
   
   int EventsPerBuffer = 1;
   int NumChannels = 10;

   for (int i = 0; i < NumChannels; ++i)
        Ain.Device().Channels().Enabled(i, true);
   Ain.Events(EventsPerBuffer);

   status = Ain.Open();
   
   // echo input to output   
   Loop.Start();
   while(!cio.KbdHit())
      {
      Sleep(50);
      }
   Loop.Stop();
      
      
   // Terminate streaming
   status = Ain.Close();      
}


I have sucsessfully done the acquisition with sample rate 50000. But when I change with more than 50000, it does not work. Can you tell me where the problem is ?

Second question, is there any example using the AdcFramedTmb ? I tried to change the timebase to this one for the code above, but it does not work either.

Thank you very much

--trides--[/quote]
Back to top
View user's profile Send private message Yahoo Messenger
jhenderson
Site Admin


Joined: 07 Mar 2006
Posts: 1177
Location: So. Cal. USA

PostPosted: Thu Jun 25, 2009 6:02 am    Post subject: Reply with quote

What is the failure mode when you exceed 50 kHz sampling rate? Try running the stock AnalogIn example .out file. Does it fail in a similar manner or does it work properly?

The Framed timebase will be of limited use on a Delfin, since the pipeline of the sigma-delta converters on the card will create a substantial amount of latency (see other Forum threads).
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    II Support Forum Index -> Delfin (GMT - 8 Hours)
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

© Copyright 2006-2008 Innovative Integration
Powered by phpBB © 2001, 2002 phpBB Group
Based on iCGstation v1.0 Template By Ray © 2003, 2004 iOptional