Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

Interfacing temperature sensor humidity sensor and lcd with nios processor

Altera_Forum
Honored Contributor II
1,014 Views

i am using altera de2 115 board i have connect temperature and humidity sensor hsm-20g with adc 0809 interface board and 0809 adc is connected with level shifter 5v to 3.3v and its connected with de2 115 board and lcd is in built in board i need what are qsys system components i have to add and i need c program for sensor,adc lcd i attached c program we can use that. please help me  

 

/ LCD module connections sbit LCD_RS at RC4_bit; sbit LCD_EN at RC5_bit; sbit LCD_D4 at RC0_bit; sbit LCD_D5 at RC1_bit; sbit LCD_D6 at RC2_bit; sbit LCD_D7 at RC3_bit; sbit LCD_RS_Direction at TRISC4_bit; sbit LCD_EN_Direction at TRISC5_bit; sbit LCD_D4_Direction at TRISC0_bit; sbit LCD_D5_Direction at TRISC1_bit; sbit LCD_D6_Direction at TRISC2_bit; sbit LCD_D7_Direction at TRISC3_bit; // End LCD module connections // Define Messages char message0[] = "LCD Initialized"; char message1[] = "Room Temperature"; // String array to store temperature value to display char *tempC = "000.0"; char *tempF = "000.0"; // Variables to store temperature values unsigned int tempinF, tempinC; unsigned long temp_value; void Display_Temperature() { // convert Temp to characters if (tempinC/10000) // 48 is the decimal character code value for displaying 0 on LCD tempC[0] = tempinC/10000 + 48; else tempC[0] = ' '; tempC[1] = (tempinC/1000)%10 + 48; // Extract tens digit tempC[2] = (tempinC/100)%10 + 48; // Extract ones digit // convert temp_fraction to characters tempC[4] = (tempinC/10)%10 + 48; // Extract tens digit // print temperature on LCD Lcd_Out(2, 1, tempC); if (tempinF/10000) tempF[0] = tempinF/10000 + 48; else tempF[0] = ' '; tempF[1] = (tempinF/1000)%10 + 48; // Extract tens digit tempF[2] = (tempinF/100)%10 + 48; tempF[4] = (tempinF/10)%10 + 48; // print temperature on LCD Lcd_Out(2, 10, tempF); } void main() { ANSEL = 0b00000100; // RA2/AN2 is analog input ADCON0 = 0b01001000; // Connect AN2 to S/H, select Vref=1.19V CMCON0 = 0x07 ; // Disbale comparators TRISC = 0b00000000; // PORTC All Outputs TRISA = 0b00001110; // PORTA All Outputs, Except RA3 and RA2 Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // CLEAR display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,message0); Delay_ms(1000); Lcd_Out(1,1,message1); // Write message1 in 1st row // Print degree character Lcd_Chr(2,6,223); Lcd_Chr(2,15,223); // Different LCD displays have different char code for degree symbol // if you see greek alpha letter try typing 178 instead of 223 Lcd_Chr(2,7,'C'); Lcd_Chr(2,16,'F'); do { temp_value = ADC_Read(2); temp_value = temp_value*1168; tempinC = temp_value/1000; tempinC = tempinC*10; tempinF = 9*tempinC/5 + 3200; Display_Temperature(); Delay_ms(1000); // Temperature sampling at 1 sec interval } while(1); } - See more at: http://embedded-lab.com/blog/?p=916#sthash.7qyadh9x.dpuf 

 

/ LCD module connections sbit LCD_RS at RC4_bit; sbit LCD_EN at RC5_bit; sbit LCD_D4 at RC0_bit; sbit LCD_D5 at RC1_bit; sbit LCD_D6 at RC2_bit; sbit LCD_D7 at RC3_bit; sbit LCD_RS_Direction at TRISC4_bit; sbit LCD_EN_Direction at TRISC5_bit; sbit LCD_D4_Direction at TRISC0_bit; sbit LCD_D5_Direction at TRISC1_bit; sbit LCD_D6_Direction at TRISC2_bit; sbit LCD_D7_Direction at TRISC3_bit; // End LCD module connections // Define Messages char message0[] = "LCD Initialized"; char message1[] = "Room Temperature"; // String array to store temperature value to display char *tempC = "000.0"; char *tempF = "000.0"; // Variables to store temperature values unsigned int tempinF, tempinC; unsigned long temp_value; void Display_Temperature() { // convert Temp to characters if (tempinC/10000) // 48 is the decimal character code value for displaying 0 on LCD tempC[0] = tempinC/10000 + 48; else tempC[0] = ' '; tempC[1] = (tempinC/1000)%10 + 48; // Extract tens digit tempC[2] = (tempinC/100)%10 + 48; // Extract ones digit // convert temp_fraction to characters tempC[4] = (tempinC/10)%10 + 48; // Extract tens digit // print temperature on LCD Lcd_Out(2, 1, tempC); if (tempinF/10000) tempF[0] = tempinF/10000 + 48; else tempF[0] = ' '; tempF[1] = (tempinF/1000)%10 + 48; // Extract tens digit tempF[2] = (tempinF/100)%10 + 48; tempF[4] = (tempinF/10)%10 + 48; // print temperature on LCD Lcd_Out(2, 10, tempF); } void main() { ANSEL = 0b00000100; // RA2/AN2 is analog input ADCON0 = 0b01001000; // Connect AN2 to S/H, select Vref=1.19V CMCON0 = 0x07 ; // Disbale comparators TRISC = 0b00000000; // PORTC All Outputs TRISA = 0b00001110; // PORTA All Outputs, Except RA3 and RA2 Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // CLEAR display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,1,message0); Delay_ms(1000); Lcd_Out(1,1,message1); // Write message1 in 1st row // Print degree character Lcd_Chr(2,6,223); Lcd_Chr(2,15,223); // Different LCD displays have different char code for degree symbol // if you see greek alpha letter try typing 178 instead of 223 Lcd_Chr(2,7,'C'); Lcd_Chr(2,16,'F'); do { temp_value = ADC_Read(2); temp_value = temp_value*1168; tempinC = temp_value/1000; tempinC = tempinC*10; tempinF = 9*tempinC/5 + 3200; Display_Temperature(); Delay_ms(1000); // Temperature sampling at 1 sec interval } while(1); } - See more at: http://embedded-lab.com/blog/?p=916#sthash.7qyadh9x.dpuf
0 Kudos
0 Replies
Reply