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 //sbit Led at RB0_bit; sbit LCD_RS at RC2_bit; sbit LCD_EN at RC3_bit; sbit LCD_D4 at RC4_bit; sbit LCD_D5 at RC5_bit; sbit LCD_D6 at RC6_bit; sbit LCD_D7 at RC7_bit; sbit LCD_RS_Direction at TRISC2_bit; sbit LCD_EN_Direction at TRISC3_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; char *l,*m,*q,*v,y[7],u[7],n[7],o[7]; unsigned int k,j,i,b,a; unsigned int x; float t; void main() { float z; ADCON1 =0b00000000; TRISA=0b00100001; TRISC=0x00; lcd_init(); lcd_cmd(_LCD_CURSOR_OFF); while(1) { t = ADC_Read(4); z=ADC_Read(0); k=t; k=k*5.2499; j=k/10; i=k%10; inttostr(j,o); inttostr(i,n); l=ltrim(o); m=ltrim(n); if ((j<=99)&&(j>9)){ Lcd_out(1,7,l); lcd_out(1,9,"."); Lcd_out(1,10,m); } else if (j<=9) { Lcd_out(1,7,l); lcd_out(1,8,"."); Lcd_out(1,9,m); } else { Lcd_out(1,7,l); lcd_out(1,10,"."); Lcd_out(1,11,m); } //Ampere x=z; x=x*2.793; b=x/10; a=x%10; inttostr(b,y); inttostr(a,u); q=ltrim(y); v=ltrim(u); if (b<=9){ Lcd_out(2,10,q); lcd_out(2,11,"."); Lcd_out(2,12,v); } else { Lcd_out(2,10,q); lcd_out(2,12,"."); Lcd_out(2,13,v); } Delay_ms(500); } }
i am agree with betwixt,Sorry but that schematic is horribly drawn and is electrically nonsense.
i want to measure both current and voltage ( so need two adc modules ).is this impossible to measure current and voltage simultaneously ( using pic16f73 )
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?