tkzilla / rsa_api_python_36

Conversion of RSA_API scripts to Python 3.6
4 stars 2 forks source link

Problems detecting ADC Overloads using Python and RSA API #1

Open heatherottke opened 7 years ago

heatherottke commented 7 years ago

I am using Python and the RSA API to control the RSA306B. I've written the following two functions in order to query the ADC overload status. If I understand correctly, the DEVICE_GetEventStatus API call when the event_id argument is set to zero, queries whether an overload event has occurred. The IQBLK_GetIQAcqInfo call returns the relevant overload status and associated timestamp information.

In order to detect the overload, I injected a CW into the RSA and increased the power until I expected to see an overload (I determined what this level should be by using the SignalVu software), yet my software failed to detect the overload event. I have scaled down and attached my code hoping that you can help me trouble shoot what I may be doing wrong. Thanks in advance!

adcOverload.txt

def query_device_status():
    event_id = c_int(0)
    event_occurred = c_bool()
    event_timestamp = c_uint64()
    rsa.DEVICE_GetEventStatus(event_id, byref(event_occurred),
                              byref(event_timestamp))
    return event_id.value, event_occurred.value, event_timestamp.value

def get_acq_info():
    acqInfo = IQBLK_ACQINFO()
    rsa.IQBLK_GetIQAcqInfo(byref(acqInfo))
    return acqInfo
tkzilla commented 7 years ago

You are using the function correctly, but don't think it is in the right place in your code. According to the API documentation, DEVICE_GetEventStatus() must be called while the RSA is in the Run state since the device status is not updated while the RSA is in the Stop state. Even then I found that the command should be used directly prior to grabbing acquisition data (e.g. SPECTRUM_GetTrace(), IQBLK_GetIQData(), DPX_GetFrameBuffer(), etc.). It did not consistently update if I used it right after calling DEVICE_Run() or SPECTRUM_AcquireTrace(), only when used right before the XXX_GetXXX() functions.

Try this out and let me know if that fixes the issue!

Example below from rsa_api_full_example.py in the acquire_spectrum function:

def acquire_spectrum(specSet):
    ready = c_bool(False)
    traceArray = c_float * specSet.traceLength
    traceData = traceArray()
    outTracePoints = c_int(0)
    traceSelector = SpectrumTraces.SpectrumTrace1

    rsa.DEVICE_Run()
    rsa.SPECTRUM_AcquireTrace()
    while not ready.value:
        rsa.SPECTRUM_WaitForDataReady(c_int(100), byref(ready))
    # Put it here!
    print(query_device_status())
    rsa.SPECTRUM_GetTrace(traceSelector, specSet.traceLength, byref(traceData),
                          byref(outTracePoints))
    rsa.DEVICE_Stop()
    return np.array(traceData)
heatherottke commented 7 years ago

Hi Morgan:

I didn't add that because I think the documentation states that if the device is not in a run state, the call below will put it in a run state. I will add that in and see what happens, thanks!

Heather

rsa.IQBLK_AcquireIQData()


From: Morgan Allison notifications@github.com Sent: Monday, June 19, 2017 10:32:38 AM To: tkzilla/rsa_api_python_36 Cc: Ottke, Heather; Author Subject: Re: [tkzilla/rsa_api_python_36] Problems detecting ADC Overloads using Python and RSA API (#1)

You are using the function correctly, but don't think it is in the right place in your code. According to the API documentation, DEVICE_GetEventStatus() must be called while the RSA is in the Run state since the device status is not updated while the RSA is in the Stop state. Even then I found that the command should be used directly prior to grabbing acquisition data (e.g. SPECTRUM_GetTrace(), IQBLK_GetIQData(), DPX_GetFrameBuffer(), etc.). It did not consistently update if I used it right after calling DEVICE_Run() or SPECTRUM_AcquireTrace(), only when used right before the XXX_GetXXX() functions.

Try this out and let me know if that fixes the issue!

Example below from rsa_api_full_example.py in the acquire_spectrum function:

def acquire_spectrum(specSet): ready = c_bool(False) traceArray = c_float * specSet.traceLength traceData = traceArray() outTracePoints = c_int(0) traceSelector = SpectrumTraces.SpectrumTrace1

rsa.DEVICE_Run()
rsa.SPECTRUM_AcquireTrace()
while not ready.value:
    rsa.SPECTRUM_WaitForDataReady(c_int(100), byref(ready))
# Put it here!
print(query_device_status())
rsa.SPECTRUM_GetTrace(traceSelector, specSet.traceLength, byref(traceData),
                      byref(outTracePoints))
rsa.DEVICE_Stop()
return np.array(traceData)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/tkzilla/rsa_api_python_36/issues/1#issuecomment-309494801, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJ-3fio0enPOFYrcxCbINFM-2One2Rnkks5sFqKmgaJpZM4N9BAw.

tkzilla commented 7 years ago

Again you're correct that IQBLK_AcquireIQData() puts the instrument in the Run state. I believe the timing of the query_device_status() may not be quite right. Where are you putting query_device_status() in the acquisition section of your code?