mariusgreuel / dwfpy

Digilent WaveForms for Python
MIT License
17 stars 5 forks source link

Data recording on specific channels #4

Closed abhinavG37 closed 8 months ago

abhinavG37 commented 8 months ago

Hi @mariusgreuel! Could you please confirm the functionality of data recording on dwfpy? I would like to simultaneously record information for 7 digital input channels.
From what I can understand, the following line of code: logic.record(sample_rate=10e3, sample_format=32,sample_count=SAMPLE_COUNT // 2,prefill=SAMPLE_COUNT // 2, start=True) records only a single np.ndarray with the number of specified samples. How does the API decide which channel to record, and how do I selectively record a specific digital-input.

Your help would be highly appreciated.

mariusgreuel commented 8 months ago

How does the API decide which channel to record

AFAIK, you cannot specify the channels. You can only specify how many channels you want (as in Waveforms), and the channels are DIN0...DINn. So you either record all of them, or you need to rewire your setup.

abhinavG37 commented 8 months ago

I'd go with recording all the channels. If you'd have some sample code to help me get started, I'd highly appreciate it. I have only been able to get single channel data out of it (single dim ndarray when logic.record() is called). Thank you so much.

mariusgreuel commented 8 months ago

The returned vector is always one-dimensional. If you record 32 channels, it returns a c_uint32 vector, where the individual channels are encoded in the respective bits of the c_uint32.

Check out https://github.com/mariusgreuel/dwfpy/blob/main/examples/digital_in_record.py

abhinavG37 commented 8 months ago

Thank you, that worked perfectly!