This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC1310: Report time smaller than 1 second for the Node Example

Part Number: CC1310
Other Parts Discussed in Thread: SYSBIOS, , CC2560

Tool/software: TI-RTOS

Hello all,

maybe there is someone who can help me with a question I have. Sorry if it sounds silly but I am new in the programming.

I use the 1310EM +SmartRF 06 development boards for my bachelor thesis where I use one of the DK to read the values of a water sensor ( using the Node example from TIRTOS). I saw that there is the posibility to set the reporting time (to the concetrator) to a minimum of 1 second. 

As I am controling the water level in a close loop (with a PID controler on the concentrator side) I need to report the ADC value more often than 1 s, for example every 300 ms. 

The question is if it is somehow possible to set the  NODE_ADCTASK_REPORTINTERVAL_SLOW to a value <1second, or is it limited through SW or HW. If possible how? 

Regards

SP

  

  • Reporting every 300ms is pretty fast. If there are few sensors, such as less than 5 in the system, I would say it should be fine.

  • Hi YK Chen,

    thank you for the answer.

    There is only one sensor in the system.

    As the time constant of the system is about 3.5 seconds, I need a sampling time that is at least 4 times smaller. Am optimal would be thou 10 times smaller, so about 300 ms. You say it shouldn't be a problem if there is only one sensor, do I only have to change the NODE_ADCTASK_REPORTINTERVAL to float and set it to .3 ? or are there other points I have to work on ?

    Regeards
    SP
  • Yes, I think you only need to change reporting interval to 300 ms.
  • YK Chnen , I tried changing the reporting tie to .3 as you sugested, ofcourse after modifing the ADC. c & ADC .H so that it is compatible with the folat value. But it didnot work as expected. after playing a little bit withh the values i get a report time of 600 ms as the concentrator is connected. Without a concntrator the sampling time is 1 second....the target of 300ms is still not reached. Here is my code:


    /***** Includes *****/

    #include <xdc/std.h>
    #include <xdc/runtime/System.h>

    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Event.h>
    #include <ti/sysbios/knl/Clock.h>

    #include <ti/drivers/PIN.h>

    /* Board Header files */
    #include "Board.h"

    #include "SceAdc.h"
    #include "NodeTask.h"
    #include "NodeRadioTask.h"


    /***** Defines *****/
    #define NODE_TASK_STACK_SIZE 1024
    #define NODE_TASK_PRIORITY 3

    #define NODE_EVENT_ALL 0xFFFFFFFF
    #define NODE_EVENT_NEW_ADC_VALUE (uint32_t)(1 << 0)

    /* A change mask of 0xFF0 means that changes in the lower 4 bits does not trigger a wakeup. */
    #define NODE_ADCTASK_CHANGE_MASK 0xFFE//FF0

    /* Minimum slow Report interval is 50s (in units of samplingTime)*/
    #define NODE_ADCTASK_REPORTINTERVAL_SLOW 1
    /* Minimum fast Report interval is 1s (in units of samplingTime) for 30s*/
    #define NODE_ADCTASK_REPORTINTERVAL_FAST 1
    #define NODE_ADCTASK_REPORTINTERVAL_FAST_DURIATION_MS 100//30000



    /***** Variable declarations *****/
    static Task_Params nodeTaskParams;
    Task_Struct nodeTask; /* not static so you can see in ROV */
    static uint8_t nodeTaskStack[NODE_TASK_STACK_SIZE];
    Event_Struct nodeEvent; /* not static so you can see in ROV */
    static Event_Handle nodeEventHandle;
    static uint16_t latestAdcValue;

    /* Clock for the fast report timeout */
    Clock_Struct fastReportTimeoutClock; /* not static so you can see in ROV */
    static Clock_Handle fastReportTimeoutClockHandle;

    /* Pin driver handle */
    static PIN_Handle buttonPinHandle;
    static PIN_Handle ledPinHandle;
    static PIN_State buttonPinState;
    static PIN_State ledPinState;

    /* Enable the 3.3V power domain used by the LCD */
    PIN_Config pinTable[] = {
    NODE_ACTIVITY_LED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
    };

    /*
    * Application button pin configuration table:
    * - Buttons interrupts are configured to trigger on falling edge.
    */
    PIN_Config buttonPinTable[] = {
    Board_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    PIN_TERMINATE
    };

    /***** Prototypes *****/
    static void nodeTaskFunction(UArg arg0, UArg arg1);
    void fastReportTimeoutCallback(UArg arg0);
    void adcCallback(uint16_t adcValue);
    void buttonCallback(PIN_Handle handle, PIN_Id pinId);


    /***** Function definitions *****/
    void NodeTask_init(void)
    {

    /* Create event used internally for state changes */
    Event_Params eventParam;
    Event_Params_init(&eventParam);
    Event_construct(&nodeEvent, &eventParam);
    nodeEventHandle = Event_handle(&nodeEvent);

    /* Create clock object which is used for fast report timeout */
    Clock_Params clkParams;
    clkParams.period = 0;
    clkParams.startFlag = FALSE;
    Clock_construct(&fastReportTimeoutClock, fastReportTimeoutCallback, 1, &clkParams);
    fastReportTimeoutClockHandle = Clock_handle(&fastReportTimeoutClock);

    /* Create the node task */
    Task_Params_init(&nodeTaskParams);
    nodeTaskParams.stackSize = NODE_TASK_STACK_SIZE;
    nodeTaskParams.priority = NODE_TASK_PRIORITY;
    nodeTaskParams.stack = &nodeTaskStack;
    Task_construct(&nodeTask, nodeTaskFunction, &nodeTaskParams, NULL);
    }

    static void nodeTaskFunction(UArg arg0, UArg arg1)
    {
    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, pinTable);
    if (!ledPinHandle)
    {
    System_abort("Error initializing board 3.3V domain pins\n");
    }

    /* Start the SCE ADC task with 1s sample period and reacting to change in ADC value. */
    SceAdc_init(0x0005000, NODE_ADCTASK_REPORTINTERVAL_FAST, NODE_ADCTASK_CHANGE_MASK);
    SceAdc_registerAdcCallback(adcCallback);
    SceAdc_start();

    /* setup timeout for fast report timeout */
    Clock_setTimeout(fastReportTimeoutClockHandle,
    NODE_ADCTASK_REPORTINTERVAL_FAST_DURIATION_MS );//1000 * 1 / Clock_tickPeriod

    /* start fast report and timeout */
    Clock_start(fastReportTimeoutClockHandle);


    buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    if (!buttonPinHandle)
    {
    System_abort("Error initializing button pins\n");
    }

    /* Setup callback for button pins */
    if (PIN_registerIntCb(buttonPinHandle, &buttonCallback) != 0)
    {
    System_abort("Error registering button callback function");
    }

    while(1) {
    /* Wait for event */
    uint32_t events = Event_pend(nodeEventHandle, 0, NODE_EVENT_ALL, BIOS_WAIT_FOREVER);

    /* If new ADC value, send this data */
    if (events & NODE_EVENT_NEW_ADC_VALUE) {
    /* Toggle activity LED */
    PIN_setOutputValue(ledPinHandle, NODE_ACTIVITY_LED,!PIN_getOutputValue(NODE_ACTIVITY_LED));

    /* Send ADC value to concentrator */
    NodeRadioTask_sendAdcData(latestAdcValue);
    }
    }
    }

    void adcCallback(uint16_t adcValue)
    {
    /* Save latest value */
    latestAdcValue = adcValue;

    /* Post event */
    Event_post(nodeEventHandle, NODE_EVENT_NEW_ADC_VALUE);
    }

    /*
    * ======== buttonCallback ========
    * Pin interrupt Callback function board buttons configured in the pinTable.
    */
    void buttonCallback(PIN_Handle handle, PIN_Id pinId)
    {
    /* Debounce logic, only toggle if the button is still pushed (low) */
    CPUdelay(8000*50);


    if (PIN_getInputValue(Board_BUTTON0) == 0)
    {
    //start fast report and timeout
    SceAdc_setReportInterval(NODE_ADCTASK_REPORTINTERVAL_FAST, NODE_ADCTASK_CHANGE_MASK);
    Clock_start(fastReportTimeoutClockHandle);
    }
    }

    void fastReportTimeoutCallback(UArg arg0)
    {
    //stop fast report
    SceAdc_setReportInterval(NODE_ADCTASK_REPORTINTERVAL_FAST, NODE_ADCTASK_CHANGE_MASK);
    }


    Is there something else I coud change to get the reporting time down?
  • Which CC1310 SDK and example do you use?

  • I use the Node example from SDK 2.10.00.36
  • What is Node example?
  • Sorry for the unclear answer, it would be the RF Wireless Sensor Network Node from the TI RTOS for CC2560 for cc1310 Development Kit.
    I attached below the Link to the TI resource explorer.

    dev.ti.com/.../
  • I suppose this NODE_ADCTASK_REPORTINTERVAL should be in ms so you shouldn't change it to float. I suppose you should use 300 instead of .3.
  • S. P: You are writing that you use SDK 2.10.00.36 but you link to an old TI-RTOS version. Which of them are you actually using? Any reason you haven't ported to the newest SDK available?
  • I Use the SDK 2.10. Sorry for the silly question, but what influence has the version of the SDK I use. I compared at the time I downloaded the old and the new vesions (code) and I found only minor changes, that I classified as not relevant.

    The reason why I do not use the newer version is that I began working with the older one and I encountered some problems while upgrading to a newer one. Don't want to mess with it as long as it works.

    I Linked to the Resource explorer with the example project because I didnot find the posibiliti to chose the version of the SDK in the TI resource explorer.
  • I tried changing it to 300ms. The report time did not change it stayed at 1s.
  • If you change it to 5000ms, does it work?