1st, PIC16C62×; Series monolithic integrated circuit’s characteristic
PIC16C62× the series is the RISC simplification instruction, the Harvard structure main line, 18 pin monolithic integrated circuit. Has characteristic which the low power loss, the high performance, the entire static state, 35 instructions are extremely easy to program. A OTP piece kind of performance-to-price ratio is extremely high. Besides has the common monolithic integrated circuit’s characteristic, PIC16C62× the series interior integrated two simulation comparators and a 4bit programmable datum potential source (REF). If uses this monolithic integrated circuit’s these characteristics, only needs several periphery parts to have A/D and the D/A transformation function, and the resolution achieves 8bit~10bit. In the price superiority causes it to control the profession, the instruments and meters, the electrical appliances product application prospect in the labor to be extremely optimistic.
This article proves A/D, D/A by the 8bit resolution to transform realizes the method, the higher resolution’s plan is completely similar, is only makes the small part adjustment in the programming.
2nd, D/A switch
PIC16C62× the series monolithic integrated circuit interior part of functional module and A/D, D/A electric circuit as shown in Figure 1.

Figure 1 PIC16C62× partial functional module and switching circuit
2.1 use the internal datum source
PIC16C62× the series monolithic integrated circuit interior datum source by 116 tap’s resistance ladder network constitutions, is equal to 4bit the resolution D/A switch, this datum source controls by the VRCON special function register. The VRCON register definition is as follows:

The VREN:REF datum potential source enables the position, when VREN=1, the internal datum potential source enables.
When VROE:REF output choice position, VROE=1, REF output to the RA2 pin.
VRR:REF section choice, REF value programmable hypothesis for height two section outputs.
VR3~VR0:4bit REF voltage value. Changed these 4 values namely to change the REF voltage value. For the later word showing need, makes these 4 binary code the following definition:
VR= VR3VR2VR1VR0
VR-1=VR3VR2 VR1VR0-1
According to PIC16C62× characteristic:
(1), when VRR=1, the low section voltage reference outputs REFL= DD*VRL/24, resolution cell VF1=DD/24.
The REFL voltage value scope is: VRL*DD/24, VRL= 0~15, express the corresponding low section binary code value.
(2), when VRR=0, the high section voltage reference outputs REFH=DD/4 DD*VRH/32, resolution cell VF2=DD/32. VRH=0~15, VRH expresses corresponding Gao Duan the binary code value.
The REFH voltage value range of variation is: DD/4~23*DD/32.
Above DD is PIC16C62× power line voltage, so long as adds a simple power source decoupling circuit in this power supply end, can the very good guarantee voltage reference REF anti-noise request.
By above obviously, PIC16C62× the series monolithic integrated circuit’s internal datum source is actually one may establish is two Duan Zhi 4bit the D/A switch, each section binary code value is 0~15, two section resolution cells is dissimilar. In order to design 8bit and the above D/A switch, must carry on the REF scope the expansion. Uses the REFH value, namely REFH =DD/4~23*DD/32, the expansion is REFH= (the DD/4-DD /32) ~23*DD/32, expands a resolution cell value DD /32 to the voltage low end, is equal expands in binary code value VRH=0~15 for - 1 ~15. This realizes the key which 8bit and above D/A transform. VRH= - 1 is a special condition, has surpassed REF the value scope correspondence binary code value VRH boundary, must realizes by low section voltage reference REFL and the periphery programmable fixed weaken ratio resistance network. PIC16C62× the interior has a field effect OC gate (drain electrode opening gate), meets the application electric circuit which it shown in Figure 1.
When OC gate GK breakover, coefficient of attenuation =1/(0 1) 0=2kΩ (internal fixed resistance).
When OC gate GK closure, coefficient of attenuation =1 (RA4 pin for high-resistance).
The field effect OC gate carries on the I/O operation through the programming to the RA4 pin to realize its breakover and the closure.
States by on, high section VRH=-1 the corresponding REFH datum value may do a tour of duty on the coefficient by low section binary code value VRL corresponding REFL to obtain.
When VRH=-1, the REFH=DD/4-DD/32=7DD /32, establishes the following equation
7DD /32 = (DD/24) * VRL* (1)
VRL=1~15 (rounded number) (2)
K <1 (3)
May result in VRL=6~15 many group of solutions, takes any group of solutions may, for example: VRL=7,=0.75.
Coefficient by external connection resistance 1 value decision. When programming, first determines the VRL value, then according to type (1) calculates the coefficient, according to =1/(0 1), 0=2kΩ calculates 1 resistance number again. 1 also available potentiometer adjustment’s way replaces.
2.2 program 4bit PWM to realize the 8bit D/A transformation
Supposes 8bit to treat binary number depositing which D/A transforms in PIC16C62×; Data-carrier storage’s one unit, defines as the following form:

