Coder Social home page Coder Social logo

logic_analyzer's Introduction

SUMP compatible logic analyzer for Arduino

This Arduino sketch implements a SUMP protocol compatible logic analyzer. This implementation is compatible with the standard SUMP client as well as an alternative OLS client. More recently support has been added to Sigrok.

This logic analyzer for Arduino supports 6 channels consisting of digital pins 8-13, which are the first 6 bits (0-5) of PORTB. Arduino pin 13 / bit 5 is the Arduino LED, bits 6 & 7 are the crystal oscillator pins. Comment out CHAN5 if you don't want to use the LED pin for an input.

On the Arduino Mega board 8 channels are supported and 7k of samples. Pins 22-29 (Port A) are used by default.

Supported Hardware

The AGLA sketch supports many Arduino boards based on the following microcontrollers, generally using an FTDI based USB to serial, or builtin in the case of the ATmega32U4. Many inexpensive boards use the 'CH340' USB to serial chipset which may or may not work well. Please test yours and file an issue.

Generally I test the Arduino Duemilanove and Arduino UNO R3 the most, but I do want to make as many boards as possible work.

The microcontrollers are listed below with corresponding Arduino boards. This is not an exhaustive list and I do not own all of these boards to test them. Again please test and file any issues.

ATmega168

  • Arduino Diecimila
  • Arduino Mini (Original was '168)

ATmega328P

  • Arduino Duemilanove
  • Arduino Mini (Original was '168)
  • Arduino Nano
  • Arduino Pro
  • Arduino Pro Mini
  • Arduino Uno (Rev2, R3, SMD)
  • Arduino Uno Mini

ATmega1280

  • Arduino Mega

ATmega2560

  • Arduino Mega 2560

ATmega32U4

  • Arduino Leonardo
  • Arduino Micro

Installation

Arduino IDE Library Manager

Starting with v0.17 you can install directly in the Arduino IDE using the Library Manager. Look under the menu 'Sketch -> Include Library -> Manage Libraries...' to open the Library Manager, then enter 'LogicAnalyzer' in the search field and it should find this project and you can click INSTALL.

Manual via ZIP file

You can use the GitHub 'Download ZIP' feature to get an installable "library" for use with the Arduino IDE. Select 'Sketch -> Include Library -> Add .ZIP Libary' from the Arduino IDE 2.x and select the zip file you downloaded from GitHub, then select open.

After Installation

Once installed you can use the 'File -> Examples -> LogicAnalyzer' menu to find different versions of the sketches. You might want to start with logic_analyzer_sigrok and use PulseView.

Client Software

Sigrok

Sigrok support via the 'ols' device configuration has been added. This mostly involved returning the capture buffer in the reverse order.

Use the logic_analyzer_sigrok sketch. Since the OLS alternative client mentioned below has some issues with newer Java versions, Sigrok is currently the only practical way to use this logic analyzer. If you use an older machine with an older operating system and older Java you can probably use the OLS client.

Sigrok support seems to work fairly well so I would currently recommend it for anyone interested in trying this sketch.

Run PulseView like this on Linux: (I'll add Windows options after more testing)

PulseView --driver=ols:conn=/dev/ttyUSB0 --dont-scan

It may be necessary to exit and relaunch PulseView to get it to recognize the device. An easy way to test the device is using the sigrok-cli utility. The command below samples channel 2 at 1MHz. If you get a device not found error, but /dev/ttyUSB0 exists, run this command a couple times and usually it will start working. Due to the way opening the serial port resets the Arduino there are some issues/bugs to work out yet.

sigrok-cli --driver=ols:conn=/dev/ttyUSB0 --config samplerate=1Mhz --config pattern=External --samples 1024 --channels 2

OLS Client(s)

NOTE: This section needs work as due to various Java issuses building a working OLS client is somewhat broken right now.

The OLS alternative client hasn't had an official release recently so you will need to compile it yourself.

Follow the build instructions here: https://github.com/jawi/ols

Older details on the OLS client is available at the project page: https://lxtreme.nl/projects/ols/

Direct link to older releases of the OLS alternative client: http://www.lxtreme.nl/ols/

The alternative client version is highly recommended. You can tried the older release ols-0.9.7.2 but most likely need to build it yourself. Use "ols-0.9.7" or newer for built-in device profiles.

To use this with the original or alternative SUMP clients, use these settings:

Sampling rate: 4MHz (or lower) (no 2MHz on ATmega168)
Channel Groups: 0 (zero) only
Recording Size:
   ATmega168:  532 (or lower)
   ATmega328:  1024 (or lower)
   ATmega2560: 7168 (or lower)
Noise Filter: doesn't matter
RLE: disabled (unchecked)

Using the Logic Analyzer

Triggering is still a work in progress, but generally works for samples below 1MHz. 1MHz works for a basic busy wait trigger that doesn't store until after the trigger fires.

Please try it out and report back. Please provide a detailed bug report if you file an issue.

Debugging

You can uncomment the #define DEBUG_MENU line to add some diagnostic menu options for capturing or dumping the capture buffer. You can uncomment the #define DEBUG and #define DEBUG_MENU for a couple extra menu options and logging of the received commands. The DEBUG option is generally only useful for development, while the DEBUG_MENU option is good for troubleshooting when the logic_analyzer sketch isn't working for you. Both are disabled by default to conserve RAM for improved stability.

CLI compiling

If you want to use the arduino-cli tool to compile this using the Makefile, you'll need to install the tool first following instructions here: https://arduino.github.io/arduino-cli/

If you use Debian or Ubuntu you can install arduino-cli and the AVR toolchain like this:

sudo snap install arduino-cli
arduino-cli core install arduino:avr

Once installed you can simply type make and you should get some basic help:

$ make
---> run 'make build' to compile for Arduino Duemilanove
---> run 'make upload' to upload to /dev/ttyUSB*

Other SUMP compatible projects

There are other projects doing some similar that have been created in the last 12 years or so since I started my work. I'll start the list with one I've read about recently.

This first project runs on a Raspberry Pi Pico and has some amazing logic analyzer specs for a $5 board!

μLA: Micro Logic Analyzer

An earlier RPi Pico SUMP logic analyzer

ESP32 based Logic Analyzer

Flexible SUMP library

STM32 based SUMP logic analyzer

Another STM32 based logic analyzer

ESP32 SUMP logic analyzer for Sigrok

Another STM32 logic analyzer

Older Notes

NOTE: Starting with v0.11 you can sample at 4MHz & 2MHz rates in addition to the 
      previous 1MHz and lower rates.  This is done via unrolled loops which
      makes the source code huge and the binary takes much more of the flash.
      v0.11 is just slightly too big for an ATmega168's flash. The code 
      automatically skips the 2MHz code on ATmega168

NOTE: v0.09 switched the channels BACK to pins 8-13 for trigger reliability.
      Please report any issues.  Uncomment USE_PORTD for pins 2-7.

NOTE: If you are using the original SUMP client, then you will get a
      "device not found" error.
      You must DISABLE the Arduino auto reset feature to use this logic analyzer
      code. There are various methods to do this, some boards have a jumper,
      others require you to cut a trace.  You may also install a *precisely*
      120 Ohm resistor between the reset & 5V piins.  Make sure it is really
      120 Ohm or you may damage your board.  It is much easier to use the
      alternative SUMP client referenced above.
      [ This is not needed with ols-0.9.7 or newer. ]
      [ DO NOT use this resistor unless absolutely necessary on old clients. ]

logic_analyzer's People

Contributors

dhiltonp avatar f0086 avatar gillham avatar qaxi avatar scottp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logic_analyzer's Issues

Overusing SRAM on 1024 bytes Arduino (ATMEGA328P)

It appears to me, after trying to understand the source code, that you are using more SRAM than is available on the atmega328p chip.
According to data sheet there is 1024 bytes in total, but you allocate both a global 1024 data buffer and a bunch of variables, globals too. Stack is also in use.

I expect some of this fall over board, and I'm baffled why it does still work...

nice code, great work, thanks

Thanks, @gillham for your great work on this project.

I feel like it's been fairly straightforward to jump into and contribute, which isn't always the case :). Thanks for putting in so much effort to make this project; I know how much time it takes to try and get everything working just right!

cannot upload the compiled binary

I've compiled the sketch with the arduino libraries in my debian jessie setup, but it fails to upload (tried with 2 different Arduino Uno boards):

...
make[1]: Entering directory '/tmp/r/logic_analyzer-master/logic_analyzer-master'
/usr/share/arduino/hardware/tools/avr/../avrdude -q -V -D -p atmega328p -C /usr/share/arduino/hardware/tools/avr/../avrdude.conf -c arduino -b 57600 -P /dev/ttyACM1 \
                -U flash:w:build-uno/logic_analyzer.hex:i
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

I've also tried uploading the sketch with a more recent IDE (v1.8) but it still fails....

build error

Arduino: 1.6.13 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\EssaM\AppData\Local\Temp\cclwLT9s.ltrans0.ltrans.o: In function `main':

cclwLT9s.ltrans0.o:(.text.startup+0x210): undefined reference to `captureInline4mhz()'

cclwLT9s.ltrans0.o:(.text.startup+0x21e): undefined reference to `captureInline2mhz()'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

increasing number of channels

Sorry if this makes no sense, but wouldn't it be better to have a whole byte representable on the logic analyzer i.e. 8 channels. Is there a way to increase the channel count?

less channels, more samples ?

Would it be possible to analyse only 4 channels and put two of them in each memory byte in order to increase the time range by two ?

Add squarewave output for calibration and testing

I've added following PWM output with 50% duty cycle to the code and i got squarewave output for calibration and testing. PWM signal generating is offloaded to the hardware, so it should not interfere with logic analyzer functionality in any way:

pinMode(3, OUTPUT);
analogWrite(3, 127);

If we add some ifndefs, we can make sure, it will always run only on unused pins no mater what MCU we use.

Also it's possible to set various frequencies, so maybe we can have different freqs at different unused pins:

============================================  
|| Frequency [Hz] || Prescaler || Setting ||  
============================================  
|| 31373.55       || 1         || 0x01    ||  
|| 3921.57        || 8         || 0x02    ||  
|| 980.39         || 32        || 0x03    ||  
|| 490.20         || 64        || 0x04    ||  
|| 245.10         || 128       || 0x05    ||  
|| 122.55         || 256       || 0x06    ||  
|| 30.64          || 1024      || 0x07    ||  
============================================  

No/incorrect triggers when using port D

When using bits 2-7 (6 channels) of port D on an (e.g. Arduino) no trigger events were acknowledged. Looking at the code this appears to be because the SUMP/OLS channels are 0 based while the port D assignments start at bit 2.

I tested this with the OLS/SUMP client from J.W. Janssen at lxtreme.nl. And an Arduino UNO.

I made a simple change on the "trigger=" and "trigger_values=" processing of the SUMP commands:
case SUMP_TRIGGER_MASK:
/*
* the trigger mask byte has a '1' for each enabled trigger so
* we can just use it directly as our trigger mask.
/
getCmd();
trigger = cmdBytes[0]<<2;
break;
case SUMP_TRIGGER_VALUES:
/

* trigger_values can be used directly as the value of each bit
* defines whether we're looking for it to be high or low.
*/
getCmd();
trigger_values = cmdBytes[0]<<2;
break;

I suspect the correct implementation should correctly determine whether to shift of not based on the configuration.
Rick Sorensen
[email protected]

Sketch issues

Hello can someone help me? I have downloaded the sketches for the arduino logic analyser but all seem to have errors when I try to upload to the arduino UNO
Many Thanks
Mark

It indicated that all CH340 based arduino board fail be detected.

I tried all my arduino boards, all of them failed, except one which is not using CH340 as usb-ttl module.

There are a lot cheap arduino boards using CH340. when I use them, it detect metadata got null.

Maybe related to auto-reset, but I tried 120 ohm resistor and also 100 uF capacitor, they may make the board not auto-reset, but still can not let ols detect the arduino device.

Last data when using trigger

I'm using this logic_analyzer with Arduino Uno and jawi/ols client and found the client get one incorrect data at the very last. This happens when using trigger with sampling rate 500khz(or less), or when triggerMicro() is executed.

Following two pictures show the issue. See glitch in signal of Channel-0 and 1 at the very last(rightmost).
The last sampling data shown at the rightmost is not placed correctly. And I believe the data should be palced in the first position, or at the leftmost.


(These are Sampling rate and Trigger setting.)

I think this part of triggerMicro() causes the issue and it seems to be not needed to me.
This patch solves this issue. But I'm not sure this is right solution, or am I missing something?

diff --git a/logic_analyzer/logic_analyzer.ino b/logic_analyzer/logic_analyzer.ino
index 2daaa42..e3c7b68 100644
--- a/logic_analyzer/logic_analyzer.ino
+++ b/logic_analyzer/logic_analyzer.ino
@@ -878,16 +878,6 @@ void triggerMicro() {
   /* re-enable interrupts */
   sei();

-  /*
-   * trigger has fired and we have read delayCount of samples after the
-   * trigger fired.  triggerIndex now points to the trigger sample
-   * logicIndex now points to the last sample taken and logicIndex + 1
-   * is where we should start dumping since it is circular.
-   *
-   * our buffer starts one entry above the last read entry.
-   */
-  logicIndex++;
-
   for (i = 0 ; i < readCount; i++) {
     if (logicIndex >= readCount) {
       logicIndex = 0;

https://github.com/gillham/logic_analyzer/blob/master/logic_analyzer/logic_analyzer.ino#L881-L889

No glitch with the patched firmware.

arduino leonardo working config file

after some hassle figured out what was wrong and got it fixed
it's just missing a line and i added my chip instead of the 32p

[code]

device.receive.timeout = 1000 // this did the trick for me in the alga cfg file

[/code]

Unrolled code for 2 and 4 MHz is flawed

The conditional compilation logic in the code for the 2 MHz (logic_analyzer_inline_2mhz.ino) and the 4 MHz (logic_analyzer_inline_4mhz.ino) is flawed. For example in the 2 MHz code one sees
...
logicdata[530] = CHANPIN;
INLINE_NOP;
logicdata[531] = CHANPIN;
INLINE_NOP;

if defined(AVR_ATmega328P)

logicdata[532] = CHANPIN;
INLINE_NOP;

...

logicdata[1022] = CHANPIN;
INLINE_NOP;
logicdata[1023] = CHANPIN;
INLINE_NOP;

elif defined(AVR_ATmega1280) || defined(AVR_ATmega2560)

logicdata[1024] = CHANPIN;
INLINE_NOP;
logicdata[1025] = CHANPIN;
INLINE_NOP;

...

which means that only the ATmega328P ever uses locations 532 to 1023 inclusive.

For anything else this results in a gap in the record sent to the client since the 'logicdata' locations in this range are never used.

Allow to enable internal pullups at runtime

Allow to enable internal pullups at runtime... It's simple to do this by modyfiing code
eg.: from pinMode(CHAN0, INPUT); to pinMode(CHAN0, INPUT_PULLUP);

I've done this and it works perfectly, but it requires recompiling and flashing. I think we might prepare some SUMP protocol extension with sigrok guys to be able to controll this at runtime from pulseview GUI!

[Arduino IDE 1.8]Sketch can't compile

Since this is actual and all others are more than one year old this is a new one:

The sketch is not able to compile due to variable problems. One variable is used but not declared. This is basic. It means it can never compile any more. `Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Programme\Arduino\arduino-1.8.3\arduino-builder -dump-prefs -logger=machine -hardware C:\Programme\Arduino\arduino-1.8.3\hardware -hardware C:\Users\Admin\AppData\Local\Arduino15\packages -tools C:\Programme\Arduino\arduino-1.8.3\tools-builder -tools C:\Programme\Arduino\arduino-1.8.3\hardware\tools\avr -tools C:\Users\Admin\AppData\Local\Arduino15\packages -built-in-libraries C:\Programme\Arduino\arduino-1.8.3\libraries -libraries C:\Users\Admin\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10805 -build-path C:\Users\Admin\AppData\Local\Temp\arduino_build_57153 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avrdude.path=C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Programme\Arduino\arduino-1.8.3\hardware\tools\avr -verbose E:\Program Files\logic_analyzer-master\logic_analyzer_inline_4mhz\logic_analyzer_inline_4mhz.ino
C:\Programme\Arduino\arduino-1.8.3\arduino-builder -compile -logger=machine -hardware C:\Programme\Arduino\arduino-1.8.3\hardware -hardware C:\Users\Admin\AppData\Local\Arduino15\packages -tools C:\Programme\Arduino\arduino-1.8.3\tools-builder -tools C:\Programme\Arduino\arduino-1.8.3\hardware\tools\avr -tools C:\Users\Admin\AppData\Local\Arduino15\packages -built-in-libraries C:\Programme\Arduino\arduino-1.8.3\libraries -libraries C:\Users\Admin\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10805 -build-path C:\Users\Admin\AppData\Local\Temp\arduino_build_57153 -warnings=default -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -prefs=runtime.tools.avrdude.path=C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Programme\Arduino\arduino-1.8.3\hardware\tools\avr -verbose E:\Program Files\logic_analyzer-master\logic_analyzer_inline_4mhz\logic_analyzer_inline_4mhz.ino
Using board 'mega' from platform in folder: C:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr
Detecting libraries used...
"C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\variants\mega" "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\sketch\logic_analyzer_inline_4mhz.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\variants\mega" "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\sketch\logic_analyzer_inline_4mhz.ino.cpp" -o "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Programme\Arduino\arduino-1.8.3\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\preproc\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"C:\Users\Admin\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Programme\Arduino\arduino-1.8.3\hardware\arduino\avr\variants\mega" "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\sketch\logic_analyzer_inline_4mhz.ino.cpp" -o "C:\Users\Admin\AppData\Local\Temp\arduino_build_57153\sketch\logic_analyzer_inline_4mhz.ino.cpp.o"
E:\Program Files\logic_analyzer-master\logic_analyzer_inline_4mhz\logic_analyzer_inline_4mhz.ino: In function 'void captureInline4mhz()':

logic_analyzer_inline_4mhz:54: error: 'trigger' was not declared in this scope

if (trigger) {

   ^

logic_analyzer_inline_4mhz:55: error: 'trigger_values' was not declared in this scope

 while ((trigger_values ^ CHANPIN) & trigger);

         ^

logic_analyzer_inline_4mhz:55: error: 'CHANPIN' was not declared in this scope

 while ((trigger_values ^ CHANPIN) & trigger);

                          ^

logic_analyzer_inline_4mhz:71: error: 'DEBUG_ENABLE' was not declared in this scope

DEBUG_ENABLE;

^

logic_analyzer_inline_4mhz:72: error: 'DEBUG_ON' was not declared in this scope

DEBUG_ON;

^

logic_analyzer_inline_4mhz:74: error: 'DEBUG_OFF' was not declared in this scope

DEBUG_OFF;

^

logic_analyzer_inline_4mhz:93: error: 'logicdata' was not declared in this scope

logicdata[0] = CHANPIN;

^

logic_analyzer_inline_4mhz:93: error: 'CHANPIN' was not declared in this scope

logicdata[0] = CHANPIN;

              ^

logic_analyzer_inline_4mhz:14444: error: 'readCount' was not declared in this scope

for (i = 0 ; i < readCount; i++) {

                ^

exit status 1
'trigger' was not declared in this scope`
The error messages of ide using this sketch. since I'm not able to check it in all details now the process is stopped. Possibly later. Now with another one if any.

trigger triggers for any single matching bit, not for a set of matching bits

```while ((trigger_values ^ (logicdata[logicIndex] = CHANPIN)) & trigger) {```

should be more like:
while ((trigger | (logicdata[logicIndex] = CHANPIN)) != trigger | trigger_values) {
Unfortunately, that hangs indefinitely, but I think it conveys the point.

Also, for 6-channel systems, we need to make sure we mask all 8 bytes from CHANPIN; something like:

#ifndef CHAN7
      if(trigger) {
        trigger |= 0xC0; // mask the top 2 bits, too
      }
#endif

I've created a "triggered" branch with these changes, but it doesn't work.

Add supported chips to readme

I'm finding it hard to figure what chips these sketches are compatible with.

I see a mention of the ATmega168, ATmega328 and ATmega2560 chips on the readme, but that's about it.

I also found the architectures=avr line on library.properties, but does that mean it is supported on every AVR chip? Or are there exceptions?

Btw, thanks for your work!! Very cool ;)

crash in serial console screen

Have noticed a crash if something takes over the port while in serial console screen:

Jan 4, 2015 12:52:31 AM nl.lxtreme.ols.util.internal.Activator logEnvironment
INFO: LogicSniffer running on macos, 10.9.5 (x86-64); Apple Inc., v1.6.0_65.
java.io.IOException: No such port!
    at nl.lxtreme.ols.io.serial.CommConnectionFactory.createConnection(CommConnectionFactory.java:111)
    at nl.lxtreme.ols.io.ConnectorServiceImpl.open(ConnectorServiceImpl.java:160)
    at org.sump.device.logicsniffer.LogicSnifferDevice.createStreamConnection(LogicSnifferDevice.java:159)
    at org.sump.device.logicsniffer.LogicSnifferDevice.getStreamConnection(LogicSnifferDevice.java:245)
    at org.sump.device.logicsniffer.LogicSnifferDevice.createAcquisitionTask(LogicSnifferDevice.java:87)
    at nl.lxtreme.ols.acquisition.BackgroundDataAcquisitionService.acquireData(BackgroundDataAcquisitionService.java:76)
    at nl.lxtreme.ols.client.ClientController.repeatCaptureData(ClientController.java:1165)
    at nl.lxtreme.ols.client.action.RepeatCaptureAction.actionPerformed(RepeatCaptureAction.java:82)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
    at java.awt.Component.processMouseEvent(Component.java:6414)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
    at java.awt.Component.processEvent(Component.java:6179)
    at java.awt.Container.processEvent(Container.java:2084)
    at java.awt.Component.dispatchEventImpl(Component.java:4776)
    at java.awt.Container.dispatchEventImpl(Container.java:2142)
    at java.awt.Component.dispatchEvent(Component.java:4604)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)
    at java.awt.Container.dispatchEventImpl(Container.java:2128)
    at java.awt.Window.dispatchEventImpl(Window.java:2492)
    at java.awt.Component.dispatchEvent(Component.java:4604)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)
    at java.awt.EventQueue.access$400(EventQueue.java:82)
    at java.awt.EventQueue$2.run(EventQueue.java:676)
    at java.awt.EventQueue$2.run(EventQueue.java:674)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:690)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
java.lang.NullPointerException
    at java.awt.font.TextLayout.getBaselineFromGraphic(TextLayout.java:2652)
    at java.awt.font.TextMeasurer.initAll(TextMeasurer.java:228)
    at java.awt.font.TextMeasurer.<init>(TextMeasurer.java:150)
    at java.awt.font.LineBreakMeasurer.<init>(LineBreakMeasurer.java:292)
    at java.awt.font.LineBreakMeasurer.<init>(LineBreakMeasurer.java:259)
    at nl.lxtreme.jvt220.terminal.swing.SwingFrontend.updateTerminalImage(SwingFrontend.java:637)
    at nl.lxtreme.jvt220.terminal.swing.SwingFrontend$1.run(SwingFrontend.java:466)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
    at java.awt.EventQueue.access$400(EventQueue.java:82)
    at java.awt.EventQueue$2.run(EventQueue.java:676)
    at java.awt.EventQueue$2.run(EventQueue.java:674)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Sigrok support?

Hello,

What is the current status regarding sigrok support?
Thank

Update ols profiles

Hi,

It seems there too much zeroes here (100mhz) :
device.clockspeed = 100000000
it should be
device.clockspeed = 1000000

also the new ols wants a new key in conf file, so adding :
device.receive.timeout = 100
makes it happier.

Thanks,

Charles

Divergence between values

Hi!

Sorry if I'm bothering you.

I'm trying to decode a protocol and I'm using an Arduino Mega running your code as logic analyzer.

The problem is I'm getting divergent values between your logic analyzer code and Arduino pulseIn function or even using interrupts.

For this reason I'm not able to decode the protocol.

Could you please show me in a simple example what's the method used to measure pulse width in your code?

Looking to your code I wasn't able to understand.

Here the values I'm getting using interrupts:

logic

Here the code:

#if defined(ESP8266)
void ICACHE_RAM_ATTR falling();
void ICACHE_RAM_ATTR rising();
#define PIN D8  // PIN where the PWM singal arrives
#else
#define PIN 2  // PIN where the PWM singal arrives
#endif

// global variables
volatile unsigned int pulse_width = 0; 
volatile unsigned int prev_time = 0; 
 
void rising() {
  attachInterrupt(digitalPinToInterrupt(PIN), &falling, FALLING);  // when PIN goes LOW, call falling()
  prev_time = micros();
}
 
void falling() {
  attachInterrupt(digitalPinToInterrupt(PIN), &rising, RISING);  // when PIN goes HIGH, call rising()
  pulse_width = micros() - prev_time;
  Serial.println(pulse_width);
}
 
void setup() {
  pinMode(PIN, INPUT_PULLUP);

  Serial.begin(115200);
  attachInterrupt(digitalPinToInterrupt(PIN), &rising, RISING);  // when PIN goes HIGH, call rising()
  sei();  // enable interrupts
}
 
void loop() { }

I'm getting similar results using pulseIn function.

Thanks in advance.

Why not PortD instead of PortB?

I were wondering why you choose to use 5 (or 6) pins from PortB and not 6 pins from PortD?

To me it looks like an easy switch with the following benefits:

  • No need to mess with the LED infested B5 (Arduino pin D13)
  • Stay clear of the SPI pins which might be handy for reflashing

PortD contains bits 2-7 that are just doing nothing. (in an LSA setup)

Detection failed! null on LogicSniffer v0.9.7.2

Hi,
I just love this project and wanted to try this, but sadly it doesn't work for me. I think I'm doing something wrong. I've compiled logic_analyzer (loaded all 3 files, compiled them succesfuly and loaded on my board), then I installed LogicSniffer v0.9.7.2, and wanted to start capture - Connection type serial port, port selected, speed 115200bps and device type Arduino Generic Logic Analyzer, but it doesn't capture anything. When I click on "Show device metadata" it prints "Detection failed! null"
When I click on this test button both TX/RX LEDs blink on my board.

I'm using RobotDyn NANO Arduino with ATmega328, LogicSniffer v0.9.7.2 and Windows 10.

Any ideas what I'm doing wrong?

Thanks.

Samples before trigger fires

Dunno if it's a known issue but it seems that samples or the sample rate before the trigger point is i bit random.

I use OLS-0.9.5 as frontend and set the "Before/After ratio" to 50/50.

Sampling a steady pulse train will show silence, or something low frequency, until the middle, where the trigger fires, and the my pulses as they are expected.

Capturing Samples

It might be useful to have some description of how to play around with the sampling rate and recording size.

It's confusing at first when you try something like 10hz and not realize that it's going to take 102s.

Sometimes I seem to notice I have to hit the cancel button even for settings like 4mhz which should return right away.

Also I seem to always get a sample count of 2 even when no samples were collected?

It can be hard as well to notice when a signal is full up/down at times too.

Pins floating due to values next to them can be misleading which is really just general Arduino knowledge but maybe good to note that.

CAPTURE_SIZE for ATmega186 (20PU)

In the Arduino Duemilanove there is a ATmega186-20PU and the Sketch does not work with the CAPTURE_SIZE of 1024. Is it possible to make it compatible with this uC too? If you need anything of if I test something, let me know.

Arduino compile error

Hi, there thanks for this valuable tool. I have downloaded the files from this page and OLS logic sniffer from the link version 0.9.17 and have tried to add the 2 files to the plugin folder but theirs new versions so i have left them alone. The problem I'm having is

Arduino: 1.5.8 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

logic_analyzer.ino: In function 'void loop()':
logic_analyzer.ino:298:27: error: 'captureInline4mhz' was not declared in this scope
Error compiling.

and many more errors for the 4MHZ file is this some thing you could please help me with.

Thank you for taking your time to make this!! :)

Not enough memory on ATmega168

I just tried to flash the sketch on my old Arduino NG with ATmega168 MCU. Compiling gives:

Sketch uses 10,776 bytes (75%) of program storage space. Maximum is 14,336 bytes.
Global variables use 1,176 bytes (114%) of dynamic memory, leaving -152 bytes for local variables. Maximum is 1,024 bytes.
processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
    at processing.app.debug.Compiler.size(Compiler.java:338)
    at processing.app.debug.Compiler.build(Compiler.java:117)
    at processing.app.Sketch.build(Sketch.java:1162)
    at processing.app.Sketch.exportApplet(Sketch.java:1180)
    at processing.app.Sketch.exportApplet(Sketch.java:1166)
    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2487)
    at java.lang.Thread.run(Thread.java:745)
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.

Any solution for this?

Capturing Analog Data on Digital Pins?

I have a setup where I'm listening to slight fluctuations on an analog pin.

How would I move such a test over to the digital pins so the logic-analyzer can read the values?

From my own testing the digital pin always seems to read 0 and then when trying with the logic-analyzer I also see no data coming through.

On the analog pin I will see fluctuations of +/-(4-20) from the IR detector.

Thanks for any help.

Error flushing serial port on Windows

Capture doesn't seem to work. After i click "run" the button changes to "Stop" for a moment, then quickly changes to "run" again. sigrok log shows:

serial-libsp: Error flushing port (995): �������� �����/������ ���� �������� ��-�� ���������� ������ ������ ��� �� ������� ����������..
pv: Acquisition took 0.04 s

(error description is provided by the OS in russian, it's ok that it cannot be read)

The board is a local Nano clone, using CP210x .

Signal capturing on unused pin

Some unused pin might be signaling HIGH when capturing data. That way we can connect LED or even sync this arduino analyzer with another analyzer using trigger, so they both start capturing at the same time.

Which sketch to load? What are the cfg files for?

Howdy Andrew,
First, THANK YOU for your hard work. No doubt this tool is indispensable for the low-budget Arduino tinkerer. I only wish I could get past square one and have a chance to use it (sound the dense user alarm)! The README you included has great information for seasoned or intuitive people, but for simpletons like me, well...I need more details (very dense).

  • On hackaday.io you stated "It is easy to use, just load the sketch and fire up the OLS client." Well I see three "ino" files. If an .ino file is a "sketch", then which sketch do I use?
  • There are two different "cfg" files, one for "mega", and the other for...well, NOT mega? Do I need to do something with these?

The device I am programming for use is a Duemilanova (ATmega 328) and my IDE is PlatformIO, which may be confusing the matter? Any help you or a contributor might provide here will set my mind at ease and get my project back on track.

Thank you!
-Dylan

OSX DMG damaged?

When I try to run the bundle installed via DMG and from a local build I get:

“LogicSniffer” is damaged and can’t be opened. You should move it to the Trash.

I'm on OSX 10.9.5.

Analog input

Atmega328 can sample analog data using ADC at 10kHz, i think we can provide analog sampling at low samplerates. Something between 1 to 10kHz seems doable (depending on number of analog pins used)... High sample rates would be still available in logic-only mode.

Not sure if SUMP protocol allows this, but sigrok/pulseview does, so we might add some custom SUMP extension (without breaking compatibility with legacy SUMP software).

Problems on Arduino Mega

I've tried to get the code working on an Arduino Mega 2560.
The code runs fine under a Arduino Uno, but if I upload the code on a Mega 2560 it does not react on any serial command. Even with DEBUG enabled, I get no answer for an "?" sent over the serial line.
I'm not sure what is broken, because if I add a

 while(1) { 
   blinkled();
   Serial.println("Test");
 }

at the and of the setup() function the LED blinks, but the String is not written to the Serial connection.
Doing the same in a minimal sketch on the same Mega board, the text is written to the serial connection.

#define ledPin 13
void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  while(1) { 
    blinkled();
    Serial.println("Test");
 }
}

void loop() {
}

void blinkled() {
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(200);
}

Just to be sure I also removed the timer2 pin toggle from the code, because it does not work on the Mega, but without any effect.

Mario.

Debug mode questions

It appears that DEBUG_ENABLE still runs in many places even when DEBUG is not set?

It would be cool if the debug serial commands supported running a capture and what not for testing (especially because of the reset-on-serial-connection behavior).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.