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.

ADS7128: RMS module not working as expected

Part Number: ADS7128

I have not been able to implement RMS function, because the RMS_DONE flag is never set.
Setting RMS_EN (bit 7) in the GENERAL_CFG register is supposed to start conversion, but even after very long time periods the RMS_DONE flag (bit 4 in the SYSTEM_STATUS register) is never set.

This is output from my host program.  I have tried several RMS sample rates, but this example is for 16384 samples.  After setting RMS_EN, the SYSTEM_STATUS register is polled every 10 milliseconds:
    <Arduino serial comm started>
    Found I2C device at address: 23 (0x17)
    Will reset I2C device.
    GENERAL_CFG reg: 0
    SYSTEM_STATUS reg: 0
    RMS_CFG reg: 100010
    GENERAL_CFG reg: 10000000
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0
    SYSTEM_STATUS reg: 10001000  MSB reg 0xC2 = 0  LSB reg 0xC1 = 0


So far, I have been able to use an Arduino microcontroller to program and use this ADS7128 using the OSR (oversampling) feature successfully on many different Ain channels.  Thus, I am confident that this particular ADS7128 is connected properly, and that my microcontroller can properly program this particular ADS7128.  So, the problem seems to be specific to the RMS function.

  • Scott,

    1. I agree with your command sequence.  It matches the approach outlined in section 8.3.12.
    2. I also agree that it is unlikely that there is some kind of connection error as you can configure registers and do OSR readings.
    3. I am not sure why you are not getting an RMS conversion complete. However, in reviewing your Arduino debug output, it seems that you are poling the SYSTEM_STATUS as well as reading the RMS MSB and LSB register.  I don’t know that this will cause an issue, but can you try only reading the SYSTEM_STATUS register?
    4. Also, you may want to try writing a “1” to the RMS_EN bit in the GENERAL_CFG. This should initiate a conversion.  The procedure in section 8.3.12 explains that you do this after you read your RMS conversion results, but you may need to also write this on the first conversion.

    Let me know if any of the above suggestions help.  I will take a look at this in the lab soon if you cannot make any progress.

    Art

  • Hello,

     

    Below are the outputs for the case not reading the RMS output registers, but only the status register.

    <Arduino serial comm started>

    called Wire.begin() for I2C comm.

    Found I2C device at address: 23 (0x17)

    Will reset I2C device.

    GENERAL_CFG reg: 0                                            this is after a reset

    SYSTEM_STATUS reg: 0

    RMS_CFG reg: 100010

    GENERAL_CFG reg: 10000000                           this is after setting bit 7 “RMS_EN”

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000                       keep reading SYSTEM_STATUS every 10 milliseconds

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000

    SYSTEM_STATUS reg: 10001000                       Long ago the RMS conversion should have finished

     

    So, reading the RMS output MSB and LSB registers had no effect on the status register.

    I had been setting the RMS_EN bit before starting each conversion.

    Thank you,

  • Hi,

    For additional confirmation about this particular ADS7128 setup, I added diagnostic outputs and re-ran using oversampling (OSR) function on Ain5 to which I had connected 5 Volts DC divided by 2, confirming that this setup is wired correctly, and that any problems seem to be restricted to the RMS function:

    <Arduino serial comm started>

    Found I2C device at address: 23 (0x17)

    Will reset I2C device.

    OSR_CFG reg 0x3 = 111                                                    set for 128 samples averaging

    GENERAL_CFG reg 0x 1 = 0                                             cleared after reset

    CHANNEL_SEL reg 0x11 = 101

    will set GENERAL_CFG to 101000                                 will set both CNVST and STATS_EN bits

    GENERAL_CFG reg 0x1 = 100000                                 instantly read that CNVST bit has been cleared by the ADS7128

    SYSTEM_STATUS reg 0x0 = 10001000                         OSR_DONE bit set

                32724                                                                        expected 2^16 / 2, so output is OK

    OSR_CFG reg 0x3 = 111                                                    will start another conversion to monitor OSR output noise

    GENERAL_CFG reg 0x 1 = 100000

    CHANNEL_SEL reg 0x11 = 101

    will set GENERAL_CFG to 101000

    GENERAL_CFG reg 0x1 = 100000

    SYSTEM_STATUS reg 0x0 = 10001000

                32721

    OSR_CFG reg 0x3 = 111

    GENERAL_CFG reg 0x 1 = 100000

    CHANNEL_SEL reg 0x11 = 101

    will set GENERAL_CFG to 101000

    GENERAL_CFG reg 0x1 = 100000

    SYSTEM_STATUS reg 0x0 = 10001000

                32724

    OSR_CFG reg 0x3 = 111

    GENERAL_CFG reg 0x 1 = 100000

    CHANNEL_SEL reg 0x11 = 101

    will set GENERAL_CFG to 101000

    GENERAL_CFG reg 0x1 = 100000

    SYSTEM_STATUS reg 0x0 = 10001000

                32722

     

    Observations:

    I get the expected DC value (50% of max. counts), with very little noise (about 14 noise-free bits for 128 sample OSR averaging, not bad from a nominal 12-bit analog-converter).

    Hope that this helps in diagnosing the problem with RMS function not working as I expected.

    Thank you,

  • Scott,

    I'm going to take a look at this in the lab.  This will take a few days. I don't see any obvious issue in your approach, so I want to do a detailed docment discribing how use RMS mode.  Sorry for the difficulty you are having. 

    Art 

  • Scott, 

    One of my colleagues may have found the answer (thanks Cynthia).  See the full post here: ADS7128: RMS conversion doesn't start.  The main point is that you will need to collect initial sample to complete the RMS conversion.  The way you complete these conversions will differ depending on the mode you use.  Let me know if this helps.  If not, I will proceed with the detailed tutorial on RMS.

    Art  

  • Hi,

    I had already followed the steps in the datasheet (also listed in that other post).

    I just tried something different, in case I needed to somehow read the channel to start conversions (although per the documentation I should only need to set the RMS_EN bit).

    I also reduced the # of RMS samples to the default 1024.

    <Arduino serial comm started>
    Found I2C device at address: 23 (0x17)
    Will reset I2C device.
    GENERAL_CFG reg: 0
    SYSTEM_STATUS reg: 0
    RMS_CFG reg: 100000                     <== set Ain2, and use default # samples = 1024
    GENERAL_CFG reg: 10000000
    also set CHANNEL_SEL reg 0x11 = 10                        <== try this to see if it helps.   Set for same Ain2 as for RMS
    read selected channel ADC conversion= 32723         <== valid for 2.5 VDC on this input during testing
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000      <== also monitor GENERAL_CFG to verify RMS_EN still set
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000      <== keep polling every 20 milliseconds
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000
    GENERAL_CFG reg=10000000  SYSTEM_STATUS reg= 10001000       <== should have seen RMS_DONE set long ago

    Regarding the requirement of an extra 40 samples for the RMS calculation, I did not see how this was significant in my testing, since an extra 40 samples beyond 16384 or even 1024 is not much for my needs; anyway I was waiting for RMS_DONE for far longer than it should have taken (I kept checking for up to 2 seconds, far longer than it should need).

    So, apparently I am still missing something.

  • Scott,

    Ok.  I will procede with the measuremtns and putting together a step-by-step tutorial.  This will take some time.

    Best regards, Art

  • Hi Scott,

    Art has been involved in working on detailing the behavior but before he could answer he had to move to some different responsibilities.  I will attempt to answer what we think may be happening.  In your last post you reset the ADS7128 and then configure various register settings.  The configuration is manual mode, but I don't see that you were actually starting new conversions.

    In manual mode you need to read the data each time to trigger a new conversion start.  As per datasheet section 8.4.2 "A new conversion is initiated on the ninth falling edge of SCL (ACK bit) when the last byte of output data is read." So you would need to read out the data for the number of RMS samples requested (1024 in the configuration) plus an additional 40 conversions before the RMS_DONE flag will be set.

    In auto-sequence mode, this is similar to the manual mode except the mux will automatically switch to the next desired channel in the sequence.  The next conversion starts following the read of the data similar to manual mode as per Table 7 in the datasheet.

    Autonomous mode is the one outlined below.  Here the ADS7128 is set to only use the RMS channel in the sequence and once the conversion is started the RMS_DONE status should be set following the completion of the number of conversion periods set in RMS_CFG.  What we found to be a bit confusing is that to reinitiate another RMS calculation, the RMS_EN bit should be cleared (set to 0) and then set back to '1' in the GENERAL_CFG register.

    For our testing we used the BP-ADS7128 and input a signal to AIN0.  We also configured for 4096 samples and did not subtract out the DC from the computation.  The process to initiate an RMS computation is as follows:

    Step

    Register

    Address

    Value

    Function

    1

     RMS_CFG

     0xC0

    0x01

    RMS on CH0, Do not subtract DC, samples = 4096

    2

     GENERAL_CFG

     0x01

    0xA0

    RMS_EN, No CRC, STATS_EN, No Comparator,

    normal conv start, default ch config, no cal, no reset

    3

     SEQUENCE_CFG

     0x10

     0x00

    SEQ_MODE = '00'

    No write needed, default works

    4

     OPMODE_CFG

     0x04

    0x00

    CONV_MODE = '00'

    No write needed, default works

    5

     GPIO_CFG

     0x07

    0x00 

    No write needed, default works

    6

     AUTO_SEQ_CH_SEL

     0x12

    0x01

    This selects channel 0 as the only channel in the sequence (not completely clear in data sheet)

    7

     SEQUENCE_CFG

     0x10

    0x01

    Stop channel sequencing, auto sequence mode

    (this is done per flow chart)

    8

     OPMODE_CFG

     0x04

    0x20

    Autonomous mode, high speed oscillator,

    Sampling freq = 1000ksps

    9

     SEQUENCE_CFG

     0x10

    0x11

    Start channel sequencing, auto sequence mode

    (this is done per flow chart)

    10

     SYSTEM_STATUS

     0x00 

     

    Pause by timer or monitor status for RMS_DONE on bit 4 = '1'

    11

     SEQUENCE_CFG

     0x10

    0x01

    Stop the sequencer

    12

     RMS_LSB

     RMS_MSB

     0xC1

     0xC2

    Read the RMS result

    13

     SYSTEM_STATUS

     0x00

    0x10

    Clear the RMS_DONE bit

    14

     GENERAL_CFG

     0x01

    0x20

     Disable RMS module

    Following the above procedure worked for our testing.

    Best regards,

    Bob B

  • Hi,

    I still do not understand why I could not get RMS function to work in Manual Mode (that mode seemed like it should be easier, and more appropriate for my task).

         I would still like to see an example recipe for using Manual Mode for RMS measurements.

    Nevertheless, I could get your recipe using auto sequencing to work, even if I don't understand:

    1) why in Step 14 it is necessary to set the STATS_EN bit in GENERAL_CFG register after conversion to allow subsequent RMS conversions (I verified that it is indeed necessary), since setting STATS_EN bit before conversion is not necessary.  Alternatively, I found that setting GENERAL_CFG = 0x00 (reset) after conversion done also allowed subsequent conversions.

    2) Why step #11 clearing SEQ_START (bit 4) is in the recipe, since the recipe worked at first when I had forgot to include that step, so adding that step did not seem necessary.

    Also, for the benefit of other readers, note that the AUTO_SEQ_CH_SEL channel selection scheme is different than for the RMS_CFG and CHANNEL_SEL registers.

    Thank you,

    Scott

  • Hi Scott,

    The auto sequence mode was easiest to implement, but we are still working on the manual mode.  The steps outlined above is based on the datasheet flow chart in Figure 33.  There may be subtle changes that might also work, but this is a sequence we know actually works.

    1) why in Step 14 it is necessary to set the STATS_EN bit in GENERAL_CFG register after conversion to allow subsequent RMS conversions (I verified that it is indeed necessary), since setting STATS_EN bit before conversion is not necessary.  Alternatively, I found that setting GENERAL_CFG = 0x00 (reset) after conversion done also allowed subsequent conversions.

    This is one of those subtle changes.  The key point here is that you need to disable the RMS_EN bit by clearing it before you can reenable the bit to start the calculation.  Unfortunately this information is not in the datasheet.  This will get updated as soon as possible. 

    2) Why step #11 clearing SEQ_START (bit 4) is in the recipe, since the recipe worked at first when I had forgot to include that step, so adding that step did not seem necessary.

    Clearing the SEQ_START to stop the channel sequencing is not necessary if you want to keep the sequence running.  In our test case, it was cleared as we had concluded the operation.

    Best regards,

    Bob B

  • Hi Scott,

    One further update.  I basically used the default power up settings and ran manual mode and was able to see the RMS_DONE bit set.  I used AIN0 as the input.  The steps I followed are as shown below:

    Step

    Register

    Address

    Value

    Function

    1

     RMS_CFG

     0xC0

    0x00

    RMS on CH0, Do not subtract DC, samples = 1024

    2

     GENERAL_CFG

     0x01

    0x80

    RMS_EN, No CRC, No STATS_EN, No Comparator,

    normal conv start, default ch config, no cal, no reset

    3

     SEQUENCE_CFG

     0x10

     0x00

    SEQ_MODE = '00' Use manual mode

    No write needed, default works

    4

     CHANNEL_SEL

     0x11

    0x00

    MANUAL_CHID = '00' Select AIN0

    No write needed, default works

    5

     GPIO_CFG

     0x07

    0x00 

    No write needed, default works

    6

     

     

    Initiate a conversion read

    7

     

     

    Continue reading conversions from the device for a minimum of 1024 + 40 additional conversions

    8

     SYSTEM_STATUS

     0x00

    Monitor status for RMS_DONE on bit 4 = '1'

    9

     RMS_LSB

     RMS_MSB

     0xC1

     0xC2

    Read the RMS result

    10

     SYSTEM_STATUS

     0x00

    0x10

    Clear the RMS_DONE bit

    11

     GENERAL_CFG

     0x01

    0x00

     Disable RMS module

    Hopefully following this procedure you will find success in manual mode.  One key point is to keep conversions continuing you must manually read from the ADS7128 by following Figure 31 on page 25 of the datasheet.  As given in the datasheet "A new conversion is initiated on the ninth falling edge of SCL (ACK bit) when the last byte of output data is read".

    Best regards,

    Bob B

  • Hi,

    Could you elaborate on steps 6 and 7 in the above sequence for Manual Mode? Providing actual register operations would be very helpful, since I did try to start ADC conversions on February 10th, and RMS still failed.  This aspect of Manual Mode RMS is not intuitive, since it seems that RMS_EN should start the process, and the actual RMS calculation results would be in the RMS_LSB and RMS_MSB registers anyway.

    Also, in your step 4 above, if one were to use other channels besides Ain0 would setting CHANNEL_SEL be necessary for any channels besides channel 0, which is set by default?

    Thank you,

    Scott

  • Hi Scott,

    In step 4 I used AIN0, but this could be set to another channel.  You can use any channel available for CHANNEL_SEL. 

    As far as steps 6 and 7 there is obviously a disconnect of understanding on how the device functions.  For manual mode you have to manually read the conversion result and start the next conversion.  This is detailed in the datasheet on page 25 in Figure 31.  The RMS will only be computed if you start and read the set number of conversions (for me it was using the default of 1024) plus an additional 40 conversions to complete the computation.  Just waiting a period of time will not work in manual mode.

    Bests regards,

    Bob B