Username:    Password: Remember me
SCANALOGIC
ikalogic's easy to build high performance logic analyzer
By Ibrahim Kamal
Last update: 2/6/10


NEW : Check SCANALOGIC-2 here!
20 MSPS, Very small package, new powerfull software, SPI, I2C, UART decoder, post trigger data, generator mode, and much much more!
   

Here is one project we are really proud of, and we hope that its simple design will encourage you to build your own, and use the provided software to obtain your own logic analyzer for less than 10$.

This device can help you in most of your projects, it's an essential measuring device when it comes to digital electronics.

Those pages will discuss all what you need to know to understand how it works, and build your own, and use it.

1.What is a Logic Analyzer?
You could read the definition on wikipedia, but as you may already know, I have my way of explaining things to beginner!

I would say that a logic analyzer is a device used to view the voltage of "logic" electric signals that are usually too fast to be measured by a voltmeter. A logic analyzer it not exactly like an oscilloscope, as it cannot measure analog voltages. Actually, it can only measure the logic state of a signal, see if it's a 1 or a 0. '0' being Zero volts and '1' being 5V (for classic TTL logic devices).

The main keypoint that makes a logic analyzer better than another is the sampling rate, or the maximum number of samples that can be recorded by second.

From a functional point of view, a logic analyzer records the states of logic signals, usually after some 'triggering condition' is met, then, recorded signals are displayed on a screen for in depth analysis.

2. Introducing Scanalogic
Scanalogic is a simple, yet effective logic analyzer specially designed to be easily built by beginners, so that it can be used for debugging and analyzing their projects.

It can be used at sampling rates as high as 4 Million Samples per second. It has only 4 channels, but that is more than enough for most hobby projects, further more, most communication buses nowadays have very few transmission lines, ranging from 2 to 4, so decided 4 was more than enough.

Scanalogic is a combination of a hardware (figure 2.a) and software application (figure 2.c). As you will see later, the hardware is as simple as it can get: An ATMEGA16 micro controller and a NAND gate! The code to be loaded in the micro controller is provided at the end of this page.

Figure 2.a

The hardware records the samples at the desired sampling rate, then send them to the PC application via the UART port of the microcontroller and the RS232 port of the PC. If your PC doesn't have an RS232 port, as mine, you can still use a USB-RS232 converter cable, as shown in figure 2b.

Figure 2.b

The software is made with visual basic. A setup file is included at the end of the page. It is compatible with windows ME all the way up to XP (or maybe Vista, can someone confirm?).

The Scanalogic software controls the hardware (as you can see, there are no buttons on the hardware) It allows you to setup the triggering conditions, to start sampling, to receive sampled signals, display them, analyze them, and even store them for later analysis.

Figure 2.c

3. Building the hardware
There are no secrets held for the hardware, as the real power of this logic analyzer comes from the innovating source code, loaded inside the ATMEGA16 microcontroller.
As you can see in figure 3.b, there are only a microcontroller, and a NAND gates IC and all of it resides in an old CDROM power supply box. The DB9 connector for serial communication is firmly glued to the box with an epoxy resin. The whole is powered from the RTS line of the RS232 connection (pin number 4), so there is no need for external power supply (but you may as well use any 5V power supply if

Figure 3.a
your serial port cannot deliver the required current).

As you can see in the schematic below, there are no level shifting IC like the MAX232, but believe or not, most if not 100% of current serial communication hardware is compatible with the approach below, where the signals are simply 'inverted', but not shifted to +/- 12V. (Originally, in the RS232 protocol, a logic 1 is represented with -12v, and a logic 0 is represented by +12V).

Pin 4 of the DB9 connector is used to power the device, as it rises to +12V (theoretically) when a communication is being carried out. The Diode D3 makes sure no negative power supply is applied to the device, and the 5.1V zener diode D4 prevent supply voltage from rising above 5.1 volts. Using the handshaking signals as a power supply is far from being my invention, it have been used in a lot of devices like mice and old external keypads...

