rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Mon Jul 09, 2012 8:53 pm

MadCow42 wrote:Is there an easy way to disable the interrupts from Python that you might suggest?
No; you need to be running in the kernel to do things like that.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Mon Jul 09, 2012 8:56 pm

What about using bash?
Ostendo ignarus addo scientia.

MadCow42
Posts: 106
Joined: Sun Jul 01, 2012 12:48 am

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Tue Jul 10, 2012 1:47 am

rgh wrote:
MadCow42 wrote:Is there an easy way to disable the interrupts from Python that you might suggest?
No; you need to be running in the kernel to do things like that.
Thanks... that's about how my day is going anyhow. :)

Kevin.

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Tue Jul 10, 2012 7:33 am

I finally got time to experiment with using DMA to capture data (but only by getting up at 5am!). I'm using dma channel 0, which should be one of the fast ones.

Currently I'm focusing on seeing how fast it can go, and what the variation is in sample rate. I'm doing this by kicking off a DMA request to read the arm-side 250MHz counter 1M times to a 4MB buffer, using a single CB. I'm then processing the data and producing a histogram of the differences between consequtive samples, so I can see what the scatter it like.

So, for example, this shows about 87.5% of the time (912245 of the samples) it samples at 44ns (11*4), and 12.5% of the time it samples at 56ns (14*4), and there is the odd sample up to 72ns (18*4):

[ 3918.766933] min 11, max 18
[ 3918.771096] 11: 912245
[ 3918.776216] 12: 4741
[ 3918.780238] 13: 184
[ 3918.785373] 14: 130320
[ 3918.789272] 15: 1003
[ 3918.794219] 16: 34
[ 3918.798101] 17: 20
[ 3918.803018] 18: 20

It may make sense that 1 in 8 samples are slower, as I've told it to use a 128 bit (i.e. 8 samples) write width.

If I tell it to use a 32 bit write width to avoid that then we still get most samples at 44ns but now 1:8 at 80ns, and I get much worse variation, up to around 800ns! That probably makes sense becuase it is presumably getting close to saturating internal or memory busses.

So next I went back to using 128 bit write width, but added some wait states between DMA reads of the 250MHz counter. I'd hoped that might hide the "1:8 is slower" issue by allowing things to overlap with the wait states. Not so, unfortunately. I added 8 wait states and now I get this:

[ 905.021287] min 20, max 38
[ 905.026319] 20: 908191
[ 905.030127] 21: 8727
[ 905.035003] 22: 253
[ 905.038817] 23: 199
[ 905.042514] 24: 122
[ 905.047477] 25: 5
[ 905.051136] 26: 1
[ 905.055814] 27: 0
[ 905.059443] 28: 0
[ 905.063017] 29: 0
[ 905.067737] 30: 0
[ 905.071328] 31: 0
[ 905.075985] 32: 128982
[ 905.079610] 33: 2011
[ 905.083185] 34: 35
[ 905.087917] 35: 17
[ 905.091567] 36: 20
[ 905.096242] 37: 1
[ 905.099890] 38: 3

So adding wait states makes the scatter worse.

Anyway....

Assuming that GPIO reads are about the same as 250MHz counter reads, then I conclude: The fastest sample rate we can manage is 17.8 to 22.7MHz (56 to 44ns), accepting that very occasionally it'll go down to 13.9MHz.

That's probably useful for some use-cases, especially if you are looking at a repeating event and can sample a few times if the odd slow sample makes your trace look 'odd'. If you wanted trigger conditions I guess you can use interrupts from the GPIO pins, and then have the CPU abort the DMA transfer. Note you can't sample for very long at 20MHz - that's 80MB of memory per second, so if you are doing it under Linux and running X so you can display the traces, 1 second is probably the best you might hope for.

Still to do: See what the effect of chaining CBs is. Presumably more variation. Verify that reading GPIOs behaves similar to reading the 250MHz counter. Explore continually updating a chain of CBs so the DMA loops round and round a set of buffers until the CPU aborts it. Explore Gert's approach of using two CBs per sample and dummy reads to reduce the sample rate - that might be interesting for lower sample rates. Of course running the DMA flat out at maximum prioity for extended periods like I'm doing at the moment may cause problems when something else wants to access the peripheral bus..

