Test and Measurement Forum

Error: The sample time interval is out of range

Post your C and C++ discussions here

Error: The sample time interval is out of range

Postby Philemon » Wed May 04, 2016 8:18 am

Hello all,

I keep getting this error (The sample time interval is out of range) while running ADC-24. i cant understand what does it mean. i didnt find anything in the manual for the range of the interval other than it has to be longer than (conversionTime)*(NoOfChannels).

Also, there are times that function HRDLRun(....) takes forever to return something. and the programm just stayes there waiting. and other times it just executes in no time. Could this be a problem or should i just wait till it finishes.

can someone help?
thanks a lot!!
Philemon
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Hitesh » Thu May 05, 2016 9:57 am

Hi Philemon,

Could you please post your code to show what parameters you are setting for the channels as well as the HRDLSetInterval() function?

With regards to the HRDLRun() function, what mode of collection are you using and what is the version of the picohrdl dll?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Error: The sample time interval is out of range

Postby Philemon » Thu May 05, 2016 10:54 am

Hi Hitesh,
thanks for the reply.

here is the code for the two functions i use for setting the channels and interval

Code: Select all
int SetChannels()
{
   int i, choise=0, yn, more, choiseChannel, choiseRange, existance=0, errorCode;
   char line[80];

   for(i=0; i<16; i++)
   {
      s_channelSettings[i].enabled = 0;
      s_channelSettings[i].error = 1;
      s_channelSettings[i].range = 0;
   }
/*---------------------Selecting-Channels-------------------------------------------*/
   printf("\nHow many channels do you want to use? (1-16) \n... ");
   scanf("%d", &NumberOfChannels);

   if(NumberOfChannels == 16)
   {
      for(i=0; i<16; i++)
         s_channelSettings[i].enabled = 1;

      printf("\nAll channels are active");
   }

   if(NumberOfChannels!=16)
   {
      printf("\nInput the numbers, of the channels you want to use (1-16)\n");

      for(i=0; i<NumberOfChannels; i++)
      {
         printf("%d: ", i+1);
         scanf("%d", &choise);
         s_channelSettings[choise-1].enabled =1;
      }
   }
/*-----------------------Voltage-Range----------------------------------------------*/
   printf("\nAll Voltage ranges set by default to 2500mV.");
   printf("\nDo you want to change this? ( y=1 / n=0 )\n... ");
   scanf("%d", &yn);

   if(yn == 1)
   {
      printf("\nChoose one of the voltage ranges in mV:\n(write one of the numbers 1-7)");
      printf("\n1-2500 \n2-1250 \n3-625 \n4-312.5 \n5-156.25 \n6-78.125 \n7-39.0625");

      printf("\nThese are the active channels: \n");
      for(i=0; i<16; i++)
      {
         if(s_channelSettings[i].enabled == 1)
         {
            printf("%d  ", i+1);
         }
      }

      do
      {
         printf("\nFor which channel do you wish to change the voltage range?\n... ");
         scanf("%d", &choiseChannel);

         printf("\nWhat is the voltage range you want for this channel?\n... ");
         scanf("%d", &choiseRange);

         s_channelSettings[choiseChannel-1].range = choiseRange;

         printf("\nDo you want to change the voltage range in an other channel? ( y=1 / n=0 )\n... ");
         scanf("%d", &more);
      }while (more != 0);
   }

/*---------------------------------Single-ended VS differential --------------------------------------------*/
   printf("\nAll channels are set to Single-Ended measurement. \nDo you want to change this? ( y=1 / n=0 )\n... ");
   scanf("%d", &yn);

   if(yn == 1)
   {
      printf("\nThese are the available channels: \n");
      for(i=0; i<16; i++)
      {
         if(s_channelSettings[i].enabled == 1 && i%2!=0)
         {
            printf("%d  ", i+1);
         }
      }
      do
      {
         printf("Please choose a channel\n... ");
         scanf("%d", &choiseChannel);
         s_channelSettings[choiseChannel-1].singleEnded = 0;

         printf("Do you want to set to differential an other channel? ( y=1 / n=0 )\n... ");
         scanf("%d", &more);
      }while (more != 0);
   }

/*-----------------------------Finito-----------------------------------------------------------------------------*/
   for(i=0; i<16; i++)
   {
      if(s_channelSettings[i].enabled == 1)
      {
         s_channelSettings[i].error = HRDLSetAnalogInChannel(TheDevice, i, s_channelSettings[i].enabled,   s_channelSettings[i].range, s_channelSettings[i].singleEnded);
      }
   }


   for(i=0; i<16; i++)
   {
      if(s_channelSettings[i].error == 0)
      {
         errorCode = HRDLGetUnitInfo(TheDevice, line, sizeof (line), HRDL_SETTINGS);
         if(errorCode != 0 && errorCode != 1 && errorCode != 2 && errorCode != 9)
         {
            switch (errorCode)
            {
               case 0: printf("\n\nError occurred with channel %d: \nThe conversion time parameter is out of range", i+1); break;
               case 1: printf("\n\nError occurred with channel %d: \nThe sample time interval is out of range", i+1); break;
               case 2: printf("\n\nError occurred with channel %d: \nThe conversion time chosen is not fast enough \nto convert all channels within the sample interval", i+1); break;
               case 3: printf("\n\nError occurred with channel %d: \nThe channel being set is valid but not currently available", i+1); break;
               case 4: printf("\n\nError occurred with channel %d: \nThe channel being set is not valid for this device", i+1); break;
               case 5: printf("\n\nError occurred with channel %d: \nThe voltage range being set for this device is not valid", i+1); break;
               case 6: printf("\n\nError occurred with channel %d: \nOne or more parameters are invalid", i+1); break;
               case 7: printf("\n\nError occurred with channel %d: \nA conversion is in progress for a single asynchronous operation", i+1); break;
               case 8: printf("\n\nError occurred with channel %d: \nCommunication failed", i+1); break;
            }
            existance++;
         }
      }
   }

   if(existance != 0) {printf("\nError occurred while setting the channels. Please try again."); SetChannels();}

   return 0;
}

