It sounds like your app is very similar to the TinyOS 2 "Oscilloscope"
app. Have you looked at the tutorial:
http://docs.tinyos.net/tinywiki/index.php/Sensing (+ compare your code
with the apps/Oscilloscope code)

Jan

On Mon, Oct 3, 2011 at 6:22 PM, Juan Verdu <[email protected]> wrote:
> Quizás quisiste decir: Hola, He encontrado una serie de errores impiden el
> código por
> Hello,
>
> The code has several serious errors sent. I attached a new code:
>
> TestAdcC.nc
>
> #include "Timer.h"
> #include "TestAdc.h"
>
> module TestAdcC
> {
>   uses  {
>   interface Boot;
>   interface Leds;
>   interface Timer<TMilli> as Timer0;
>   interface Msp430Adc12Overflow as overflow;
>   interface Msp430Adc12SingleChannel as adc;
>   interface Resource;
>   interface SplitControl as Control;
>   interface Packet;
>   interface AMSend;
>  }
>
> provides {
> interface AdcConfigure<const msp430adc12_channel_config_t*> as
> adc_configure;
> }
> }
>
> implementation
> {
> #define BUF_SIZE 100
> uint16_t buf[BUF_SIZE];
> message_t packet;
> uint16_t counter = 0;
>
> msp430adc12_channel_config_t adc_config = {
>     inch: SUPPLY_VOLTAGE_HALF_CHANNEL,
>     sref: REFERENCE_VREFplus_AVss,
>     ref2_5v: REFVOLT_LEVEL_1_5,
>     adc12ssel: SHT_SOURCE_SMCLK,
>     adc12div: SHT_CLOCK_DIV_1,
>     sht: SAMPLE_HOLD_64_CYCLES,
>     sampcon_ssel: SAMPCON_SOURCE_SMCLK,
>     sampcon_id: SAMPCON_CLOCK_DIV_1
>   };
>
> event void Boot.booted() {
>     call Leds.led0Off();
>     call Leds.led1Off();
>     call Leds.led2Off();
>     call Control.start();
>
> }
>
> event void Timer0.fired() {
>
>     call Resource.request();
>
>
>   }
>
> event void Control.startDone(error_t err) {
>     if (err == SUCCESS){
>     call Resource.request();
>         }
>     else
>     call Control.start();
>  }
>
> event void Control.stopDone(error_t err) { }
>
>
> async command const msp430adc12_channel_config_t*
> adc_configure.getConfiguration() {
> return &adc_config;
> }
>
> async event void overflow.conversionTimeOverflow() {
> }
>
> async event void overflow.memOverflow() {
> }
>
> async event error_t adc.singleDataReady(uint16_t data){
>
>     test_serial_msg_t* rcm = (test_serial_msg_t*)call
> Packet.getPayload(&packet, sizeof(test_serial_msg_t));
>     call Resource.release();
>     rcm->counter = data;
>     if(call AMSend.send(AM_BROADCAST_ADDR, &packet,
> sizeof(test_serial_msg_t)) == SUCCESS){
>         call Leds.led1Toggle();
>
>         return SUCCESS;
>
>   }
>   }
> async event uint16_t *adc.multipleDataReady(uint16_t *buffer, uint16_t
> numSamples){
>             return buffer;
>   }
>
> event void Resource.granted() {
>
>     error_t e;
>     e = call adc.configureSingle(&adc_config);
>     call adc.getData();
>
> }
>
> event void AMSend.sendDone(message_t* bufPtr, error_t error) {
>
>     call Timer0.startOneShot(3072);
>
>
>   }
>
> }
>
>
> TestAdcAppC.nc
>
> #include "TestAdc.h"
> configuration TestAdcAppC {
> }
> implementation
> {
> components MainC,
>              TestAdcC,
>              LedsC;
>
> components ActiveMessageC as AM;
> components new TimerMilliC() as Timer0;
> components new Msp430Adc12ClientAutoRVGC() as Lectura;
>
> //components new TimerMilliC() as Timer1;
>
>
> TestAdcC.overflow -> Lectura;
> TestAdcC.Resource -> Lectura;
> TestAdcC.adc -> Lectura;
> TestAdcC.adc_configure <- Lectura;
>
> TestAdcC -> MainC.Boot;
> TestAdcC.Leds -> LedsC;
> TestAdcC.Timer0 -> Timer0;
> TestAdcC.Control -> AM;
> TestAdcC.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG];
> TestAdcC.Packet -> AM;
>
> //TestAdcC.Timer1 -> Timer1;
>
> }
>
>
> TestAdc.h
>
>
> #ifndef TEST_SERIAL_H
> #define TEST_SERIAL_H
>
> typedef nx_struct test_serial_msg {
>   nx_uint16_t counter;
> } test_serial_msg_t;
>
> enum {
>   AM_TEST_SERIAL_MSG = 0x89,
> };
>
> #endif
>
>
> Makefile
>
> #ifndef TEST_SERIAL_H
> #define TEST_SERIAL_H
>
> typedef nx_struct test_serial_msg {
>   nx_uint16_t counter;
> } test_serial_msg_t;
>
> enum {
>   AM_TEST_SERIAL_MSG = 0x89,
> };
>
> #endif
>
>
> Quizás quisiste decir: En vez de dos segundos, se pretende que envian datos
> cada 3 segundos pero por desgracia
> Escribe texto o la dirección de un sitio web, o bien, traduce un documento.
> Cancelar
>
> traducción del español al inglés
>
> Instead of two seconds, my intention is to send data every 3 seconds but
> unfortunately data are sent at high speed, the speed is much higher than
> that for 3 seconds.
>
> Could someone help me?
>
> A greeting and thank you very much!
> Escribe texto o la dirección de un sitio web, o bien, traduce un documento.
> Cancelar
>
> traducción del español al inglés
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> El 3 de octubre de 2011 17:47, Juan Verdu <[email protected]> escribió:
>>
>> Hello everyone,
>>
>> Thank you very much Jan for your reply. Based on your response and ADC12
>> readme.txt in the folder, I have made a number of changes, as shown in the
>> code below. I have obtained different values OFFF and apparently are valid.
>>
>> What I do not get done properly is to show the internal voltage reading
>> every 2 seconds. Messages via radio or do not arrive more than once or do a
>> lot of times but not completed the period I need.
>>
>> If I run the following code is performed only once execution.
>> If I remove the line call Resource.release (); in adc.singleDataReady
>> (uint16_t data), it runs a lot of times like an infinite loop but does not
>> respect me 2 seconds.
>>
>> The code is:
>>
>> TestAdcC.nc
>>
>> #include "Timer.h"
>> #include "TestAdc.h"
>>
>> module TestAdcC
>> {
>>   uses  {
>>   interface Boot;
>>   interface Leds;
>>   interface Timer<TMilli> as Timer0;
>>   interface Msp430Adc12Overflow as overflow;
>>   interface Msp430Adc12SingleChannel as adc;
>>   interface Resource;
>>   interface SplitControl as Control;
>>   interface Packet;
>>   interface AMSend;
>>  }
>>
>> provides {
>> interface AdcConfigure<const msp430adc12_channel_config_t*> as
>> adc_configure;
>> }
>> }
>>
>> implementation
>> {
>> #define BUF_SIZE 100
>> uint16_t buf[BUF_SIZE];
>> message_t packet;
>> uint16_t counter = 0;
>>
>> msp430adc12_channel_config_t adc_config = {
>>     inch: SUPPLY_VOLTAGE_HALF_CHANNEL,
>>     sref: REFERENCE_VREFplus_AVss,
>>     ref2_5v: REFVOLT_LEVEL_1_5,
>>     adc12ssel: SHT_SOURCE_SMCLK,
>>     adc12div: SHT_CLOCK_DIV_1,
>>     sht: SAMPLE_HOLD_64_CYCLES,
>>     sampcon_ssel: SAMPCON_SOURCE_SMCLK,
>>     sampcon_id: SAMPCON_CLOCK_DIV_1
>>   };
>>
>> event void Boot.booted() {
>>     call Leds.led0Off();
>>     call Leds.led1Off();
>>     call Leds.led2Off();
>>     call Control.start();
>>     call Resource.request();
>>     call Resource.release();
>>
>> }
>>
>> event void Timer0.fired() {
>>     call adc.getData();
>>
>>   }
>>
>> event void Control.startDone(error_t err) {
>>     if (err == SUCCESS){
>>     //continua
>>         }
>>     else
>>     call Control.start();
>>  }
>>
>> event void Control.stopDone(error_t err) { }
>>
>>
>> async command const msp430adc12_channel_config_t*
>> adc_configure.getConfiguration() {
>> return &adc_config;
>> }
>>
>> async event void overflow.conversionTimeOverflow() {
>> }
>>
>> async event void overflow.memOverflow() {
>> }
>>
>> async event error_t adc.singleDataReady(uint16_t data){
>>
>>     test_serial_msg_t* rcm = (test_serial_msg_t*)call
>> Packet.getPayload(&packet, sizeof(test_serial_msg_t));
>>     // Call to a led
>>     rcm->counter = data;
>>     if(call AMSend.send(AM_BROADCAST_ADDR, &packet,
>> sizeof(test_serial_msg_t)) == SUCCESS){
>>         call Leds.led1Toggle();
>>                 call Resource.release();
>>         return SUCCESS;
>>
>>   }
>>   }
>> async event uint16_t *adc.multipleDataReady(uint16_t *buffer, uint16_t
>> numSamples){
>>             return buffer;
>>   }
>>
>> event void Resource.granted() {
>>
>>     error_t e;
>>     e = call adc.configureSingle(&adc_config);
>>     call Timer0.startPeriodic(2048);
>> }
>>
>> event void AMSend.sendDone(message_t* bufPtr, error_t error) {
>>   }
>>
>> }
>>
>> TestAdcAppC.nc
>>
>> #include "TestAdc.h"
>> configuration TestAdcAppC {
>> }
>> implementation
>> {
>> components MainC,
>>              TestAdcC,
>>              LedsC;
>>
>> components ActiveMessageC as AM;
>> components new TimerMilliC() as Timer0;
>> components new Msp430Adc12ClientAutoRVGC() as Lectura;
>>
>> TestAdcC.overflow -> Lectura;
>> TestAdcC.Resource -> Lectura;
>> TestAdcC.adc -> Lectura;
>> TestAdcC.adc_configure <- Lectura;
>>
>> TestAdcC -> MainC.Boot;
>> TestAdcC.Leds -> LedsC;
>> TestAdcC.Timer0 -> Timer0;
>> TestAdcC.Control -> AM;
>> TestAdcC.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG];
>> TestAdcC.Packet -> AM;
>>
>> }
>>
>> Makefile
>>
>> COMPONENT=TestAdcAppC
>> CFLAGS += -DADC12_TIMERA_ENABLED
>> #CFLAGS += -DADC12_ONLY_WITH_DMA
>>
>> include $(MAKERULES)
>>
>> CFLAGS += -DCC2420_DEF_CHANNEL=20
>>
>> TestAdc.h
>>
>> #ifndef TEST_SERIAL_H
>> #define TEST_SERIAL_H
>>
>> typedef nx_struct test_serial_msg {
>>   nx_uint16_t counter;
>> } test_serial_msg_t;
>>
>> enum {
>>   AM_TEST_SERIAL_MSG = 0x89,
>> };
>>
>> #endif
>>
>> Could someone help me?
>>
>> A greeting and thank you very much!
>>
>>
>> El 30 de septiembre de 2011 10:46, Jan Hauer <[email protected]>
>> escribió:
>>>
>>> Hi Juan,
>>>
>>> take a look at tos/chips/msp430/sensors/Msp430InternalVoltage* which
>>> measures supply voltage and compare it with our configuration.
>>>
>>> Jan
>>>
>>> On Thu, Sep 29, 2011 at 7:51 PM, Juan Verdu <[email protected]> wrote:
>>> > Hello everyone,
>>> >
>>> > I am working with the MSP430F2617 microcontroller and CC2420 radio. I'm
>>> > using Zolertia driver.
>>> >
>>> > I have written an application that sends temperature readings every 2
>>> > seconds microcontroller to a base station (BaseStation Application).
>>> > The
>>> > readings are consistent and depending if you use the power of two
>>> > batteries
>>> > or USB power values are different but them are apparently valid.
>>> >
>>> > The configuration selected in the case of temperature is:
>>> >
>>> >  msp430adc12_channel_config_t adcconfig = {
>>> >     inch: TEMPERATURE_DIODE_CHANNEL,
>>> >     SREF: REFERENCE_AVcc_AVss,
>>> >     ref2_5v: REFVOLT_LEVEL_1_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
>>> >   };
>>> >
>>> > Now, I want to read the internal voltage of the microcontroller, but
>>> > always
>>> > gives OFFF reading if I use both batteries (2.6 V) or with USB power
>>> > (3.3V)
>>> > and I do not know the error Could someone help me?
>>> >
>>> > The code used in the case of voltage is:
>>> >
>>> >
>>> > TestAdcC.nc
>>> >
>>> > #include "Timer.h"
>>> > #include "TestAdc.h"
>>> >
>>> > module TestAdcC
>>> > {
>>> >   uses interface Boot;
>>> >   uses interface Leds;
>>> >
>>> >   uses interface Timer<TMilli> as Timer0;
>>> >
>>> >   uses interface Msp430Adc12Overflow as overflow;
>>> >   uses interface Msp430Adc12SingleChannel as adc;
>>> >   uses interface Resource;
>>> >
>>> >   uses interface SplitControl as Control;
>>> >   uses interface Packet;
>>> >   uses interface AMSend;
>>> > }
>>> >
>>> > implementation
>>> > {
>>> > #define BUF_SIZE 100
>>> > uint16_t buf[BUF_SIZE];
>>> > message_t packet;
>>> > uint16_t counter = 0;
>>> > uint16_t Data;
>>> >
>>> > void configureSingle();
>>> >
>>> > msp430adc12_channel_config_t adcconfig = {
>>> >     inch: SUPPLY_VOLTAGE_HALF_CHANNEL,
>>> >     sref: REFERENCE_VREFplus_AVss,
>>> >     ref2_5v: REFVOLT_LEVEL_1_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
>>> >   };
>>> >
>>> > event void Boot.booted()
>>> >   {
>>> > call Leds.led0Off();
>>> > call Leds.led1Off();
>>> > call Leds.led2Off();
>>> > call Control.start();
>>> > call Resource.request();
>>> >  }
>>> >
>>> > async event void overflow.conversionTimeOverflow(){
>>> > }
>>> >
>>> > async event void overflow.memOverflow(){
>>> > }
>>> >
>>> > async event uint16_t *adc.multipleDataReady(uint16_t *buffer, uint16_t
>>> > numSamples){
>>> >             return buffer;
>>> > }
>>> >
>>> > task void send(){
>>> >     test_serial_msg_t* rcm = (test_serial_msg_t*)call
>>> > Packet.getPayload(&packet, sizeof(test_serial_msg_t));
>>> >     call Leds.led0Toggle();
>>> >     rcm->counter = Data;
>>> >     if(  call AMSend.send(AM_BROADCAST_ADDR, &packet,
>>> > sizeof(test_serial_msg_t)) == SUCCESS){
>>> >         call Leds.led1Toggle();
>>> >      }
>>> > }
>>> >
>>> > async event error_t adc.singleDataReady(uint16_t data){
>>> >     Data = data;
>>> >     post send();
>>> >         return SUCCESS;
>>> >   }
>>> >
>>> > event void Resource.granted(){
>>> >     configureSingle();
>>> >         call Timer0.startPeriodic(2048);
>>> >   }
>>> >
>>> > void configureSingle(){
>>> >     error_t e;
>>> >     e = call adc.configureSingle(&adcconfig);
>>> >      }
>>> >
>>> > event void Timer0.fired()
>>> >   {
>>> >     call adc.getData();
>>> >   }
>>> >
>>> > event void AMSend.sendDone(message_t* bufPtr, error_t error) {
>>> >     call Leds.led2Toggle();
>>> > }
>>> >
>>> > event void Control.startDone(error_t err) {
>>> >   if (err == SUCCESS){
>>> >         } else {
>>> >     call Control.start();
>>> >       }
>>> > }
>>> >
>>> > event void Control.stopDone(error_t err) {
>>> >     }
>>> >
>>> > }
>>> >
>>> >
>>> > TestAdcAppC.nc
>>> >
>>> > #include "TestAdc.h"
>>> > configuration TestAdcAppC {
>>> > }
>>> > implementation
>>> > {
>>> >   components MainC,
>>> >              TestAdcC,
>>> >              LedsC;
>>> >  components ActiveMessageC as AM;
>>> >  components new TimerMilliC() as Timer0;
>>> >  components new Msp430Adc12ClientAutoDMAC() as Lectura;
>>> >
>>> >  TestAdcC.overflow -> Lectura;
>>> >   TestAdcC.adc -> Lectura;
>>> >   TestAdcC.Resource -> Lectura;
>>> >
>>> >   TestAdcC -> MainC.Boot;
>>> >   TestAdcC.Leds -> LedsC;
>>> >   TestAdcC.Timer0 -> Timer0;
>>> >   TestAdcC.Control -> AM;
>>> >   TestAdcC.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG];
>>> >   TestAdcC.Packet -> AM;
>>> >
>>> > }
>>> >
>>> >
>>> > TestAdc.h
>>> >
>>> > #ifndef TEST_SERIAL_H
>>> > #define TEST_SERIAL_H
>>> >
>>> > typedef nx_struct test_serial_msg {
>>> >   nx_uint16_t counter;
>>> > } test_serial_msg_t;
>>> >
>>> > enum {
>>> >   AM_TEST_SERIAL_MSG = 0x89,
>>> > };
>>> >
>>> > #endif
>>> >
>>> >
>>> > Makefile
>>> >
>>> > #ifndef TEST_SERIAL_H
>>> > #define TEST_SERIAL_H
>>> >
>>> > typedef nx_struct test_serial_msg {
>>> >   nx_uint16_t counter;
>>> > } test_serial_msg_t;
>>> >
>>> > enum {
>>> >   AM_TEST_SERIAL_MSG = 0x89,
>>> > };
>>> >
>>> > #endif
>>> >
>>> > A greeting and thank you very much!.
>>> >
>>> > _______________________________________________
>>> > Tinyos-help mailing list
>>> > [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