Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
resources:eval:user-guides:matlab_bsp_extend [02 May 2019 01:24] – created Travis Collinsresources:eval:user-guides:matlab_bsp_extend [02 May 2019 01:37] (current) – add headings Travis Collins
Line 5: Line 5:
 The MATLAB and Simulink interfaces can be extended in two ways. The MATLAB and Simulink interfaces can be extended in two ways.
  
-1. Directly address properties through the underlying libIIO API calls. For example, the RSSI measurement is not provided as part of the AD9361 transceiver interfaces. To read this attribute directly we could do the following with the [[https://github.com/analogdevicesinc/MathWorks_tools/blob/master/%2Badi/%2Bcommon/Attribute.m#L25|common abstractions from here]]:+==== Directly Addressing Attributes ==== 
 +1. Directly address properties through the underlying libIIO API calls. By default the AD9361 receiver interfaces only provide or control the following properties: 
 +<code> 
 +rx =  
 + 
 +  adi.AD9361.Rx with properties: 
 + 
 +             CenterFrequency: 2.4000e+09 
 +                SamplingRate: 3000000 
 +                 RFBandwidth: 3000000 
 +     GainControlModeChannel0: 'slow_attack' 
 +    EnableQuadratureTracking: true 
 +          EnableRFDCTracking: true 
 +    EnableBasebandDCTracking: true 
 +             SamplesPerFrame: 32768 
 +                channelCount:
 +          EnableCustomFilter: false 
 +                         uri: 'ip:192.168.2.1' 
 +</code> 
 +This does not provide status attributes or other more obscure control attributes. For example, the RSSI measurement is not provided as part of the AD9361 transceiver interfaces. To read this attribute directly we could do the following with the [[https://github.com/analogdevicesinc/MathWorks_tools/blob/master/%2Badi/%2Bcommon/Attribute.m#L25|common abstractions from here]]:
 <code> <code>
 rx = adi.AD9361.Rx('uri','ip:192.168.2.1'); rx = adi.AD9361.Rx('uri','ip:192.168.2.1');
 rssiValue = rx.getAttributeLongLong('voltage0','rssi',false); rssiValue = rx.getAttributeLongLong('voltage0','rssi',false);
 </code> </code>
 +
 +==== Adding MATLAB Properties For Attributes ====
 +2. If additional APIs are needed for a device, and that code will be used by others, then it is recommended to add an actual property to the class. This can provide additional documentation as well as range checking. Below the [[https://github.com/analogdevicesinc/MathWorks_tools/blob/master/%2Badi/%2BAD9361/Rx.m|Rx]] class is modified to allow to selection of the RF port attribute of the transceiver. This is done by inserting the following:
 +<code>
 +    properties
 +        %RFPort RF Port
 +        %   specified as one of the following:
 +        %   'A_BALANCED' - Select A Balanced RF input
 +        %   'B_BALANCED' - Select B Balanced RF input
 +        %   'TX_MONITOR1' - Select TX Monitor 1 RF input
 +        %   'TX_MONITOR2' - Select TX Monitor 2 RF input
 +        RFPort = 'A_BALANCED';
 +    end
 +</code>
 +Now under the standard methods scope the following set method is added
 +<code>
 +        % Check RFPort 
 +        function set.RFPort (obj, value)
 +            obj.RFPort = value;
 +            if obj.ConnectedToDevice
 +                id = 'voltage1';
 +                obj.setAttributeRAW(id,'rf_port_select',value,false);
 +            end
 +        end
 +</code>
 +Now when the class is expanded the new property is populated:
 +<code>
 +rx = 
 +
 +  adi.AD9361.Rx with properties:
 +
 +             CenterFrequency: 2.4000e+09
 +                SamplingRate: 3000000
 +                 RFBandwidth: 3000000
 +                      RFPort: 'A_BALANCED'
 +     GainControlModeChannel0: 'slow_attack'
 +    EnableQuadratureTracking: true
 +          EnableRFDCTracking: true
 +    EnableBasebandDCTracking: true
 +             SamplesPerFrame: 32768
 +                channelCount: 2
 +          EnableCustomFilter: false
 +                         uri: 'ip:192.168.2.1'
 +</code>
 +
 +
resources/eval/user-guides/matlab_bsp_extend.txt · Last modified: 02 May 2019 01:37 by Travis Collins