s0y
Junior Member level 1
- Joined
- Apr 11, 2014
- Messages
- 19
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 3
- Activity points
- 115
sir please convert this code in hi-tech c 9.80
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 unsigned char ch; unsigned int adc_rd0; unsigned int temp0=0,temp1=0; unsigned max_point0 = 0; unsigned int i,tlong0,tlong1; // LCD module connections sbit LCD_RS at RB7_bit; sbit LCD_EN at RB6_bit; sbit LCD_D4 at RB5_bit; sbit LCD_D5 at RB4_bit; sbit LCD_D6 at RB3_bit; sbit LCD_D7 at RB2_bit; sbit LCD_RS_Direction at TRISB7_bit; sbit LCD_EN_Direction at TRISB6_bit; sbit LCD_D4_Direction at TRISB5_bit; sbit LCD_D5_Direction at TRISB4_bit; sbit LCD_D6_Direction at TRISB3_bit; sbit LCD_D7_Direction at TRISB2_bit; // End LCD module connections char message1[] = "PK:000V"; char message2[] = "RMS:000V"; char *freq = " 00"; void Display_Freq(unsigned int freq2write) { freq[1] = (freq2write/10) + 48; // Extract tens digit freq[2] = (freq2write/1)%10 + 48; // Extract ones digit // Display Frequency on LCD Lcd_Out(2, 11, freq); Lcd_Out(2,14,"Hz"); } void main() { TRISA = 0xFF; // set all pins of PORT A as input TRISC = 0x00; // set all pins as output PORTC = 0x00; // clear port C PORTB = 0x00; // clear port B ADCON1=0x00; // set all Analog Delay_ms(1000); OPTION_REG = 0b00101000; // set TOCKI as clock counter Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Measurement of"); Lcd_Out(2,1,"AC parameter "); Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); while(1) { // Find the peak amplitude of the sine wave... max_point0 = 0; for(i=0;i<5000;i++) { ADCON0 = 0b00000001; if(temp0 = ADC_Read(0),temp0>max_point0) { max_point0 = temp0; } Delay_us(5); } max_point0 = abs(ceil((long)max_point0)); tlong0 = (long)max_point0*(5/255)*11*220/12; // find the peak amplitude of the line tlong1 = (long)max_point0*((5/255)*11*220/12)*0.707; // find the rms value of the line voltage message1[3] = tlong0/100 + 48; // convert into ASCII message1[4] = (tlong0/10)%10 +48; // convert into ASCII message1[5] = (tlong0)%10 +48; // convert into ASCII Lcd_Out(1,1,message1); // Display message on LCD RC0_bit = ~RC0_bit; message2[4] = tlong1/100 + 48; // convert into ASCII message2[5] = (tlong1/10)%10 +48; // convert into ASCII message2[6] = (tlong1)%10 +48; // convert into ASCII Lcd_Out(1,9,message2); // Display message on LCD TMR0=0; // clear TMR0 Delay_ms(1000); // Delay 1 Sec Lcd_Out(2,1,"FREQUENCY:"); Display_Freq(TMR0/2); // divide by 2 TMR0=0; }// while }// void main
Last edited by a moderator: