Keywords: DS1858, DS1859, DS1847, DS1848, fiber, digital resistor, SFF-8472, optical diagnostics, laser driver, internal calibration, look-up table, temperature compensation, analog to digital, a/d, a to d, adc, converter
Related Parts |

APPLICATION NOTE 2858

Abstract: What sets the DS1859 apart from the crowd is its internal calibration and right shifting (scalable dynamic ranging) features. When used in conjunction, these features greatly enhance the DS1859's 12 bit analog-to-digital converter (ADC), giving it the precision and accuracy of up to a 16 bit ADC without the added cost and size. Furthermore, the DS1859's internal calibration features both programmable gain and programmable offset, eliminating most, if not all, external signal conditioning circuitry. By providing programmable gain in the analog domain before the ADC, the input signal can be amplified/attenuated to make use of the entire range of the ADC. Then, while in the digital domain, right shifting can then be used to scale (divide) the digital output back down so that the desired (or mandated by SFF-8472) LSB remains unaffected and even transparent to the user.

The purpose of this application note is to illustrate how an application can benefit from using internal calibration and right shifting. Furthermore, this application note will provide valuable information on how to implement internal calibration and right shifting. Finally, an example is provided to illustrate the application of the discussed topics.

As shown in the figure, a single-ended voltage is applied to a DS1859 MON pin. While in the analog domain, the voltage is fed into a programmable gain block capable of attenuation as well as gain. The gain block makes it possible to calibrate the MON channel to achieve a desired LSB or

Following the gain block is the 12-bit ADC. The 12-bit conversions are output left justified in 2 byte (16 bit) values. The ADC is capable of outputting digital values of 0000h to FFF8h.

Once in the digital domain, the DS1859 impressively takes internal calibration a step further by featuring a user-programmable digital offset capable of adding either positive or negative offset. The digital offset can be used to internally add positive or negative offsets by simply performing digital addition. It is important to point out that positive offsets will still clamp at the digital value of FFF8h, but the minimum digital value will now be greater than zero. Likewise, negative offsets will have a full-scale digital value of less than FFF8h (since the negative offset subtracts from the conversions). The minimum digital value in this case will remain at 0000h. Detailed information regarding the digital offset is provided later in the

The final operation before the digital values are output is Right Shifting. Each MON input has 3 bits, which control the number of desired right shifts. The benefits of right shifting will be discussed later. Setting the three bits to zero results in zero right shifts and disables the right shifting functionality. As was the same with offset, right shifting also affects the full-scale digital output. For example, if set to 2 right shifts, the full-scale digital output becomes 3FFEh. After the shifting is performed, the value is then written to the appropriate register where the user reads the conversion. This is also the value that is used for alarm and warning comparisons.

A factory-trimmed device will output one of 4096 digital values for input voltages from 0 to 2.5V, yielding a resolution of 610µV (2.5V/4096) for the 12-bit conversion. Ideally, the input signal to be digitized is a 0 to 2.5V signal so that the entire range is utilized. However, in real life, we know this will not always be the case. Take Receive Power for example, where voltages of 0 to .5V are common. It is a shame that 80% of the digital output codes will never be used. It is a waste that the 12-bit converter, capable of generating 4096 codes, will only be outputting one of 820 codes (20% of 4096). The remaining 3276 digital codes will never be used. Furthermore, of the 820 codes that are used, the resolution remains 610µV.

In an attempt to make use of more of the digital codes, it is tempting to re-calibrate at least the Receive Power MON input to a full-scale voltage less than 2.5V. However, doing so alone does not solve the problem because the LSB will change and no longer match the desired LSB. The way to solve the problem is by using internal calibration in conjunction with right shifting as described in the following section.

The benefit of using internal calibration and right shifting can best be illustrated in the example shown in Figure 2.

All three plots in Figure 2 are shown side-by-side on the same y-axis and scale so that for a particular point on the input signal (Figure 2A), a horizontal line can be drawn through the point and each of the transfer functions so that a rough approximation of the digital output can be made. Going back to the example input signal ranging from 0V to 0.5V, where 0.5V is indicated by the bold horizontal line across all 3 plots, the benefit of right shifting can be seen by comparing plots B and C. This simply reiterates that when the input range of the ADC spans a voltage range much greater than the range of the input signal, numerous steps will be wasted (see plot B). Only 819 of the 4096 are used. The remaining 80% in plot B are wasted. In contrast, plot C shows that by internally calibrating to a smaller full-scale voltage and using right shifting, the precision increased. Now 3276 of the 4096 digital codes are used to digitize the signal. The best part is that after right shifting, the desired LSB is maintained. The right shifting is transparent to the user. This can be verified by observing that both plots output approximately the same digital value.

