Skip to content

Update Scaling Algorithm for Variable Resolution #264

@tylerkron

Description

@tylerkron

Type: Feature
Priority: High
Epic: Enhanced Resolution & Range Support

Description

Update the analog sample scaling algorithm to support any resolution (not just 12-bit) based on device-reported capabilities.

Acceptance Criteria

  • Modify ScaleAnalogSample() method to use channel's actual resolution
  • Support resolutions from 8-bit to 24-bit (future-proof)
  • Maintain backward compatibility with existing 12-bit devices
  • Update scaling formula to handle different bit depths correctly
  • Add resolution validation and bounds checking
  • Unit tests for various resolution configurations

Current vs Updated Formula

Current (fixed 12-bit):

return analogValue / channel.Resolution * channel.PortRange * channel.CalibrationMValue * 
       channel.InternalScaleMValue + channel.CalibrationBValue;

Updated (variable resolution):

// Resolution = 2^bits, e.g., 262144 for 18-bit
return analogValue / channel.Resolution * channel.PortRange * channel.CalibrationMValue * 
       channel.InternalScaleMValue + channel.CalibrationBValue;

Files to Modify

  • Daqifi.Desktop/Device/AbstractStreamingDevice.cs (ScaleAnalogSample method)

Value

Correctly scales 18-bit data from Nyquist 3 and maintains accuracy for future higher-resolution devices

Testing Requirements

  • Test 12-bit scaling (Nyquist 1 compatibility)
  • Test 18-bit scaling (Nyquist 3)
  • Test edge cases (8-bit, 24-bit)
  • Verify scaling accuracy with known test values

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions