Digchip : Database on electronics components
 
Member, Distributor  
Log In
Email:
Password:


Part: AN426

Category:

Description:

Company:

Datasheet: Download AN426 datasheet     File size : 50 kB

Request For quote: Find where to buy AN426



Datasheet text preview:
Philips Semiconductors

Application note

Controlling air core meters with the 87C751 and SA5775

AN426

INTRODUCTION
Often, certain classes of microcontroller applications surface where large amounts of on-chip resources such as a large program memory space and numerous I/O pins are not required. These applications are typically cost sensitive and desirable attributes of the MCU include low cost and modest on-chip resources such as program and data memory, I/O, and timer-counters. Substantial benefits of reduced design cycle time can be realized by using an industry-standard architecture having software compatibility with existing popular microcontrollers.

SA5775 Serial Gauge Driver
The SA5775 is a monolithic driver for controlling air core meters typically used in automotive instrument clusters and is shown in Figure 3. The SA5775 receives a 10-bit serial word and converts that word to four voltage outputs that appear at the SINE+, SINE­, COSINE+, and COSINE­ outputs. The differential voltage at the SINE outputs are applied to one coil of the meter and the COSINE outputs are applied to the other coil of the meter. The currents through these coils produce a resultant magnetic force which is the vector sum of the magnetic forces produced by each of the two coils. Since the currents through the coils are bidirectional this magnetic vector can rotate through a full 360 degrees. The magnetized disc within the air core meter will follow the rotating vector and the needle will indicate the vector's current position. Since 10 bits are used, there are 1024 discrete words available resulting in an angular displacement of 0.3516 degrees per bit. This is small enough to provide an apparently smooth movement of the needle. The smoothness of the motion will depend greatly on the damping factor of the meter movement. A simplified block diagram of the SA5775 is shown in Figure 4. This device consists of a serial-in/parallel-out shift register, a data latch, a D/A converter, a multiplexer, and output buffers. A logic high must be present on the chip select (CS) input to clock in the data. Data appearing on the data input (DI) pin is clocked into the shift register on the rising edge of the clock (CLK) input. The data output (DO) pin is the overflow from the shift register, allowing the user to daisy chain multiple SA5775 devices. Note that data is clocked out of this pin on the falling edge of the clock. The CS pin is also used to latch the parallel outputs of the shift register into the data latch. The outputs of the data latch feed the inputs to the D/A converter. The D/A converter outputs are buffered to form the drive signals for the meter coils. The D/A converter circuits, multiplexer and associated output buffers are purposely designed such that the span of these circuits do not include the power supply rails. This is to avoid inaccuracies that would otherwise occur if the output were to become very close to either supply rail. With a supply voltage of 14 volts (VIGN), the outputs will span a range of approximately 1 to 11 volts. The SA5775 is designed to drive air core meters having a

minimum winding impedance of 180 at ­40°C. The clock high and low time requirements are 175ns minimum and the maximum data rate is 1.6 megabits per second. At this rate it would require approximately 6.4ms to ramp from zero to full scale if all binary codes were loaded into the SA5775. However, the air core meter cannot respond to such data rates. Both inertia of the movement and damping build into the design of typical air core meter movements limit their response speed. A high on the output enable input pin (OE) is required to permit the SA5775 to drive the air core gauge. In Figure , OE is held low while the microcontroller is being reset to prevent the gauge from being driven.

THE 87C751
The Philips 87C751 is one such microcontroller that easily meets these requirements. This device, shown in Figure 1, has a 2k x 8 program memory, 64 bytes of RAM, 19 parallel I/O lines, and a 16-bit autoreload timer-counter. It also includes an I2C serial interface and a fixed rate timer. The 87C751 is based on the 80C51 core and thus uses an industry-standard architecture and instruction set. The device is available in both ROM (83C751) and EPROM (87C751) versions. The EPROM version is available in both UV erasable and OTP packages. References to the 87C751 in this document also apply to the 83C751, unless explicitly stated.

P3.4/A4 1 P3.3/A3 2 P3.2/A2/A10 3 P3.1/A1/A9 4 P3.0/A0/A8 5 P0.2/VPP 6 P0.1/SDA/ 7 OE­PGM P0.0/SCL/ 8 ASEL RST 9 CERAMIC AND PLASTIC DUAL IN-LINE PACKAGE AND SHRINK SMALL OUTLINE PACKAGE

24 VCC 23 P3.5/A5 22 P3.6/A6 21 P3.7/A7 20 P1.7/T0/D7 19 P1.6/INT1/D6 18 P1.5/INT0/D5 17 P1.4/D4 16 P1.3/D3 15 P1.2/D2 14 P1.1/D1 13 P1.0/D0

X2 10 X1 11 VSS 12

TYPICAL APPLICATION
A typical example of such an application is the interface between the 87C751 and the Philips SA5775 Serial Gauge Driver, SGD, shown in Figure 2. This circuit includes the 87C751 microcontroller, the SA5775 Serial Gauge Driver, an NE555 timer, and discrete support components. An air core meter differs from a conventional (d'Arsonval) meter movement in that it has no spring to return the needle to a predetermined position, no zeroing adjustment, and no permanent magnet in the classical sense. Instead, it consists of two coils of wire wound in quadrature with each other around a central core in which there is a disc magnetized along its diameter. A shaft is placed through the center of this disc so that the shaft rotates with the disc. An indicating needle attached to this shaft will rotate with it.

4 5

1

26 25

PLASTIC LEADED CHIP CARRIER 11 12 Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Function P3.4/A4 P3.3/A3 P3.2/A2/A10 P3.1/A1/A9 NC* P3.0/A0/A8 P0.2/VPP P0.1/SDA/OE-PGM P0.0//SCLASEL NC* RST X2 X1 V SS 18 Pin 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Function P1.0/D0 P1.1/D1 P1.2/D2 P1.3/D3 P1.4/D4 P1.5/INT0/D5 NC* NC* P1.6/INT1/D6 P1.7/T0/D7 P3.7/A7 P3.6/A6 P3.5/A5 VCC 19

* DO NOT CONNECT

SU00315

Figure 1. Pin Configuration

January 1992

5-8

Revision date: 1995 Nov 01

January 1992
+BATT Data Out SINP COSP COSM SINM 1 CS SINM SINP 2 15 16

Philips Semiconductors

10

SA5775 ACMD

9 CLK 10 µF

6 DI OE 8 10k 100k 78L05 12MHz Reset 0.1 µF +5V 20pF 9 RST V CC T0 20 24 10 11 Rate 20pF Int. 10 µF

Data In

COSH COSP 5 DO VIGN 4 11 ST 12 NC 13 DGND AGND 14 V CC 7 3

Clock

+5V

CS

Controlling air core meters with the 87C751 and SA5775

Figure 2. Interface Between the 87C751 and the Philips SA5775

5-9 87C751
Gnd P3.4 P3.3 P3.2 P1.3 P1.2 P1.1 P1.0 P3.6 P3.5 12 1 2 3 16 15 14 13 22 23 Count Up Count Down Pulse Monitor Program Select Delay Start/ Count

10k

10k

+5V

10k

0.1 µF

7

P0.1/SDA

8

1k Ext. 3 NE555 5 1 6 1.6k 8 4 7 1k

P0.0/SCL

6

P0.2

P3.1

P3.0

+5V

500k Rate Control

4

5

7 1.1 µF

10k 10k 10k 10k 10k 10k 10k 10k 10k 10k

Ext. Pulse In

AN426

Application note

SU00373A

INC Select

Philips Semiconductors

Application note

Controlling air core meters with the 87C751 and SA5775

AN426

SIN­ SIN+ AGND VIGN DATAOUT DATAIN VCC OE

1 2 3 4 5

16 15 14 13 12 11 10 9

COS+ COS­ AGND DGND NC ST CS S CLK

executed, the INC SELECT (S2) switch selects the incremental step sizes of two of the routines, and the DELAY switch (S4) is used to set the delay between successive word transmissions in one of the routines. The START/COUNT button (S5) is used to begin execution of a routine, and to cause the next incremental step in Routine #1. The COUNT UP/DOWN switch (S6) is used in Routine #1 to determine whether the count is increased or decreased with transmission of successive words.

bit) are masked off, leaving twice the value of the port selected in the accumulator. Twice the read value is needed for the next few main program lines that determine which routine to execute. Line 31 moves the address of label JMPTBL (Jump Table) to the 16-bit Data Pointer (DPTR) register. Line 32 causes a program jump to the address that is the sum of the value in the accumulator (two times the routine number selected) plus the DPTR register. Since each of the commands on lines 33 through 40 are two byte commands, these addresses are all separated by two bytes; hence, the need for the accumulator to contain a number that is twice the number of the selected routine. Routine 0 This routine begins on line 41 by incrementing the 10-bit word in registers 7 and 6 by the amount indicated by the setting of the INCREMENT SELECT switch, then sending that word to the SA5775. When a full scale overflow is detected, a full scale code (3FF hex) is sent out, followed by a delay of 500 ms, then successive output codes are sent out, decremented by an amount indicated by the INCREMENT SELECT switch. When an underflow is detected a code of zero scale is sent and the routine returns to the beginning of the program. This routine is implemented with a series of subroutine calls. The SO subroutine begins on line 356 and starts by sending out whatever ten bits that in the two LSBs of register 7 (R7) plus the 8 bits of R6 by calling the SENDIT subroutine. Then it calls the UP subroutine, which increases the word value to be sent out. The program then jumps to the beginning of this subroutine, repeating the process of sending out a word and incrementing to the next word until an overflow from the tenth bit (bit 2 of R7) is detected at line 362. The SENDIT subroutine (beginning on line 476) brings the CS line high, sets a bit counter (R1) to 2 (to send out two bits of R7), brings the value of R7 to the accumulator, rotates the accumulator to the right three times through the carry bit to bring the two LSBs to the position of the two MSBs, calls the SEND1 routine, which sends the number of bits in the accumulator, starting with the MSB, indicated by R1. Counter R1 is then set to 8 to send out all 8 bit of R6 and the accumulator is loaded with the contents of R6. The SEND1 routine is again called to send out the final 8 bits, and, on line 491, the CS line is brought low, loading the SA5775 internal parallel latch with the contents of the input shift register.

