measure_frequency
Measure signal frequency on PicoScope oscilloscope channels after capturing data. Use this tool to analyze waveforms and obtain frequency measurements in Hz.
Instructions
Measure signal frequency on a channel.
Note: This requires a recent capture. Call capture_block first.
Args: channel: Channel to measure.
Returns: Dictionary containing frequency in Hz and measurement details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes |
Implementation Reference
- The core handler function for the 'measure_frequency' tool, decorated with @mcp.tool(). It checks device connection and channel configuration, currently returns guidance on usage as implementation is stubbed pending capture data.@mcp.tool() def measure_frequency(channel: Literal["A", "B", "C", "D"]) -> dict[str, Any]: """Measure signal frequency on a channel. Note: This requires a recent capture. Call capture_block first. Args: channel: Channel to measure. Returns: Dictionary containing frequency in Hz and measurement details. """ 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 # In a real implementation, we might store the last capture return { "status": "info", "message": "To measure frequency: 1) Configure channel, 2) Set trigger, 3) Capture block, then extract frequency from captured data", "channel": channel, } except Exception as e: return { "status": "error", "error": str(e), "channel": channel, }
- src/picoscope_mcp/server.py:18-18 (registration)Top-level registration call to register_analysis_tools(mcp), which defines and registers the measure_frequency tool using nested @mcp.tool() decorators.register_analysis_tools(mcp)
- src/picoscope_mcp/tools/analysis.py:9-10 (registration)The registration function that contains the @mcp.tool() decorated measure_frequency handler and other analysis tools.def register_analysis_tools(mcp: Any) -> None: """Register signal analysis tools with the MCP server."""
- src/picoscope_mcp/utils.py:38-38 (helper)Helper function imported but not yet used in measure_frequency, intended for frequency calculation from time and voltage arrays.def calculate_frequency(time_values: np.ndarray, voltage_values: np.ndarray) -> float: