​ ​ ​ A simple Logic Analyser and (slow) oscilloscope - Blogs - PICAXE Forum
View RSS Feed

Jamster's Jar of Jamy Blogs :)

A simple Logic Analyser and (slow) oscilloscope

Rate this Entry
I recently finished a simple logic analyser and oscillascope using an 08M2 and a PC, it's not much: it provides a scan rate of just above 100hz across 2 channels but thats all I really need. The PICAXE is just a simple program which reads the ADC value of two pins an sends it to the computer. The computer has a slightly harder job of processing the data and drawing a graph of it.

setfreq m8
SYMBOL inpinA = C.1
SYMBOL inpinB = C.2
SYMBOL datapacket = w0
SYMBOL dataA = b0
SYMBOL dataB = b1
main: do
  readadc10 inpinA,datapacket
  sertxd(1,dataA,dataB )
  readadc10 inpinB,datapacket
  sertxd(2,dataA,dataB )
Computer code (BBC BASIC):
REM Open serial port
      port% = OPENUP("COM1: baud=9600 parity=N data=8 stop=1")
      IF port% = 0 PRINT "Could not open COM1" : END
     REM Resize window
      DIM rc{l%,t%,r%,b%}
      rc.l% = 0
      rc.t% = 0
      rc.r% = 1000
      rc.b% = 200
      SYS "AdjustWindowRect", rc{}, &CF0000, 0
      SYS "SetWindowPos", @hwnd%, 0, 0, 0, rc.r%-rc.l%, rc.b%-rc.t%, 6
      VDU 26
      REM declare variables
      Adatalocation% = ^data%
      Bdatalocation% = Adatalocation%+1
      channel& = 0
      lasttime1% = 0
      lastdata1% = 0
      lasttime2% = 0
      lastdata2% = 0
      lasttime3% = 0
      lastdata3% = 0
      lasttime4% = 0
      lastdata4% = 0
      REM assign zoom and scale variables
      REM main loop
      TIME = 0
        REM get channel and 2 data bytes from buffer and combine bytes to integer
        chars% = EXT#port%
        IF chars%  0 THEN
          channel& = BGET#port%
          ?Adatalocation% = BGET#port%
          ?Bdatalocation% = BGET#port%
        REM draw Channel1
        IF channel& = 1 THEN
          GCOL 2
          MOVE lasttime1%*zoom&,lastdata1%/scale&
          DRAW TIME*zoom&,data%/scale&
        ELSEIF channel& = 2
          REM draw Channel2
          GCOL 4
          MOVE lasttime2%*zoom&,lastdata2%/scale&
          DRAW TIME*zoom&,data%/scale&
        REM Reset cursor if offscreen
        IF TIME*zoom&>=rc.r%*2 THEN
          TIME = 0
          lasttime1% = 0
          lasttime2% = 0
If I can get my hands on a resonator I will try at higher frequencies but I doubt the computer will be able to handle it.
Pics will come later when I can get to software better than MS paint.

BBC BASIC available at: available at http://www.rtrussell.com/

EDIT: Pics uploaded
Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Osc3.jpg 
Views:	321 
Size:	19.9 KB 
ID:	10070   Click image for larger version. 

Name:	Osc2.jpg 
Views:	308 
Size:	26.4 KB 
ID:	10071  

Submit "A simple Logic Analyser and (slow) oscilloscope" to Digg Submit "A simple Logic Analyser and (slow) oscilloscope" to del.icio.us Submit "A simple Logic Analyser and (slow) oscilloscope" to StumbleUpon Submit "A simple Logic Analyser and (slow) oscilloscope" to Google

Tags: None Add / Edit Tags


    Pretty cool. I am fascinated by the BBC basic. I used a long time ago Microsoft Basic compiler V4.5 ... had a few low-level libraries back in the DOS days! I will have to carve out some time to loo, at this more.
    Last time I needed to display PICAXE output, I went with StampPlot Pro from SelmaWare... but the rate was just 1 Hz... still, a nice, free plotting program with data capture and 'macros'.


    - Ray
    Nice writeup there, I really want to try this with a faster chip but as I say it might be too fast...
    I'll have a look at that software, thanks.