Jump to content
  • 0

WaveForms API (Demo Device) FDwfAnalogInRecordLengthSet not working correctly


agentsmith

Question

I working on an application that allows continuous streaming of data.

Due to certain reasons, I cannot use the ShiftScreen functionality: My producer process (the AD2 device) captures the available samples from the device and then they are sent to the consumer process. For this, I used the sample AnalogIn_Record_Wave_Mono.py as a basis.

Note: This behavior has only been seen on demo devices yet. Since I'm in Homeoffice right now, I do not have physical access to our Analog Discovery to verify if it is an issue with the API or the Demo Implementation. However, even if it is an issue with the demo device this is crucial, for debugging reasons, I also need to not require physical hardware.

  1. The first thing I noticed is that the API call differs from the WafeForm API Documentation. The Code suggests, that a -1 passed to the function
    # AnalogIn_Record_Wave_Mono.py, Line 79: 
    dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(-1)) # -1 infinite record length
    however, the documentation clearly says that a zero must be passed to set the record length to infinite:
    Quote

    FDwfAnalogInRecordLengthSet(HDWF hdwf, double sLegth):
    Description: Sets the Record length in seconds. With length of zero, the record will run indefinitely.
    Parameters:
    - hdwf – Interface handle.
    - sLegth – Record length to set expressed in seconds.

     

  2. Secondly, the passed -1 seems to work with physical hardware (like the AD2). The same parameter seems to be accepted also by the Demo devices, however, using this line with the Demo device and reading the available samples raises a ValueError:
    # AnalogIn_Record_Wave_Mono.py, Line 140
    rgSamples = (c_int16*cAvailable.value)()
    
    # ---------------------------------------------------#
    Traceback (most recent call last):
      File "C:\...\py\AnalogIn_Record_Wave_Mono.py", line 140, in <module>
        rgSamples = (c_int16*cAvailable.value)()
    ValueError: Array length must be >= 0, not -2146675454

     

  3. Passing a zero, the data captures are corrupted but are not recognized by the drive as currupted.
    dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(10)) # 10 seconds

    Figure_1_10s.png.0330f75cfa7e3c840c0af7bba315daf5.png

    dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(0)) # 10 seconds

    Figure_1_indef.png.98a2970914c4e0ef0705371be3df58b0.png

 

I have attached my example file as well.  How do I cope with this issue (Point 2/Point3)?

 

Kind regards,

Chris
 

AnalogIn_Record_Wave_Mono.py

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @agentsmith,

I'm not a python expert (as in minimal experience) and the WaveForms developer is out of office, but I was able to verify the behavior you are seeing with your existing code.

However, when I attempted to replicate this behavior with the built in AnalogIn_Record.py which also generates a sine wave, records the data, and spits out a pyplot graph, I was not able to reproduce this behavior when passing a 0 or a 1 to FDwfAnalogInRecordLengthSet. Best that I could tell from my limited experience is that the built-in example used numpy.fromiter to create the array rather than concatenate like you used, though I don't know why this made all the difference.

Regardless, I'll make a request to have the documentation be updated for clarity on the correct value to pass for infinite record length.

I hope this helps.

Thanks,
JColvin

Link to comment
Share on other sites

  • 0

Hi @agentsmith

Both zero or negative record length specify infinite record length.

The demo mode is intended to be used with the WaveForms app to discovery the application and various device features. The demo mode is not fully functional, it does not emulate all the features correctly like record mode, triggering...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...