Dangerous Prototypes

Other projects => Open Bench Logic Sniffer => Topic started by: kinsa on February 26, 2011, 11:28:41 am

Title: Continuous sampling mode
Post by: kinsa on February 26, 2011, 11:28:41 am
Attached is the VHDL code for continuous sampling mode.

Continuous mode is enabled by issuing 0x10 command. The ARM led will blink slowly once data transfer has begun. If there is data overrun, the rate of blinking will increase and the TRIG led will lit up.

Note that triggering is ignored and RLE is not supported.

On my netbook with version 3.0 of the PIC firmware, the system can only achieve a maximum sample rate of 10kHz for 8 bit samples. Currently, the bottleneck is the PIC USB transfer rate.

Included is a test SUMP client to demonstrate this new capability. Select Test Mode and memory depth of 256K. Test mode outputs the contents of a 32 bit counter incremented by the sample rate clock.
Title: Re: Continuous sampling mode
Post by: ian on February 26, 2011, 12:23:28 pm
Very cool, I will test it today.
Title: Re: Continuous sampling mode
Post by: jack.gassett on March 02, 2011, 07:24:49 pm
Kinsa,

I just wanted to put out a quick message that this has not been forgotten. Your VHDL cleanup and continuous sampling mode contributions are greatly appreciated.

Right now I'm putting all of my effort into the new automated build/release system and the new OLS information portal at http://gadgetfactory.net/logicsniffer (http://gadgetfactory.net/logicsniffer). Once these tasks are done I intend to check this out and get an experimental release put together so everyone can give this a try.

Thank you for your contribution and please bear with us for a little longer.

Thanks,
Jack.
Title: Re: Continuous sampling mode
Post by: jbeale on March 02, 2011, 11:03:14 pm
I don't have the OBLS logic sniffer (yet), but I'm just curious about the possibilities here. 

I assume this mode is a 10 kHz analyzer (0.1 millisecond time resolution), is that right? Now, let's say I have two input signals that have very infrequent logic transitions, like only 1 per second, but I would like to measure the edges with high accuracy (eg 10 ns resolution) on a continuous basis forever. Is this something that could be done with the continuous mode, or could it be developed? In other words, the board's FPGA would sample inputs at 100 MHz but it would select out the (rare) transitions and just send a few 32-bit timer values every second over the USB connection, so there shouldn't be a USB bandwidth issue there.  This would be using the sniffer as a continuous-running TIC (time interval counter) with 10 ns resolution. Is it possible?
Title: Re: Continuous sampling mode
Post by: kinsa on March 03, 2011, 01:17:14 am
Hello Jack, this is just a proof of concept and I'm learning VHDL through your great little device. No worries :)

jbeale, I think you need continuous mode RLE. Needs to be implemented though.
Title: Re: Continuous sampling mode
Post by: Rubu on March 03, 2011, 01:48:27 am
Even with RLE enabled in continuous mode, you probably wont make it.
I'm not sure about this but I think that even with all the signals grounded, at 100Mhz the ram will just fill up faster than you can send it to the PC.
I'm not saying that what you are asking for isn't possible with this hardware, just (probably) not within the SUMP specification.
Title: Re: Continuous sampling mode
Post by: jbeale on March 03, 2011, 02:15:24 am
Thanks for the replies. Yes, what I'm looking for is different from a standard logic analyzer. I guess it would need a circular RAM buffer in the FPGA (?) so that the signal is always captured at (say) 100 MHz and it overwrites old data as it wraps around; meanwhile a separate RLE process is scanning through the RAM and sending only the compressed data out to the PIC.  The RLE process has to process samples at the input sample rate or else it will eventually fall behind and loose data. So, since would need to work at the sample rate, you should not need a large RAM buffer, in fact maybe you don't need a buffer at all.  Or maybe it's not even possible, I don't know enough about FPGAs.
Title: Re: Continuous sampling mode
Post by: Rubu on March 03, 2011, 02:32:12 am
I was thinking about something slightly different. As you're really only interested in the changes, you could just initialize a say 32 bit counter and everytime a change occurs, send out the value of the counter, and initialize a new counter 32bits ahead. I'm not entirely sure how this would be implemented in an FPGA, but I do think something along these lines would be possible.
Title: Re: Continuous sampling mode
Post by: kinsa on March 03, 2011, 07:39:59 am
RLE of 10kHz signal at 100MHz sampling would, in worst case, generate twice the amount of data than normal sampling.

