Post Go back to editing

Disable CN0359 Automatic Gain Control

While using the CN0359 with my sensor probe I have noticed that sometimes the values reported back are much higher than they should be. This can last for seconds, minutes, or even longer before it jumps back to where it should be. This normally only happens right after power up (i.e. once it reads the correct value it generally does not jump up or down). Removing the probe and dunking it back in can fix it sometimes, as will a reset. If I am using a 53 mS/cm solution to test I have seen it as high as 120 - 180 mS/cm or sometimes higher. I am very careful to make sure there are no air bubbles in the probe and the probe is well away from all the container walls.

I am pretty sure at this point that what is happening is the automatic gain control selects the wrong gain. Is there a way for me to set the gain to be static in the firmware so I can test if this is the culprit? I am using Rev A of the firmware. Happy to provide more detail if needed.

  • Hi rwatson,

    Here is a function in the firmware which steps up or steps down the gain using the AD8253 based on the current ADC reading:

    (The part highlighted in blue steps down the current and voltage gain when the ADC results are greater than 94% of the full scale. The part highlighted in green steps up the current and voltage gain when the ADC results are less then 8.8% of the full scale)

    1. static int on_adc0(int argc, char *argv[])
    2. {
    3.                 ad8253_file ad8253;
    4.                 timer t;
    5.  
    6.                 rewind(p_ad8253);
    7.                 fread(&ad8253, sizeof(ad8253_file), 1, p_ad8253);
    8.  
    9.                 if (abs(adc0_result) > (0x10000000 * 0.94)) //upper threshold is 0.94*FS
    10.                 {
    11.                                 if ((adc0_cfg & 0x1) == 0x0) //current channel
    12.                                 {
    13.                                                 if (ad8253.i_gain > 1)
    14.                                                 {
    15.                                                                 ad8253.i_gain /= 10;
    16.  
    17.                                                                 fseek(p_ad8253, (int) (&ad8253.i_gain) - (int) (&ad8253), SEEK_SET);
    18.  
    19.                                                                 fwrite(&ad8253.i_gain, sizeof(ad8253_file::i_gain), 1, p_ad8253);
    20.  
    21.                                                                 fflush(p_ad8253);
    22.  
    23.                                                                 t.time = 50;
    24.                                                                 t.timer_app.argc = 0;
    25.                                                                 t.timer_app.fun = start_adc0;
    26.                                                                 t.timer_app.argv = new char*;
    27.  
    28.                                                                 new_timer(t);
    29.  
    30.                                                                 return 0;
    31.                                                 }
    32.                                 }
    33.                                 else //voltage channel
    34.                                 {
    35.                                                 if (ad8253.v_gain > 1)
    36.                                                 {
    37.                                                                 ad8253.v_gain /= 10;
    38.  
    39.                                                                 fseek(p_ad8253, (int) (&ad8253.v_gain) - (int) (&ad8253), SEEK_SET);
    40.  
    41.                                                                 fwrite(&ad8253.v_gain, sizeof(ad8253_file::v_gain), 1, p_ad8253);
    42.  
    43.                                                                 fflush(p_ad8253);
    44.  
    45.                                                                 t.time = 50;
    46.                                                                 t.timer_app.argc = 0;
    47.                                                                 t.timer_app.fun = start_adc0;
    48.                                                                 t.timer_app.argv = new char*;
    49.  
    50.                                                                 new_timer(t);
    51.  
    52.                                                                 return 0;
    53.                                                 }
    54.                                 }
    55.                 }
    56.  
    57.                 if (abs(adc0_result) < (0x10000000 * 0.088)) //lower threshold is 0.088*FS
    58.                 {
    59.                                 if ((adc0_cfg & 0x1) == 0x0) //current channel
    60.                                 {
    61.                                                 if (ad8253.i_gain < 1000)
    62.                                                 {
    63.                                                                 ad8253.i_gain *= 10;
    64.  
    65.                                                                 fseek(p_ad8253, (int) (&ad8253.i_gain) - (int) (&ad8253), SEEK_SET);
    66.  
    67.                                                                 fwrite(&ad8253.i_gain, sizeof(ad8253_file::i_gain), 1, p_ad8253);
    68.  
    69.                                                                 fflush(p_ad8253);
    70.  
    71.                                                                 t.time = 50;
    72.                                                                 t.timer_app.argc = 0;
    73.                                                                 t.timer_app.fun = start_adc0;
    74.                                                                 t.timer_app.argv = new char*;
    75.  
    76.                                                                 new_timer(t);
    77.  
    78.                                                                 return 0;
    79.                                                 }
    80.                                 }
    81.                                 else //voltage channel
    82.                                 {
    83.                                                 if (ad8253.v_gain < 1000)
    84.                                                 {
    85.                                                                 ad8253.v_gain *= 10;
    86.  
    87.                                                                 fseek(p_ad8253, (int) (&ad8253.v_gain) - (int) (&ad8253), SEEK_SET);
    88.  
    89.                                                                 fwrite(&ad8253.v_gain, sizeof(ad8253_file::v_gain), 1, p_ad8253);
    90.  
    91.                                                                 fflush(p_ad8253);
    92.  
    93.                                                                 t.time = 50;
    94.                                                                 t.timer_app.argc = 0;
    95.                                                                 t.timer_app.fun = start_adc0;
    96.                                                                 t.timer_app.argv = new char*;
    97.  
    98.                                                                 new_timer(t);
    99.  
    100.                                                                 return 0;
    101.                                                 }
    102.                                 }
    103.                 }

    Best Regards,

    Nikko

  • Wonderful, thank you Nikko. I will take a look and see if setting it to static gain fixes my issue. I will comment back and change to answered once I do that. Best, Rob.