6 7 8

NE555 Timer
The NE555 timer shown in this application example is used as a free running squarewave generator used to simulate sensor inputs such as those which might be found in an automobile, etc. The NE555 timer (U4) operates in the astable mode to produce an output frequency that can be varied from about 1Hz to about 200 Hz. Three of the program routines measure the input period and produce an output code that is proportional to the frequency present at pin 20 (TO) of the microcontroller. A RATE switch (S7) is used to select between the on board oscillator or an external source. The program listing is included at the end of this application note. Program Entry The program starts at address 030(hex) on line 21 of the program listing. The first task is to write 1's to all pins of each port. Lines 25 and 26 clear registers 6 and 7. These registers are used in this program only to hold the data that is sent out to the SGD. The registers are cleared to be sure that the starting value is zero. At line 27 the program waits until the START/COUNT button (S5) is depressed before continuing. Lines 28 and 29 set the timer to overflow after 10ms. This is done by setting the timer registers for a count of 10,000 microseconds less than full scale. When the timer counter overflows the timer flag is set, and the timer is reloaded with the value in the timer register. By examining the timer flag we know when 10ms has expired. Line 30 calls subroutine RPS (Read Port Selected), which reads Port 3 to determine which routine has been selected. Since the PROGRAM SELECT switch (S3) is connected to port pins P3.2 through P3.4, subroutine RPS (lines 507 through 511 at the end of the program) first reads Port 3 into the accumulator, then complements it because the switches used are complementary binary. The reading is then rotated right once and the upper nibble and the LSB (least significant

NOTE: D package available in large SO (SOL) package only.

SU00374A

Figure 3. D and N Packages

87C751 Microcontroller
The 87C751 microcontroller provides all of the intelligence in this application. It samples various input ports to determine which demonstration programs to run, the incremental step sizes for angular displacement of the meter core, and the time delay between increments. In one of the demonstration modes, it also samples a variable frequency input and positions the meter core in response to the frequency of that input. The 87C751 also transmits the 10-bit serial data to the SA5775. Data input (DI), Clock (CLK), and Chip Select (CS) lines are driven from the 87C751. Port 0 of the 87C751 is a 3-bit wide port and is used for communicating data to the SGD. Data is transmitted, MSB first, in a serial stream clocked into the DI of the SA5775 on the rising edge of the clock. In order to clock in data, the CS pin of the SA5775 must be high. The data in the input register is shifted into a latch that drives the DAC on the high to low transition of the CS line. As data is shifted into the SGD, it overflows through the Data Out (DO) pin on the falling edge of the clock. With this facility, multiple SGDs can be daisy-drained with DO of one SGD being connected to DI of the next one, and common clock and chip select lines may be used. This simplifies the interfacing to multiple meter drivers. The 78L05 regulator (Q2) provides 5 Volt power for the board so that single supply of +14 volts can be applied to the board. Three rotary switches are used on this board. The PROGRAM SELECT switch (S3) is used to select the program routine that is January 1992

5-10

Philips Semiconductors

Application note

Controlling air core meters with the 87C751 and SA5775

AN426

