A simple Logic Analyser and (slow) oscilloscope
by
, 10-01-2012 at 16:54 (1415 Views)
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:
Computer code (BBC BASIC):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
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.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
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








Email Blog Entry