Figure 3.b
The probes are directly connected to micro controller. A better approach would be to add buffers to protect the micro controller but, for simplification, I didn't include one.

The crystal oscillator X1 can be anything from 1Mhz to 16Mhz, but remember that the clock frequency of the microcontroller directly affects the maximum sampling rate, according to the following equation:

Max_Sampling_rate = Clock_frequency/4


That is simply because, the most efficient code I could ever write, needs at least 4 clock cycles to sample and store new signals.

D1 is simply a red LED, used to signal if the device is powered up and correctly functioning.

Download the hex file to be loaded into the ATMEGA16 for different crystal frequencies:
- 8 MHz
- 12 MHz
- 16 MHz
(Need hex files for other frequencies? request for it in the forum)


4. Downloading and using the PC side software
Scanalogic software, especially this first version is very simple and intuitive.

After you have plugged the Hardware, the configuration is simply made via 3 steps:
1- Press F2 to chose the crystal frequency at which your microcontroller is running, and to chose the COM port to which the hardware is connected.
2- Press F3 to chose the sampling rate
3- Press F4 to chose the triggering condition

Then you simply need to Press F5 anytime to start the sampling. Note that if you chose a triggering condition, the sampling will only start when this condition is met.


Download the installation file for SCANALOGIC


I hope this article was useful. Any comments and further questions are welcome in the forum below.


Project under construction,
register to the forum to get informed of updates by e-mail.



