论坛风格切换切换到宽版
  • 6472阅读
  • 14回复

DIY 数显电压表方案 [复制链接]

上一主题 下一主题
离线Apple
 
发帖
759
只看楼主 倒序阅读 0楼 发表于: 2002-11-20
diy 数显电压表方案
大家好

我还是菜鸟。
想自己自己做一个数字显示的电压表。
0-30v 精度0.1v,现在想到的方案是用数码管显示,然后用一个89c2051
来做a/d和显示驱动。

各位高手有什么建议吗?或者有更简单更便宜的方法?

谢谢观赏
离线BA3CE
发帖
1652
只看该作者 1楼 发表于: 2002-11-20
at89c2051 successive approximation a-to-d conversion

name   sa_adc_test

; test program to loop on successive approximation a-to-d conversion.
; allows digital codes and resulting dac output to be viewed on 'scope.


    dseg at 0020h

    org   0060h     ; stack origin
stack:     ds   0020h     ; stack depth


    cseg

    org   0000h     ; power on/reset vector
    jmp   on_reset

    org   0003h     ; external interrupt 0 vector
    reti         ; undefined

    org   000bh     ; timer 0 overflow vector
    reti         ; undefined

    org   0013h     ; external interrupt 1 vector
    reti         ; undefined

    org   001bh     ; timer 1 overflow vector
    reti         ; undefined

    org   0023h     ; serial i/o interrupt vector
    reti         ; undefined

    org   0040h     ; begin constant data space

    org   0080h     ; begin code space
    using   0     ; register bank zero
on_reset:
    mov   sp, #(stack-1)   ; initialize stack pointer

    mov   ie, #0     ; deactivate all interrupts
    mov   a, #0ffh   ; deactivate output ports
    mov   p1, a     ;
    mov   p3, a     ;

  loop:
    call   adc     ; convert
    sjmp   loop     ; again


adc:

  ; convert analog-to-digital.
  ; executes a successive approximation algorithm in an attempt to
  ; find an eight-bit code which causes the dac output to match the
  ; unknown voltage at the comparator input. the algorithm returns
  ; one of 256 values ranging from 00000000 (zero volts) to 11111111
  ; (full scale). the exact correspondence between the code and input
  ; voltage is determined in hardware.
  ; before the search begins, zeros are written to the dac and the
  ; comparator is checked to verify that its output is low. if it is
  ; not, a code of zero is returned immediately. if the routine
  ; completes and the comparator output has never gone high, a code
  ; of all ones is returned, corresponding to full scale.
  ; delays have been inserted to allow for worst case op amp slew rate,
  ; resulting in a conversion time of approximately 275 microseconds.
  ; the code is returned in a. all other registers are preserved.

    push   b     ; save
    mov   b, r7     ;
    push   b     ;

    mov   b, #0     ; first code
    call   dac     ; write dac

    nop         ; wait for op amp to slew f.s. to zero
    nop         ;   plus settling time
    nop         ;   total five us at 12 mhz
    nop         ;
    nop         ;

    jb   p3.6, xxx   ; exit if comparator high

    clr   c     ; intialize loop counter/bit mask
    mov   a, #10000000b   ;
  aaa:
    orl   b, a     ; set bit in dac code
    call   dac     ; try new code

    nop         ; wait for op amp to slew 1/2 f.s.
    nop         ;   plus settling time
    nop         ;   total five us at 12 mhz
    nop         ;
    nop         ;

    jnb   p3.6, bbb   ; jump if voltage still low, keep bit
    xrl   b, a     ; voltage too high, reset bit
  bbb:
    rrc   a     ; shift loop counter/bit mask
    jnc   aaa     ; loop until bit in mask moves into c
  xxx:
    mov   a, b     ; return code in a

    pop   b     ; restore
    mov   r7, b     ;
    pop   b     ;
    ret