This can be easily handled once the PIC usb code is optimized.
Title: Re: Continuous sampling mode
Post by: rsdio on March 03, 2011, 10:49:23 am
[quote author="jbeale"]I guess it would need a circular RAM buffer in the FPGA (?) so that the signal is always captured at (say) 100 MHz and it overwrites old data as it wraps around; meanwhile a separate RLE process is scanning through the RAM and sending only the compressed data out to the PIC.  The RLE process has to process samples at the input sample rate or else it will eventually fall behind and loose data. So, since would need to work at the sample rate, you should not need a large RAM buffer, in fact maybe you don't need a buffer at all.[/quote]
I think you have it backwards.  No matter how much RAM you have, it's going to be better to handle RLE first, then fill the circular buffer, then transmit to the PIC.  RLE will typically fill up memory much slower.  kinsa is correct that the worst case will fill memory twice as fast as non-RLE, but the average case will be much, much better than the worst case.  After you have reduced the data, it will be far easier for the PIC and USB to keep up.

I think that the only glitch would be when the circular buffer erases old data and you're left with a starting repeat count with no known data to repeat.  But discarding that one glitch should be fairly easy with the out-of-band RLE flag bit (stored in one of the extra two bits of the 16-bit/18-bit SRAM inside the FPGA).
Title: Re: Continuous sampling mode
Post by: dogsbody on March 04, 2011, 01:32:07 am
I don't think RLE is as bad as you think.    It should never be worse than the original sample rate. 

If every sample is different, all it stores are values.  ie:
  <1><2><1><2><1><2>  =>  <1><2><1><2><1><2>

If there are duplicates, only then do you get counts.  ie:
  <1><1><2><1><1><2>  =>  <1><count=1><2><1><count=1><2>

A 10Khz signal sampled at 100Mhz in non-rle mode would store 10000 samples per 10Khz pulse.  In 16 bit or 32 bit rle-mode, it consumes only 4 samples per pulse:  <1><count=4999><0><count=4999> repeat...  In 8 bit mode, the same 10KHz signal  burns 158 samples per pulse (counters are too small).

Assuming 32-bit mode, jbeale's one event per second sampled at 100Mhz is very doable.  That is only three or four samples per second.  The 31-bit rle-counter can handle over 20 seconds of nothing.  A single buffer full represents hours of captures at that rate.
-- IED
Title: Re: Continuous sampling mode
Post by: kinsa on March 04, 2011, 07:04:13 am
My current RLE code always sends the counts irrespective of the RLE bit implementation. This was meant to standardize the interface to the client.

So in worst case scenario, a 10kHz signal would generate 20k samples/second.
Title: Re: Continuous sampling mode
Post by: Rubu on March 04, 2011, 12:03:30 pm
[quote author="dogsbody"]"..."[/quote]

Doh! I forgot that with 16/32 channels, the RLE counter is also 16/32 bits!

[quote author="kinsa"]My current RLE code always sends the counts irrespective of the RLE bit implementation. This was meant to standardize the interface to the client.

So in worst case scenario, a 10kHz signal would generate 20k samples/second.[/quote]

That probably doesn't matter for jbeale's scenario, as it only makes a difference when changes are only 10ns apart, which, from my understanding, won't be very often.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01122098824session_write_close ( )...(null):0
20.01152230416ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01152231192Database_MySQL->query( ).../DatabaseHandler.php:119
40.05622369920Database_MySQL->error( ).../Db-mysql.class.php:273