|
我原来那个 1602 LCD 的 6.5 位表头,很早就做了一个用 12864 点阵,带模拟条图的亮骚版
而且不少坛友也挺喜欢的样子 {:4_320:} 但是原来帮我画 PCB 帮我做(手工)板的学弟上个月跑去修仙去了 {:4_327:} 而我不太会画 PCB {:4_309:} 所以在这里求画板,最好还能帮我发行这个套件最好啦 {:4_313:}
电路图和源程序公开如下:
源程序
$Device= m16
$Stack = 32
$Clock = 8
$Timer2 = PWM, 8, Normal
$GLCD HD61202, Data=PORTC, Ctrl=PORTA, 128, 64, 3
$Gctrl EN=0, WR=2, DI=1, CS1=5, CS2=4
$ShiftIn Data=PORTA.6, Clock=PORTA.7, Msb
$LeadChar="0", Format(1,6)
Dim F3HD As Flash Byte
Dim F2HD As Flash Byte
Dim F1HD As Flash Byte
Dim F0HD As Flash Byte
Dim LTC2400arr1 As Flash Byte
Dim i As Byte
Dim iBusystp As Byte
Dim iTrd As Byte
Dim iDraw As Word
Dim iDa As Byte
Dim iDb As Byte
Dim iDc As Byte
Dim iDd As Byte
Dim iTa As Byte
Dim iTb As Byte
Dim iTc As Byte
Dim iTd As Byte
Dim bREGa(33) As Byte
Dim bREGb(33) As Byte
Dim bREGc(33) As Byte
Dim bREGd(33) As Byte
Dim iMax As Byte
Dim iMin As Byte
Dim lMax As Long
Dim lMin As Long
Dim lrec As Long
Dim fOut As Float
Dim fTrn As Float
Dim fMax As Float
Dim fMin As Float
Pwm2 = 3
Set DDRD.7
Start Timer2
' Reset Graph LCD
DDRA.3 = 1
PORTA.3=0
WaitMs 200
PORTA.3=1
GLcdInit
Gcls
FontSet F0HD
GLcd(0, 5), "0 Min Max 5"
'GLcd(0, 7), "AZ:OFF FILT:SMTH 32Pt"
FontSet F1HD
GLcd(0, 0), "Voltmeter"
GLcd(0, 1), "Range 5000"
FontSet F2HD
GLcd(94, 0), "mVDC"
ImgSet(0,4),LTC2400arr1
'主体程序开始
Do
'等待 LTC2400 结束信号
iBusystp = 0
Do
iBusystp = iBusystp + 1
WaitMs 1
Loop While PINA.6 = 1
'GLcd(0, 0), Str(iBusystp)
'读取所有的转换数据
iDa = ShiftIn
iDb = ShiftIn
iDc = ShiftIn
iDd = ShiftIn
iDd = iDd And &b11110000
iDd = Swap(iDd)
iTrd = iDc And &b00001111
iTrd = Swap(iTrd)
iTd = iDd + iTrd
iTrd = iDc And &b11110000
iTc = Swap(iTrd)
iTrd = iDb And &b00001111
iTrd = Swap(iTrd)
iTc = iTrd + iTc
iTrd = iDb And &b11110000
iTb = Swap(iTrd)
iTrd = iDa And &b00001111
iTrd = Swap(iTrd)
iTb = iTrd + iTb
iTrd = iDa And &b00110000
iTa = Swap(iTrd)
'将当前结果立即打印到显示器上
fTrn = 5 * (16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432) / 16777216
ImgSet(0,4),LTC2400arr1
iDraw = 3 + iTb * 100 / 211
LineV(iDraw-2,36,36),1
LineV(iDraw-1,35,38),1
LineV(iDraw,34,38),1
LineV(iDraw+1,35,38),1
LineV(iDraw+2,36,36),1
'GLcd(0, 0), "Orig= "; fTrn; " VDC"
'对转换结果进行一阶滞后滤波
'fPre = fCur
'fCur = fTrn * 2 / 4 + fPre * (4 - 2) / 4
'GLcd(0, 3), "Filt= "; fCur; " VDC"
'GLcd(30, 0), fTrn
'设置一个先入先出寄存器
For i = 1 To 32
bREGd(i) = bREGd(i + 1)
bREGc(i) = bREGc(i + 1)
bREGb(i) = bREGb(i + 1)
bREGa(i) = bREGa(i + 1)
Next i
bREGd(32) = iTd
bREGc(32) = iTc
bREGb(32) = iTb
bREGa(32) = iTa
'排查最大最小值
lrec = 16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432
lMax = lrec
lMin = lrec
iMax = 1
iMin = 1
fOut = 0
For i = 1 To 32
iTa = bREGa(i)
iTb = bREGb(i)
iTc = bREGc(i)
iTd = bREGd(i)
lrec = 16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432
fTrn = 5000 * (16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432) / 16777216
If lrec > lMax Then ' 找到最大值
lMax = lrec
iMax = i
End If
If lrec < lMin Then ' 找到最小值
lMin = lrec
iMin = i
End If
fOut = fOut + fTrn
Next i
'GLcd(0, 1), "Max= "; iMax; " Min= "; iMin
'显示未经剔除最大最小值的平滑滤波结果
'GLcd(0, 1), "Smor= "; fOut / 10; " VDC"
fOut = fOut / 32
fOut = fOut * (10000 / 10004)
FontSet F3HD
Format(4,3)
GLcd(0, 2), fOut
'剔除最大值
iTa = bREGa(iMax)
iTb = bREGb(iMax)
iTc = bREGc(iMax)
iTd = bREGd(iMax)
fMax = 5 * (16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432) / 16777216
'剔除最小值
iTa = bREGa(iMin)
iTb = bREGb(iMin)
iTc = bREGc(iMin)
iTd = bREGd(iMin)
fMin = 5 * (16777216 * iTa + 65536 * iTb + 256 * iTc + iTd - 33554432) / 16777216
'显示剔除了最大最小值的平滑滤波结果
'fOut = (fOut - fMax - fMin) / 8
'GLcd(0, 1), "Max = "; fMax; " VDC"
'GLcd(0, 2), "Min = "; fMin; " VDC"
'GLcd(0, 3), "Smth= "; fOut; " VDC"
FontSet F0HD
Format(1,6)
GLcd(0, 6), fMin; " "; fMax
Format(Scientific,2)
GLcd(0, 7), "Peak:"; fMax - fMin; " Vpp"
'GLcd(62, 3), fOut
Loop
$Include "..\Help\samples\F3HD.bas" ‘ 字体建模
$Include "..\Help\samples\F2HD.bas" ‘ 字体建模
$Include "..\Help\samples\F1HD.bas" ‘ 字体建模
$Include "..\Help\samples\F0HD.bas" ‘ 字体建模
$Include "..\Bitmap\LTC2400arr1.bas" ‘ 小游标(指针)建模
|
|