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.

LAUNCHXL-CC1310: How to config COMPB (CC1310) with Sensor Controller Studio

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Hey all,

at the moment I'm working with a TI CC1310 and the Sensor Controller Studio.
I'm trying to measure the time of decharging a capacitor with a series resistor from 3.0V to 0.825V.
For that I'm using the COMPB-module which should fire an event, if the voltage level on the capacitor (PIN_COMP) falls below 0.825V (COMPB_REF_VDDS_DIV4).
To visualize the moment of the event as accurate as possible, I set a digital output pin (PIN_TRIGGERED) to high if I start decharging and to low if the event occurs.

I expect that the time in which PIN_TRIGGERED is high should always be on the same time, because its always the same resistor and the same capacitor, but the event occurs on different times.
It looks like the event is not triggered through falling below the 0,825V level.

What did I do wrong?

Thanks,
Manuel

------------------ Initialisation Code ------------------

// GENERAL
state.initDone = 0;
state.loadingCap = 1;

// DIGITAL OUTPUTS
gpioClearOutput(AUXIO_O_PIN_R_REF);
gpioClearOutput(AUXIO_O_PIN_TRIGGERED);

// COMPB
compbSelectGpioInput(AUXIO_A_PIN_COMPB_2);
compbEnable(COMPB_REF_VDDS_DIV4);
evhSetupTimer1Trigger(0, 3, 0);
evhSetupCompbTrigger(0, 0, EVH_COMPB_TRIG_ON_MATCH);
state.initDone = 0;
-------------------- Execution Code --------------------
if(state.loadingCap == 1){
    // Charging C116
    state.loadingCap = 0;
    gpioSetOutput(AUXIO_O_PIN_R_REF);
    
    for(U16 n=0; n < 3; n++){
        fwDelayUs(10000, FW_DELAY_RANGE_100_MS);
    }
    evhSetupCompbTrigger(0, 1, EVH_COMPB_TRIG_ON_MATCH);
    
    output.pTdcValueH = 0;
    output.pTdcValueL = 0;
}else{
    // Discharging C116
    state.loadingCap = 1;
    gpioSetOutput(AUXIO_O_PIN_TRIGGERED);
	
    // COMPB
    compbSelectGpioInput(AUXIO_A_PIN_COMPB_2);
    compbEnable(COMPB_REF_VDDS_DIV4);
    evhSetupTimer1Trigger(0, 3, 0);
    
    gpioClearOutput(AUXIO_O_PIN_R_REF);
}
----------------- Event Handler A Code -----------------
if (state.initDone == 0) {
    compbGetOutput(state.currTriggerLevel);
    state.initDone = 1;
}

if (state.currTriggerLevel == 0) {
    // C116 voltage below 0.825V 
    gpioClearOutput(AUXIO_O_PIN_TRIGGERED);
    state.currTriggerLevel = 1;
} else {
    // C116 voltage over 0.825V
    //evhSetupCompbTrigger(0, 1, EVH_COMPB_TRIG_ON_MATCH);
    state.currTriggerLevel = 0;
}
---------------- Task iteration action sequence --------------------

