APPLICATION NOTE 6262

RTD Measurement System Design Essentials


Abstract: This application note describes the methods to minimize error in RTD temperature measurement.

Introduction

High-accuracy temperature measurements provide essential data for industrial automation applications to ensure both product quality and safety. Many types of temperature sensors are available, and each one has its advantages and disadvantages. This application note focuses on resistance temperature detectors (RTD), and explains the design essentials to optimize the measurement accuracy.

Resistance Temperature Detectors

RTDs contains an element whose resistance changes with temperature. Most elements are either platinum, nickel, or copper. A platinum RTD provides the best performance because platinum has the most linear and repeatable temperature-to-resistance relationship over a large temperature range.

Generally, RTDs generate more stable and repeatable outputs, compared to thermocouples and thermistors. Hence, RTDs achieve higher measurement accuracy.

High-Accuracy RTD Measurement Design Options

The two most common methods to measure an RTD are constant current excitation (Figure 1) and constant voltage excitation (Figure 2).

The goal is to accurately measure the RTD resistance and convert it to temperature using an equation or a lookup table. For ideal cases:

Equation 01. for constant current excitation,

or

Equation 01. for constant voltage excitation.

However in practice, the lead wires of the RTD have resistance. Long lead wires greatly affect the measurement accuracy. Therefore, the actual resistance measured by the circuits shown in Figures 1 and 2 is:

RTD + (2 × RWIRE),

where RWIRE is the resistance of the lead wires, assuming both wires have the same resistance. Although theoretically acceptable, the same RWIRE implies that both wires are of the exact same length and made with the exact same material. Such an assumption cannot be guaranteed in critical temperature sensing applications. For this reason, RTDs feature 3-, and 4-wire configurations to help eliminate the measurement error contributed by lead wires.

2-wire constant current excitation configuration. Figure 1. 2-wire constant current excitation configuration.

2-wire constant voltage excitation configuration. Figure 2. 2-wire constant voltage excitation configuration.

3-Wire RTD Configuration

Typical constant current and constant voltage excitation circuits for 3-wire RTD are shown in Figure 3 and Figure 4, respectively. In both cases, the ADC samples a resistance of RTD + RWIRE3 (where RWIRE3 is the resistance of the return lead wire). The system eliminates RWIRE2 because the ADC inputs are typically high-impedance and virtually no current flows through RWIRE2. Therefore, the ADC only measures the voltage across RTD and RWIRE3. RWIRE3 contributes to measurement error. Compared to 2-wire configuration, however, the error contributed by the lead wires are reduced by roughly 50%.

One method to further improve the measurement accuracy is by adding an analog switch to the circuit. The ADC then measures the voltage (VX) at the output of the excitation signal and obtains a value for RWIRE1. By assuming RWIRE1 is approximately the same as RWIRE3, the RWIRE3 can be subtracted out. Referring to Figure 3, in current excitation configuration, RWIRE1 resistance equals to:

Equation 03.

And, the improved approximation of the RTD resistance is:

Equation 04.

For voltage excitation configuration:

Equation 05.

and

Equation 06.

This method to improve the measurement accuracy does require extra hardware and adds complexity to the software.

3-wire constant current excitation configuration. Figure 3. 3-wire constant current excitation configuration.

3-wire constant voltage excitation configuration. Figure 4. 3-wire constant voltage excitation configuration.

4-Wire RTD Configuration

A 4-wire RTD configuration provides the highest measurement accuracy. Figure 5 and Figure 6 show the constant current excitation and constant voltage excitation circuits, respectively, for 4-wire RTD. For current excitation configuration,

Equation 07.

because no current passes through RWIRE2 or RWIRE3. Therefore, the voltage across RWIRE2 + RTD + RWIRE3 is the same as the voltage across the RTD. Unfortunately, when using a constant voltage excitation configuration, because of the voltage divider effect, RWIRE1 and RWIRE4 still creates errors in the RTD measurement unless the ADC system has the ability to measure the voltage at the excitation voltage output (VX). If the voltage at VX is known, then the reference current can be calculated by

Equation 08.

where RREF is 3.32kΩ in this case. Similarly,

Equation 09.

is the same as the formula for the current excitation configuration.

Many other factors in the signal chain affect the accuracy of measurement. These factors include the input impedance of the ADC system, the resolution of the ADC, the amount of current through the RTD, the stability of the voltage reference, and the stability of the excitation signals.

The inputs of the ADC system must be high impedance to avoid voltage drops across the lead wires (RWIRE2 and RWIRE3 in 4-wire configuration for example). If the ADC doesn't have high impedance inputs, buffers should be added in front of the inputs of the ADC.

4-wire constant current excitation configuration. Figure 5. 4-wire constant current excitation configuration.

4-wire constant voltage excitation configuration. Figure 6. 4-wire constant voltage excitation configuration.

Heating Error

Although an RTD is a sensor, it is also a resistor. When current passes through a resistor, there is power dissipation. The dissipated power heats up the resistor. This self-heating effect creates error in the measurement. Excitation current must be carefully chosen to ensure the error created is within the error budget. The key formula to calculate the self-heating error is

ΔT = (I2REF ×RRTD) × F,

where F is the self-heating factor of RTD, expressed in mW/°C. For example, a PT-100 platinum RTD with a 0.05°C/mW self-heating factor submerged in ice water. When the measuring temperature is 0°C, RRTD equals to 100Ω. If the IREFis set to 10mA, the self-heating error becomes

