A simple Logic Analyser and (slow) oscilloscope

Jamster

Senior Member
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.

PICAXE Code:
Code:
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 )
 loop
Computer code (BBC BASIC):
Code:
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
      data%=0
      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
      zoom&=1
      scale&=3
      
      REM main loop
      TIME = 0
      REPEAT
        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%
        ENDIF
        REM draw Channel1
        IF channel& = 1 THEN
          GCOL 2
          MOVE lasttime1%*zoom&,lastdata1%/scale&
          DRAW TIME*zoom&,data%/scale&
          lasttime1%=TIME
          lastdata1%=data%
        ELSEIF channel& = 2
          REM draw Channel2
          GCOL 4
          MOVE lasttime2%*zoom&,lastdata2%/scale&
          DRAW TIME*zoom&,data%/scale&
          lasttime2%=TIME
          lastdata2%=data%
        ENDIF
        REM Reset cursor if offscreen
        IF TIME*zoom&>=rc.r%*2 THEN
          CLS
          TIME = 0
          lasttime1% = 0
          lasttime2% = 0
        ENDIF
      UNTIL FALSE
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.
Jamster

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

EDIT: Pics uploaded

 

Attachments

mrburnette

Senior Member
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'.

http://www.instructables.com/id/A-PICAXE-Infrared-logging-Thermometer/

- Ray
 

Jamster

Senior Member
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.
Jamster
 
Top