Discussion (Last 15 posts preview...)
Preview of the last 15 messages discussing this page. Messages are sorted from the newest to the oldest.
Posted by:
nachi
on: 06 Jul 2010
Scanalogic
['Quote ]
Dear Sir

Thank you so much for the wonderful guidance and prompt reply .

Wish you all the very best for your upcoming projects and may you achieve success to your satisfaction.

Best regards

Nachiket.
Posted by:
User avatar
ikalogic

on: 05 Jul 2010
Re: Scanalogic
['Quote ]
No, but various users have provided the hex file for M32, you will find it among the 20 pages this thread... :)
Posted by:
nachi
on: 05 Jul 2010
Atmega 16 L to Atmega 32 possible with same HEX code ?
['Quote ]
Dear Sir

Can the Atmega 16 L chip be replaced with that of an Atmega 32 in the circuit and be burned with the same hex file ?

Awaiting reply .

Thanks in advance.

Regards

Nachiket Kalantre
Posted by:
yan78
on: 08 Jun 2010
Re: Scanalogic
['Quote ]
Ika ! Even with one channel I could do a a lot of work on a Weather transmiter protocol. It's a wonderfull tool . I will try to find more time to resolve that bug in software . I will post this problem in arduino forum . Maybe someone will have more time so solve the problem .

Bye !
Posted by:
User avatar
ikalogic

on: 07 Jun 2010
Re: Scanalogic
['Quote ]

Quoting Yan78: New release!
Scanalogic with 2999 samples . Serial speed 115200 bps , DTR deactivated so Arduino will not restart .
It will work only with Arduino based on ATMEGA 328 - 16 Mhz . ONLY CHANNEL ONE IS WORKING . Did not had time to investigate !


Thanks yan for all the efforts!!

did you get any luck with other channels?

besides, i am not Arduino user at all, but are other Arduino fans out there aware of that? maybe we can let them work with you on that! :)
Posted by:
yan78
on: 04 Jun 2010
Re: Scanalogic
['Quote ]
New release!
Scanalogic with 2999 samples . Serial speed 115200 bps , DTR deactivated so Arduino will not restart .
It will work only with Arduino based on ATMEGA 328 - 16 Mhz . ONLY CHANNEL ONE IS WORKING . Did not had time to investigate !
Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
Another version for Arduino now adata is 2000 samples large . But someone will have to modify the source in Visual Basic for Scanalogic .

Onlz channel 1 is working ( I didn't had time to find why because I'm playing with some decoding for a 433 Mhz weather receiver )
Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
It's working better without Timer0 overflow int. activated .
line 1323 in source file

//TCCR0B = (1<<CS00)|(0<<CS01)|(1<<CS02); //TC2 counts Clock_io/1024
SREG = 0x80; //enable general interrupts in SR
//TIMSK0 = TIMSK0 | (1<<TOIE0);//Enable timers interrupts
//TCNT0 = 0;


Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
Ika ! your solution was good . But I don't know why is only sampling for channel 1 .
For those ho want to try and to upgrade the software this is the code .
Posted by:
User avatar
ikalogic

on: 03 Jun 2010
Re: Scanalogic
['Quote ]

Quoting Yan78: That's easy , but the next problem is this one :

asm("in r30,0X27"); //start at "signal"'s memory location
asm("LDI r31,0"); //..

asm("IN r11,0x03"); //perpare the first reading
//** detect the trigering condition



the adress is stored in R30 .....
what can I say is that I'm a beginer in ASM so if someone here is good and have time to do it then all the Arduino freaks will have a good tool .
Thank's again Ika !

I think this would solve it


asm("in r30,0X27"); //replace 0x27 with the address of OCRA
asm("in r31,0"); //replace 0 with the address of OCRB


Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
That's easy , but the next problem is this one :

asm("in r30,0X27"); //start at "signal"'s memory location
asm("LDI r31,0"); //..

asm("IN r11,0x03"); //perpare the first reading
//** detect the trigering condition



the adress is stored in R30 .....
what can I say is that I'm a beginer in ASM so if someone here is good and have time to do it then all the Arduino freaks will have a good tool .
Thank's again Ika !
Posted by:
User avatar
ikalogic

on: 03 Jun 2010
Re: Scanalogic
['Quote ]

Quoting Yan78: I will try to explain :
- in avr simulator &data = 0x107H ; this is a 16 bit value because of memory alocation in SRAM ( page 18 for [url=http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf>ATmega168 datasheet"> [link]
- when OCR0A = &adata is executed then OCR0A became 0x07H and not 0x107H because OCR0A is a 8 bit register

From this mometn the code will not save sampled data to data[] .

In your original code ( simulated in avr ) &data = 0x67H and the PORTA that keep's this adress is initialised corectly .

So ! My question is how to rewrite the ASM routine to avoid the first problem I tryed to explain .

Thank's !


Okay... now i see.

hmm...

Why not use OCRA and OCRB:

OCRA = &data ; //hold 0x07H
OCRB = (&data) >> 8; //HOLD 0x1H



Then the trick is to construct back the 16 bit address in asm later.
Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
I will try to explain :
- in avr simulator &data = 0x107H ; this is a 16 bit value because of memory alocation in SRAM ( page 18 for [url=http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf>ATmega168 datasheet"> [link]
- when OCR0A = &adata is executed then OCR0A became 0x07H and not 0x107H because OCR0A is a 8 bit register

From this mometn the code will not save sampled data to data[] .

In your original code ( simulated in avr ) &data = 0x67H and the PORTA that keep's this adress is initialised corectly .

So ! My question is how to rewrite the ASM routine to avoid the first problem I tryed to explain .

Thank's !
Posted by:
User avatar
ikalogic

on: 03 Jun 2010
Re: Scanalogic
['Quote ]
Yan i don't quite understand the problem..... ?
Posted by:
yan78
on: 03 Jun 2010
Re: Scanalogic
['Quote ]
No idea ? :(
You have to be a member to post replies.
Username: Remember me
Register now! it only takes an instant.
Forgot your password?


 
Unless mentioned, all content is written and designed by Ibrahim Kamal, copying is prohibited and unethical
ikalogic.com: Electronics and Robotics related projects.
All content on this site is provided as is and without any guarantee of any kind. We cannot be held responsible for any errors, omissions, or damages arising out of use of information available on this web site.
Creative Commons License
IMPORTANT COPYRIGHT NOTE: Electronics and Robotics Articles by Ibrahim KAMAL are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.