((0.01A)2 × 100Ω) × 50°C/W = 0.5°C.

Depending on the application, this error may or may not be acceptable. For high-accuracy measurements, a lower excitation current reduces the self-heating error. For example, if IREF is lowered to 1mA, the self-heating error becomes 0.005°C. This level of error is much more tolerable. While reducing the excitation current reduces the self-heating error, it also reduces the voltage signal span across the RTD, thus requiring the RTD signal to be amplified so that the ADC can extract more discrete signal levels. An alternative would be to use a higher resolution ADC.

Up to this point, all the formulas discussed involve either IREF or VREF. But, what if these excitation signals are not stable? Instability can result from short term or long-term drift. Clearly, if the excitation signals become inaccurate, all the calculations above have errors. Consequently, periodic calibrations are required. Of course, an engineer could use a super stable voltage reference with ultra-low temperature drift and long-term drift. However, usually such devices are very costly. Alternatively, the ratiometric temperature measurement method eliminates errors caused by inaccurate excitation signals.

Ratiometric Temperature Measurement

A ratiometric measurement provides measurement of the resistance of the RTD as a ratio of the reference resistance, instead of measuring the resistance using an absolute voltage. In other words, RRTD will be a function of RREF instead of VREF or IREF. This uses the same excitation signal to generate both the voltage across the RTD and the voltage reference for the ADC. When the excitation signal changes, that change is reflected on both the voltage across the RTD and the reference inputs of the ADC. Figure 7 and Figure 8 show the ratiometric measurement circuits for current excitation and voltage excitation configurations.

The general ADC conversion formula is:

Equation 10.

where

VIN = ADC input voltage
VREF = reference voltage (REFP - REFN)
CODE = ADC code
N = resolution of the ADC.

VIN equals the voltage across the RTD. For current excitation mode

VIN = IREF × RRTD and VREF = IREF × RREF.

Substituting VIN and VREF into the ADC conversion formula yields,

Equation 11.

and subsequently,

Equation 12.

Similarly for voltage excitation,

Equation 13.

Substituting VIN into the ADC conversion formula yields,

Equation 14.

Solving for RRTD gives,

Equation 15.

In both cases, after the simplification, RRTD becomes a function of RREF and ADC code; hence, the accuracy of the RTD measurement depends on RREF. For this reason, when selecting a reference resistor, the engineer must pick one with low temperature and long-term drift.

Current excitation configuration for ratiometric measurement. Figure 7. Current excitation configuration for ratiometric measurement.

Voltage excitation configuration for ratiometric measurement. Figure 8. Voltage excitation configuration for ratiometric measurement.

RTD to Temperature Conversion

No matter how well the circuit measures the resistance of the RTD, all efforts are wasted if the engineer does not have a good method to accurately convert RTD resistance to temperature. One common method is to use a lookup table. However, if the resolution requirement is high and the measuring temperature range is wide, the lookup table becomes unwieldy, and the method less effective. Another method is to calculate the temperature.

For a platinum RTD, the Callendar-Van Dusen equation describes the relationship between resistance and temperature as:

R(t) = R0 × (1 + A × t +B × t2 + (t - 100) × C × t3),

where

R(t) = RTD resistance
t = temperature
R0 = resistance of the RTD at 0°C
A = 3.908 × 10-3
B = -5.775 × 10-7
C = -4.183 × 10-12 when t < 0°C
C = 0 when t > 0°C

This equation provides the expected RTD resistance given a known temperature. If the temperature range of interest is above 0°C, then the constant C becomes 0 and the equation becomes a quadratic formula. Solving a quadratic equation is straightforward. But, if the temperature goes below 0°C and the C constant becomes non-zero, the equation becomes a difficult 4th order polynomial. In this case, polynomial interpolation approximation is a very useful tool. Here is a Microsoft Excel solution:

  1. On a spreadsheet, create two columns of data. One column lists the temperature. The second column lists the corresponding RTD resistances calculated from the Callendar-Van Dusen equation.
  2. Create an X-Y scatter plot.
  3. Add a polynomial trendline for the plot. A higher order of the polynomial gives a more accurate approximation.
  4. Select "Display Equation on Chart" in the "Format Trendline" menu.

The resulting polynomial equation for a PT100 for t < 0°C is:

t = -1.6030e -13 × r6 + 2.0936e -10 × r5 -3.6239e -8 × r4 -4.2504e -6 × r3 + 2.5646e -3 × r2 + 2.2233 × r -2.4204e2

Increasing the decimal places of the polynomial coefficients reduces error. With four decimal places, as shown in the formula above, the temperature approximation error is less than 0.005°C, tolerable for most applications.

Maxim Reference Design Solution

MAXREFDES67# System Board. Figure 9. MAXREFDES67# System Board.

