Pluto SDR and MATLAB parallel workers

Hi,

I need to receive data from two Plutos at the same time. I wrote some parallel code in MATLAB using spmd but one of the Plutos disconnects during the process.

If I perform sequential readings everything works fine, no USB nor Pluto issues, but obviously my received data belongs to different time instants. With the parallel code, one of the Pluto disconnects and I have to physically disconnect and reconnect the USB cable to reset it.

I'm wondering if there is support for reentrability at the driver level here. This is Windows 10.

My next option for this is to work on Linux at the IIO level to get the data and later process it in MATLAB.

Comments are welcome. Regards

  • 0
    •  Analog Employees 
    on Apr 26, 2021 9:31 PM

    How are you initializing the different objects? Within the spmd call or outside? Some sample code would help.

    -Travis

  • Sure! This is the latest incantation, been trying some stuff in and out to make sure the workers weren't stepping on each other. I first initialize and later read. The IDs are determined by calling findPlutoRadio and checking for the transmitter SerialNum. Then rx1 gets the same id as tx, and rx2 the other one. The parallel pool is fixed to 2 workers

    % Set up the transmitter
    tx = sdrtx('Pluto', 'RadioID', txid, 'CenterFrequency', params.fc, ...
               'BasebandSampleRate', params.fs, 'Gain', -20, ...
               'ShowAdvancedProperties', true);
    txRadioInfo = info(tx);

    % Set up the receivers
    numSamples = 1024*1024;
    receivedSig = complex(zeros(numSamples,2));
    spmd
        switch labindex
            case 1
                rx = sdrrx('Pluto', 'RadioID', rx1id, 'CenterFrequency', params.fc, ...
                   'BasebandSampleRate', params.fs, 'SamplesPerFrame', numSamples, ...
                   'OutputDataType', 'double', 'ShowAdvancedProperties', true);
                rxRadioInfo = info(rx);
                fprintf("ID: %s",rx.RadioID);
            case 2
                rx = sdrrx('Pluto', 'RadioID', rx2id, 'CenterFrequency', params.fc, ...
                   'BasebandSampleRate', params.fs, 'SamplesPerFrame', numSamples, ...
                   'OutputDataType', 'double', 'ShowAdvancedProperties', true);
                rxRadioInfo = info(rx);
                fprintf("ID: %s",rx.RadioID);
        end
    end
    rxConst = parallel.pool.Constant(rx);
       
    for i = 1:5
        spmd
          switch labindex
            case 1
                fprintf("ID: %s",rxConst.Value.RadioID);
                rxRadioInfo = info(rxConst.Value);
               receivedSig(:,labindex) = rxConst.Value();
            case 2
                fprintf("ID: %s",rxConst.Value.RadioID);
                rxRadioInfo = info(rxConst.Value);
                receivedSig(:,labindex) = rxConst.Value();
          end
        end
        fprintf("Round %d\n", i);
    end

    % Release the radios
    release(tx);
    spmd
        release(rxConst.Value);
    end

  • +1
    •  Analog Employees 
    on Apr 26, 2021 10:21 PM in reply to scaprile

    My guess would be that MATLAB is holding onto a context somewhere. USB contexts are limited to a single accessible process. So if a certain process or instance of MATLAB holds a context (tx or rx) only that process can talk to that radio. spmd I believe runs code on different processes. In your case this might be 3 since you have the main and 2 child workers.

    Try putting all object creation within the spmd call. This probably means just hardcoding the serial numbers used for now. You can also try accessing the devices over IP which is not as limiting as USB.

    -Travis

  • Removed the tx initialization, and even hardcoded rx1id and rx2id so there was no call to the Pluto functions other than within each worker. Same results.


    Switching to IP IDs seems to do the trick, I can also initialize the transmitter in the main context.

    findPlutoRadio set me in USB thinking mode, didn't think using the IPs within MATLAB was possible. Thx

  • 0
    •  Analog Employees 
    on Apr 27, 2021 5:37 PM in reply to scaprile

    MathWorks add their own layer ontop to add more management of the ADI code which can be a little confusing sometimes.

    Glad to hear its working.

    -Travis