Hi Arena,

Sorry i completely missed your update on this subject. I'll get back to you
as soon as i get get the chance to look through the sensor code.

Best regards,
Martin

On Tue, May 17, 2011 at 9:36 AM, Arena Marco <
[email protected]> wrote:

> Hi Martin,
> thanks for your answer. I'm trying to program the 1.3 shimmer mote adding a
> flex gyro daughter board (plugged into the the expansion connector). I don't
> have any problem in sending me data from the two sensors at the same time,
> actually I have troubles in sending me data at different time. I understood
> you have already used SPINE with different sensors, how do you have
> implemented the resource sharing? If you need it I can show you the code I
> wrote for the gyro (but is very similar to the one I've already posted), I
> think my problem is in the Resource.release() method that it is not called
> at the right time.
>
> Many thanks!
> Marco
> ________________________________________
> Da: Martin Kjeldsen [[email protected]]
> Inviato: martedì 17 maggio 2011 8.36
> A: Arena Marco
> Cc: [email protected]
> Oggetto: Re: [Tinyos-help] ADC resource sharing problem
>
> Hi Arena,
>
> That's strange. If you were trying to access two sensors from the same
> driver, i could imagine you'd have issues and would need to use resource
> sharing. But i can't recall ever having issues with SPINE sending me data
> from two seperate drivers at the same time.
>
> Which mote are you programming? What does the other driver do?
>
> Best regards,
> Martin
>
>
> On Fri, May 13, 2011 at 11:50 AM, Arena Marco <
> [email protected]<mailto:
> [email protected]>> wrote:
> Dear All,
> I'm trying to simultaneously support 2 sensors on a single shimmer mote. I
> want to individually access the 2 sensors (e.g. sampling at different times)
> and I'm are trying to use TinyOS Resource interface to share the ADC but I'm
> dealing with some problems: it seems that the ADC is correctly configured
> but I'm not signaled by the ADC correctly. It is like ADC.dataReady (I use
> interface Msp430Adc12MultiChannel as ADC) is getting signalled to each
> driver every time the ADC is sampled but sampling the two sensor with a
> different rate, instead of receiving a dataReady event for each sensor at
> the shortest sampling time I have the opposite behaviour. It looks like
> resource arbiter doesn't work (it seems that the Resource.release event is
> not called at the right moment), do you have any suggestion?
> ======================================================================
> Here is the code of one of the two sensor, the other one is similar:
> configuration HilAccSensorC
> {
>  provides interface Sensor;
> }
> implementation
> {
>  components MainC, Mma7260P;
>  components new Msp430Adc12ClientAutoRVGC() as ADC;
>  components HilAccSensorP, SensorsRegistryC;
>  //-----------
>  components LedsC;
>  //----------
>  ADC.AdcConfigure -> HilAccSensorP;
>  HilAccSensorP.Resource -> ADC.Resource;
>  HilAccSensorP.ADC -> ADC;
>  MainC.SoftwareInit -> Mma7260P.Init;
>  MainC.SoftwareInit -> HilAccSensorP.Init;
>  //----------
>  HilAccSensorP.Leds -> LedsC;
>  //----------
>  HilAccSensorP.Boot -> MainC;
>  Sensor = HilAccSensorP;
>  HilAccSensorP.Mma7260 -> Mma7260P;
>  HilAccSensorP.SensorsRegistry -> SensorsRegistryC;
> }
> -----------------------------------------
> #include "Msp430Adc12.h"
> #include "Mma7260.h"
> module HilAccSensorP {
>  provides interface AdcConfigure<const msp430adc12_channel_config_t*>;
>  provides interface Init;
>  provides interface Sensor;
>  uses interface Mma7260;
>  uses interface Boot;
>  uses interface SensorsRegistry;
>  uses interface Msp430Adc12MultiChannel as ADC;
>  uses interface Resource;
>  //----------
>  uses interface Leds;
>  //----------
> }
> implementation {
>    uint16_t accData[3],dbuff[3];
>    uint8_t blinky = 0;
>    uint8_t valueTypesList[3] = { CH_1, CH_2, CH_3 };
>    uint8_t acquireTypesList[1] = { ALL };
>  uint8_t enableADC;
>
>  const msp430adc12_channel_config_t config = {
>      inch: INPUT_CHANNEL_A3,
>      sref: REFERENCE_VREFplus_AVss,
>      ref2_5v: REFVOLT_LEVEL_2_5,
>      adc12ssel: SHT_SOURCE_ACLK,
>      adc12div: SHT_CLOCK_DIV_1,
>      sht: SAMPLE_HOLD_4_CYCLES,
>      sampcon_ssel: SAMPCON_SOURCE_SMCLK,
>      sampcon_id: SAMPCON_CLOCK_DIV_1
>  };
>  adc12memctl_t memctl[2] = {
>       { INPUT_CHANNEL_A4, REFVOLT_LEVEL_2_5, 0},
>       { INPUT_CHANNEL_A5, REFVOLT_LEVEL_2_5, 1} };
>  command error_t Init.init() {
>    return SUCCESS;
>  }
>
>    event void Boot.booted() {
>      call Mma7260.setSensitivity(RANGE_6_0G);
>
>   // the driver self-registers to the sensor registry
>   call SensorsRegistry.registerSensor(ACC_SENSOR);
>   atomic {
>    enableADC = 0;
>  }
>   }
>    async command const msp430adc12_channel_config_t*
> AdcConfigure.getConfiguration()
>    {
>      return &config;
>    }
>    event void Resource.granted() {
>      call ADC.configure(&config,memctl,2,dbuff,3,0);
>    }
>    command uint8_t Sensor.getSignificantBits() {
>      return 12;
>    }
>    task void dataReady() {
>      signal Sensor.acquisitionDone(SUCCESS, acquireTypesList[0]);
>   call Leds.led0Toggle();
>   call Resource.release();
>    }
>
>    command error_t Sensor.acquireData(enum AcquireTypes acquireType) {
>      call Leds.led1Toggle();
>   if (acquireType != acquireTypesList[0])
>         return FAIL;
>   atomic {
>  enableADC = 1;
>   }
>   call Resource.request();
>      return call ADC.getData();
>    }
>    async event void ADC.dataReady(uint16_t *data,uint16_t numSamples) {
>      if(enableADC == 1)
>   {
>    atomic {
>   enableADC = 0;
>
>   if (numSamples > 3)
>     numSamples = 3;
>   memcpy(accData, data, sizeof(*data)*numSamples);
>    }
>    post dataReady();
>   }
>     }
>
>    command uint16_t Sensor.getValue(enum ValueTypes valueType) {
>   switch (valueType) {
>          case CH_1 : return accData[0];
>          case CH_2 : return accData[1];
>          case CH_3 : return accData[2];
>          default : return 0xffff;
>        }
>    }
>    command void Sensor.getAllValues(uint16_t* buffer, uint8_t* valuesNr) {
>   *valuesNr = sizeof valueTypesList;
>   atomic {
>           memcpy(buffer, accData, sizeof(*accData)*3);
>      }
>    }
>    command enum SensorCode Sensor.getSensorCode() {
>      return ACC_SENSOR;
>    }
>    command uint16_t Sensor.getSensorID() {
>      return 0x2249; // the ID has been randomly choosen
>    }
>    command uint8_t* Sensor.getValueTypesList(uint8_t* valuesTypeNr) {
>      *valuesTypeNr = sizeof valueTypesList;
>      return valueTypesList;
>    }
>    command uint8_t* Sensor.getAcquireTypesList(uint8_t* acquireTypesNr) {
>      *acquireTypesNr = sizeof acquireTypesList;
>      return acquireTypesList;
>    }
> }
>
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]<mailto:
> [email protected]>
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to