int SetIntervals()
{
   int Rate, conv, conv60, conv100, conv180, conv340, conv660;
   long interval;
   float sugg_interv, sugg_rate;

   printf("\nLets set the timings for our sampling");

   printf("\nGive the conversion time");
   printf("\n(Write one of the numbers: 60ms, 100ms, 180ms, 340ms, 660ms) \n... ");
   scanf("%d", &time);

   sugg_interv = (float) time * (float) NumberOfChannels;
   sugg_rate   = 1000 / sugg_interv;

   printf("\nGive me the rate of the measurements for each channel");
   printf("\nGiven rate must be lesser than or equal to %2.1f(counts/s) \n... ", sugg_rate);
   scanf("%d", &Rate);

   interval = 1000 / Rate;

   switch (time)
   {
      case 60:  conv60  = HRDLSetInterval (TheDevice, (long) interval, HRDL_60MS);  conv = conv60;  break;
      case 100: conv100 = HRDLSetInterval (TheDevice, (long) interval, HRDL_100MS); conv = conv100; break;
      case 180: conv180 = HRDLSetInterval (TheDevice, (long) interval, HRDL_180MS); conv = conv180; break;
      case 340: conv340 = HRDLSetInterval (TheDevice, (long) interval, HRDL_340MS); conv = conv340; break;
      case 660: conv660 = HRDLSetInterval (TheDevice, (long) interval, HRDL_660MS); conv = conv660; break;
   }

   return conv;
}

As for the HRDLRun() function, i use the block for the mode of collection (HRDL_BM_BLOCK)
and for the picohrdl.dll version, is 1.4.0.205

thank you
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Hitesh » Mon May 09, 2016 1:43 pm

Hi Philemon,

What are you setting for the value of Rate?

Having run your code with, I can see that Rate is being assigned to an int value which could be causing a problem (particularly when the rate is less than 1 as it results in a divide by zero exception).

