Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
NTC Class Reference
NTC temperature A:D conversion. More...
#include <ntc.h>
Public Types | |
| enum | ntcBetaCurve { B0_50, B25_50, B25_80, B25_85, B25_100, B_OTHER } |
NTC Beta curves to choose from for Temperature calculations. More... | |
Public Member Functions | |
| NTC (PinName p_ana, const NTC_TypeDef *ntc_parameter) | |
| Configure gpio pin. | |
| NTC (PinName p_ana) | |
| Configure gpio pin. | |
| uint16_t | read_ad_reg () |
| Read A:D register value. | |
| int | get_ntc_res () |
| Get the NTC resistance value. | |
| int | get_ntc_beta (int beta=B25_85) |
| Get the NTC beta value. | |
| int | get_series_res () |
| Get the resistance value for the series resistor. | |
| float | get_ntc_res_viaAD (uint16_t din=0) |
| calculate NTC resistance based on A:D reading | |
| float | get_ntc_temp (int curve, uint16_t din=0) |
| calculate NTC temperaure | |
Detailed Description
NTC temperature A:D conversion.
#include "mbed.h" #include "ntc.h" #define NTC_VREF 3.3f #define NTC_AD_RESOL 65536.0f // Connections: // 3.3V (or other Vref) // --+-- // | // -+- // | | // | | // | | Series // | | Resistor // | | // -+- // | // +---> To A:D // | // -+- // | | // | | // | | NTC // | | // | | // -+- // | // --+-- // --- Ground // - const NTC_TypeDef ntc_my_paramtr = { // Vref NTC_VREF, // Vref NTC_AD_RESOL, // A:D 16-bit resolution // muRata NCP15XH103J03RC 10000, // NTC resistance 5, // NTC initial tolerance 0, // NTC B0/50 (none) 3380, // NTC B25/50 3428, // NTC B25/80 3434, // NTC B25/85 3355, // NTC B25/100 0, // NTC other beta (none) 1, // NTC beta tolerance // 3.32k 1% 100ppm 3320, // Series resistor value 1, // Series resistor tolerance 100 // Series Resistor tempco ppm }; NTC ntc(A1, &ntc_my_paramtr); //initialize NTC temperature A:D main() { printf("\r\n\r\n-------------------------------------------\r\n"); printf("NTC Res: %5d B0/50: %4d B25/50: %4d B25/80: %4d B25/85: %4d B25/100: %4d B_OTHER: %4d SeriesR: %d\r\n", ntc.get_ntc_res(), ntc.get_ntc_beta(NTC::B0_50 ), ntc.get_ntc_beta(NTC::B25_50 ), ntc.get_ntc_beta(NTC::B25_80 ), ntc.get_ntc_beta(NTC::B25_85 ), ntc.get_ntc_beta(NTC::B25_100 ), ntc.get_ntc_beta(NTC::B_OTHER ), ntc.get_series_res()); uint16_t ad = ntc.read_ad_reg(); printf("NTC A:D Val: %5d Volt A:D: %.6f NTC-R_now: %7.1f Temp: %+.2f\r\n", ad, NTC_VREF / NTC_AD_RESOL * (float)ad, ntc.get_ntc_res_viaAD(ad), ntc.get_ntc_temp(NTC::B25_85 , ad)); while(1) { printf("Temp: %+.2f\r\n", ntc.get_ntc_temp(NTC::B25_85 )); wait(2.0); } }
Definition at line 135 of file ntc.h.
Member Enumeration Documentation
| enum ntcBetaCurve |
Constructor & Destructor Documentation
| NTC | ( | PinName | p_ana, |
| const NTC_TypeDef * | ntc_parameter | ||
| ) |
Configure gpio pin.
- Parameters:
-
A:D I/O pin parameters for NTC (NTC_TypeDef)
| NTC | ( | PinName | p_ana ) |
Member Function Documentation
| int get_ntc_beta | ( | int | beta = B25_85 ) |
| int get_ntc_res | ( | ) |
| float get_ntc_res_viaAD | ( | uint16_t | din = 0 ) |
calculate NTC resistance based on A:D reading
- Parameters:
-
none din optional read from read_ad_reg(). din -> if missing or 0, read_ad_reg() value is used for calculation din -> if != 0, then value of din is used for calculation
- Returns:
- resistance of NTC
| float get_ntc_temp | ( | int | curve, |
| uint16_t | din = 0 |
||
| ) |
calculate NTC temperaure
- Parameters:
-
curve Beta curve to use. See ntcBetaCurve {}; din optional read from read_ad_reg() din -> if missing or 0, read_ad_reg() value is used for calculation din -> if != 0, then value of din is used for calculation
| int get_series_res | ( | ) |
Generated on Tue Jul 19 2022 19:28:44 by
1.7.2