Documentation
Go to AppSign InSign Up
    Getting Started
    • Introduction to Flux
    • What is Flux?
    • Quick Start
    • The Flux Method
    • Creating an Account
    • Flux for Organizations
    • Setting Up Your Browser
      • Mouse & Trackpad
      • Multi-Screen Operation
      • Keyboard Shortcuts
    • Your First PCB in Flux
      • DFM & Export
      • PCB Layout & Routing
      • Project Setup
      • Schematic
      • Export & Manufacturing
    • KiCAD to Flux
      • Layout
      • Parts & Libraries
      • Schematics
    • Eagle to Flux
    • EasyEDA to Flux
    • Upverter to Flux
    • Altium to Flux
    • Getting Help
    Tutorials
    • Tutorials
    • Getting Started With Flux
      • Customizing Flux
    • Flux Use Cases
      • AI Architecture Design
      • AI Component Research
      • AI Design Reviews
      • AI Testing & Debugging
      • AI Auto-Layout
      • Generative AI
    • Start Learning Flux, No Matter Your Skill Level
      • Advanced Designer
      • First Time Designer
      • Intermediate Designer
    • Power Regulator
      • 1 – Part Selection
      • 2 – PCB Layout
      • 2 – Schematics
    • Routing
      • High-speed Routing
      • High Density Designs (HDI)
      • Working with Polygons
    • Adding Components to the Library
      • Publishing Components to the Library
      • Creating Components from Scratch
      • Importing Components
      • Working with Footprints
      • Working with Symbols
    • What is a Module?
      • Module Design Best Practices
      • Creating Modules
      • Using Modules
    • Generic Components
      • Creating a generic part
    • Copper Fills Tutorial
      • Creating Copper Cutouts
    • Board Outline Shape and Size
    • The Toolbar
    • Using Layout Rules
    • Intro to collaboration
    • Embedding a Flux Project
    • Reviewing component updates
    • Version Control Deep Dive
    • Custom Shapes
    • AI-Assisted Design with Flux
    • PCB Design Reviews (DRC)
    • Component Placement
    • Component Procurement
    • Multi-Layer PCB Design
    • Working with Ground Signals
    • Reusing Projects
      • Useful links
    Reference
    • Flux Context Menu
    • Calculator Tool
    • Change Project Name
    • Code Tool
    • Convert to component
    • Flux ACUs
    • Overview
    • Data Portability
    • Delete & Archive Projects
    • Design Rule Check (DRC)
    • Expressions
    • File Tool
    • FMEA Report Generation
    • Gerber Exports
    • Help Tool
    • Special Part Types
    • JEP30 PartModel Import/Export
    • Knowledge Base
    • Library Tool
    • Managing Units
    • Measuring Distances
    • Model Selection
    • Nets and Traces
      • Curved Traces
      • Impedance Control
      • Trace Width
    • Object Types
      • AssetNode
      • ControlNode
      • ElementNode
      • ElementTerminalNode
      • OutputNode
      • PropertyNode
      • RouteNode
      • RouteTerminalNode
    • Pads & Holes
    • Passive Component Consolidation
    • Layout Rules Reference
      • Layout Rules List
      • Object-Specific Layout Rules
      • Selector-Based Layout Rules
      • Layout Rules Inheritance & Precedence
      • Layout Rules Modifiers
    • Polygons
    • Comments
    • Cursors
    • Forking & Cloning
    • Copper Fills
    • Importing Schematics
    • Importing Components
    • Schematic Inspector
      • Assets Panel
      • Pricing & Availability Panel
      • Properties Panel
      • Simulation Panel
    • The Library
    • Project Launcher
      • New Blank Project
    • Layout Object Tree
      • PCB Object Types
    • Schematic Object List
    • The PCB Editor
      • Locking
      • Layer View Control
      • Positioning & Routing
      • Selecting Objects
      • Stackup Editor
    • Permission Tiers
    • Preloaded Examples
    • The Profile Page
      • Featured Projects
    • The Schematic Editor
      • Positioning & Wiring
    • Global Search
    • Sharing & Permissions
    • History & Version Control
    • Silkscreen
    • Simulator Tool
    • Star a Project (Favorite)
    • Vias
      • Smart Vias
    Copilot
    • Copilot Overview
    • Model Selection
    • Flux ACUs
    • Knowledge Base
    • Flux Context Menu
    • Calculator Tool
    • Code Tool
    • File Tool
    • Help Tool
    • Library Tool
    • Simulator Tool
    • FMEA Report Generation
    • Passive Component Consolidation
    FAQ
    • Schematic Editor
    • General FAQs
    • Flux and AI FAQs
    • PCB Editor FAQs
    • Parts and Modules
    • Pricing
    • Private and public projects
    • Data security and IP protection
    • When things go wrong: Errors and how to handle them
      • Lost connection
    Legal
    • Terms of Service
    • Privacy Statement
    • Main Services Agreement
    • Subprocessors

