Oscilloscope from a PIC

Status
Not open for further replies.

AtomSoft

Well-Known Member
Does anyone have any tutorials or links on how to make a simple PIC oscilloscope?

I just want to make one so i can measure pulses. I would like to make something like the PICkit 2 Logic Analyzer. It would basically start from a interrupt.

Measure the time High
Measure the Time Low

I dont care about visuals like waves and stuff i care more for numbers. Like a result should be like:

High 7us, low 22us, high 7us, low 22us, low 20us, high 14us, low 22us.

Hence it will display the information of the input for a specific period of time. Or Collect the information in a buffer of some sort and then save the buffer to eeprom and output the eeprom to pc.

The only thing i need help on is the timer and that rising edge and falling edge stuff. So any links or tips or anything of the sort would be awesome. Thanks !
 
atom, if you do not want to fetch the signal shape, then you want to build logic analyser and not the scope...

check out:
PIC16F873: http://www.geocities.com/ted_rossin/Electronics/Pic/Pic.html#LogicAnalyzer
PIC18C252: **broken link removed**
different PIC's: **broken link removed**
PC Parallel port: **broken link removed**
PC Parallel port: http://hackaday.com/2008/01/28/parallel-port-logic-analyzer/

and do not forget to check out the topic on this forum where ikalogic is making the LA but AVR based:
https://www.electro-tech-online.com/threads/avr-based-logic-analyzer.39196/#post311336
 
Last edited:

hi atom,
Look at the PORTB.0 input as the trigger input.

Use a 10MHz xtal if you need a good timing resolution.
 
arhi: Thanks a bunch.. after i eat some lunch ill take a look at them.

Eric: I have some (3 or so) 20mhz crystals (1 resonator) and some 8 and 4 mhz also. I suppose for best timing i use the 20 MHz so i can get faster input. (am i right?)
 
Yes, the faster the clock the finer resolution you'll get. Use the CAPTURE/COMPARE
MODULE in conjunction with a timer for best accuracy. What PIC did you have in mind?
 
I was thinking about using a PIC18F448 or Similar like a 248 or even a 18F4525 or well anything i have that can run at 20MHz... 18F4620 etc...

I dont thing it matters with 18F pics. Most are the same almost or maybe ALL do have A/D and timers and most have Compare/Capture stuff so ill be set as long as its fast enough. Time to look at those links thanks again guys. If you have any other thoughts or tips ....

...Keep em coming...
 
Last edited:
wow after i make this (for fun now) i will buy this maybe in like 1 month:

Nice catch! The price isn't bad either ~170$

Could be handy.

BTW There was an article in one of the electronics rags last year, I think it was Everyday Practical Electronics, with a four channel logic analyzer. Nice and simple. I would find the reference, but I'm in the middle of moving right now.
 
Last edited:
What i recommend you use a dsPIC33F since they run at up to 160Mhz and it has a DMA. What the DMA dose is move data between preperials and ram or other preperials, and it dose it really fast and best of all without the CPU doing anything. I guess that would allow you to sample a port at 40Mhz.

Doing this on a 18F will probably end up with like 1 or 2 Mhz sample rate since they only go up to 10MIPS and the CPU has to do it all.

Also for analog signals some PICs can run the ADC at a 2Mhz sample rate. That could make a basic oscilloscope for simple things.

But your best method of making a logic analiser is a FIFO buffer chip. Basicaly you just clock the write pin with the sample rate you want and send the sigals in the data pins. A pic can then read out the buffer and send it to the PC. With this method its possible to get 200Mhz sample rates.
 
SomeoneElectro, can the dsPIC move the data from PIC to external RAM (parallel or spi) ?

for "just a logic analyser" I made (some time ago) LA that sampled data directly into RAM chips, and PIC was used only to select/start/stop external oscillator that was clocking the ram (and d-latch) and to read data from RAM and forward to serial port .. nothing else (no sampling done on PIC itself) and it was "ok" ..

If I do sampling on the PIC, can you write a "few line example" (pseudo lang .. just so I can see the techique) how can I "move" that data to external ram (as with high frequency sampling, storing data in PIC will give useless amount of data)


atom, for the LA itself, the application that is going to interpret the data is much more complex then the device collecting data ... fairly simple circuit (you have bunch of links now) will sniff out most of digital data running around the board, problem is interpreting is, the simple "show / measure" is not that hard to develop (you have bunch of sources around to use), but if you want to interpret / debug SPI, I2C, RS232, CAN..... you need much more complex software on the PC side (like app that comes with that device you posted link to)
 
Depending on what you need this for, you might consider either buying or building a pickit2 and using the microchip logic analyzer. Not super high speed but $35 or less...
 
Depending on what you need this for, you might consider either buying or building a pickit2 and using the microchip logic analyzer. Not super high speed but $35 or less...

Since Microchip came out with the LA tool for PICkit2 I use my Junebugs instad of my analog scope for quite a few tasks. It is great for serial communication debugging.
 
By the way, does anyone know the minimum you have to implement to to support the LA tool? My guess is GND, PGC, PGD, AUX and Vcc feedback circuits. Skip all the Vpp generation and control, I suppose. I'll give it a try someday.
 
Nope, moveing data trough the pic in to external ram is too slow.You need a ram chip and feed it the data directly while giving it clock.The pic can however detect the triger start, to begin sampleing.. That's the best easy way to make a high speed analiser. I find the pickit 2 built in analiser too pour for bigger use. The 1Mhz only sample rate is offten too slow but mostly the small storage. Also it dosent decode serial lines. Meaby I'll make a 100MHz analiser with a few Megs of memory and serial decodeing. I just have to get around too it.
 
someone electro, that is why I asked if dsPic can do it .. you mentioned it has dma of a kind .. for LA the easiest way is to go directly to RAM (I made one LA with 4 512KB chips some time ago but never got around to make "good" software to debug SPI / I2C / Serial .. so it is fairly useless) ... but if dsPic can move data to external RAM quickly enough, then one can make a scope with it, limited but fairly useful for some debugging .. not that I need it (got me a picoscope recently) but the theory of operation might be interesting ... never tried any dsPic (I have few at home sitting in a box doing nothing, waiting for me to try them out when I get some interesting project in mind)
 

Sure, for a general LA, it sucks. But it also doesn't cost a lot of money and is useful for some simple tasks. For example, I was debugging bit banged manchester RF comm. It was perfect for looking at what was going on.

If my guess is correct about the circuits needed, an LA only pickit2 clone will cost about $10. I'd put that in the category of "no brainer".

As some one else pointed out, most of the work for this kind of tool is analysis software on the PC, not the PIC (or what ever) code. I think an interesting exercise would be an open source, community developed logic analyzer. It would be really great if there was a standard interface that allowed different HW implementations, sample widths and speeds. With a plugin architecture, people could develop different analysis modules (like async, spi, I2C, canbus and so on).
 
Last edited:
I hooked up a damaged Junebug that reports a shorted VPP. The bits toggle in the "LOGIC IO" window when I touch AUX PGM and PGD to +5 or GND.

The thing is that I do not see a large savings. There are maybe 3 bucks in parts.
By the way, does anyone know the minimum you have to implement to to support the LA tool? My guess is GND, PGC, PGD, AUX and Vcc feedback circuits. Skip all the Vpp generation and control, I suppose. I'll give it a try someday.
 
Last edited:
I hooked up a damaged Junebug that reports a shorted VPP. The bits toggle in the "LOGIC IO" window when I touch AUX PGM and PGD to +5 or GND.

The thing is that I do not see a large savings. There are maybe 3 bucks in parts.

Maybe a bit more but the key is it's really really simple.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…