program oscope_4550_20mhz
Hello everyone,
my goal is to get an oscilloscope in XY mode that works to make a curvetracer.
The display on the oscilloscope with the analog part is finished.
For the digital oscilloscope I used a PIC18F4550 with 20MHz oscill. and Glcd 128x64 Wintek the mod. W12864A.
It works but has a bandwidth ridiculous.
I started from a code found on the forum for the 16F877A and 4MHz oscill.. but as you can imagine was even slower.
I tried to send a sinusoidal signal but after a few Hz, also changing (via sw) the 'Sweep rate factor' no improvement.
I was thinking of bypassing the ADC, making it a library dedicated to increase the sampling rate but I do not know if it will do.
I think we should also work on synchronism and variable (word instead of float).
Any advice?
I put some working code I hope it can be a stimulus for a common developmen..
Thanks for your help
Antonio
Hello everyone,
my goal is to get an oscilloscope in XY mode that works to make a curvetracer.
The display on the oscilloscope with the analog part is finished.
For the digital oscilloscope I used a PIC18F4550 with 20MHz oscill. and Glcd 128x64 Wintek the mod. W12864A.
It works but has a bandwidth ridiculous.
I started from a code found on the forum for the 16F877A and 4MHz oscill.. but as you can imagine was even slower.
I tried to send a sinusoidal signal but after a few Hz, also changing (via sw) the 'Sweep rate factor' no improvement.
I was thinking of bypassing the ADC, making it a library dedicated to increase the sampling rate but I do not know if it will do.
I think we should also work on synchronism and variable (word instead of float).
Any advice?
I put some working code I hope it can be a stimulus for a common developmen..
Thanks for your help
Antonio
Code:
'Microprocessor: 18F4550
'Xtal 20MHz no PLL
'pbaden=off
'This program is designed to make a simple oscilloscope.
'with GLCD W12864A
'Mikrobasic 7.0.2
'--------------------------------------------------------------------
symbol DDRA=TRISA
symbol DDRB=TRISB
symbol DDRC=TRISC
symbol DDRD=TRISD
symbol ControlPort=PortB
symbol DataPort=PortD
symbol Channel=0
dim
X as integer
Y, K, Sr, Offset as float
Xmin, Xmax, Ymin, Ymax as float
XX, YY as short
GLCD_VSize as byte
GLCD_HSize as byte
const 'for GLCD Wintek 128x64 W12864A
cs1=2
cs2=3
rs=4
rw=5
rst=7
en=6
sub procedure Initialize
ADCON1=0x0E 'A0 as analog input
DDRA=0x01 'ADC on A0
DDRB=0x00
DDRC=0x00
DDRD=0x00
glcd_Init(ControlPort,cs1,cs2,rs,rw,rst,en,DataPort)
Glcd_Fill(0) 'Clear display
end sub
main:
Initialize
'User defined
'----------------------
GLCD_VSize=63
GLCD_HSize=127
Sr=1 'Sweep rate factor
Xmin=0.0
Ymin=0.0
K=10.0 'ADC bits
'----------------------
Xmax=float(GLCD_HSize)*Sr
Offset=float (GLCD_VSize)/2.0 'Bottom of GLCD = 0V
Ymax=pow (2.0, K)-1.0 'Top of GLCD = 5V
Display:
for X=integer(Xmin) to integer(Xmax) step 1
Y=float(Adc_Read(Channel))+ Offset
YY=short((float (GLCD_VSize)/(Ymax-Ymin))*(Ymin-Y))
XX=short((float (GLCD_HSize)/(Xmax-Xmin))*(float(X)-Xmin))
Glcd_Dot(XX,YY,1)
next X
Glcd_Fill(0)
Goto Display
end.