用 M8+LTC2400 做的 6.5 位表头阶段性完成并粗略测试
算法为 10 点先入先出,剔除最大最小值的 8 点平滑算法,每秒读数大约是 6.2 个读数,相当于 34401/3457 的 NPLC=10 的速度。对比测试源使用了横河可编程电源 7651,对比参照表 6581。因为手头上没有高速光耦,所以还没有做至少 5 万点的编程测试第一个测试视频:先入先出平滑算法测试源为锂离子电池的视频
http://www.tudou.com/programs/view/f3snD1PI-7U/
第二个测试视频:用 7651 可调电源为源,6581 为参考表的测试视频,前半段为 50 点对照绝对误差(亦可作为线性度)测试,后半段为灵敏度测试
http://www.tudou.com/programs/view/axLrS1Jawvc/
电路总图:
http://cache.amobbs.com/bbs_upload782111/files_43/ourdev_660019PCKWEP.jpg
(原文件名:kt_281.jpg)
ADC 板
http://cache.amobbs.com/bbs_upload782111/files_43/ourdev_660017SRA496.jpg
(原文件名:DSC03864.jpg)
测试中
http://cache.amobbs.com/bbs_upload782111/files_43/ourdev_660016N5K5UR.jpg
(原文件名:DSC03902.jpg)
对比测试
http://cache.amobbs.com/bbs_upload782111/files_43/ourdev_660018JYT2UD.jpg
(原文件名:kt_282.jpg)
对比测试图表(误差绝对值)
http://cache.amobbs.com/bbs_upload782111/files_43/ourdev_660020HDQPMZ.jpg
(原文件名:kt_283.jpg) 源程序,我只会 BASIC...
'/////////////////////////////////////////////////////////
'/// FastAVR Basic Compiler for AVR by MICRODESIGN ///
'/// Name of Your project
'/////////////////////////////////////////////////////////
$Device= m8 ' used device
$Stack = 32 ' stack depth
$Clock = 8 ' adjust for used crystal
$Lcd=PORTB.0, RS=PORTB.5, EN=PORTB.4, 16, 2
$LeadChar="0", Format(2,6)
$ShiftIn Data=PORTC.4, Clock=PORTC.5, Msb
$Baud = 1200,n,8,1
$1Wire=PORTD.7
Dim i As Byte
Dim iBusystp As Byte
Dim iSMPL As Byte
Dim iSiG As Byte
Dim iExR As Byte
Dim iTrd As Byte
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 iWRa As Byte
Dim iWRb As Byte
Dim iWRc As Byte
Dim iWRd As Byte
Dim bREGa(15) As Byte
Dim bREGb(15) As Byte
Dim bREGc(15) As Byte
Dim bREGd(15) 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
DDRC.3 = 1
PORTC.3 = 0
InitLcd()
Cls
Lcd "Init Program...."
Wait 1
Cls
Locate 1,1 : Lcd "Result=10Smth8"
iSMPL = 0
Do ' place your code in next line
'等待 LTC2400 的 ADC 忙碌信号
'iBusystp = 0
Do
'iBusystp = iBusystp + 1
WaitMs 1
Loop While PINC.4 = 1
'Locate 1,1 : Lcd iBusystp
' 读出 LTC2400 的所有字节
iDa = ShiftIn
iDb = ShiftIn
iDc = ShiftIn
iDd = ShiftIn
'Locate 1,1 : Lcd Hex(iDa); Hex(iDb); Hex(iDc); Hex(iDd)
'获得低 8 位转换结果
iDd = iDd And &b11110000
iDd = Swap(iDd)
iTrd = iDc And &b00001111
iTrd = Swap(iTrd)
iTd = iDd + iTrd
'获得中 8 位转换结果
iTrd = iDc And &b11110000
iTc = Swap(iTrd)
iTrd = iDb And &b00001111
iTrd = Swap(iTrd)
iTc = iTrd + iTc
'获得高 8 位转换结果
iTrd = iDb And &b11110000
iTb = Swap(iTrd)
iTrd = iDa And &b00001111
iTrd = Swap(iTrd)
iTb = iTrd + iTb
'Locate 1,1 : Lcd Hex(iTb); Hex(iTc); Hex(iTd);
iTrd = iDa And &b00110000
iTa = Swap(iTrd)
'先入先出寄存器
For i = 1 To 9
bREGd(i) = bREGd(i + 1)
bREGc(i) = bREGc(i + 1)
bREGb(i) = bREGb(i + 1)
bREGa(i) = bREGa(i + 1)
Next i
bREGd(10) = iTd
bREGc(10) = iTc
bREGb(10) = iTb
bREGa(10) = iTa
iWRa = bREGa(9)
iWRb = bREGb(9)
iWRc = bREGc(9)
iWRd = bREGd(9)
'Locate 1,5 : Lcd Hex(iWRa); Hex(iWRb); Hex(iWRc); Hex(iWRd)
'识别正负符号
iSiG = iWRa And &b00000010
If iSiG = 2 Then
iTrd = iWRa And &b00000001
lrec = 16777216 * iTrd + 65536 * iWRb + 256 * iWRc + iWRd
Else
lrec = 65536 * iWRb + 256 * iWRc + iWRd - 16777216
End If
'Locate 1,1 : Lcd Str(lrec)
'寻找最大最小值
lMax = lrec
lMin = lrec
iMax = 1
iMin = 1
fOut = 0
For i = 1 To 10
iWRa = bREGa(i)
iWRb = bREGb(i)
iWRc = bREGc(i)
iWRd = bREGd(i)
'识别正负符号
iSiG = iWRa And &b00000010
If iSiG = 2 Then
iTrd = iWRa And &b00000001
lrec = 16777216 * iTrd + 65536 * iWRb + 256 * iWRc + iWRd
fTrn = 5 * (16777216 * iTrd + 65536 * iWRb + 256 * iWRc + iWRd) / 16777216
Else
lrec = 65536 * iWRb + 256 * iWRc + iWRd - 16777216
fTrn = 5 * (65536 * iWRb + 256 * iWRc + iWRd - 16777216) / 16777216
End If
'找出最大值
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
'Locate 1,1 : Lcd iMax
'Locate 2,1: Lcd Hex(bREGb(iMax)); Hex(bREGc(iMax)); Hex(bREGd(iMax))
'Locate 1,15 : Lcd iMin
'Locate 2,11: Lcd Hex(bREGb(iMin)); Hex(bREGc(iMin)); Hex(bREGd(iMin))
'剔除最大值
iWRa = bREGa(iMax)
iWRb = bREGb(iMax)
iWRc = bREGc(iMax)
iWRd = bREGd(iMax)
iSiG = iWRa And &b00000010
If iSiG = 2 Then
iTrd = iWRa And &b00000001
fTrn = 5 * (16777216 * iTrd + 65536 * iWRb + 256 * iWRc + iWRd) / 16777216
Else
fTrn = 5 * (65536 * iWRb + 256 * iWRc + iWRd - 16777216) / 16777216
End If
fOut = fOut - fTrn
'剔除最小值
iWRa = bREGa(iMin)
iWRb = bREGb(iMin)
iWRc = bREGc(iMin)
iWRd = bREGd(iMin)
iSiG = iWRa And &b00000010
If iSiG = 2 Then
iTrd = iWRa And &b00000001
fTrn = 5 * (16777216 * iTrd + 65536 * iWRb + 256 * iWRc + iWRd) / 16777216
Else
fTrn = 5 * (65536 * iWRb + 256 * iWRc + iWRd - 16777216) / 16777216
End If
fOut = fOut - fTrn
fOut = fOut / 8
Locate 2,1: Lcd fOut; " VDC"
Select Case iSMPL / 4
Case 0
Locate 2,16: Lcd "S"
Case 1
Locate 2,16: Lcd "M"
Case 2
Locate 2,16: Lcd "P"
Case 3
Locate 2,16: Lcd "L"
End Select
iSMPL = iSMPL + 1
If iSMPL > 15 Then iSMPL = 0
'WaitMs 200
Loop
End 不错 好资料啊~~~mark了~~~我也要做一个!!! GOOD mark MARK mark 在38度论坛见过,不错 MARK mark 好玩 准备用LTC2445做个,这IC速度快些 准备用LTC2445做个,这IC速度快些 好,标记备用 好资料,顶一下。有那个高手能转成C语言就好了。 kejiren123 发表于 2012-6-25 22:38 static/image/common/back.gif
好资料,顶一下。有那个高手能转成C语言就好了。
没有办法呀,只能看懂点C的同顶! 好资料,能弄成个文件包再上传就好了,谢谢LZ 请教一下你这个原题图是哪个软件呐? 好资料,顶一下 这个不错,标记一下 {:funk:}好东西。。。。 都在挖。进来了也挥一锄头。。{:lol:}{:lol:} 好东西,准备仿制一个 xuexi xia mark LTC2400 是24位A/D转换器,Linear提供样片吗? {:smile:} 见楼主在吧问题发来,望回复,谢谢
看见楼主用ADS1232这AD芯片,问声这颗芯片在接上1V 电压的情况下跑, 10uV的稳定数据是否可以做到,我用MAX6173 和ADS1232 跑发现 1mV 下面的数据跳动很大,我想把数据处理下,做到让他接上 1V 电压 可以稳定在10uV~~20 uV左右有跳动,其他数据稳定,如果不行的话,max6173和LTC2440可否做到,另外问声楼主正负数据怎么排序,比较大小,正在看楼主的BASICAVR 程序 但有点犯糊涂,忘指点谢谢
强 mark
好资料,能弄成个文件包再上传就好了,谢谢LZ 顶一下BASIC。
页:
[1]