1. | Set the right shift bits to 0. |

2. | Internally calibrate the part to yield the desired LSB (this will determine the initial full-scale voltage). |

3. | Apply the min and max input signal and read the corresponding digital outputs to determine the used range. |

4. | Determine what percentage of the ADC range is used. If the digital readings exceed 7FFFh, then right shifting should not be used (zero right shifts). However, if the digital readings are less than 7FFFh, then at least one right shift can be used. If the digital readings are less than 3FFFh, then two right shifts can be used, and so forth. Refer to Table 9 in the DS1859 data sheet for the remaining ranges. |

5. | In order to compensate for the division of the digital values, which result from right shifting, gain must be added in the analog domain so that the desired LSB is maintained. This is done by calculating a new full-scale voltage using the formula: new full-scale voltage = initial full-scale voltage / 2^{# of right shifts}. So, if the internal calibration from step 2 resulted in a full-scale voltage of 2.0V (in order to obtain the desired LSB), and digital readings were greater than 1FFFh but never exceeded 3FFFh, two right shifts would be ideal. The new full-scale voltage for this example is 2.0V/2² = 0.5V. |

6. | Internally calibrate the channel (with the right shift bits still set to 0) to the new full-scale voltage. |

7. | Set the right shift bits to their new value. |

Once the evaluation determines the ideal number of right shifts and the full-scale voltage for a particular application, only steps 1, 6, and 7 are needed for production calibration.

V_{CC} |
MON1 | MON2 | MON3 | |

Gain Cal | 92-93h | 94-95h | 96-97h | 98-99h |

Offset Cal | A2-A3h | A4-A5h | A6-A7h | A8-A9h |

Right Shifts | N/A | 8Eh (b6-b4) | 8Eh (b2-b0) | 8Fh (b6-b4) |

Readings | 62-63h | 64-65h | 66-67h | 68-69h |

Table 01h |

Programming the Gain Cal register, unfortunately, is not as simple as saying "I would like a gain of 4...so I will write a 4 into the Gain Cal register." Furthermore, due to device to device (and lot to lot) variation of the capacitors in the switched capacitor network, it really is necessary to calibrate the setting. The procedure for this calibration and for determining the value that needs to be written in the Gain Cal register is provided in the DS1859 data sheet in the section titled "Internal Calibration". Additional information is provided in this application note in the "How to Internal Calibrate" section.

One final note of caution when calibrating the DS1859, it is important to know the value of the both the offset and the right shifting registers. Otherwise, if they are non-zero and not compensated for, the device will not be calibrated as intended.

While the internal calibration pseudo code shown in the DS1859 "Internal Calibration" section of the data sheet shows how to determine the Offset Cal value needed to "null" out the offset, this section provides additional information as well as examples of positive and negative offset.

Offset Cal is calculated by first determining how many counts should be added to or subtracted from the conversions. One way this is typically done is by applying the null input (such as laser off) and then reading the conversion. This would be the value that you would have subtracted off of all the conversions.

The value that needs to be written into the Offset Cal register is calculated by inserting the desired count into the equation provided in the DS1859 data sheet and repeated below.

Offset Cal Register = [4000h - (Count/2)] XOR 4000h

Offset Cal register = [4000h - (C8h/2)] XOR 4000h = 7F9Ch

Keep in mind that in this case, a subtraction is being performed, so the full-scale count (FFF8h) will also decrease by C8h, giving a new full-scale count of FF30h.

Offset Cal register = [4000h + (C8h/2)] XOR 4000h = 0064h

To calculate the new full-scale count you would (attempt) to add C8h to FFF8h. However FFF8h is the maximum possible reading, so the full-scale count would remain FFF8h.

Offset Cal register = [4000h - (0/2)] XOR 4000h = 0000h

This also happens to be the factory default for the Offset Cal register.

To further illustrate the result of right shifting,

In order to use the pseudo-code algorithm, one must have the ability to set the laser to two different intensities, for example minimum and 90% of the maximum, and also have ability to go through multiple iterations. For non-optical applications, two different voltages must be applied on command to the MON inputs. The algorithm provided in the data sheet uses 90% of maximum so that the upper limit is less likely to clamp. However, when applying a percentage of the desired full scale it is important to calculate the corresponding percentage of the digital values as well.

The algorithm begins by setting the offset and right shifting registers to a known state, namely zero offset and zero right shifts. Although this example sets both registers to zero, other values can be used as long as they are compensated for. For example, when starting out with a programmed offset, FFF8h may no longer be the clamped, full-scale digital value (see the Offset Cal Register section). In addition to initializing registers, the algorithm begins by also calculating a few important constants, which are a function of the desired LSB.

The binary search for the gain value begins by setting the Gain Cal register to half scale, 8000h. The gain value is then tested by applying the 90% maximum input to the MON channel being calibrated and then reading the corresponding digital conversion. This value is then called Meas2. Meas2 is checked to see if it is clamped, FFF8h (since offset and right shifts are zero). If the reading is clamped, it cannot be concluded whether the conversion is actually FFF8h or if it is much greater (which is also FFF8h). Either way, the gain setting is too high. In binary search fashion, the gain value is cut in half and the process repeats until a non-clamping gain value is found.

As soon as a non-clamping Meas2 is found, the algorithm continues by forcing the null input and reading its digital conversion. This conversion becomes Meas1. Finally, the delta between Meas2 and Meas1 is calculated and compared to the desired delta (CNT2-CNT1) using the constants calculated at the beginning of the algorithm. If Meas2-Meas1 is less than CNT2-CNT1, then the gain is again cut in half. Otherwise, if Meas2-Meas1 is greater than CNT2-CNT1, then the gain is increased by cutting the gain in half and this time adding it to the current gain. The process repeats until a total of 16 iterations are performed. The resultant is a 16-bit value that yields the desired gain (and desired LSB).

An alternate way of visualizing the gain calibration procedure is as follows. Beginning with the MSB (b15) of the 16 bit Gain Cal register, set the bit to a 1 (all other bits are initially set to 0). With the MSB = 1, the process of applying the analog input and reading the digital output is performed. If the reading is clamped, then the gain is too high and the MSB is written back to a 0. Otherwise, the MSB remains a 1. The MSB is now known. Now on to the next bit, b14. Set b14 to 1 (leave b15 set to what was already determined). Bits 13 down to b0 are still 0. Again go through the process to determine if the gain is still too high. If so, then b14 becomes a 0. Otherwise, it becomes a 1. The procedure then continues bit by bit until all 16 bits are determined. The result is again a 16 bit value which yields the desired gain.

Once the desired gain is achieved, a new offset can be calibrated or it can be left at 0 (no offset). The method of calibration depends on how the offset feature is to be used. The explanation accompanying the algorithm in the data sheet assumes that the user wants to apply negative offset to null out the digital readings so that the null analog input will produce all zeros output. This is done simply by applying the null analog input and reading the conversion. If the null input (laser off for example) produces a digital output of say 20h, the offset can be programmed such that 20h will be digitally subtracted from every conversion. In this example, 20h is substituted into the offset formula and the result is then programmed into the Offset Cal register for the desired MON channel.

In this example, MON3 is used to monitor Rpower. When the minimum input of -40dBm is applied, a voltage of 10mV is presented to the MON3 pin of the DS1859. The desired digital output for this input is 0000h. When a 0dBm input is applied, 300mV is presented to MON3. The desired digital output in this case is 2710h and was chosen in order to satisfy the LSB dictated by SFF-8472 (the LSB for Rpower is 0.1µW).

Determining the ideal number of right shifts for this example is relatively simple since the range of the desired digital output has been given (0000h-2710h). Using Table 9 of the DS1859 data sheet, the ideal number of right shifts is 2. Now with 2 right shifts in mind, in order for a 2710h to be the final output

Customer Signal Rpower (dBm) | Voltage applies to MON3 pin (mV) | Digital outputs during cal. (0 right shifts)(hex) | Final Digital output (2 right shifts)(hex) |

-40 |
10 |
0000 | 0000 |

50 | 0563 | ||

100 | 0C1F | ||

150 | 12DB | ||

200 | 1997 | ||

250 | 2051 | ||

0 |
300 |
9C40 | 2710 |

Once the relationship between input and output is determined (shown in Table 2), the internal calibration routine provided in the data sheet is used to internally calibrate the device. The routine begins by performing some preliminary calculations, which are shown below. Notice that the 90% shown in the data sheet routine is not used here because the second calibration point (300mV = 9C40h) is already less than 90% of the full scale value. Therefore the internal calibration routine used in this example has all references to the 90% removed.

Given Table 2, the following calculations are made.

LSB = (0.300V - 0.010V)/(9C40h - 0000h) = 0.290V/40,000 = 7.25µV

Full Scale Voltage = FS = LSB × 65535 = 7.25µV × 65535 = 0.475128V

CNT1 = 0.010/LSB = 1379.3 => 1379 (dec)

CNT2 = 0.300/LSB = 41379.31 => 41379 (dec)

CNT1 and CNT2 are the expected (desired) digital outputs when the two calibration points are applied. The internal calibration routine will iterate in search for a slope as close as possible to the slope determined by these two values.

The iterative portion of the routine goes through 16 cycles of programming a slope in a binary search fashion and then checking if it is equivalent to the desired slope. For the purpose of this example, a DS1859 was calibrated using the internal calibration procedure and the inputs and outputs of all 16 iterations are shown in

The first column of Table 3, Iteration, is equivalent to n in the routine. The column

Iteration | gain_result | Meas2 | Meas1 | Meas2 | Meas1 | Meas2-Meas1 | CNT2-CNT1 | bit result | Gain Cal |

(dec) | (hex) | (hex) | (dec) | (dec) | (dec) | (bin) | (hex) | ||

15 | 8000 | fd58 | 870 | 64856 | 2160 | 62696 | 40000 | 0 | 5 |

14 | 4000 | 82a0 | 450 | 33440 | 1104 | 32336 | 40000 | 1 | |

13 | 6000 | c010 | 658 | 49168 | 1624 | 47544 | 40000 | 0 | |

12 | 5000 | a138 | 558 | 41272 | 1368 | 39904 | 40000 | 1 | |

11 | 5800 | b0b8 | 500 | 45240 | 1280 | 43960 | 40000 | 0 | 0 |

10 | 5400 | a938 | 5a0 | 43320 | 1440 | 41880 | 40000 | 0 | |

9 | 5200 | a530 | 578 | 42288 | 1400 | 40888 | 40000 | 0 | |

8 | 5100 | a328 | 568 | 41768 | 1384 | 40384 | 40000 | 0 | |

7 | 5080 | a238 | 568 | 41528 | 1384 | 40144 | 40000 | 0 | 3 |

6 | 5040 | a1a8 | 560 | 41384 | 1376 | 40008 | 40000 | 0 | |

5 | 5020 | a170 | 558 | 41328 | 1368 | 39960 | 40000 | 1 | |

4 | 5030 | a190 | 558 | 41360 | 1368 | 39992 | 40000 | 1 | |

3 | 5038 | a198 | 558 | 41368 | 1368 | 40000 | 40000 | 1 | 8 |

2 | 503C | a1a0 | 558 | 41376 | 1368 | 40008 | 40000 | 0 | |

1 | 503a | a1a0 | 558 | 41376 | 1368 | 40008 | 40000 | 0 | |

0 | 5039 | a1a0 | 558 | 41376 | 1368 | 40008 | 40000 | 0 |

With the device programmed to its new Gain Cal value, the Offset Cal is determined by forcing 10mV (the voltage which we want to read 0000h) and reading the digital result. The device used in this example output a value of 0558h with 10mV applied. Using the offset formula, the Offset Cal is calculated as shown below.

MON3 Offset Cal = [4000h - 0558h/2] XOR 4000h = 7D54h

And finally, the new clamp value can be calculated as follows:

New clamp value (pre- right shift) = FFF8h - 0558h = FAA0h

With the internal calibration complete, the 2 right shifts are enabled by writing 20h to Table 01h, location 8Fh.

Questions/comments/suggestions concerning this application note can be sent to: .