I added pandriver-dma.c to https://github.com/richardghirst, in case anyone wants to look.

Richard

User avatar
jbeale
Posts: 3702
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Tue Jul 10, 2012 7:15 pm

Thanks very much Richard for your detailed analysis! This answers the questions I had about the RPi hardware capabilities. The 250 MHz counter rate got me excited, but it seems that timing resolution cannot be put to use in any simple way to time-stamp an incoming edge with anything better than about 50 nsec. So I'm back to an FPGA solution, for now.

secretagent
Posts: 36
Joined: Wed Mar 07, 2012 10:09 am

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Wed Jul 11, 2012 9:37 am

jbeale wrote:Thanks very much Richard for your detailed analysis! This answers the questions I had about the RPi hardware capabilities. The 250 MHz counter rate got me excited, but it seems that timing resolution cannot be put to use in any simple way to time-stamp an incoming edge with anything better than about 50 nsec. So I'm back to an FPGA solution, for now.
You may want to look into a microcontroller with high-speed input capture capabilities as it may work for your application and is much easier than FPGA. I have used one such microcontroller from the LPC17xx family in a similar situation with good results. If you are interested in more details PM me so that we don't derail this thread any further.

atererus
Posts: 1
Joined: Sat Aug 18, 2012 12:38 pm
Location: the Netherlands

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Sat Aug 18, 2012 12:49 pm

Just FYI. I'm a FPGA designer, and looking into hooking up TheRasp via GPIO as front end. I'm looking for high speed GPIO talk for a few day's know, and end up in Panalyzer. Feel free to contact me at atererus@saiying.nl. For now, I'm heading to a 5-channel FPGA based analyzer "probe". Although my main intrest is not (limited) to analyzing, but also serial bus (e.g. i2c, SPI, JTAG) driving. At this moment I'm trying to get a development platform assembled and running. The GPIO connection is the last missing part. If I do not find anything else, I might take the Panalyzer and use that as a base, or try the standard GPIO functions from Mike that include i2c and SPI for a start.

User avatar
jbeale
Posts: 3702
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Sat Aug 18, 2012 2:58 pm

An FPGA design would be the fastest option for R-Pi I/O. For those interested in intermediate speeds, note the Parallax Propeller has 32 GPIO pins, runs at 80 MHz (generally overclockable to 100 MHz) and it can capture pin data on every clock cycle (12.5 or 10 ns resolution), if you use four of its eight cores for the job. It is available in a 40-pin DIP package and is (from my point of view) easier to program than a FPGA.

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Thu Aug 30, 2012 11:46 pm

I updated the code on github https://github.com/richardghirst/Panalyzer. I included a kernel module and Panalyzer binary, though I expect the module will fail to load due to kernel updates before very long. This version is not significantly different from the previous one from a user perspective, but the code is re-written to use gtk-3.0 and the screen update handling is much more efficient when moving the cursors. There is now also a Panalyzer.ui file which must be present in the directory Panalyzer is invoked from.

DrPinball
Posts: 57
Joined: Fri May 04, 2012 6:44 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Wed Jun 12, 2013 9:56 pm

rgh wrote:I updated the code on github https://github.com/richardghirst/Panalyzer. I included a kernel module and Panalyzer binary, though I expect the module will fail to load due to kernel updates before very long. This version is not significantly different from the previous one from a user perspective, but the code is re-written to use gtk-3.0 and the screen update handling is much more efficient when moving the cursors. There is now also a Panalyzer.ui file which must be present in the directory Panalyzer is invoked from.
rgh - thanks a lot for pursuing this work. I have been working on a project sampling data at 1MHz using GPIO Async Rising Edge detection and polling. However, I now need to sample at 3MHz and possibly 5MHz. Switching to sampling the GPIO using DMA, then post processing the sampled data is working a treat.
In fact, I start the DMA transfer from GPIO to memory then immediately start parsing the stored data to look for clock edges and then read off the relevant data. Setting disable_pvt=1 is an absolute must as you have found.

