Hello Friends ..

After lot of efforts i was able to implement Multichannel ADC interface
successfully .
i.e. Msp430Adc12Multichannel
It was wired to component Msp430Adc12ClientAutoRVGC which takes care of
internal reference voltage generator .

First i will explain steps to implement Multichannel interface .

for example .

----------------------------------------------------
uses interface Msp430Adc12MultiChannel as PhaseA;
----------------------------------------------------

PhaseA will be multichannel interface .

----------------------------------------------------
const msp430adc12_channel_config_t config1 =
 {
     INPUT_CHANNEL_A0, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_1_5,
     SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_4_CYCLES,
     SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
   };
----------------------------------------------------

config1 is configuration used for ADC

Here first channel to be sampled is A0 (it can be any channel ) (if we want
to measure 4 channels then its not mandatory that we should sample them in
their ascending order, we can measure them in any random way.)

REFERENCE_VREFplus_AVss -> it tells adc client that ref voltage is required
. and its value is given by REFVOLT_LEVEL_1_5


----------------------------------------------------
event void resource.granted()
{
adc12memctl_t memctl[ADCNUMS-1];
   memctl[0].inch=3;
memctl[1].inch=6;
 memctl[2].inch=7;
   for(i=0; i<ADCNUMS-1; i++)
     {
       memctl[i].sref=REFERENCE_VREFplus_AVss;
}
     numMemctl = ADCNUMS - 1;//chs - 1
 result = call PhaseA.configure(&config1, memctl , numMemctl , buffer ,
NUM_SAMPLES , JIFF );
   if (result == SUCCESS)
   {

       call PhaseA.getData();
       }
}

----------------------------------------------------


Here adc12memctl_t is structure which defines information about other
channels which are required to be sampled.
memctl is the variable of that structure . its an array with number of
elements equal to no of additional channel. (total no of channel -1)
here ADCNUMS is total no of channels .. here ADCNUMS=4
now memctl has 3 entries. memctl.inch -> it is the no of additional channel
to be sampled.
memctl.sref -> its reference voltage .
memctl.eos -> end of sequence. this is not needed to be given by user. Its 0
initially . and only for last channel to be sampled , its is internally set
to 1. More detail can be found in MSP430 users guide.


in PhaseA.configure numMemctl in additional no of channels.
buffer is the buffer array which should be declared earlier as uint16_t
buffer[NUM_SAMPLES]

JIFF is the delay required between sampling of channels . If JIFF = x (say)
then

channel 1 will be sampled -> delay of x ticks (of clock source given in
SAMPCON field of config1) -> channel2 will be sampled + delay . . . . .. .
.

this will continue till no of samples equals NUM_SAMPLES.

after that data ready event will be signalled

----------------------------------------------------
async event void PhaseA.dataReady(uint16_t *bufA, uint16_t numSamples )
----------------------------------------------------

here bufA contains samples. Samples are is positioned according to sequence
of sampling of channel.


In this way multichannel interface has to be used.

Now about Msp430Adc12ClientAutoRVGC() component .

this component when used , call configuration of adc when resources are
requested .
and it according to configuration , if internal ref voltage is required it
will make that work . and wait till voltage level is stabilized.

some precautions are needed to be taken when we use this component.

As it requires AdcConfiguration  ,
our application should provide that interface

----------------------------------------------------
provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
----------------------------------------------------

then we need to implement one command when configuration is requested by
client.
----------------------------------------------------
async command const msp430adc12_channel_config_t*
AdcConfigure.getConfiguration()
   {
     return &config1;
   }
----------------------------------------------------



Now in Component file .

----------------------------------------------------
components new Msp430Adc12ClientAutoRVGC() as PhaseA;


 App.PhaseA -> PhaseA;
   App.Resource -> PhaseA;
   App.AdcConfigure <- PhaseA;
----------------------------------------------------


this will wire client to our application so it can call to get our adc
configuration .

Thats all ..

Thanks a lot who helped me in this . Special thanks to Jan Hauer and Alfonso
Cardell .

Cheers ..


-- 
With Best Regards
Himanshu Barve
M.Tech Electrical Engineering (Power System)
IIT Kharagpur , West Bengal , India
Ph: - +91 9775201181
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to