Run Execution Code
If event trigger 0 occured{
    Run Event Handler A Code (trigger0)
    Wait for 1 second
}

  • Hi Manuel,

    In Sensor Controller Studio, in the task testing view, do you see the value of state.currTriggerLevel changing even though the event is not triggered?

    Regards,

    Arthur

  • Hey Arthur, thank you for your quick response. state.currTriggerLevel changes its value even the comparator pin is connected to 3.3V.

    Best regards,

    Manuel

  • Hi Manuel,

    Could you send me a whole zipped sensor controller studio project? I am missing a lot of information on the pin configuration, and COMPB trigger configuration.

    Regards,

    Arthur

  • Hey Arthur,

    sure, thanks for caring.

    Regards,

    Manuel

    Temperatur.zip

  • Hi Manuel,

    I am not sure yet as to what is the issue is, as the event seems to be executed. Here is what I see when connecting DIO27 to different sources:

    Is it what you are seeing as well?

    Let me know,

    Arthur

  • One more thing, as per https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/851516/ccs-cc1310-ad-sampling/3148905#3148905, it seems like your code did not set the next trigger as it should.

    I have modified the event Handler A to be as follows:

    if (state.currTriggerLevel == 0) {
        compbDisable();
        evhCancelTrigger(0);
        gpioClearOutput(AUXIO_O_PIN_TRIGGERED);
        //gpioToggleOutput(AUXIO_O_PIN_TRIGGERED);
        evhSetupCompbTrigger(0, 1, EVH_COMPB_TRIG_ON_MATCH);
        state.currTriggerLevel = 1;
        
        //Test TDC
        //timer0Stop();
        //tdcGetValue(output.pTdcValueH, output.pTdcValueL);
        state.timerValueH = output.pTdcValueH;
        state.timerValueL = output.pTdcValueL;
        state.taskNumber = 4;
    } else {
        // ARI: Note the modification
        evhSetupCompbTrigger(0, 0, EVH_COMPB_TRIG_ON_MATCH);
        state.currTriggerLevel = 0;
        state.taskNumber = 5;
    }

  • Hey Arthur,

    yes, it looks like this for me too.

    Regards,

    Manu

  • Hey Arthur,

    i tryed your modification, but the behavior is already the same. The graph for state.taskNumber is only for visualizing where the programm jumps to. Here I expect the pattern looks like 1, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4.

    1: Initializing Code

    2: Loading capacitor

    3: Discharging capacitor

    4: CompB-Event for voltage falling below 0.825V

    Regards,

    Manuel

  • Hey Arthur, is there anything new?

    Regards,

    Manuel

  • Hi Manuel,

    Still no updates, let me come back with something tomorrow.

    Regards,

    Arthur

  • Manuel,

    I have set up a better test setup to debug that. As always, you will hear from me tomorrow.

    Regards,

    Arthur

  • Hey Arthur,

    cool, thank you.

    Regards,

    Manuel

  • Hi Manuel,

    This time, I modified Event Handler A:state.currTriggerLEvel == 0 to set the PIN_TRIGGERED gpio instead of clearing it in both cases, and I observe the event being triggered as it should:

    if (state.initDone == 0) {
        compbGetOutput(state.currTriggerLevel);
        state.initDone = 1;
    }
    
    if (state.currTriggerLevel == 0) {
        // Cm Spannung unter 0,85V TRIGGER!!!
        compbDisable();
        evhCancelTrigger(0);
        gpioSetOutput(AUXIO_O_PIN_TRIGGERED);
        //gpioToggleOutput(AUXIO_O_PIN_TRIGGERED);
        evhSetupCompbTrigger(0, 0, EVH_COMPB_TRIG_ON_MATCH);
        state.currTriggerLevel = 1;
        
        //Test TDC
        //timer0Stop();
        //tdcGetValue(output.pTdcValueH, output.pTdcValueL);
        state.timerValueH = output.pTdcValueH;
        state.timerValueL = output.pTdcValueL;
        state.taskNumber = 4;
    } else {
        // Cm Spannung über 0,85V
        gpioClearOutput(AUXIO_O_PIN_TRIGGERED);
        evhSetupCompbTrigger(0, 0, EVH_COMPB_TRIG_ON_MATCH);
        state.currTriggerLevel = 0;
        state.taskNumber = 5;
    }

    Can you confirm that this is what you were expecting?

    Regards,

    Arthur

  • Hey Arthur,

    unfortunately not. I'd like to implement a slope Analog-to-Digital conversion like in SLAA129C on the sensor controller. So I have to measure the time of discharging the condensator to 0.825V precisely. And the issue with the CompB Event Trigger is that it occures at different times and depends not realy on on exact time of falling below 0.825V.

    I've got a solution for that but it's not the gentle way. I'm polling the status of compb output (every 1us)  in a loop and if the CompB output flipps to 0 then I take the loopCounter for determination of time.

    Is there any way to use the CompB Event Trigger instead of polling?

    I've attached the project with polling the CompB output and the scope pics too, as well as the graph of loopCylcles.

    3 measurements

    2744.Temperatur.zip

  • Hi Manuel,

    There is an additional thing missing from the new code you sent, that might explain the behaviour.

    You should actually wait 750 uS before getting a valid output from COMPB after enabling it.

    Also, keep in mind that COMPB being a clocked comparator, it will only measure every 32 KHz.

    Finally, sorry for misleading you, but in order to check for correct timings, you should instead use Run-Timing logging, and not task testing, as the event trigger is setup by Sensor Controller Studio.

    Regards,

    Arthur

  • Hey Arthur,

    I've read over that COMPB is clocked with 32kHz. This is to slow for our application. What's the proper way for measuring temperature by slope Analog to Digital conversion with the sensor controller. Should I take COMPA with an external voltage divider for refernece voltage?

    Regards,

    Manuel

  • Hi Manuel,

    In that case, I think you could indeed use COMPA, coupled with the TDC to get the time, as if you would do for capacitive sensing.

    Only this time, you would actually monitor the capacitor discharge.

    Here is it, described in the Sensor Controller Studio help:

    Trigger on the COMPA negative edge, from the EVH_COMPA_TRIG_ON_EDGE should work.

    Regards,

    Arthur

  • Hey Arthur,

    using COMPA with TDC works for me. In the execution task I'm waiting for TDC_STOPTRIG_COMPA_LOW with tdcWaitUs(25000). The event EVH_COMPA_TRIG_ON_EDGE  is not available for CC1310 (only on CC13x2), but I'm ok with the other solution.

    Tank you for helping

    Regards,

    Manuel