If you're interested, you can see my work at http://www.drpinball.co.uk.

Cheers.

stragulus
Posts: 1
Joined: Thu Mar 06, 2014 7:22 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Thu Mar 06, 2014 7:38 pm

Hey Richard,

I'd like to express my thanks for your project. I am using your project to analyze a bunch of faulty ADM-3A serial terminals from the 70's. Their circuitry is all discrete components without fancy CPU's, and panalyzer has proven to be an excellent debugging tool to trace faulty IC's. It's the first time I ever did measurements on a live circuit like this so I'm extremely excited about how easy it was to get panalyzer to work. A couple of of test leads, a level shifter, breadboard, some hookup wires and there you have it; an ultra-cheap logic analyzer at work.

I have a more modern binary kernel module available as well as the Panalyzer ui program itself if you're interested; both of those in the current github project do not run on the current raspbian.

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Tue Mar 25, 2014 10:02 pm

stragulus wrote:I have a more modern binary kernel module available as well as the Panalyzer ui program itself if you're interested; both of those in the current github project do not run on the current raspbian.
Thanks, I'll rebuild and push to github myself when I get time - I'm sure your binaries are fine but I don't want to end up answering questions about binaries I didn't build myself :)

MiBe26
Posts: 1
Joined: Fri Jun 13, 2014 10:19 am

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Fri Jun 13, 2014 11:30 am

stragulus wrote:Hey Richard,

I'd like to express my thanks for your project. I am using your project to analyze a bunch of faulty ADM-3A serial terminals from the 70's.....
Hi stragulus / Richard,

I would be very, very interested in an updated version of the Panalyzer project (am using kernel version 3.12.21+). So far I have tried to compile the project on my own, but have given up - too many error messages and unfortunately too little understanding of how to compile... Is there a way for you to describe step by step how to compile on a raspberry? Your help is very much appreciated :-)

Best regards,
Michael

rgh
Posts: 212
Joined: Fri Nov 25, 2011 3:53 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Mon Jun 16, 2014 10:46 pm

Hi Michael,
If you are running Raspbian and you run rpi-update, you will hopefully end up with this kernel:

Code: Select all

richard@raspberrypi ~ $ cat /proc/version 
Linux version 3.12.22+ (dc4@dc4-arm-01) (gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) ) #690 PREEMPT Mon Jun 16 13:25:46 BST 2014
richard@raspberrypi ~ $ 
In which case, if you get the latest pandriver.ko and Panalyzer binaries from github, it should work for you.

I've also updated the README with instructions for compiling the module.

adgriff2
Posts: 3
Joined: Wed Jun 05, 2013 1:16 am

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Thu Nov 06, 2014 2:06 am

Are the included binaries still working? I'm getting many errors:

Code: Select all

** (Panalyzer:2632): WARNING **: Error retrieving accessibility bus
address: org.freedesktop.DBus.Error.ServiceUnknown: The name
org.a11y.Bus was not provided by any .service files

(Panalyzer:2632): Gtk-WARNING **: Theme parsing error:
gtk-widgets.css:2:19: Theming engine 'adwaita' not found

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenuBar.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local

(Panalyzer:2632): Gtk-WARNING **: Unknown property: GtkMenu.ubuntu-local
The window still pops up, but I don't think it's working.

I tried compiling my own binaries, but I'm not exactly following how the README is saying to alter the make file to compile on the pi itself. It says I need to change the KERNEL_TREE variable to point at my kernel tree. Where is this on the pi? Or is this something just for cross compiling? As instructed, I removed the

Code: Select all

ARCH=arm
and

Code: Select all

CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-
items. This leaves most lines looking like

Code: Select all

make -C ${KERNEL_TREE} M=$(PWD) modules
Is this correct? I'm getting tons of deprecated gtk warnings, but then fails with the error

Code: Select all

make[1]: *** No rule to make target 'modules'. Stop.
Any help would be much appreciated.

EDIT: I should note that uname -r returns 3.12.31+

Brucom
Posts: 3
Joined: Sat Feb 14, 2015 10:04 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Fri Mar 13, 2015 11:17 am

I resume this thread to see if anybody can help with the pandriver installation.
I'm an IT man but with a limited experience with Linux.
Compiled the user interface I'm now trying to understand how to load the module.
Followed the instruction in pandriver.c comments and other from the forum but I don't see the module loaded (lsmod).
Is there anybody can drive me in this ?
Thank you in advance and sorry for me poor english.
Ah, by the way, hope the provided module still works with my 3.18.5+ #744 :|

User avatar
joan
Posts: 15001
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Fri Mar 13, 2015 12:03 pm

Brucom wrote:I resume this thread to see if anybody can help with the pandriver installation.
...
My piscope digital waveform viewer may do what you want.

Brucom
Posts: 3
Joined: Sat Feb 14, 2015 10:04 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Sat Mar 14, 2015 9:32 am

Thank you Joan
looks like what I'm looking for and very interesting but I tryied to use the GUI on the Raspberry itself but it is not feasible, too slow.
So I installed a Ubuntu Virtual Machine for the GUI part but ...

Code: Select all

user@ubuntuvm:~$ wget abyz.co.uk/rpi/pigpio/piscope.tar
--2015-03-14 10:23:17--  http://abyz.co.uk/rpi/pigpio/piscope.tar
Resolving abyz.co.uk (abyz.co.uk)... 91.238.161.4
Connecting to abyz.co.uk (abyz.co.uk)|91.238.161.4|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 522240 (510K) [application/x-tar]
Saving to: ‘piscope.tar’

100%[======================================>] 522.240     1,14MB/s   in 0,4s   

2015-03-14 10:23:18 (1,14 MB/s) - ‘piscope.tar’ saved [522240/522240]

user@ubuntuvm:~$ tar xvf piscope.tar
PISCOPE/
PISCOPE/command.h
PISCOPE/piscope.x86_64
PISCOPE/README
PISCOPE/piscope.hf
PISCOPE/pigpio.h
PISCOPE/Makefile
PISCOPE/piscope.c
PISCOPE/piscope.sf
PISCOPE/piscope.glade
user@ubuntuvm:~$ cd PISCOPE
user@ubuntuvm:~/PISCOPE$ make x86_64
cp piscope.x86_64 piscope
user@ubuntuvm:~/PISCOPE$ make install
sudo install -m 0755 -d	           /usr/local/bin
[sudo] password for user: 
sudo install -m 0755 -d	           /usr/share/piscope
sudo install -m 0755 piscope       /usr/local/bin
sudo install -m 0644 piscope.glade /usr/share/piscope
user@ubuntuvm:~/PISCOPE$ piscope
bash: /usr/local/bin/piscope: cannot execute binary file: Exec format error
Do you have any suggestion about this ?
I've a doubt, does it work on a 32 bit ?

User avatar
joan
Posts: 15001
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Sat Mar 14, 2015 10:14 am

The pre-built executables are for the Pi or a 64 bit Linux machine. You'll have to build from source for a 32-bit non Pi.

The piscope GUI will be slow on non Pi2 models, which is why I invariably run the GUI on a desktop. It seems fine on a Pi2 though.

The data will still be captured even if the GUI can't keep up. I suggest you capture the data and then use play mode at a suitable speed. It's hardly going to be slower than capturing the data in one program and then launching another program to view the data.

Brucom
Posts: 3
Joined: Sat Feb 14, 2015 10:04 pm

Re: Panalyzer - a RaspberryPi based Logic Analyzer

Sat Mar 14, 2015 11:07 am

Thank you so much, just finished to install from the iso file a new virtual machine based on Ubuntu 14.04.2 64 bit and the GUI works as per your confirmation.
Quite hard to get now a PI 2, unless you are prepared to pay much of the official price.
Asap I'll try to use the scope and study the protocol from a 433MHz door sensor :)
Just a few hardship because the PC is in a room while the PI downstairs, but this is another story :mrgreen:

Return to “Automation, sensing and robotics”