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.

TMAG3001: About low power operation using WOC(Wake On Change) angle function

Part Number: TMAG3001

Tool/software:

Hello
I am making a product using TMAG3001 by referring to TMAG3001_Exmaple_Code provided in this link. :www.ti.com/.../TMAG3001

I am interested in recognizing the angle change of the magnet, 

So I referred to the WOC_ANGLE_EXAMPLE area.

   
    float prevAngle = 0.0;
    float currAngle = 0.0;
    uint8_t angle_hyst = ANGLE_HYST_8DEG;

    // Configure device settings
    TMAG3001enableMagChannels(MAG_CH_EN_XYZ);                // Enable magnetic channels
    TMAG3001enableAngleMeasurement(ANGLE_EN_X1stY2nd);       // Configure the device to enable angle measurements
    TMAG3001setRanges(RANGE_80mTor240mT, RANGE_80mTor240mT); // Configure the range of the device
    TMAG3001interruptThroughINT(0x00);                       // Configure the device to enable interrupts on the INT pin
    TMAG3001intPinLatchedPulsed(INT_STATE_Pulse);            // Configure the interrupt state of the device
    TMAG3001enableWakeOnAngleChange(angle_hyst);             // Enable WOC for angles

    // Trigger a data conversion and read the initial angle measurement
    // Note: This initial angle measurement will be used to check to see if the interrupt occurred as the result of an
    //       angle change as specified by angle_hyst or due to the angle going from 359->0 or 0->359
    TMAG3001readSingleRegisterWithTrigger(CONV_STATUS_ADDRESS); // Read CONV_STATUS register and trigger conversion
    delay_ms(1);                                                // Delay to allow time for conversion to complete
    prevAngle = TMAG3001getMeasurementANGLE();                  // Read initial angle measurement

    TMAG3001enterContinuousMeasureMode(); // Enable continuous measure mode to continuously sample data
In the example, I saw that TMAG3001 is set to Continuous Mode in the last line of the initialization code.
When I did this, an interrupt fell every time the angle changed, and it worked as I intended.

However, my product is battery-based, so I have to wait in low power when the magnet is not rotating.

So I tried changing this part to enter the WakeAndSleep Mode.

But when I do this, I get endless interrupts with a cycle of about 2~5ms.

This is the exact opposite of what I intuitively think.

Is there some additional setup that I'm missing? or Can't I use low power performance and WOC_ANGLE feature at the same time? 

Please advice.