Divides into two 4bit it the binary codes: VR=VR3VR2VR1 VR0, VP=VP3VP2VP1V P0. The VR control datum potential source realizes 4bit D/A to transform, VP uses to the datum source output voltage carries on 4bit PWM (pulse-duration modulation). The PWM high level is VR the corresponding VREF voltage value, the PWM low level is VR-1 the corresponding VREF voltage value. So, by 4bit D/The transformation datum potential source’s two neighboring binary code correspondence’s two VREF value, separately as the 4bit PWM high level and the low level, this composes 8bit the D/A switch. Figure 2, chart 3 is conventional PWM and the D/A PWM difference, the conventional PWM high level is VDD (for example 5V), the low level is 0V, its principle audiences all know, here no longer in detail narrates. This article states the D/A PWM its PWM principle of work and the conventional PWM principle of work is the same, is only the PWM pulse high level and the low level separately by VR and the VR-1 value decision. When programming, first will wait the 8bit binary number which D/A transforms to divide into high 4 with low 4, low 4 depositing in PIC16C62× some data-carrier storage R0, high 4 make 4 time right lateral (to transfer to byte low end) deposits in PIC16C62× in another data memory R1. Using PIC16C64× a timer interrupt compiles the PWM procedure, the PWM dutyfactor (i.e. the VP value) decided by the R0 in value. Establishes the timer interrupt as the highest first rank, guarantees PWM the dutyfactor precision. This section of procedure’s essence is: In procedure carries on the evaluation operation by binary code VP in the decision dutyfactor’s PWM to the VRCON control register. The PWM pulse’s high level by loads the VR production to VRCON control register low 4, the PWM pulse low level by loads the VR-1 production to VRCON control register low 4. In the procedure must judge: When VRH=0, VR-1 corresponding REF the REFL low section value which states before realizes.

OUT is the 8bit D/A output. The PWM filter circuit by 0, 2, 1 is composed, its time-constant designated according to the PWM cycle, concerns with the concrete application to the D/A transformation request’s speed with the programming. As a result of PIC16C62× the high speed RISC simplification instruction, the D/A conversion rate may achieve above the 400Kbit /s. DD floats the request to be as far as possible small warm. OUT may according to need to carry on the enlargement or the level transformation.
3 A/D switch
As shown in Figure 1, simulated signal receives PIC16C62× an internal comparator’s synchronism end fore-mentioned D/The transformation output’s OUT, waits the transformation simulated signal to receive comparator’s opposition end, this constitutes one typically to approach a/D switch gradually. Its principle says in many textbooks clearly, this article no longer relates in detail.
Because PIC16C62× has the comparator look-at-me function, may raise the programming efficiency using the comparator interrupt and raise a/D conversion rate fully. Defines a PIC16C62× data-carrier storage unit to take a/D transformation result data register, before starting A/D transforms, in this register initializes an empirical data, uses the method which fore-mentioned D/A transforms this data conversion OUT level, the OUT level with waits the transformation simulated signal level to carry on the comparison. When comparator’s synchronism end level is higher than the opposition end level, comparator output logic “1″, and has an interrupt. When comparator’s synchronism end level is lower than the opposition end level, comparator output logic “0″, also has an interrupt. The comparator output logic condition “1″ or “0″ may from its special function register’s related position inquiry gain. In the comparator interrupt routine, revises “a/D transformation result data register” gradually according to the inquiry result the data, enables the OUT level to approach and restrains in treats the transformation simulated signal level, when restraining in data register’s value is a/D transformation result finally gradually. Convergence algorithm’s fit and unfit quality are raise a/D conversion rate the key, this and the concrete application situation and the peripheral circuit parameter is related. However, in the majority electrical appliances product application the simulated signal which transforms for the low speed slow change signal, is not high to a/D conversion rate’s request. Therefore, is not high to convergence algorithm’s request, usually uses from MSB carries on the comparison gradually to LSB the algorithm. Moreover, waits the transformation simulated signal to undergo the level transformation, causes its range of variation with the OUT level range of variation consistent.
4 Subtotal
PIC16C62×; The series monolithic integrated circuit interior has two independent simulation comparators, and its digital I/O mouth has the direct drive light emitter diode and LED nixietube ability. Uses A/D which, the D/A switch principle’s application electric circuit this article states only to take its internal simulation comparator, a datum source, 4 pin resources, the peripheral circuit is also very simple, the application system easy to achieve the volume to be small, the reliability is high, the performance-to-price ratio is good. The shortcoming is A/D, the D/A conversion rate is slow and takes monolithic integrated circuit’s massive time resources, suits in the low speed change signal application.
Reference
1 MICROCHIP. PIC16C62× DATA SHEET. 1997. 10 ~ 22