Skip to main content
Glama

configure_channel

Set up oscilloscope channels by specifying coupling type, voltage range, and DC offset to prepare for signal acquisition and measurement.

Instructions

Configure a channel on the oscilloscope.

Args: channel: Channel identifier (A, B, C, or D). enabled: Whether the channel is enabled. coupling: AC or DC coupling. voltage_range: Voltage range in volts (e.g., 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20). analog_offset: DC offset voltage in volts.

Returns: Dictionary containing configuration status and applied settings.

Input Schema

NameRequiredDescriptionDefault
analog_offsetNo
channelYes
couplingNoDC
enabledNo
voltage_rangeNo

Input Schema (JSON Schema)

{ "properties": { "analog_offset": { "default": 0, "type": "number" }, "channel": { "enum": [ "A", "B", "C", "D" ], "type": "string" }, "coupling": { "default": "DC", "enum": [ "AC", "DC" ], "type": "string" }, "enabled": { "default": true, "type": "boolean" }, "voltage_range": { "default": 5, "type": "number" } }, "required": [ "channel" ], "type": "object" }

Implementation Reference

  • MCP tool handler for 'configure_channel' decorated with @mcp.tool(). Handles input parameters, creates ChannelConfig, calls device_manager.configure_channel, and returns status.
    @mcp.tool() def configure_channel( channel: Literal["A", "B", "C", "D"], enabled: bool = True, coupling: Literal["AC", "DC"] = "DC", voltage_range: float = 5.0, analog_offset: float = 0.0, ) -> dict[str, Any]: """Configure a channel on the oscilloscope. Args: channel: Channel identifier (A, B, C, or D). enabled: Whether the channel is enabled. coupling: AC or DC coupling. voltage_range: Voltage range in volts (e.g., 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20). analog_offset: DC offset voltage in volts. Returns: Dictionary containing configuration status and applied settings. """ try: if not device_manager.is_connected(): return { "status": "error", "error": "No device connected", } # Create channel config config = ChannelConfig( channel=channel, enabled=enabled, coupling=ChannelCoupling.AC if coupling == "AC" else ChannelCoupling.DC, voltage_range=voltage_range, analog_offset=analog_offset, ) # Configure the channel success = device_manager.configure_channel(config) if success: return { "status": "success", "channel": channel, "enabled": enabled, "coupling": coupling, "voltage_range": voltage_range, "analog_offset": analog_offset, } else: return { "status": "error", "error": "Failed to configure channel", "channel": channel, } except Exception as e: return { "status": "error", "error": str(e), "channel": channel, }
  • ChannelConfig dataclass defining the structure for channel configuration parameters used in the tool.
    class ChannelConfig: """Channel configuration settings.""" channel: str enabled: bool coupling: ChannelCoupling voltage_range: float analog_offset: float
  • Registration of all tool sets in the main server, including register_configuration_tools which registers the configure_channel tool.
    register_discovery_tools(mcp) register_configuration_tools(mcp) register_acquisition_tools(mcp) register_analysis_tools(mcp) register_advanced_tools(mcp)
  • Core helper method in PicoScopeManager that performs the actual channel configuration using PicoSDK ps5000aSetChannel.
    def configure_channel(self, config: ChannelConfig) -> bool: """Configure a channel. Args: config: Channel configuration. Returns: True if successful, False otherwise. """ if not self.is_connected(): return False try: # Map channel letter to PS5000A channel constant channel_map = { "A": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"], "B": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"], "C": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_C"], "D": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_D"], } if config.channel not in channel_map: return False # Map coupling type coupling = ( ps.PS5000A_COUPLING["PS5000A_AC"] if config.coupling.value == "AC" else ps.PS5000A_COUPLING["PS5000A_DC"] ) # Map voltage range to closest available range range_map = { 0.02: "PS5000A_20MV", 0.05: "PS5000A_50MV", 0.1: "PS5000A_100MV", 0.2: "PS5000A_200MV", 0.5: "PS5000A_500MV", 1.0: "PS5000A_1V", 2.0: "PS5000A_2V", 5.0: "PS5000A_5V", 10.0: "PS5000A_10V", 20.0: "PS5000A_20V", } # Find closest range closest_range = min(range_map.keys(), key=lambda x: abs(x - config.voltage_range)) voltage_range = ps.PS5000A_RANGE[range_map[closest_range]] # Convert analog offset to ADC counts if self.device_info: analog_offset_adc = mV2adc( config.analog_offset * 1000, # V to mV voltage_range, self.device_info.max_adc_value ) else: analog_offset_adc = 0 # Set the channel self.status[f"setCh{config.channel}"] = ps.ps5000aSetChannel( self.chandle, channel_map[config.channel], 1 if config.enabled else 0, coupling, voltage_range, analog_offset_adc ) assert_pico_ok(self.status[f"setCh{config.channel}"]) # Store configuration self.channel_configs[config.channel] = config return True except Exception as e: return False
  • ChannelCoupling Enum used in ChannelConfig for coupling type.
    class ChannelCoupling(str, Enum): """Channel coupling types.""" AC = "AC" DC = "DC"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/markuskreitzer/picoscope_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server