MAXREFDES67# reference design implements the 4-wire ratiometric configuration and polynomial approximation, as described above. In addition, design files and firmware are available for subsequent modification and implementation. Furthermore, this reference design (Figures 9, 10, 11) is a complete universal analog input for industrial applications. Besides RTD measurement, this unique 24-bit front-end also accepts bipolar voltage and current, and thermocouple (TC) inputs. Built in Maxim Integrated's ultra-small Micro PLC form factor, the MAXREFDES67# performs with an effective resolution up to 22.3 bits with temperature error as low as ±0.1% across a range of -40°C to 150°C. Figure 12 shows the temperature error measured by the MAXREFDES67# RTD input versus temperature referenced to three different thermometers. The references are the Omega HH41 thermometer, the ETI reference thermometer, and Fluke 724 temperature calibrator, respectively. The MAXREFDES67# connected RTD probe (Omega P-M-1/10-1/4-6-0-G-3) was placed in the Fluke 7341 calibration bath and calibrated at 20°C.

  Distributor book cost is not available. Please Request a Quote in Model N "); $("#inventoryDetails").removeClass("col-sm-6"); $("#inventoryDetails").addClass("col-sm-12"); } else { var partNumber = encodeURIComponent(part_no); var htmlBulkOrder = "

" ; $("#buyQuantityDiv").html(htmlBulkOrder); } } } if( sampleJson.canQuote != true ) { $("#requestQuoteDiv").hide(); } if(sampleJson.leadTime == 0 && !(sampleJson.cf == "true" && sampleJson.carrierType == "Tape") ){ if($('#requestQuoteDiv').css('display') != "block") { $('#forLeadtime').removeClass('hidden'); } //$('#quantity5000').show(); } if(maxInventory == 0) { $("#stdleadTime").html('Lead time'); } if(params == 'Quote'){ $('#rowDiv').addClass("hidden"); $("#quoteRow").removeClass("hidden"); $("#nonQuote").addClass("hidden"); } else { if(leadTime != "" && leadTime != "undefined" && (parseInt(leadTime) > 0 && parseInt(leadTime) < 98) || parseInt(leadTime) == 0 ){ }else { if(userType != "DISTRIBUTOR") { $('#rowDiv div:not("#inventoryDetails,#requestQuoteDiv, #requestQuoteDiv2")').hide(); if($(".requestQuoteFromBuyCart").css('display') == 'none'){ $("#contactSales").show(); } } } } $('#addToCartP').modal('show'); if (userType == "EMPLOYEE" ) { $(document).find('#qtytobuyText').hide(); $(document).find('#product-quantity').hide(); $(document).find('#addToCartButton').hide(); $(document).find('#employeeMsg').show(); } if(sampleJson.cf == "true" && sampleJson.carrierType == "Tape" && maxInventory == 0){ $("#priceBreak").remove(); $("#orderingquotetext").remove(); $("#quantity5000").remove(); $('#useExistingQuote').remove(); $('#borderid').remove(); $('#inventoryDetails').removeClass('col-sm-6'); $('#inventoryDetails').addClass('col-sm-12'); $('#inventoryDetails').css('padding-left', '55px'); $('#inventoryDetails').css('padding-right', '55px'); $("#sotPartswithnostock").html('Unfortunately there is no inventory to support this request. We only sell this type of product when we have excess inventory available because this package type comes off of our testers in reels. When we have excess inventory from a lot that completes final test, we can sell this product on cut tape strips in quantities less than reel size until it is sold out, which is currently the case. Please change your order to the tape & reel part number (usually ending in +T or +T&R) if you would like to order this product or check with our distribution partners in your region for smaller quantities.'); } } } else { document.getElementById('buyParams').innerHTML = "Default"; digitalErrorFunction('System error occured. customer support for assistance.'); bootbox.alert('System error occured. customer support for assistance.'); } } }); var url = "/bin/checkQuoteAvailabilty?partNumber=" + encodeURIComponent(part_no) $.ajax({ url: url, dataType: "json", type: 'POST', async: false, xhrFields: { withCredentials: true }, success: function(data) { result = data; if(result != ""){ if(result.quoteList.quotes.quoteAvailable){ var quoteAvailable = result.quoteList.quotes.quoteAvailable; if(quoteAvailable == "true"){ $("#ortext").removeClass("hidden"); $('#useExistingQuote').show(); } } } } }); if (CQ_Analytics.PersonalInfoStoreMgr.getProperty("isLoggedIn") == "") { $.cookie("redirect","widget"); $.cookie("buy",buy); $.cookie("part_no",encodeURIComponent(part_no)); $.cookie("sampQty",sampQty); if(params == "ProductOrderTab"){ $.cookie("orderTab","true"); } } } else if (buy == "sample" && (CQ_Analytics.PersonalInfoStoreMgr.getProperty("isLoggedIn", true) || CQ_Analytics.PersonalInfoStoreMgr.getProperty("isLoggedIn", true) == "true")) { if(userType == "DISTRIBUTOR" || userType == "EMPLOYEE" ){ window.location.href = "https://shop.maximintegrated.com/backoffice/general/index.php?action=DISTRIBUTOR"; return false; } var userId = CQ_Analytics.ProfileDataMgr.getProperty("email"); var isSampleOrderAllowed = "true"; var sampleMessage = ""; var data = "userId="+userId; $.ajax({ type: "post", url: '/bin/validateSampleOrder', async: false, data: data, success: function(msg) { if(msg.error == "genericerrorText"){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); } else if(msg.status == false){ if(msg.message.match("^Your session expired")){ bootbox.confirm('Your session expired. Please login and try again.', function(result) { var authorizableId = CQ_Analytics.PersonalInfoStoreMgr.getProperty("authorizableId"); CQ.shared.Util.load("\x2Fbin\x2FLogoutServlet\x3Flanguage\x3Den"+"&authorizableId="+authorizableId); window.location="/en/mymaxim/login.html"; }); } else { digitalErrorFunction(msg.message); bootbox.alert(msg.message); } } else { isSampleOrderAllowed = msg.output.validateEmailDomain.isOrderAllowed; sampleMessage = msg.output.validateEmailDomain.message; var itemCount = msg.output.validateEmailDomain.itemCount; var orderCount = msg.output.validateEmailDomain.orderCount; if(localStorage.getItem(part_no) == 1) { mycart_widget("sample", function(status){ if(status && typeof _satellite != "undefined") _satellite.track("cart: add"); }); return false; } else { sampleAddToCart(isSampleOrderAllowed, sampQty, part_no, sampleMessage,itemCount,orderCount); } } } }); } else { $.cookie("redirect","widget"); $.cookie("buy",buy); $.cookie("part_no",encodeURIComponent(part_no)); $.cookie("sampQty",sampQty); if(params == "ProductOrderTab"){ $.cookie("orderTab","true"); } gigya.accounts.showScreenSet(aem.login.params); } } } function redirect_rochester(part_no){ var url = 'https://api.rocelec.com/parts/MAX/1?callback=callback&q='+ part_no +'&key=Z3kk1y*'; $.ajax({ type: 'GET', url: url, async: false, jsonpCallback: 'callback', contentType: "application/json", dataType: 'jsonp', success: function(json) { if(json.parts[0] != undefined){ if('permalink' in json.parts[0]){ window.open(json.parts[0].permalink,'_blank'); } else{ digitalErrorFunction('
Rochester currently does not carry this part, but you can contact them here to see if they are able to procure it. If not, please contact our technical applications engineers , who can help in finding a similar device you could use as a replacement.
'); bootbox.alert('
Rochester currently does not carry this part, but you can contact them here to see if they are able to procure it. If not, please contact our technical applications engineers , who can help in finding a similar device you could use as a replacement.
'); } } else{ if(typeof _satellite != "undefined"){ _satellite.track("rochester-popup"); } bootbox.alert('
Rochester currently does not carry this part, but you can contact them here to see if they are able to procure it. If not, please contact our technical applications engineers , who can help in finding a similar device you could use as a replacement.
'); } }, error: function(e) { console.log(e.message); digitalErrorFunction(e.message); } }); } function getDistrbutorInventoryData(partNumber) { if(typeof partNumber != "undefined" && partNumber != "") { var distributors = {}; var distributor_template = Handlebars.compile($("#distributorData").html()); var data = "query="+encodeURIComponent(partNumber); $.ajax({ type: "post", url: '/bin/distributorInventoryComponent', async: true, data: data, success: function(data) { if(data.error == "genericerrorText"){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); } else if(data != null || data != ""){ $('#distributor-loading-image').hide(); if(data != "") { var dataJSON = JSON.parse(data); dataJSON['code']=partNumber; $('#distributor-modal').html(distributor_template(dataJSON)); } } } }); } } function add_to_cart(part_no, buy, params, sampQty,quantity) { var userType = encodeURI(CQ_Analytics.PersonalInfoStoreMgr.getProperty("userType")); if(userType == "") { userType="anonymous"; } var userId = CQ_Analytics.ProfileDataMgr.getProperty("email"); if(params == 'Quote'){ $("#addToCartP").attr('data-quote-id', sampQty.quoteId); $("#addToCartP").attr('data-quote-item-number', sampQty.quoteItemNumber); } if (buy == "part") { var message = ""; var data = "userId="+userId; var isOrderAllowed="true"; $.ajax({ type: "post", url: '/bin/validateRevenueOrder', async: false, data: data, success: function(msg) { if(msg.error == "genericerrorText"){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); } else{ isOrderAllowed = msg.output.validateEmailDomain.isOrderAllowed; message = msg.output.validateEmailDomain.message; } } }); if(isOrderAllowed == "true") { var result; var small_template = Handlebars.compile($("#buyModalBody").html()); document.cookie="mySearchServlet="+window.location+";domain=.maximintegrated.com;path=/"; var servletName = "/bin/SFComponent"; var url = servletName + "?input=single&query=" + encodeURIComponent(part_no); $.ajax({ url: url, dataType: "json", type: 'POST', xhrFields: { withCredentials: true }, success: function(data) { result = data; if(result == "genericerrorText"){ document.cookie="mySearchServlet="+window.location+";domain=.maximintegrated.com;path=/"; digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); }else if (result != "") { if(result.errors != undefined && result.errors[0].message) { document.cookie="mySearchServlet="+window.location+";domain=.maximintegrated.com;path=/"; digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); }else { document.cookie="mySearchServlet="+window.location+";domain=.maximintegrated.com;path=/"; var sampleJson = result; var vol = sampleJson.volumePrices; sampleJson.userType = userType; var noPricingMsg = 0; minQty = sampleJson.min; mult = sampleJson.mult; if(vol != undefined && userType != "DISTRIBUTOR" ) { for (var i = 0; i < vol.length; i++) { var j = i + 1; var vol1 = ""; if (j <= vol.length) { if(vol[i].minQuantity < 1000) { stdPricingFlag = 1; if(j == vol.length) { vol1 = vol[i].minQuantity + "+"; } else { vol1 = vol[i].minQuantity + "-" + vol[i].maxQuantity; } } else if(vol[i].minQuantity == 1000) { vol1 = "1000+"; stdPricingFlag = 1; } else { if(i ==0 && vol[i].minQuantity > 1000) { //vol1 = "No standard pricing available"; noPricingMsg++; delete sampleJson.volumePrices[i].formattedValue; } else { delete sampleJson.volumePrices[i]; continue; } } } else if(j == vol.length && j == 1) { vol1 = vol[i].minQuantity + "-" + 24; stdPricingFlag = 1; } sampleJson.volumePrices[i].minQuantity = vol1; } } maxInventory = sampleJson.stock.atpInv; leadTime = sampleJson.leadTime; if (maxInventory == "" || maxInventory == undefined) { maxInventory = 0; } $('#addToCart').html(small_template(sampleJson)); if(userType != "DISTRIBUTOR") { call(quantity); } } } else { document.getElementById('buyParams').innerHTML = "Default"; digitalErrorFunction('System error occured. customer support for assistance.'); bootbox.alert('System error occured. customer support for assistance.'); } } }); } else { digitalErrorFunction('System error occured. Contact customer support for assistance.'); $('#revenuedomainerrordialog').modal('show'); } } else if (buy == "sample") { if(userType == "DISTRIBUTOR" || userType == "EMPLOYEE" ){ window.location.href = "https://shop.maximintegrated.com/backoffice/general/index.php?action=DISTRIBUTOR"; return false; } var isSampleOrderAllowed = "true"; var sampleMessage = ""; var data = "userId="+CQ_Analytics.ProfileDataMgr.getProperty("email"); $.ajax({ type: "post", url: '/bin/validateSampleOrder', async: false, data: data, success: function(msg) { if(msg.error == "genericerrorText"){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); } else if(msg.status == false){ if(msg.message.match("^Your session expired")){ bootbox.confirm('Your session expired. Please login and try again.', function(result) { var authorizableId = CQ_Analytics.PersonalInfoStoreMgr.getProperty("authorizableId"); CQ.shared.Util.load("\x2Fbin\x2FLogoutServlet\x3Flanguage\x3Den"+"&authorizableId="+authorizableId); window.location="/en/mymaxim/login.html"; }); } else { digitalErrorFunction(msg.message); bootbox.alert(msg.message); } }else{ isSampleOrderAllowed = msg.output.validateEmailDomain.isOrderAllowed; sampleMessage = msg.output.validateEmailDomain.message; var itemCount = msg.output.validateEmailDomain.itemCount; var orderCount = msg.output.validateEmailDomain.orderCount; if (localStorage.getItem(part_no) == 1) { mycart_widget("sample", function (status) { if (status && typeof _satellite != "undefined") _satellite.track("cart: add"); }); return false; } else { sampleAddToCart(isSampleOrderAllowed, sampQty, part_no, sampleMessage,itemCount,orderCount); } } } }); } } function sampleAddToCart(isSampleOrderAllowed, sampQty, part_no, sampleMessage,itemCount,orderCount) { if(isSampleOrderAllowed == "true"){ if(typeof orderCount != 'undefined' && parseInt(orderCount) >= 1){ bootbox.alert("Maxim's free sample policy limits the number of orders that each member is allowed.You have exceeded this maximum.If you feel you have received this message in error, please email samples-admin@maximintegrated.com "); return; } else if(typeof itemCount != 'undefined' && parseInt(itemCount) >= 4){ bootbox.alert("You have exceeded the sample line maximum of four (4) lines per order. You may purchase additional parts by visiting our ordering page here, and searching for parts to order."); return; } else{ //var qty = document.getElementById('product-quantity').value; if (sampQty >= 1 || userType == "DISTRIBUTOR" || userType == "EMPLOYEE") { var qty = 1; //taking qty fixed as 5 for sample var data = "input=addtocart&qty=" + qty + "&part_no=" + encodeURIComponent(part_no) + "&CartType=sampleCart&sampleQty="+sampQty+"&usertype="+userType; $.ajax({ type: "post", url: '/bin/cartOperations', async: false, data: data, success: function (msg, textStatus, jqXHR) { if (textStatus == "success") { if (msg == "false") { digitalErrorFunction('Maximum quantity exceeded. Please lower the quantity to proceed.'); bootbox.alert('Maximum quantity exceeded. Please lower the quantity to proceed.'); return false; } else if (msg.match("^You") || msg.match("^Product")) { bootbox.confirm('Your session expired. Please login and try again.', function (result) { var authorizableId = CQ_Analytics.PersonalInfoStoreMgr.getProperty("authorizableId"); CQ.shared.Util.load("\x2Fbin\x2FLogoutServlet\x3Flanguage\x3Den" + "&authorizableId=" + authorizableId); window.location = "/en/mymaxim/login.html"; }); } else if (msg.match("^No orderable unit")) { digitalErrorFunction(msg); bootbox.alert(msg); } else { localStorage.setItem(part_no, "1"); mycart_widget("sample", function (status) { if (status && typeof _satellite != "undefined") _satellite.track("cart: add"); }); } } else { digitalErrorFunction('System error occured. Contact customer support for assistance.' + JSON.stringify(msg)); bootbox.alert('System error occured. Contact customer support for assistance.' + JSON.stringify(msg)); } } }); } else { digitalErrorFunction('Not enough quantity available for samples, the max quantity available for sample is' + sampQty); bootbox.alert('Not enough quantity available for samples, the max quantity available for sample is' + sampQty); } } } else { if(sampleMessage =='SAMPLEEMAILDENIAL'){ //bootbox.alert(sampleMessage); $('#sampleemaildenialerrordialog').modal('show'); } else{ $('#domainerrordialog').modal('show'); } //bootbox.alert(sampleMessage); } } $(document).on("click", ".useThisBuyQuote", function () { var quantity = ""; quantity = $('#product-quantityBuyQuote').val(); quantity = quantity.trim(); if(quantity.length == 0){ digitalErrorFunction('Enter quantity to proceed'); bootbox.alert('Enter quantity to proceed'); quantity.focus(); return false; } var part_no = $('#Pcode').val(); var quoteId= $(this).data("quote-id"); var quoteItemId = $(this).data("quote-item-id"); $.ajax({ type: "post", url: '/bin/cartOperations', data: "input=addtocart"eId="+quoteId+""eItemNumber="+quoteItemId+"&qty=" + quantity + "&part_no=" + encodeURIComponent(part_no), success: function(msg, textStatus, jqXHR) { if (textStatus == "success") { if(msg.match("^You") || msg.match("^Product")){ if(msg.match("^Your session expired")) { bootbox.confirm('Your session expired. Please login and try again.', function(result) { var authorizableId = CQ_Analytics.PersonalInfoStoreMgr.getProperty("authorizableId"); CQ.shared.Util.load("\x2Fbin\x2FLogoutServlet\x3Flanguage\x3Den"+"&authorizableId="+authorizableId); window.location="/en/mymaxim/login.html"; }); } else { digitalErrorFunction(msg); bootbox.alert(msg); return false; } } else if (msg.match("^No Price found")){ //bootbox.alert(msg); digitalErrorFunction('This part requires a quote for the quantity you have entered.'); bootbox.alert('This part requires a quote for the quantity you have entered.'); return false; } else if(msg.match('This part requires a quote for the quantity you have entered.')){ digitalErrorFunction(msg); bootbox.alert(msg); return false; } else if(msg==""){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); return false; } else if(quoteId != "" && quoteId != undefined && ! msg.match("statusCode=success")) { digitalErrorFunction(msg); bootbox.alert(msg); return false } else { $('#useQuoteModal').modal('hide'); mycart_widget(); if ($("#buyParams").html() == "SavedLater") { //alert("Yes inside"); deleteSavedForLater(part_no); } } } else { digitalErrorFunction('System error occured. Contact customer support for assistance.'+ JSON.stringify(msg)); bootbox.alert('System error occured. Contact customer support for assistance.'+ JSON.stringify(msg)); } } }); }); function call(quantity) { var qty ="",quoteId,quoteItemNumber = ""; if(typeof quantity != "undefined" && quantity !="") { qty=quantity; } else { var value = $('#product-quantity1').val(); if(value != "undefined" && value != "") { qty = value; } else{ qty = document.getElementById('product-quantity').value; } } qty = qty.trim(); var orderInMult = $('#orderInMult').val(); var orderInMin = $('#orderInMin').val(); var inventoryVal = $('#stockAvaliability').val(); var stockAvaliability = $('#stockAvaliability').val(); var cfValue = $('#cfValue').val(); var carrierTypeValue = $('#carrierTypeValue').val(); quoteId=$("#addToCartP").attr('data-quote-id'); quoteItemNumber=$("#addToCartP").attr('data-quote-item-number'); if(quoteId == undefined){ quoteId =""; quoteItemNumber = ""; } if(quoteId != "" && quoteId != undefined){ } else { if(!(cfValue == 'true' && carrierTypeValue == 'Tape')){ if(parseInt(qty) > parseInt(inventoryVal)){ if(qty != "" && orderInMult != "" && orderInMin != "" ){ if(parseInt(qty) < parseInt(orderInMin)){ $('#product-quantity').val(orderInMin); $('#quantity-label').show(); return false; } else if(qty % orderInMult == 0){ $('#quantity-label').hide(); } else { var modvalue = parseInt(qty) % parseInt(orderInMult); var q4 = parseInt(orderInMult)-parseInt(modvalue); var nearestNum = parseInt(qty) + parseInt(q4); //var nearestNum = (Math.round(qty / orderInMult)+1) * orderInMult; $('#product-quantity').val(nearestNum); $('#quantity-label').show(); return false; } } } else if(parseInt(qty) <= parseInt(inventoryVal) && carrierTypeValue == 'Reel'){ if(qty != "" && orderInMult != "" && orderInMin != "" ){ if(parseInt(qty) < parseInt(orderInMin)){ $('#product-quantity').val(orderInMin); $('#quantity-label').show(); return false; } else if(qty % orderInMult == 0){ $('#quantity-label').hide(); } else { var modvalue = parseInt(qty) % parseInt(orderInMult); var q4 = parseInt(orderInMult)-parseInt(modvalue); var nearestNum = parseInt(qty) + parseInt(q4); //var nearestNum = (Math.round(qty / orderInMult)+1) * orderInMult; $('#product-quantity').val(nearestNum); $('#quantity-label').show(); return false; } } } } // Bulk SOT Check if(cfValue == 'true' && carrierTypeValue == 'Tape'){ if(parseInt(stockAvaliability) == 0){ digitalErrorFunction('Unfortunately there is no inventory to support this request. We only sell this type of product when we have excess inventory available because this package type comes off of our testers in reels. When we have excess inventory from a lot that completes final test, we can sell this product on cut tape strips in quantities less than reel size until it is sold out, which is currently the case. Please change your order to the tape & reel part number (usually ending in +T or +T&R) if you would like to order this product or check with our distribution partners in your region for smaller quantities.'); bootbox.alert('Unfortunately there is no inventory to support this request. We only sell this type of product when we have excess inventory available because this package type comes off of our testers in reels. When we have excess inventory from a lot that completes final test, we can sell this product on cut tape strips in quantities less than reel size until it is sold out, which is currently the case. Please change your order to the tape & reel part number (usually ending in +T or +T&R) if you would like to order this product or check with our distribution partners in your region for smaller quantities.'); return false; } } } var part_no = document.getElementById('Pcode').value; if(qty.length == 0){ digitalErrorFunction('Enter quantity to proceed'); bootbox.alert('Enter quantity to proceed'); qty.focus(); return false; } if (qty % 1 != 0) { digitalErrorFunction('Please do not use decimals or negatives (positive integers only).'); bootbox.alert('Please do not use decimals or negatives (positive integers only).'); return false; } var userId = CQ_Analytics.ProfileDataMgr.getProperty("email"); if(CQ_Analytics.PersonalInfoStoreMgr.getProperty("isLoggedIn", true) || CQ_Analytics.PersonalInfoStoreMgr.getProperty("isLoggedIn", true) == "true") { var userType = encodeURI(CQ_Analytics.PersonalInfoStoreMgr.getProperty("userType")); if(typeof quantity != "undefined") { $.removeCookie("redirect"); $.removeCookie("part_no"); $.removeCookie("sampQty"); $.removeCookie("quantity"); $.removeCookie("buy"); } var message = ""; var data = "userId="+userId; var isOrderAllowed="true"; $.ajax({ type: "post", url: '/bin/validateRevenueOrder', async: false, data: data, success: function(msg) { if(msg.error == "genericerrorText"){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); } else{ isOrderAllowed = msg.output.validateEmailDomain.isOrderAllowed; message = msg.output.validateEmailDomain.message; } } }); if(isOrderAllowed == "true") { $.ajax({ type: "post", url: '/bin/cartOperations', data: "input=addtocart"eId="+quoteId+""eItemNumber="+quoteItemNumber+"&qty=" + qty + "&part_no=" + encodeURIComponent(part_no), success: function(msg, textStatus, jqXHR) { if (textStatus == "success") { if(msg.match("^You") || msg.match("^Product")){ if(msg.match("^Your session expired")) { bootbox.confirm('Your session expired. Please login and try again.', function(result) { var authorizableId = CQ_Analytics.PersonalInfoStoreMgr.getProperty("authorizableId"); CQ.shared.Util.load("\x2Fbin\x2FLogoutServlet\x3Flanguage\x3Den"+"&authorizableId="+authorizableId); //window.location="/en/storefront.html"; window.location="/en/mymaxim/login.html"; }); } else { digitalErrorFunction(msg); bootbox.alert(msg); return false; } } else if (msg.match("^No Price found")){ //bootbox.alert(msg); digitalErrorFunction('This part requires a quote for the quantity you have entered.'); bootbox.alert('This part requires a quote for the quantity you have entered.'); return false; }else if(msg.match('This part requires a quote for the quantity you have entered.')){ digitalErrorFunction(msg); bootbox.alert(msg); return false; }else if(msg.match("^zeroInventoryErrorMsg")){ digitalErrorFunction('Unfortunately there is no inventory to support this request. We only sell this type of product when we have excess inventory available because this package type comes off of our testers in reels. When we have excess inventory from a lot that completes final test, we can sell this product on cut tape strips in quantities less than reel size until it is sold out, which is currently the case. Please change your order to the tape & reel part number (usually ending in +T or +T&R) if you would like to order this product or check with our distribution partners in your region for smaller quantities.'); bootbox.alert('Unfortunately there is no inventory to support this request. We only sell this type of product when we have excess inventory available because this package type comes off of our testers in reels. When we have excess inventory from a lot that completes final test, we can sell this product on cut tape strips in quantities less than reel size until it is sold out, which is currently the case. Please change your order to the tape & reel part number (usually ending in +T or +T&R) if you would like to order this product or check with our distribution partners in your region for smaller quantities.'); }else if(msg==""){ digitalErrorFunction('System error occured. Contact customer support for assistance.'); bootbox.alert('System error occured. Contact customer support for assistance.'); return false; } else if(quoteId != "" && quoteId != undefined && ! msg.match("statusCode=success")) { digitalErrorFunction(msg); var msgMatch = msg.match("^Quote compliance not met for quote number (.[0-9]*) as compliance is (.[0-9]%)$"); if(msgMatch){ bootbox.alert('Quote compliance not met for quote number '+ msgMatch[1] + ' as compliance is ' + msgMatch[2]); }else { bootbox.alert(msg); } return false } else if(msg.match('To order this part, you must order the entire inventory of')){ bootbox.alert(msg); return false; } else if(msg.match('We are sorry! Unfortunately, there is not enough excess inventory to support this bulk SOT part request')){ bootbox.alert(msg); return false; } else if(msg.match('A valid quote is required to purchase this part')){ bootbox.alert(msg); return false; }else { $('#addToCartP').modal('hide'); mycart_widget("", function(status){ if(status && typeof _satellite != "undefined") _satellite.track("cart: add"); if(msg.match("entryNumber=1") && typeof _satellite != "undefined"){ _satellite.track("cart: open"); } }); if(quoteId != null && quoteId != "" && quoteId != undefined && msg.match("statusCode=success")){ window.digitalQuoteData = { quoteID : quoteId, quoteQuantity : qty, partNo : encodeURIComponent(part_no) } if(typeof _satellite != "undefined"){ _satellite.track("use-quote"); } } if ($("#buyParams").html() == "SavedLater") { //alert("Yes inside"); deleteSavedForLater(part_no); } } } else { digitalErrorFunction('System error occured. Contact customer support for assistance.'+ JSON.stringify(msg)); bootbox.alert('System error occured. Contact customer support for assistance.'+ JSON.stringify(msg)); } } }); } else { digitalErrorFunction('System error occured. Contact customer support for assistance.'); $('#revenuedomainerrordialog').modal('show'); } }else{ $.cookie("quantity",qty); $("#addToCartP").modal("hide"); gigya.accounts.showScreenSet(aem.login.params); } } function redirectBulkOrder(partNumber,quantity){ var url="/en/storefront/bulk-order.html"; if(typeof partNumber != "undefined" && partNumber != "") { url+="?partNumber="+partNumber; } if(typeof quantity != "undefined" && quantity != "") { url+="&quantity="+quantity; } window.location.href = url; } function redirectToModelN(){ window.open("https://maxim.modeln.com/", '_blank',"width=400,height=150").focus(); } $(document).on('click', '.quoteDetails', function() { $("#useQuoteModal .modal-body").html(""); var index = ""; var quoteNo = ""; var part = $(this).data("part-no"); if(part == "" || part == "undefined") { digitalErrorFunction('Please enter a valid part number.'); bootbox.alert('Please enter a valid part number.'); return false; } if(quoteNo != "" && quoteNo != "undefined") { getQuotesList(part, index, quoteNo); } else { getQuotesList(part, index, quoteNo); digitalErrorFunction('Enter valid quote number'); //bootbox.alert('Enter valid quote number'); //return false; } }); var useQuoteModalTemplate = $("#useQuoteModalBody").html(); function getQuotesList(part, index, quoteId) { var userType = CQ_Analytics.PersonalInfoStoreMgr.getProperty("userType"); var oldPart = $("#partHidden"+index).val(); //oldpart == part to handle unnecessary quotelists api calls for same part. if(part == "" || part == undefined || part.length < 5 || oldPart == part) { return false; } if(userType == "" || userType == undefined){ $("#modelBuyCartButton").trigger("click"); gigya.accounts.showScreenSet(aem.login.params); return false; } var queryString = "quoteId="+quoteId+"&pendingStatus=&summery=disti&quantity=&materialNumber="+encodeURIComponent(part); var materialNumber = part; var activeFlag = 0; $.ajax({ url:"/bin/QuoteMangementServlet", type: 'GET', data: queryString, success:function(data){ //alert(JSON.stringify(data)); var useQuoteTemplate = Handlebars.compile(useQuoteModalTemplate); var useQuoteJson = {quotesList : [], code : materialNumber, index : index}; if(data.status == false) { var useQuoteJson = {quotesList : [], code : materialNumber, index : index, errorMessage : data.error.errorList.errors.message }; $("#modelBuyCartButton").trigger("click"); $("#quoteLineFlag"+index).val("false"); $('#useQuoteModal').html(useQuoteTemplate(useQuoteJson)); $('#useQuoteModal').modal('show'); digitalErrorFunction(data.error.errorList.errors.message); return false; } else { var quoteListJson = data.quoteList.quotes.quote; } if($.type(data.quoteList.quotes.quote) != "array") { if($.type(quoteListJson.quote_items) != "array") { if(quoteListJson.quote_items.product.code == materialNumber) { var quoteId = quoteListJson.ecom_qt_id_h; var quantity = quoteListJson.quote_items.quantity; //var price = findPriceByQuantity(quoteListJson.quote_items.product.volumePrices, quoteListJson.quote_items.quantity); price = (quoteListJson.quote_items.requote_price * 1).toFixed(3); if(userType == "DISTRIBUTOR") { price = (quoteListJson.quote_items.adj_disti_cost * 1).toFixed(3); quoteId = quoteListJson.modelNQuoteNumber; } var total = price * quantity; total =total.toFixed(3); if(quoteListJson.quote_items.quoteItemStatus == "ACTIVE" && quantity != "" && quantity != "undefined"){ activeFlag = 1; useQuoteJson.quotesList.push({"totalCost":total, "quoteItemId" : quoteListJson.quote_items.code, "status" : quoteListJson.quote_items.quoteItemStatus, "quantity":quantity, "entryNumber":quoteListJson.quote_items.item_num,"quoteId": quoteId, "price": price, "orderCompilance": quoteListJson.quote_items.ordcompliance}); } } else { //return useQuoteJson; //break; } } else { for(var i =0; i