element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Use the ZYNQ XADC with DMA part 2: get and show samples in PYNQ
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 30 Nov 2021 4:03 PM Date Created
  • Views 6910 views
  • Likes 6 likes
  • Comments 6 comments
  • summer_of_fpgas
  • zynq
  • xilinx
  • fpga
  • vivado
  • summer_of_fpga
  • pynq
Related
Recommended

Use the ZYNQ XADC with DMA part 2: get and show samples in PYNQ

Jan Cumps
Jan Cumps
30 Nov 2021

In this series of 2 blogs, I'm trying to sample the ADC at high speed and move the samples to memory fast.
The goal is to achieve the highest speed - 1 MSPS (Megasamples per second = millions of samples per second).
In the previous article, I checked this bare metal: write the Vivado hardware design and create a ARM program (C, running bare metal ARM A9) to look at the results.

In this post I'm using the exact same Vivado design, now running on Linux with PYNQ.
Repeat: Like many posts in my Zynq/PYNQ series, I'm using code and work of someone else. In this case a Hackster.io article by Adam Taylor.

Get the Data Sampled by the XADC in a Jupyter Notebook, using DMA

The title says it all. Many of the mechanisms, we've seen in use before.

Prepare PYNQ

There is something that I haven't seen before though: custom Overlay Python code.

image

It doesn't do much. I'm wondering if this is a legacy way to prepare overlay load, or if it's really needed.
For the moment, I've kept it as explained by Adam, and it works.

Place the bit- and hwh file from previous blog in a ~/pynq/overlays/xadc_scope folder, together with the two Python files above. rename both to xadc_scope.*.
You don't need to type. The code is available on Adam's hackster.io post.

Prepare Hardware

I'm using a function generator to generate a test signal. It has to be between 0 and  1 V.
In my setup, I used a sinus of 16 kHz, between 148 mV and 554 mV

image

The dedicated analogue input of the Zynq is used, on connector J5:

J5.GND function generator ground
J5.Vn function generator ground
J5.Vp function generator signal

Don't turn the generator on before the PYNQ-Z2 is powered on.
Because we're using PYNQ and Linux, the boot jumper JP1 needs to be placed back to the SD Card position, the card needs to be entered and the network cable plugged in.

Jupyter Notebook and Results

I'm using screen captures here. The blog of Adam has the source code.
First step is to load the bitfile and prime the DMA and memory buffer.

image

The design is running. We can retrieve a buffer of data and plot it.
You can repeat this step as often as you want.

image

When you're finished, mop op the allocated memory

image

To close this post, a capture of a 100 kHz signal, same amplitude

image

Thank you for reading.

 

Pynq - Zync - Vivado series
Add Pynq-Z2 board to Vivado
Learning Xilinx Zynq: port a Spartan 6 PWM example to Pynq
Learning Xilinx Zynq: use AXI with a VHDL example in Pynq
VHDL PWM generator with dead time: the design
Learning Xilinx Zynq: use AXI and MMIO with a VHDL example in Pynq
Learning Xilinx Zynq: port Rotary Decoder from Spartan 6 to Vivado and PYNQ
Learning Xilinx Zynq: FPGA based PWM generator with scroll wheel control
Learning Xilinx Zynq: use RAM design for Altera Cyclone on Vivado and PYNQ
Learning Xilinx Zynq: a Quadrature Oscillator - 2 implementations
Learning Xilinx Zynq: a Quadrature Oscillator - variable frequency
Learning Xilinx Zynq: Hardware Accelerated Software
Automate Repeatable Steps in Vivado
Learning Xilinx Zynq: Try to make my own Accelerated OpenCV Function - 1: Vitis HLS
Learning Xilinx Zynq: Try to make my own Accelerated OpenCV Function - 2: Vivado Block Design
Learning Xilinx Zynq: Logic Gates in Vivado
Learning Xilinx Zynq: Interrupt ARM from FPGA fabric
Learning Xilinx Zynq: reuse and combine components to build a multiplexer
PYNQ version 2.7 (Austin) is released
PYNQ and Zynq: the Vitis HLS Accelerator with DMA training - Part 1: Turn C++ code into an FPGA IP
PYNQ and Zynq: the Vitis HLS Accelerator with DMA training - Part 2: Add the Accelerated IP to a Vivado design
PYNQ and Zynq: the Vitis HLS Accelerator with DMA training - Part 3: Use the Hardware Accelerated Code in Software
PYNQ and Zynq: the Vitis HLS Accelerator with DMA training - Deep Dive: the data streams between Accelerator IP and ARM processors
Use the ZYNQ XADC with DMA part 1: bare metal
Use the ZYNQ XADC with DMA part 2: get and show samples in PYNQ
VHDL: Convert a Fixed Module into a Generic Module for Reuse

  • Sign in to reply
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to Jan Cumps

    and this video, closer to the boards and software we use: https://www.youtube.com/watch?v=aJ9KAVmQs0U

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to yepe

    I found this (10 year old) design: https://support.xilinx.com/s/article/58582?language=en_US

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to yepe

    This is the only experience I have with the ADCs: replicating someone else's project.

    I'd like to say: "ask questions about the design on that article's page", but I did that last year and didn't get an answer.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yepe
    yepe over 2 years ago

    One question you may have thought about. My goal is to capture a signal up to 10 kHz and programmatically determine the frequency using an FFT (and/or create a spectrogram). I would need to know a timestamp or delta_t. Is it correctly understood if you have a static sample rate on the ADC? That way you know the time between each sample.

    Also I noticed you used the V_N and V_P differential ADC input. What if you had to use two inputs? Are you able to pipe the input to, say, A0 and A1, or are they limited in some way?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • yepe
    yepe over 2 years ago

    Great blog post Jan! I am studying this to develop my next sub-module for the same project as the ultrasound pulser. The Arduino XADC I have been testing is too slow with only 1 kS/s Wink

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube