Fast logic analyser using Cortex-m0 mbed
.
I'm prototyping a logic analyser using a beta version of the new mbed Cortex-m0.
I'll write a Python-based app using PyUSB on the PC to capture and present the data.
The new mbed has arrived!
Time to run through the example code.
When I tried the USB mouse emulator example, it worked perfectly.
The sample HID code works, even though I am running the Windows code in a VirtualBox VM.
I'm now reading a set of inputs and sending these in the USB HID report. I'd like to use PortIn but this won't be available on the new mbed for a few days, so I'm using the slower DigitalIn/BusIn for now.
I started by sampling once a second, and using a DIL switch to control the inputs.
I now have a trivial program which captures a byte-wide stream and sends it over USB one byte at a time. I'm extending the Python client to write the output to a file; for my next test I will try to capture an I2C exchange between an Arduino and an LCD display. That should verify that the software is fast enough to be useful.
Now that my USB hub has arrived I have a programming connection to the mbed and a test connection to the USB breakout board. I even remembered to remove the Vcc connection from the breakout board. That would have connected the 5v rails on both USB ports. Probably not fatal, but not a good idea.
I've switched to a Java client on UBUNTU. Performance looked poor, so I changed the mbed code to just send a report without reading inputs via BusIn; the client is receiving about 125 bytes/sec which is very disappointing. This seems to be determined by the mbed rather than the client.
So, on the plus side,
- the USB HID class has been very easy to use
- the beta compiler and the m0 have worked well
- I've gained some experience with the windows Pyhon client and discovered a usable Linux Java client
- it's worth experimenting with my classic mbed to see if I can drive SUMP using a serial output. (Thanks for the suggestion!)
on the minus side, the protocol seems too slow to be usable in my intended application.
I hope I'm doing something really dumb. Here's main on the mbed:
int main(void) { //Fill the report send_report.length = 1; while (1) { //Send the report // send_report.data[0] = port; hid.send(&send_report); } }
Update: The original design was too simple: it used 8 of the mbed digital I/O pins to capture the state of a circuit under test, and transferred data to a PC using USB HID to stream the data.
It turns out that the USB HID protocol is easy to use but currently limited to about 64k Bytes/sec. USB bulk transfer looks like a lot of work; I'm taking a look at using good old serial or a TCP socket instead.
6 comments on Fast logic analyser using Cortex-m0 mbed:
Please log in to post comments.
Hi Romilly, I submitted a similar idea for the new mbed. My initial focus would be on monitoring and analysing serial protocols, in particular I2C. Maybe we can work on this together somehow. Dont have the new mbed, but will start looking into possible solutions based on mbed m3.
Wim