Running DAC-ADC Pmod Example "" hangs with Pmod AD1

I am trying to run the example " DAC-ADC Pmod Examples …" that can be found at the link below on a PYNQ-Z1. PYNQ/pmod_dac_adc.ipynb at v2.5 · Xilinx/PYNQ · GitHub

However, instead of a PmodAD4 I have a Pmod AD1 (The PmodAD4 is out of stock).

I am able to run all of the setup code,

from pynq.overlays.base import BaseOverlay
from pynq.lib import Pmod_ADC, Pmod_DAC
ol = BaseOverlay("base.bit")
dac = Pmod_DAC(ol.PMODB)
adc = Pmod_ADC(ol.PMODA)

I am able to write to the DAC (I can see this on an oscilloscope so I know it’s working).

But when I come to read from the ADC, it hangs,
sample =

I can leave it for several minutes but it will never complete, and just stays as [*]. I tried restarting the PYNQ-Z1, restarting the kernel, and writing some of my own code but it always hangs at the same line. If I interrupt the kernel I get the error below, but I am not sure how to read into this error or what causes it.

KeyboardInterrupt Traceback (most recent call last)
in ()
----> 1 sample =

/opt/python3.6/lib/python3.6/site-packages/pynq/lib/pmod/ in read(self, ch1, ch2, ch3)
203 # Send the command
→ 204 self.microblaze.write_blocking_command(cmd)
206 # Read the last sample from ADC

/opt/python3.6/lib/python3.6/site-packages/pynq/lib/pmod/ in write_blocking_command(self, command)
152 “”"
→ 154 while + MAILBOX_PY2IOP_CMD_OFFSET) != 0:
155 pass

/opt/python3.6/lib/python3.6/site-packages/pynq/lib/pynqmicroblaze/ in read(self, offset, length)
304 “”"
305 if length == 1:
→ 306 return
307 elif length > 1:
308 return [ + 4*i) for i in range(length)]

/opt/python3.6/lib/python3.6/site-packages/pynq/ in read(self, offset, length)
141 # Read data out
→ 142 return int(self.array[idx])
144 def write(self, offset, data):


I am very new to Pynq, and to Juptyer notebooks in general (I come from an Ancaoda/spyder background) so I fully admit I may be missing something simple. Looking at the docs for the library call, I don’t see anything about this library only being for PmodAD2, but maybe there is a compatibility issue
that I am running into?

I am not sure how to get my PYNQ version number, as if I they root@pynq:/home/xilinx# pynq --version into the Jupyter terminal I get bash: pynq: command not found. However, if I open the file REVISION I see “Release 2018_02_16 e5c8aeb” so I assume that is my version.

Hi @adowney2,

Welcome to our community.
What board are you using? I would suggest you get the latest SD Card image version (2.7) from here PYNQ - Python productivity for Zynq - Board.

It is also likely that the driver you are trying to use does not work for that PMOD. You can use the PYNQ Peripherals project to write the driver for that PMOD. GitHub - Xilinx/PYNQ_Peripherals


Thanks for the help,

  • I am using a PYNQ-Z1.
  • I just installed the image last week, but there is a chance I could have installed an old one. How could I check what version I have? I would love to be able to figure this out.
    • From a Jupyter terminal, if I log and type pynq --version' I get bash: pynq: command not found`
    • However, if I open the file REVISION in the pynq directory I see “Release 2018_02_16 e5c8aeb” so I assume that is my version.
  • On the driver issue, how would I know what Pmods that driver would work for? I am getting the feeling that the PMODS are hit and miss in terms of working out of the box and are a Diligent thing that I will have to work around.


In a notebook you can do

import pynq

Each notebook should state which PMOD works with it. Also, the driver for each PMOD is open source, so you can check if the code implements the functionality to talk to the PMOD.
Writing your own driver if this is what you need should be relatively easy with the PYNQ Peripherals project


Thanks, This is helpful, Let me work through these ones by one.

import pynq 


AttributeError Traceback (most recent call last)
in ()
1 import pynq
----> 2 print(pynq.version)

AttributeError: module ‘pynq’ has no attribute ‘version

form the source file it, it has the following, but no version.

author = “Yun Rock Qu”
copyright = “Copyright 2016, Xilinx”
email = “

all = [‘lib’, ‘tests’]

For the PMOD, thanks!
I looked in the source code and in the header, I see “Pmod_ADC(object)” is only for " The Pmod AD2 (PB 200-217) ". To me, I thought that this worked for all ADC Pmods. I will have to look for / create a driver for the AD1. Here is a link to the source code.
pynq.lib.pmod.pmod_adc — Python productivity for Zynq (Pynq) Thanks for your help on this.


Well, based on this. It would appear that you have in the best case scenario the PYNQ 2.3 version or older. Which is really old.
Please get the SD Card image for the 2.7 version.


Thanks, you were correct. I installed an older version. That is updated now. With 2.7 print(pynq.__version__) returns 2.7.0

I think that closes out all the questions I had on this thread. Thanks for your help!

1 Like