On Sun, 22 Feb 2009, Gonzalo A. de la Vega wrote:
> With the default kernel 2.4 you get usleep() of 10ms, so
> usleep(1)=usleep(1000)=usleep(10000)... thats 10ms.
Yes. This is an FAQ for the 2.4 kernels. usleep only gives you
a resolution of 1/HZ where HZ is usually set to 100 in the kernel.
Girisha can of course recompile his kernel and attempt to generate
a higher clock tick rate - say 1000Hz to give him a resolution of a
millisec.
> Then your program
> does something and that's 10 more ms, so you get
> 20ms/read*1000read=20s.
No. You can actually get a program to do things every 10millisecs. My
adc_logger program can log samples every 10millisecs and a bit. So I
suspect something else is happenning here.
> I understand read_channel() as defined on ep93xx_adc.h is using EoC.
> Have you tried looking at the input with an oscilloscope?
>
> On Sat, Feb 21, 2009 at 10:59 PM, Girisha De Silva
> <> wrote:
>> Hey
>>
>> Thanks Rod for your reply. Anyways this is what I do in the loop.
>>
>> cur_ch = ADC_CH2;
>>
>> //discard two samples
>> read_channel(adc_page, cur_ch);
>> read_channel(adc_page, cur_ch);
>>
>>
>> //read 1000 more samples
>> for(j = 0; j < NOSAMPLE; j++)
>> {
>> usleep(1000);
>> adc_result[j] = read_channel(adc_page, cur_ch);
>>
>> avg = adc_result[j];
>>
>> if(avg < 0x7000)
>> avg = avg + 0x10000;
>>
>> avg = avg - 0x9E58;
>> val = ((double)avg * 3.3) / 0xC350;
>>
>> sprintf(pBuff,"%f",val);
>> fprintf(file,"%s\n",pBuff);
>>
>> }
>>
>> Hope I am doing it the correct way.
>>
>> Regards Girisha
>>
>> ________________________________
>> From: Rod Nussbaumer <>
>> To:
>> Sent: Sunday, February 22, 2009 1:11:06 AM
>> Subject: [ts-7000] Re:U Sleep
>>
>> How are you reading the ADC? Most ADCs have a bit somewhere to signal
>> End-of-Conversion. If your loop is simply reading a register that is
>> supposed to contain converted data, but is not waiting for EoC, that
>> would explain erratic readings. If a time-delay is inserted, as with
>> usleep(), it would allow time for the conversion to complete, and
>> provide you with valid readings. Again, this is consistent with the
>> behavior you are seeing. Can you confirm that you are reading the ADC in
>> a way that assures it has completed a conversion?
>> --- rod.
>>
>>
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|