1. I have installed all Linux (Ubuntu 18.04) drivers for libiio correctly.
2. I have been able to connect with the ADALM2000 with info_iio command and receive a listing of ADALM2k services.
3. I have installed Scopy software and been able to run the delightful software.
4. However, as seen in the gnuradio flowgraph below, I dont seen to be connecting to ADALM2k via the IIO Attribute Source block, even when I am using the correct URI, USB:2.3.5 that I used for connecting to ADALM2k via iio_info.
My aim is to capture a square-wave waveform being fed to the ADALM2k from a function generator and to delay the waveform by say 300, 350 and 400 microseconds. The flowgraph below is a simulation that ran successfully.
The flowgraph here is the one I have a problem with:
Thanks in advance...
If you want to capture a signal in GRC using gr-iio, you should use 'IIO Device Source' block, setting the device to "m2k-adc" and the channels to ["voltage0", "voltage1"]. This block streams short items, so you wil have to convert them. Also you will have to set some attributes, such as clk_powerdown and powerdown, sampling frequency and so on.Here is an example:
Thank you very much, TeoPeri!
I tried your suggested flowgraph and get an error output. I think there seems to be an error in the 'channels' attribute of the IIO Device Source, from the error dump.
My goal is to display the input waveform at the adc, delay it by say 300 usecs and display both the original and delayed waveforms on the 'scope' display, as well as output the delayed waveform from one of the I/Os.
I am new to GRC, so thank you for your time and patience...
I tried "voltage0" for channels in the IIO Device Source and received an error saying "voltage0" cannot be processed. When I use an integer, that is accepted. I have tried using 0, 1 and 2 for channels[ ] but get an error during execution...
Enter exactly as it shown in bold
If you want only a channel, set the parameter to: ["voltage0"] or ["voltage1"].
The channel must be between square brackets.
I set the 'channels [ ] to "voltage0" instead of [voltage0] and this is what I get - 8 channels of the ADC.
You did not set the channel right. For one channel set the parameter like this:
You got 8 channels because you forgot to use square brackets, and the string "voltage0" has 8 characters, so the device source considers you have 8 channels.
Wooo yes, I got the display. My inputs are floating right now, so the display is a mess...
Thank you, TeoPeri and mhennerich! Much obliged for getting me out of this hole...
I will trouble you more later...
For ADALM2000, you have to set both channels in order to get the expected signal. If you do not need a channel, just connect it to a 'Null Sink' and set the input type of the sink to short.
I did the needful and connected a null sink to the second channel, as can be seen in the flowgraph below. I'm still not getting a display of the +/- 1VDC 1kHz square wave I have connected to the 1+ and 1- terminals. Is it something to do with the ADALM2k sampling rate of 10,000,000 MSPS and the sampling rate at the time sink? Something about the conversion from short-to-float-to-short?
Also, when I get the square wave display right, I want to output the result of a delay block to one DAC channel, as shown in the flowgraph. The delay block is missing right now - I just want to get my original waveform on the output first. Blocks that appear disabled in the flowgraph, are actually enabled.
With the square wave connected to the 1+ and 1- terminals, I get the very mobile display below...
but as soon as I disconnect the function generator connected to the 1+ and 1- terminals, the display freezes to something like below...
What am I doing wrong, that I cannot display the waveform at the input?
ADC and DAC are different, therefore you cannot easily create a loopback in gnuradio.
ADC ranges: high gain - values between -2.5V and 2.5V low gain - values between -25V and 25VDAC ranges: values between -5V and 5VADC samplerates: [1000, 10000, 100000, 1000000, 10000000, 100000000]DAC samplerates: [750, 7500, 75000, 750000, 7500000, 75000000]
In order to get your original waveform, please follow the steps below:
1. Configure ADC: powerdown = 0 (m2k-fabric: global) clk_powerdown = 0 (m2k-fabric: input voltage0) gain = high (m2k-fabric: input voltage0) oversampling_ratio = 1 (m2k-adc: global) sampling_frequency = 1000000 (m2k-adc: global)
2.Configure DAC: powerdown = 0 (m2k-fabric: output voltage0) powerdown = 0 (ad5625: output voltage0) powerdown = 0 (ad5625: output voltage2) sampling_frequency = 750000 (m2k-dac-a: global) oversampling_ratio = 1 (m2k-dac-a: global)
To capture a signal and then to generate it you have to simulate a calibration - ADC output values are quite different than DAC input values (different ranges).
3. Capture the signal:M2k-adc streams short values. The voltage value of the signal is dependent on multiple parameters such as calibration gain and offset, ADC sample rate and gain mode. After calibration one can read out the values from the iio attributes. A gnuradio block that handles this conversion is still in work. You can use a simple short to float block with scale of ~600 for testing purposes, however this won't account for the values I mentioned above. You will need to adjust this value for your board/setup.Because of the difference of sample rates between ADC and DAC, you will have to resample the signal. Using a 'Rational Resampler' block, set the interpolation value to DAC samplerate and decimation value to ADC samplerate.
4.Generate the signal:The m2k-dac has similar parameters to the ADC, therefore it is not trivial to convert from voltage to raw samples. An experimental value that we found for the float_to_short block is ~310. After conversion all samples need to be shifted by 4 to the left (multiply by 16).
Thank you TeoPeri!
I will get back to you by this evening, after trying this out...