dac:

  ; write the eight bit code in register b to the dac.
  ; the six most significant bits of the code are written to the
  ; six most significant bits of port one. the two least significant
  ; bits of the code are written to bits five and four of port three.
  ; it is assumed that the comparator is in use, so the bits in port
  ; one corresponding to the comparator inputs are set.
  ; all unused bits are undisturbed.
  ; no delays are included for dac settling or op amp slewing.
  ; all registers are preserved.

    push   b     ; save code
    orl   b, #00000011b   ; enable comparator
    mov   p1, b     ; write bits seven to two
    pop   b     ; restore code
    mov   c, b.1     ; write bit one
    mov   p3.5, c     ;
    mov   c, b.0     ; write bit zero
    mov   p3.4, c     ;
    ret


    end
离线Apple
发帖
759
只看该作者 2楼 发表于: 2002-11-20
最初由 bg3abl 发布
at89c2051 successive approximation a-to-d conversion

抄收了!!

thank you !!!!
离线BA3CE
发帖
1652
只看该作者 3楼 发表于: 2002-11-20
晚上下班在给您找个低成本方案。
离线Apple
发帖
759
只看该作者 4楼 发表于: 2002-11-20
最初由 bg3abl 发布
晚上下班在给您找个低成本方案。


太谢谢了! 要耽误你不少时间,有简单的方法给个线索就行,
不用什么都告诉我,我自己找。

我的问题耽误你那么多时间不好意思啊!
:rolleyes: ;) ;)
离线BD3RJ
发帖
18844
只看该作者 5楼 发表于: 2002-11-20
3abl电流如何???使用哪个ic??
离线Apple
发帖
759
只看该作者 6楼 发表于: 2002-11-20
最初由 bg3rj 发布
3abl电流如何???使用哪个ic??


电流使我下一步要想的:)
现在想的是在保险管上做一个电压采样。如果保险管电阻太小
可能要加一个采样电阻(0.1~1欧?)

您以为如何?
离线BD7CE
发帖
1289
只看该作者 7楼 发表于: 2002-11-20
好极了,本版第一篇完整资料。。。 :)

另外,to bg3abl: 电路图请不要用jpg格式压缩,会造成边缘不清晰,请用gif格式。
离线BA3CE
发帖
1652
只看该作者 8楼 发表于: 2002-11-20
7107
离线Apple
发帖
759
只看该作者 9楼 发表于: 2002-12-09
方案最终是这样的:

我在家里找到了5,6片icl7129.查了一下资料好像精度还挺高的。
pdip 40pin的,昨天去找41/2的字符液晶屏,没有找到。
离线wgqaz
发帖
22504
只看该作者 10楼 发表于: 2002-12-30
别做啦。。直接找个dt830。拆改拆改 就可以成一个电流电压双显示表头。
离线slka
发帖
1126
只看该作者 11楼 发表于: 2002-12-30
我的电源设备电压电流表全都是DIY的
都是用7107加数码管制成的。就连-5伏也是也是用7107的38脚推动一个三极管带动一个小变压器再整流后得到的,整个表头只需要+5伏就可以工作,调试简单,性能稳定,精度也不错
离线BG4-2-12747
发帖
1611
只看该作者 12楼 发表于: 2003-01-12
Re: 我的电源设备电压电流表全都是DIY的
最初由 slka 发布
都是用7107加数码管制成的。就连-5伏也是也是用7107的38脚推动一个三极管带动一个小变压器再整流后得到的,整个表头只需要+5伏就可以工作,调试简单,性能稳定,精度也不错


你好,我想请教一下:我已经买过2个7107了,可是表头还是没有做出来,难道我买的国产的7107真的都是坏的么?还是我在携带的过程中(静电)损坏了呀.:( 谢谢。
离线bg4aoc
发帖
9383
只看该作者 13楼 发表于: 2003-03-09
最初由 apple 发布
电流使我下一步要想的:)
现在想的是在保险管上做一个电压采样。如果保险管电阻太小
可能要加一个采样电阻(0.1~1欧?)
您以为如何?


需要合适的采样电阻,看你要多少量程和精度,可能需要多级采样电阻。
注意电阻功率!!!测大电流时电阻上的发热很厉害的,此时要保持精度要考虑电阻值随温度的变化,可以在程序里补偿。
离线bg2rah
发帖
7065
只看该作者 14楼 发表于: 2003-03-10
最初由 wgqaz 发布
别做啦。。直接找个dt830。拆改拆改 就可以成一个电流电压双显示表头。


是的便宜的830才10多圆.