Copilot

Code Tool

Copilot

Flux Code Tool


Flux includes a powerful code tool that allows you to generate and execute Python scripts for data analysis, visualization, and complex calculations directly from the chat interface. This tool helps you perform advanced operations that go beyond simple calculations without having to set up a separate programming environment.

Overview

The code tool enables you to:

  • Generate and execute Python code based on natural language descriptions
  • Create visualizations such as graphs, charts, and plots
  • Perform complex data analysis and calculations
  • Simulate circuit behavior and analyze results
  • Generate reports with formatted output

How to Use the Code Tool

To generate and execute Python code using Flux, use the @code tool in your query:

@code Create a plot of a sine wave with frequency 1kHz sampled at 10kHz for 10ms

@code Calculate the frequency response of an RC low-pass filter with R=10k and C=0.1uF

When you use the @code tool, Flux will:

  1. Generate Python code based on your description
  2. Execute the code using a secure Python interpreter
  3. Return the results, including any text output, tables, or visualizations
  4. Provide the generated code for your reference

Python Libraries

The code tool has access to many popular Python libraries for scientific computing and visualization:

Data Analysis and Computation

  • NumPy - For numerical computations and array operations
  • SciPy - For scientific and technical computing
  • Pandas - For data manipulation and analysis
  • SymPy - For symbolic mathematics

Visualization

  • Matplotlib - For creating static, animated, and interactive visualizations
  • Seaborn - For statistical data visualization
  • Plotly - For interactive, publication-quality graphs

Electronics and Signal Processing

  • PySpice - For circuit simulation
  • SciPy Signal - For signal processing functions

Example Use Cases

Here are some examples of how you can use the code tool:

Circuit Analysis and Simulation

@code Simulate a voltage divider with R1=10k and R2=5k with an input of 5V

@code Plot the frequency response of a second-order Butterworth filter with a cutoff frequency of 1kHz

@code Calculate the step response of an RLC circuit with R=100 ohm, L=1mH, and C=10uF

Data Visualization

@code Create a bar chart comparing the power consumption of different microcontrollers

@code Generate a scatter plot of voltage vs. current measurements with a trend line

@code Create a heatmap showing the temperature distribution on a PCB

Complex Calculations

@code Calculate the optimal values for a PID controller given a step response

@code Perform Monte Carlo analysis on a circuit with component tolerances

@code Solve the differential equation for an RC charging circuit

Working with Data

The code tool can work with data from various sources:

Manual Input

You can provide data directly in your query:

@code Plot the following voltage measurements: [3.3, 3.28, 3.31, 3.29, 3.32, 3.27]

Attached Files

You can attach data files (CSV, TXT, etc.) to your chat and reference them:

@code Analyze the temperature data in the attached CSV file and create a line chart with a 7-day moving average

Generated Data

You can ask the code tool to generate synthetic data for analysis:

@code Generate a noisy sine wave and apply a low-pass filter to clean it up

Output Formats

The code tool can generate various types of output:

Text Output

Simple text results for basic calculations and analysis.

Tables

Structured data presented in tabular format for easy reading.

Visualizations

Graphs, charts, and plots rendered as images in the chat.

Interactive Elements

Some visualizations may include interactive elements for exploring data.

Tips for Effective Code Generation

To get the most out of the code tool:

  1. Be specific about your requirements - Clearly describe what you want the code to do, including any specific parameters or methods.

  2. Specify visualization details - Mention axis labels, titles, and other formatting preferences for charts and graphs.

  3. Break complex tasks into steps - For very complex analyses, consider breaking them into a sequence of simpler steps.

  4. Reference specific libraries if needed - If you know you want to use a particular library or function, mention it in your query.

Limitations

While the code tool is powerful, it has some limitations to be aware of:

  • Execution time is limited, so very complex computations may time out
  • Available memory is restricted, limiting the size of datasets that can be processed
  • Not all Python libraries are available in the execution environment
  • The tool cannot access external resources like websites or databases
  • Generated code runs in a sandboxed environment for security reasons

The code tool works well with other Flux capabilities:


Previous

Calculator Tool

Next

File Tool