Regards.

  • Hi Dong,

    Thank you for posting to the Sensors forum!

    When an interrupt occurs, do you read the data from the device? If so, before re-entering W&S mode, you'll need to trigger a conversion to save the new reference value.

    Best,

    ~Alicia

  • Hi, thanks for your reply.

    Yes surely, I read the Angle Data every time an interrupt occurs and then send a command to WakeOnsleep.

    INT -> S 68 19 rS 69 XX XX XX P -> S S 68 01 03 P  accorded to the oscilloscope measurements.

    As in my observation, if you set Mode to WakeOnSleep, the work that should be done in Continuous will be done at low power.

    If you set Mode to Continuous, the work that should be done in WakeOnSleep will be done at normal power (2.1mA).

    This is my serious mystery.

    Please check this again.

    T.T

  • Hi Dong,

    Our team is out today.  We should be able to take a look at your question when we are back in the office starting tomorrow.

    Regards,

    Mekre

  • Hi Dong,

    Yes surely, I read the Angle Data every time an interrupt occurs and then send a command to WakeOnsleep.

    When in W&S mode, after an interrupt occurs and you read the angle data, you must trigger a conversion. After triggering a conversion, you will need to wait for it to complete before re-entering W&S mode.

    Best,

    ~Alicia 

  • Hi Alicia.

    Thanks for your advice.

    So, I tried reading the angle data after the interrupt occurred, then reading the CONV_STATUS at register address 0x18 with the trigger bit set.

    My Interrupt Service Routine is below:

    S 68 19 Sr 69 XX XX Xx P -> S 68 98 Sr 69 31 P -> Wait 1ms -> S 68 01 03 P

    Read Angle Data -> Triggering Conversion -> Wait for it -> re-enter W&S mode

    But this work had no effect on me.

    The interrupt still occurs repeatedly even if I dont turn the magnet.

    Just in case, I saw that the RESULT_STATUS bit of the CONV_STATUS read result was 1 so I tried to remove the wait 1ms.

    However, there was no significant difference.

    The only difference between my code's initialization process and WOC_ANGLE_EXAMPLE is that I used TMAG3001enterWakeUpAndSleepMode() instead of TMAG3001enterContinuousMeasureMode().

    Is there anything else I need to consider to use WOC ANGLE in W&S mode?

  • Hi Dong,

    As a quick test to see if the issue is related to the reference angle not getting updated or if it's something else, instead of triggering a conversion, can you try the following:

    1. Disable WOC
    2. Re-enable WOC
    3. Wait a couple μs
    4. Enter W&S mode 

    Best,

    ~Alicia

  • Thanks for the quick and kind reply.

    But unfortunately it didn't work either.

    Going back to the beginning, could you please advise me on a low-power way to do this based on the WOC_ANGLE_EXAMPLE code you provided?

  • Hi Dong,

    Just to make sure that there isn't something wrong with the device itself, using the same configurations mentioned in the example (shown below), after initially putting the device into W&S mode, could you remove any further I2C communication?

    TMAG3001enableMagChannels(MAG_CH_EN_XYZ);                               // Enable magnetic channels
    TMAG3001enableAngleMeasurement(ANGLE_EN_X1stY2nd);                 // Configure the device to enable angle measurements
    TMAG3001setRanges(RANGE_80mTor240mT, RANGE_80mTor240mT); // Configure the range of the device
    TMAG3001interruptThroughINT(0x00);                                                        // Configure the device to enable interrupts on the INT pin
    TMAG3001intPinLatchedPulsed(INT_STATE_Pulse);                                  // Configure the interrupt state of the device
    TMAG3001enableWakeOnAngleChange(angle_hyst);                                 // Enable WOC for angles
    TMAG3001setWakeUpAndSleepMode(0x03); // Enter W&S mode with a sleeptime of 15ms (Note: adjust sleeptime according to application need)

    After entering W&S mode, just monitor the INT pin and remove any further I2C communication that would occur following an interrupt. With the above settings, WOC for angle while in W&S should work as expected. If the above works, then we can isolate the issue to being related to the I2C communication that occurs following an interrupt and debug further from there. If it doesn't work, then the issue may be related to the firmware/hardware, or even this particular unit, as the above settings worked as expected for me.

    Best,

    ~Alicia  

  • Well, 

    I made the initialization process the same as you mentioned, and did not try any I2C communication in the interrupt service routine.
    Then, as you mentioned, and as I wanted, the angle change interrupt worked well.
    I like this for now.

    However, just in case, I tried TMAG3001getMeasurementANGLE() in the interrupt service routine.
    Then, endless interrupts occurred again, just like the previous problem.

    Then, should I consider it a proper way to infer the angle change based on the number of interrupts rather than measuring how much the magnet angle changed in the ISR?

  • Hi Dong,

    For the ISR could you try the following sequence for when an interrupt occurs:

    1. Configure device to be in standby mode by setting Operating_Mode to 0h in Device_Config_2
      1. TMAG3001writeToSingleRegister(DEVICE_CONFIG_2_ADDRESS, 0x00);
        1. should a NAK occur when the above communication is sent, do the following:
          1. delay tstart_sleep (50us)
          2. TMAG3001writeToSingleRegister(DEVICE_CONFIG_2_ADDRESS, 0x00);
    2. Trigger a conversion
      1. TMAG3001readSingleRegisterWithTrigger(DEVICE_CONFIG_2_ADDRESS);
    3. Wait for conversion to complete
    4. Read angle measurement from angle result registers by doing either a or b:
      1. TMAG3001readMultipleRegisters(ANGLE_RESULT_MSB_ADDRESS, 2, 0, data_result);
      2. TMAG3001getMeasurementANGLE();
    5. Put device into W&S mode
      1. TMAG3001setWakeUpAndSleepMode(0x03);

    With the above sequence, I was able to get WOC angle working in W&S mode and still read the angle data from the device.

    Best,

    ~Alicia

  • Hi Alicia,

    Thank you so much for your dedicated advice.
    This solved the issue I was struggling with for weeks.

    I guess the key point was to enter standby mode from ISR and then do the necessary work.

    One thing to note is that when I first try to enter standby mode from ISR, I often see a NACK.

    Also, once a NACK occurs, all retries for 15ms will have a NACK.

    Only in the next ISR does the ACK occur and the process of generating the trigger, reading the angle, and entering W&S mode works smoothly as you suggested.

    For now, there is no problem in the overall operation of our product, so I think the first prototyping will be possible.

    Thanks again.