6

5

7

4

3

2 8 9 Logic 1 10 16 DAC MUX 15

Shut-Down Logic

11

12

13

14

SU00375

Figure 4. Block Diagram of the SA5775 The SEND1 routine rotates the accumulator left through the carry bit, moves the value of the carry bit to port pin PO.1 (SDA--Serial Data pin), waits to provide a setup time, brings the clock low, waits, brings the clock high, waits, then decrements bit counter sends the next bit if the counter is not zero. A return is executed when the counter becomes zero. The UP subroutine, beginning at line 364, reads the delay selected by switch S4 at port pin P1, complements it (again, because the rotary switches are complementary binary), masks off the upper four bits (because the delay switch has just four positions and is connected to the lower four bits of the port), multiplies it by 4 (rotates left twice), then moves the result to R1. If R1 is not zero, the program jumps around line 376 and calls a 10ms delay (subroutine DLY10MS) the number of times entered into R1. The 10ms delay subroutine (starting at line 436) sets the timer for 10ms, waits at line 446 for the timer flag to be set, clears the timer flag, stops the timer, and returns, in this case, to line 379, where the program decrements R1 and repeats the 10ms delay until R1 is zero. If the selected delay was zero, the program jumps from line 376 to line 380 and reads port 3 to determine the amount the sent out word is to change from the value previously sent out. The accumulator is complemented and the upper 6 bits masked off to recover only the two bits of the selected increment amount. Since increments of 1, 2, 3, or January 1992 4 LSBs are hardly noticeable, the program then multiplies the result by 8 (rotate left three times). To insure a minimum change amount, the accumulator is increment by one at line 386. This all means that the increment amounts that can be selected are 1, 9, 17, or 25 LSBs. This amount is added, in lines 387 through 391, to the word previously send out and we return from this subroutine. After calling the S0 subroutine, PR0GO call the FULLSC (full scale) subroutine, which sends out the full scale code of 3E8(hex). Although a 10-bit full scale code would be 3FF(hex), going only to 3E8 allows an easy distinction between zero scale and full scale when looking at the display. The FULLSC subroutine is found at line 352. After advancing to full scale, there is a 500ms delay, found at line 464 and called from line 48, then 49 calls the S0D subroutine to send out decreasing word values. The S0D subroutine begins at line 393 and begins by sending out the current word in R7 and R6 from line 398, then calling subroutine DOWN, which calculates the next (decreasing) word to send out. DOWN begins at line 402. It essentially does the same thing as the UP subroutine, but subtracts the INCREMENT SELECT value from the previously sent word rather than adding to it. At line 50 subroutine ZEROSC is called to send a zero scale code to the SA5775, then the program branches back to the beginning. Routine 1 This routine is selected with the PROGRAM SELECT switch is in position 1 or position 9. Routine 1 (PROG1) increments or decrements the word send out, depending upon the setting of the COUNT UP/COUNT DOWN switch, S6. The amount of change is determined by the setting of the INC SELECT switch, S2. At line 63, the program examines S6 at port pin P3.6 and jumps to the decrement portion of the routine if the pin is low. If this pin is high, the UP subroutine is called from line 64 to increase the R7/R6 word value. The UP subroutine was previously described. If pin P3.6 is low, the DOWN subroutine (line 402) decreases the previous word sent out by the amount determined from the INC SELECT switch setting. To insure enough delay to allow the user time to release the START/COUNT button (S5), a delay of 200ms is included at line 66 before jumping to line 27, where another depression of the START/COUNT button is awaited. If S3 (PROGRAM SELECT) is still set to 1 or 9, depression of S5 will cause a jump back to line 52. If another program is selected, the program will jump to the selected routine. Holding down S5 with PROGRAM SELECT set at position 1 or 9 will cause increasing or decreasing word values to be sent to the SA5775.

5-11

Philips Semiconductors

Application note

Controlling air core meters with the 87C751 and SA5775

AN426