I would suggest the following:

Code: Select all
float Rate;
scanf("%f", &Rate);

If this does not work, then what values are you passing into the HRDLSetInterval() function?

With regards to the HRDLRun() function, please e-mail support@picotech.com indicating if you require a 32-bit or 64-bit driver and this can be made available for you to download.

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Error: The sample time interval is out of range

Postby Philemon » Mon May 09, 2016 7:08 pm

Hello Hitesh,

For the value of Rate: i am using this value to overcome the difficult (for me) concept of interval. i was thinking that, instead of asking the user to insert the conversion time and the interval, to ask him to input the conversion time and the rate (samples per second (Hz)). i do that because i find the concept of rate easier to use and more familiar for the user, since it is more common to speak about the sample rate than the sample interval. of course thats the way i see it and it doesnt have to be correct. Actually, could you please tell my why pico used interval rather than rate?

You are right about the int, i used it cause my usage will be with integer type rate, but you are right, i will change it.

The values i'm passing to HRDLSetInterval() are:
-TheDevice : global int type, the return of HRDLOpen(), what is called "handle" in the manual.
- interval : the interval for the collecting of the values. interval = 1000/Rate (splits 1 second in how many times the user wants to take a sample) (i believe the problem lies here, but im not sure what is it)
- HRLD_NUMBERMS : the conversion time chosen by the user.

thanks for the advice, i will send the mail!

thank you for the reply!
Phil
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Hitesh » Thu May 12, 2016 10:23 am

Hi Phil,

We refer to interval as opposed to rate as each reading takes time to settle to it's final value due to the fact that these are high resolution devices.

It might be useful to know the actual value being passed for the interval parameter and the conversion time selected in the call to HRDLSetInterval() when the error occurs as well as how many channels are enabled as this may give some indication as to why an error code is returned.

Did you send an e-mail to us?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Error: The sample time interval is out of range

Postby Philemon » Mon May 16, 2016 11:16 am

Hello Hitesh,

I see. So, this time that each reading needs, is excactly equal to the conversion time. right? or a little bit more?

The actuall values are (in the format of: (interval,conversion_time,channels):
*All uses of HRDLRun() in block mode

- (334, HRDL_60MS, 5), (200, HRDL_100MS, 2) error-> stucks between HRDLRun() and HRDLReady
- (334, HRDL_60MS, 5) error -> error number 2 after HRDLSetIntervals()
- (1000, HRDL_60MS, 16) error -> none, works fine
- (___, HRDL_60MS, 1) intreval: 63, 100, 112, 125, 143, 167, 200, 250, 334 error -> error number 2 after HRDLSetIntervals()
- (500, HRDL_60MS, 1) error-> during HRDL(GetTimesAndValues() crashes

- (1000, HRDL_60MS, 16) stream mode, error-> HRDLGetTimesAndValues() returns 0 either without returning any values or after returning just from the first run of the loop.


i did send you the mail yesteray.

thanks a lot!!
phil
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Philemon » Mon May 16, 2016 11:58 am

Also, forgot to tell,
i work with Eclipse Mars 2, on windows 7.
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Hitesh » Tue May 24, 2016 3:07 pm

Hi Phil,

Thanks for the information.

I've run some tests but am unable to reproduce the issue. Could you please post code that I can run here in order to try and replicate the issue?

I've seen that you've e-mailed us. Has the new driver had any impact?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Error: The sample time interval is out of range

Postby Philemon » Thu May 26, 2016 7:53 am

Hello!

I did email you but I couldn't download the file cause it wouldn't allow me, I needed some authorization. Could you please send it again?

Thanks again!
Phil
Philemon
Newbie
 
Posts: 0
Joined: Mon Mar 28, 2016 9:44 am

Re: Error: The sample time interval is out of range

Postby Hitesh » Thu May 26, 2016 8:45 am

Hi Phil,

The link has been checked. Could you please try it again and if you encounter the problem again please respond via your e-mail support ticket.

Thanks,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 2058
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests