Gain value get reset before capture

Hi,

Today noticed somethig that I don’t uderstand…
I was receiving ADC gain too low error, so I tried to increase scope.gain.db value but I don’t see the plot increase the range of captured data, no matter what value I config the range was always between -0.1 and 0.1
I printed the gain.db value just before the trace being captured and just after the capture, and looks like it is always doing the capture at db=21, as after doing the capture the value is always back to 21

Here is the code of the cap_pass_trace function so you can see there is no modification of the gain value inside that function:
image

Something else must be touching the gain. Add a print(scope.gain.db) before and after anything that uses the scope object: reset_target(), scope.arm(), scope.capture(), and scope.get_last_trace().

HI @jpthibault

I did what you asked for and the results are nonsense for me:

I modified def_pass_trace to look like this:

def cap_pass_trace(pass_guess):
    print("Gain before reset_target:")
    print(scope.gain.db)
    reset_target(scope)
    print("Gain after reset_target:")
    print(scope.gain.db)
    num_char = target.in_waiting()
    while num_char > 0:
        target.read(num_char, 10)
        time.sleep(0.01)
        num_char = target.in_waiting()
    print("Gain before scope_arm:")
    print(scope.gain.db)
    scope.arm()
    print("Gain after scope_arm:")
    print(scope.gain.db)
    target.write(pass_guess)
    print("Gain before scope_capture:")
    print(scope.gain.db)
    ret = scope.capture()
    print("Gain after scope_capture:")
    print(scope.gain.db)
    if ret:
        print('Timeout happened during acquisition')
    print("Gain before get_last_trace:")
    print(scope.gain.db)
    trace = scope.get_last_trace()
    print("Gain after get_last_trace:")
    print(scope.gain.db)
    return trace

then ran the capture and looks like it changes magically

tried several values, and it goes back to 20db inmediatly after entering def_pass_trace what have no logic at all to me


What can be happening here?

Looks like the gain changes when you call reset_target(). Follow the code!

In Jupyter, if you run:
reset_target??

you will get the actual code of the reset_target() function. There must be something in there that’s touching the gain. This shouldn’t be hard to pinpoint.

Thank you very much!!!

Problem fixed… I modified Setup_generic.ipynb to config the initial scope.gain.db to 21 as with 25 clipping errors appearch almost every time, but i did something wring and it overwrite that value each time the target is reset