Routine 2 PROG2 is the most complex of all these routines. The purpose of this routine is to cause the air core meter deflection to represent the frequency presented at the timer/counter input to the microcontroller. This is done by measuring the period of the input square wave and taking the inverse of the period. The input here must be a square wave because a slow rise and fall time at this input will cause fluctuating readings. To determine the frequency by counting pulses for a time would require a much longer time and, therefore, is impractical. The MEAS (measure) subroutine is called at line 79 to measure the period of the input waveform and the CALC (calculate) subroutine is called at line 80 to calculate the code to send to the SA5775. The SENDIT subroutine is then called to send the word to the SA5775 and the program jumps back to line 28. The MEAS subroutine begins at line 83 by being sure the timer is not running and clearing the timer (overflow) flag, then entering zero into both high and low bytes of the timer and the timer register. The carry bit is then cleared (line 90) and the timer started and the timer interrupt enabled. Lines 93 and 94 form a short loop that waits until either the carry bit is set or until the TO input is low. The carry bit is set when the timer has gone beyond one second. This is done by the timer interrupt subroutine, found at lines 16 through 19. If the TO input never goes low, we know the frequency is at or near zero and the program jumps to GZS (line 108) where R3 is loaded with a 1F (hex) to cause the CALC subroutine to load zero scale into R7/R6. When (and if) TO is found to be low, the program jumps to line 95 and waits for that input to go high. Time out process is the same as above. Now that the TO input is found high (if is is before the one second time out), the timer and carry bit are cleared in lines 97 through 100 (R3 is an extension of the timer). At lines 101 through 107 we wait for one complete cycle at the TO input, with the timer/counter measuring that period, then return to line 80, where the CALC subroutine is called.

The CALC subroutine, starting at line 113, begins by initializing the word to send out (R7/R6) to zero, clearing the carry bit, checking to see if R3 indicates a time above one second, returning to line 81 if it does. Otherwise the program continues at line 26, where the program checks to see if the input frequency is beyond full scale (timer reading above 00 12 88 hex). If it is, R7/R6 is loaded with 12 88 hex (full scale of decimal 1,000). This value was chosen because it is sufficiently far from zero scale that it is easily discerned from zero scale on the display. If the result is not to be full scale or zero scale, the program continues at line 140 with a shift and subtract divide routine. The dividend would be 1,000,000 (decimal) to convert back to frequency in Hertz (period measurements is in microseconds), but that would provide a maximum count of 200 at 200Hz, only one fifth of the full scale desired of 1,000. So we made the dividend to be 5,000,000 decimal, or 4C 4B 40 hex. This algorithm is found in lines 156 through 192 and works as follows: 1. Clear a counter. 2. Rotate dividend until the first one is in the second MSB position. Since a code of 4C has already provides that, no shifting is necessary. 3. Rotate the divisor (the period in microseconds in this case) left until the first one is in the second MSB position, but the first byte is LESS THAN the first byte of the dividend. Increment the counter each time the divisor is rotated. 4. Initialize a counter to zero. 5. Rotate the quotient (answer) and dividend one bit left. 6. If first byte of quotient is smaller than the first byte of the quotient, jump to step 8. 7. Add one to the quotient and subtract the divisor from the dividend. 8. Decrement the counter and go to step 5 if it is not zero. Once the CALC subroutine is completed, the program calls SENDIT from line 81 and jumps, ultimately, to the selected routine. Routine 3 PROG3, beginning at line 194, measures the input period four times, then calculates the code to display that is the average of these four readings.

It starts by setting a counter for three readings, taking those three readings and storing them in memory, beginning at RAM address 20 hex, using register RO as an index register. At line 212 the program takes a fourth reading, then adds the three previous readings to it in lines 213 through 227; and divides the sum by four (rotates right twice) in lines 229 through 239. The word to send out is then calculated from line 240 and sent to the SGD, after which the program then looks for and jumps to the selected routine. Routine 4 PROG4 begins at line 243 and displays the average of the current and last three words sent out. RAM space used is first initialized to zero and a new reading is taken and a new word is calculated and saved. At lines 264 through 284, the new word is added to the last three readings and the average calculated and stored in RAM locations 28 and 29 (hex), and the average word is sent out. At line 286, the program reads for the program selected and jumps to line 254 if this routine is selected, otherwise it goes to line 28. Routine 5 PROG5 begins at line 293 and, very simply, send in sequence the codes for 1/8 through full scale in 1/8 scale steps, with 500ms between steps. It then steps down to zero scale in 1/8 scale steps, then returns to line 28. Routine 6 PROG6 begins at line 314 and does the same as PROG5, but steps in 1/4 scale increments. Routine 7 PROG7 loads the code for 3/8 scale into R7/R6, sends it, waits 500ms, changes r& for 5/8 scale, sends it, waits for 500ms, then repeats this sequence 9 more times (for a total of ten times), waits 500ms, then returns the output to zero scale and the program jumps to line 28.

January 1992

5-12




Others parts begin by an
AN-1   AN-2   AN-3   AN-4   AN-5   AN-6   AN-7   AN-8