measure_amplitude
Measure signal amplitude on PicoScope channels to analyze voltage characteristics using peak-to-peak, RMS, mean, max, or min calculations after capturing data.
Instructions
Measure signal amplitude on a channel.
Note: This requires a recent capture. Call capture_block first.
Args: channel: Channel to measure. measurement_type: Type of amplitude measurement.
Returns: Dictionary containing amplitude in volts and measurement type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | ||
| measurement_type | No | peak_to_peak |
Implementation Reference
- The core handler function for the 'measure_amplitude' tool. Decorated with @mcp.tool() for automatic registration and schema inference from type hints and docstring. Implements placeholder logic: checks device connection and channel configuration, returns guidance or error responses. Intended to compute amplitude types like peak-to-peak using imported utils.@mcp.tool() def measure_amplitude( channel: Literal["A", "B", "C", "D"], measurement_type: Literal["peak_to_peak", "rms", "mean", "max", "min"] = "peak_to_peak", ) -> dict[str, Any]: """Measure signal amplitude on a channel. Note: This requires a recent capture. Call capture_block first. Args: channel: Channel to measure. measurement_type: Type of amplitude measurement. Returns: Dictionary containing amplitude in volts and measurement type. """ try: if not device_manager.is_connected(): return { "status": "error", "error": "No device connected", } # Check if channel is configured if channel not in device_manager.channel_configs: return { "status": "error", "error": f"Channel {channel} not configured. Configure and capture first.", } # For now, we need to guide the user to capture data first return { "status": "info", "message": "To measure amplitude: 1) Configure channel, 2) Set trigger, 3) Capture block, then extract measurements from captured data", "channel": channel, "measurement_type": measurement_type, } except Exception as e: return { "status": "error", "error": str(e), "channel": channel, }
- src/picoscope_mcp/server.py:18-18 (registration)Invocation of register_analysis_tools(mcp) in the main server setup, which defines and registers the measure_amplitude tool along with other analysis tools.register_analysis_tools(mcp)
- src/picoscope_mcp/utils.py:79-82 (helper)Helper function calculate_peak_to_peak imported in analysis.py for use in measure_amplitude (one of the measurement_type options), computes max - min from numpy array.def calculate_peak_to_peak(voltage_values: np.ndarray) -> float: """Calculate peak-to-peak voltage. Args: