Jump to content
Electronics-Lab.com Community

G_i_o

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by G_i_o

  1. ADC_GetConversion(adc_channel_t channel): This routine is used to select desired channel for conversion and to get the analog to digital converted value. CODE: ---------------------------------------------------- #include "mcc_generated_files/mcc.h" #include "lcd.h" #include "stdio.h" /* Main application */ // This function creates seconds delay. // The argument specifies the delay time in seconds void Delay_Seconds(unsigned char z) { unsigned char x,y; for (y = 0; y < z; y++) { for (x = 0; x < 100; x++)__delay_ms(10); } } //**************Declare Global Variables************************************** uint16_t convertedValue = 0; float voltage ; char Buffer[20]; void main(void) { // Initialize the device SYSTEM_Initialize(); // initialize the LCD LCD_Initialize(); LCDPutCmd(LCD_CURSOR_OFF); //LCD Cursor off LCDPutStr("ADC with MCC"); //Display String "ADC with MCC" LCDGoto(0,1); //Go to second line LCDPutStr("Turn POT on AN0"); //Display String "Turn Potentiometer on AN0" Delay_Seconds(2); // 2 seconds delay DisplayClr(); // Clear the display while (1) { convertedValue = 0; ADC_StartConversion(channel_AN0); while(!ADC_IsConversionDone()); convertedValue = ADC_GetConversionResult(); voltage = (convertedValue * 5.0)/1023; // convert ADC count into voltage LCDPutStr("Voltage = "); //Display "Voltage" on the screen sprintf(Buffer, " %.3g", voltage ); // Convert voltage to string, rounded to 3 decimal points number LCDPutStr(Buffer); //Display the Voltage on the screen LCDPutStr(" "); // Clear after comma LCDGoto(0,0); //Go to first line } } /** End of File */ -------------------------------------------------- Comment: Instead of voltage = (convertedValue * 5.0)/1023; you can add your conversion equation of NTC sensor. such as temperature=B/(ln(convertedValue/r¤)) Here the convertedValue is the measured resistance of NTC. B is the Beta value - need to be calculated. ln is the natural logarithm. r¤ is the reference resistance at a certain K temperature.
  2. Wow, for the fans you need to draw more power externally or as mentioned above , build in a power enhancer (easiest way to implement a power transistor).
×
  • Create New...