# Rigol DG5000 Pro MATLAB and Python Demonstrations

Experimental MATLAB and Python examples for controlling Rigol DG5000 Pro
function generators through their raw SCPI TCP socket. No VISA layer is used.

## Audience

Engineers, scientists, educators, and laboratory users who want readable
examples that can be adapted into purpose-specific test applications.

## Current Demonstrations

- Direct TCP/SCPI connection without VISA
- Distinct starter outputs for side-by-side validation: Python on Channel 1
  at 5 kHz and 2 Vpp, and MATLAB on Channel 2 at 7 kHz and 1.5 Vpp
- Multi-channel sine-wave configuration
- Per-channel frequency, amplitude, and phase
- Output selection for 2-, 4-, and 8-channel models
- Bundled-channel phase alignment
- Write, read-back, verify, then enable workflow
- Complete native MATLAB and Python error reporting

## Main Files

- `DG5254Pro_First_Script_Show_IDN_Start_Ch2.m`: introductory MATLAB connection,
  identification, and 7 kHz, 1.5 Vpp Channel 2 example.
- `DG5254Pro_First_Script_Show_IDN_Start_Ch1.py`: introductory Python version with
  a 5 kHz, 2 Vpp Channel 1 output, newline-terminated SCPI reading, and
  automatic socket cleanup.
- `DG5000Pro_MultiChannel_Sine_Demo.m`: verified multi-channel sine-wave
  demonstration with per-channel load settings.

The examples intentionally leave enabled waveform outputs running after the
TCP connection closes. Confirm the load, voltage, frequency, and connected
circuit before running them.

## AI Coworker Context

This project includes layered context for reuse with language models:

- `AGENTS.md`: project workflow, collaboration rules, and reference-library
  routing.
- `MATLAB_STYLE.md`: MATLAB coding and explanation preferences.
- `references/MATLAB_REFERENCE_INDEX.md`: topic-to-document page index.
- `references/MATLAB_SIGNATURE_METHODS.md`: distinctive algorithms and
  teaching methods worth consulting before choosing an implementation.
- `references/SOURCE_LINKS.md`: stable web pages for the optional course-note
  PDFs.
- `references/SOURCES_AND_RIGHTS.md`: provenance and reuse notes.
- `TESTING.md`: what has been checked and what still needs hardware verification.

An AI working in this directory should read `AGENTS.md` first. The indexes are
useful on their own; download only a relevant PDF when its figures or detailed
explanation would materially help the current task.

## Cycles of Efficiency™

This project applies **Cycles of Efficiency™**, Ron Fredericks's term for
an iterative method first documented in a 2005 Embedded Components, Inc.
LectureMaker service brochure. Curated technical references inform the code;
the code is executed under user direction; instrument read-back and
independent measurements provide evidence; and validated findings improve the
code and project guidance used during the next cycle.

The reference library can grow with the work. A new MATLAB or engineering
source from Ron or another contributor should be linked or included only with
appropriate permission, attribution, and reuse terms. Its useful techniques
should then be routed through the reference index and, when distinctive,
summarized in the signature-methods guide so later projects can retrieve them
without loading an entire document.

For the live validation described in `TESTING.md`, MATLAB and Python
communicated with the Rigol over TCP. With explicit user authorization, the AI
coworker operated the development environments and observed Rigol and
Tektronix displays, while Ron retained control between consequential steps.
This access was session-specific; the project files do not grant future
hardware or computer-control access.

## Optional Reference Library

The large PDFs are not bundled in this portable download. They remain freely
available from [BiophysicsLab.com's MATLAB Projects page](https://www.biophysicslab.com/portfolio/matlab-projects/).

| PDF | Pages | Main coverage |
| --- | ---: | --- |
| `MasterMATLABGuidedProblems_CourseNotes.pdf` | 253 | Broad MATLAB problem solving, plotting, time series, matrix analysis, statistics, and fitting |
| `MasterTheFourierTransformMATLABPython.pdf` | 104 | Fourier foundations, FFT scaling and phase, resolution, stationarity, STFT, and 2D transforms |
| `SignalProcessingProblemsMATLABPython.pdf` | 126 | Denoising, filters, convolution, wavelets, resampling, outliers, and features |
| `Incomplete linear algebra3.pdf` | 145 | Vectors, matrices, rank, spaces, systems, determinants, inverses, and projections |

## Status

Demonstration and educational code. Verify limits, loading, output levels,
and safety requirements before adapting it for production or automated tests.

Tested hardware: Rigol DG5254 Pro firmware 00.01.01 and Tektronix MSO64B.
Other DG5000 Pro models and firmware should be checked against their current
programming guide.
