From c43f1dff506f435e7fdf076ce46e878c5a7ffda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 16 Jun 2018 21:37:27 +0200 Subject: [PATCH] more info --- LICENSE | 4 ++-- README.md | 23 ++++++++++++++++++-- UNITS.INI | 64 ++++++++----------------------------------------------- 3 files changed, 32 insertions(+), 59 deletions(-) diff --git a/LICENSE b/LICENSE index 3f28a5f..669bc54 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,9 @@ MIT License -Copyright (c) +Copyright (c) 2018 Ondřej Hruška Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index f270036..4655295 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,27 @@ # demo-bode-plotter -GEX demo measuring the amplitude and phase frequency response of analog filtes +GEX demo measuring the amplitude and phase frequency response of analog filtes. -To run it, change the 'gex' symlink to point to your copy of the GEX client library. +This demo uses an external waveform generador AD9833 (on a breakout module from eBay). +It could also use the built-in DAC, but the performance is sub-optimal and the plots +obtained with it had a lot of glitches. Feel free to adjust the script to use the +internal DAC and try it. + +The AD9833 is connected to SPI on pins PA4 (SS), PA5 (SCK), and PA7 (MOSI). +Pins PA1 and PA2 are used by the ADC and attach before and after the filter (DUT). + +The generator has a very low output amplitude (0.65 V max). To better utilize the +input range of the ADC, I used OP213 in a non-inverting configuration +(resistors 7.5k and 2.2k), with a 10M resistor from the input to GND. This gives us gain +of around 4.4, enough to reach just under 3V. + +## To run the script + +- Change the 'gex' symlink to point to your copy of the GEX client library. +- Load the attached UNITS.INI file into GEX (intended for GEX Hub) +- Connect the external circuitry and run the script. + +Dependencies - pyplot, numpy, and whatever you need to use the GEX library: typically pyusb or pyserial. ## Example outputs diff --git a/UNITS.INI b/UNITS.INI index ce23b06..5bb5326 100644 --- a/UNITS.INI +++ b/UNITS.INI @@ -7,9 +7,9 @@ # remove the same way. Reload to update the unit sections below. # Digital output -DO=areset +DO= # Digital input with triggers -DI=psign +DI= # Neopixel RGB LED strip NPX= # I2C master @@ -25,7 +25,7 @@ ADC=adc # Shift register driver (595, 4094) SIPO= # Frequency and pulse measurement -FCAP=fcap +FCAP= # Capacitive touch sensing TOUCH= # Simple PWM output @@ -33,35 +33,7 @@ PWMDIM= # Two-channel analog output with waveforms DAC= -[DO:areset@1] -# Port name -port=A -# Pins (comma separated, supports ranges) -pins=8 -# Initially high pins -initial=8 -# Open-drain pins -open-drain= - -[DI:psign@2] -# Port name -port=A -# Pins (comma separated, supports ranges) -pins=3 -# Pins with pull-up -pull-up= -# Pins with pull-down -pull-down= - -# Trigger pins activated by rising/falling edge -trig-rise= -trig-fall= -# Trigger pins auto-armed by default -auto-trigger= -# Triggers hold-off time (ms) -hold-off=100 - -[SPI:spi@3] +[SPI:spi@2] # Peripheral number (SPIx) device=1 # Pin mappings (SCK,MISO,MOSI) @@ -83,48 +55,30 @@ first-bit=MSB # SS port name port=A # SS pins (comma separated, supports ranges) -pins=14 +pins=4 [ADC:adc@4] # Enabled channels, comma separated # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 C0 C1 C2 C3 C4 C5 Tsens Vref -channels=1-2, 17 +channels=1-2 # Sampling time (0-7) sample_time=2 # Sampling frequency (Hz) -frequency=10000 +frequency=1000 # Sample buffer size # - shared by all enabled channels # - defines the maximum pre-trigger size (divide by # of channels) # - captured data is sent in half-buffer chunks # - buffer overrun aborts the data capture -buffer_size=256 +buffer_size=512 # Enable continuous sampling with averaging # Caution: This can cause DAC output glitches -averaging=Y +averaging=N # Exponential averaging coefficient (permil, range 0-1000 ~ 0.000-1.000) # - used formula: y[t]=(1-k)*y[t-1]+k*u[t] # - not available when a capture is running avg_factor=800 - -[FCAP:fcap@5] -# Signal input pin - one of: -# Full support: A0, A5, A15 -# Indirect only: A1, B3 -pin=A0 - -# Active level or edge (0-low,falling; 1-high,rising) -active-level=1 -# Input filtering (0-15) -input-filter=0 -# Pulse counter pre-divider (1,2,4,8) -direct-presc=1 -# Pulse counting interval (ms) -direct-time=1000 - -# Mode on startup: N-none, I-indirect, D-direct, F-free count -initial-mode=N