No subject


Tue Jan 13 16:53:41 PST 2009


93.2ms not 100ms now.

Why is it incorrectly operate?
Our project must integrate sensor value with time. Thus exact conversion
period is important.

implementation
{


   const msp430adc12_channel_config_t config = {

    INPUT_CHANNEL_A0, REFERENCE_AVcc_AVss, REFVOLT_LEVEL_NONE,
    SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_64_CYCLES,
    SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1

   };

  event void Boot.booted()
  {
    call Resource.request(); //from adc test

  }
     adc12memctl_t memctl[16];
  uint8_t numMemctl;
  #define ADCNUMS 5
  #define NUM_SAMPLES 50
  uint16_t buffer[NUM_SAMPLES];

  event void Resource.granted()
  {
    error_t result;
    uint8_t i;

    for(i=0; i<ADCNUMS-1; i++){
     memctl[i].inch=i+1; //List of additional channels
     memctl[i].sref=REFERENCE_AVcc_AVss;
    }

    numMemctl = ADCNUMS - 1;//chs - 1

    //1000000 MCLK / 500 sample per sec for all chs = 2000.
    result = call MultiChannel.configure(&config, memctl, numMemctl, buffer,
NUM_SAMPLES, 2000);

    if (result == SUCCESS){
      call MultiChannel.getData();
    }
    else{

    }

  }

//This must be called every 100ms. 10hz.
       //But now it is called 93.2ms every.!!! Why?
  async event void MultiChannel.dataReady(uint16_t *buf, uint16_t
numSamples)
  {
call Leds.led1Toggle(); //check by oscilloscope LED1 pin.

call MultiChannel.getData(); //call next conversion sequence...

  }


best regards,
K.S.Lee

--0016e64f683ae8999a0462dbaef2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<span class=3D"Apple-style-span" style=3D"border-collapse: collapse; ">Hi a=
ll,<div><br></div><div>I am working with&nbsp;Msp430Adc12MultiChannel inter=
face.</div><div>But it has problem about conversion period.</div><div><br><=
/div><div>
It has 5 sensors which is assigned to from A0 to A4. Conversion period for =
each channel is&nbsp;</div><div>100hz and all channels have same configurat=
ion.</div><div>Thus a ADC into MSP430 will convert 500 per second.</div><di=
v>
To check ADC conversion complete timing I have used oscilloscope and LED1 p=
in.</div><div>From Below code , LED1 should toggle every 100ms. but it is t=
oggling at 93.2ms not 100ms now.</div><div><br></div><div>Why is it incorre=
ctly operate?</div>
<div>Our project must integrate sensor value with time. Thus exact conversi=
on period is important.</div><div><br></div><div><div>implementation</div><=
div>{ &nbsp;&nbsp;</div><div>&nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;&nbs=
p;</div><div>&nbsp;&nbsp; const msp430adc12_channel_config_t config =3D {</=
div>
<div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;INPUT_CHANNEL_A0, REF=
ERENCE_AVcc_AVss, REFVOLT_LEVEL_NONE,</div><div>&nbsp;&nbsp; &nbsp;SHT_SOUR=
CE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_64_CYCLES,</div><div>&nbsp;&nbsp; &n=
bsp;SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1&nbsp;</div><div>
&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; };</div><div>&nbsp;&nbsp;</div><=
div>&nbsp;&nbsp;event void Boot.booted()</div><div>&nbsp;&nbsp;{</div><div>=
&nbsp;&nbsp; &nbsp;call Resource.request();<span style=3D"white-space: pre;=
 ">	</span>//from adc test</div><div>&nbsp;&nbsp; &nbsp; &nbsp;</div><div>&=
nbsp;&nbsp;}</div><div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adc12memctl_t memctl[16];</div><div>&nbsp;&nb=
sp;uint8_t numMemctl;</div><div>&nbsp;&nbsp;#define ADCNUMS 5<span style=3D=
"white-space: pre; ">	</span></div><div>&nbsp;&nbsp;#define NUM_SAMPLES 50<=
/div><div>&nbsp;&nbsp;uint16_t buffer[NUM_SAMPLES];</div><div>&nbsp;&nbsp; =
&nbsp;&nbsp;</div>
<div>&nbsp;&nbsp;event void Resource.granted()</div><div>&nbsp;&nbsp;{</div=
><div>&nbsp;&nbsp; &nbsp;error_t result;</div><div>&nbsp;&nbsp; &nbsp;uint8=
_t i;</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;for(i=3D0;=
 i&lt;ADCNUMS-1; i++){</div><div>&nbsp;&nbsp; &nbsp;<span style=3D"white-sp=
ace: pre; ">	</span>memctl[i].inch=3Di+1;<span style=3D"white-space: pre; "=
>		</span>//List of additional channels</div>
<div>&nbsp;&nbsp; &nbsp;<span style=3D"white-space: pre; ">	</span>memctl[i=
].sref=3DREFERENCE_AVcc_AVss;</div><div>&nbsp;&nbsp; &nbsp;}</div><div>&nbs=
p;&nbsp; &nbsp;<span style=3D"white-space: pre; ">	</span></div><div>&nbsp;=
&nbsp; &nbsp;numMemctl =3D ADCNUMS - 1;//chs - 1</div><div>&nbsp;&nbsp; &nb=
sp;</div>
<div>&nbsp;&nbsp; &nbsp;//1000000 MCLK / 500 sample per sec for all chs =3D=
 2000.&nbsp;</div><div>&nbsp;&nbsp; &nbsp;result =3D call MultiChannel.conf=
igure(&amp;config, memctl, numMemctl, buffer, NUM_SAMPLES, 2000);</div><div=
>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nb=
sp;if (result =3D=3D SUCCESS){</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;call MultiChannel.getData();</div><div>&nbsp=
;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;else{</div><div>&nbsp;&nbsp; &=
nbsp;<span style=3D"white-space: pre; ">	</span></div><div>&nbsp;&nbsp; &nb=
sp;}</div><div>&nbsp;&nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp;}</div><div>=
<br></div><div><span style=3D"white-space: pre; ">	</span>//This must be ca=
lled every 100ms. 10hz.</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; //But now it is called 93.2ms every.!!! Why=
?</div><div>&nbsp;&nbsp;async event void MultiChannel.dataReady(uint16_t *b=
uf, uint16_t numSamples)</div><div>&nbsp;&nbsp;{</div><div><span style=3D"w=
hite-space: pre; ">	</span>call Leds.led1Toggle();<span style=3D"white-spac=
e: pre; ">		</span>//check by oscilloscope LED1 pin.</div>
<div><br></div><div><span style=3D"white-space: pre; ">	</span>call MultiCh=
annel.getData();<span style=3D"white-space: pre; ">	</span>//call next conv=
ersion sequence...</div><div>&nbsp;&nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nb=
sp;}</div><div><br></div><div>
<br></div><div>best regards,</div><div>K.S.Lee</div></div></span>

--0016e64f683ae8999a0462dbaef2--


More information about the Tinyos-help mailing list