in this article I will discuss the Pic 16f676 Microcontroller Voltmeter and pic16f676 programming . In the previous article I have discussed the interface of Ultrasonic sensor and the Raspberry Pi using the Python language. So this post will be oriented around how to use Pic 16f676 Microcontroller as a Voltmeter and understanding about Pic Microcontroller programming
Pic 16f676 Microcontroller Voltmeter:
After reading this post you will be able to understand the basics of the circuit Pic 16f676 Microcontroller Voltmeter and also you will learn about the important c code for pic voltmeter 7 segment So sit back keep reading and enjoy learning.
Equipment Required of project :
we are using these components
- common andoe 7segment displsy
- pic microcontroller 16f676
- 14 pin base
- resistor 10k,10k veriable resistors
- 7805 for voltage regulator
- 100uf .01uf capcitor
- led
- diode
- pic kit 2 for programming
Pic16f676 adc c code:
here is the code of reading adc in c language and it is compile in pic ccs c compiler
SET_ADC_CHANNEL(3); // for(i=0;i<2;i++) // { // delay_ms(1); mux(); mux();mux();mux(); mux();mux(); result=read_adc(); //} val2=result; // value = (int8) (read_adc() * 500)/1023; //val2 = read_adc (); value = (val2* 5000)/1023;
pic voltmeter 7 segment:
3 digit 7 segment with pic 16f676 microcontroller. this is a very simple pic microcontroller voltmeter using 7 segment it can measure up to 99.9 voltage
here is the circuit of 7 segment voltmeter
pic16f676 voltmeter code:
in this code we are using pic ccs c compiler and read analog signal and convert in to digital
here is the full code of pic16f676 voltmeter
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | #include <16f676.h> #FUSES NOWDT //No Watch Dog Timer #FUSES INTRC //Internal RC Osc, no CLKOUT #FUSES NOMCLR //Master Clear pin used for I/O #FUSES NOBROWNOUT //No brownout reset #FUSES PUT #device ADC=10 #use delay(INT=4Mhz) #define aon output_LOW(PIN_C0); #define aof output_HIGH (PIN_C0); #define bon output_LOW(PIN_C1); #define bof output_HIGH (PIN_C1); #define con output_LOW(PIN_C2); #define cof output_HIGH (PIN_C2); #define don output_LOW(PIN_C3); #define dof output_HIGH (PIN_C3); #define eon output_LOW(PIN_C4); #define eof output_HIGH (PIN_C4); #define fon output_LOW(PIN_C5); #define fof output_HIGH (PIN_C5); #define gon output_LOW(PIN_A2); #define gof output_HIGH (PIN_A2); #define d1_of output_LOW(PIN_A1); #define d1_on output_HIGH (PIN_A1); #define d2_of output_LOW(PIN_A0); #define d2_on output_HIGH (PIN_A0); #define d3_of output_LOW(PIN_A5); #define d3_on output_HIGH (PIN_A5); int32 value=0,val2,ind=0,ind2=0,cnt5=0,d1; void off(); int thu,ten,unit,digit; void zero(){ aon; bon; con; don; eon; fon; gof; } void one(){ aof; bon; con; dof; eof; fof; gof; } void two(){ aon; bon; cof; don; eon; fof; gon; } void three(){ aon; bon; con; don; eof; fof; gon; } void four(){ aof; bon; con; dof; eof; fon; gon; } void five(){ aon; bof; con; don; eof; fon; gon; } void six(){ aon; bof; con; don; eon; fon; gon; } void seven(){ aon; bon; con; dof; eof; fof; gof; } void eight(){ aon; bon; con; don; eon; fon; gon; } void nine(){ aon; bon; con; don; eof; fon; gon; } void comp1(){ if(digit==0)zero(); if(digit==1)one(); if(digit==2)two(); if(digit==3)three(); if(digit==4)four(); if(digit==5)five(); if(digit==6)six(); if(digit==7)seven(); if(digit==8)eight(); if(digit==9)nine(); DELAY_MS(1); } void mux(){ d1_on;digit=thu;comp1();d1_of; d2_on;digit=ten;comp1();d2_of; d3_on;digit=unit;comp1();d3_of; //d3_on;digit=unit;comp1();d3_of; } void mdelay() { mux();mux();//mux();mux(); mux();mux();mux();mux(); mux();mux();mux();mux(); mux();mux();mux();mux(); mux();mux();mux();mux(); mux();mux();mux();mux(); //mux();mux();mux();mux(); //mux();mux();mux();mux(); } void getad(){ int32 result=0;int8 i; SET_ADC_CHANNEL(3); // for(i=0;i<2;i++) // { // delay_ms(1); mux(); mux();mux();mux(); mux();mux(); result=read_adc(); //} val2=result; // value = (int8) (read_adc() * 500)/1023; //val2 = read_adc (); value = (val2* 5000)/1023; thu = (value/1000); mux(); mux();mux();mux(); mux();mux(); ten = (value/100)%10; mux(); mux();mux();mux(); mux();mux(); unit = (value/10)%10; mux(); mux();mux();mux(); mux();mux(); /* putc(thu+48); putc(ten+48); putc(unit+48); unit = value%10; putc(unit+48); putc(10);putc(13); */ } void main () { DELAY_MS(1); /* //SETUP_ADC_PORTS(NO_ANALOGS); // set_tris_a(0); set_tris_c(0x00); setup_comparator(NC_NC_NC_NC); setup_adc_ports(sAN0 | VSS_VDD); setup_adc(ADC_CLOCK_INTERNAL); setup_adc(ADC_CLOCK_INTERNAL ); set_tris_c(0x00); set_tris_a(0xff); set_tris_a(0b00011001); setup_comparator(NC_NC_NC_NC); // not use comparator module setup_adc_ports( sAN3 | VSS_VDD); setup_adc(ADC_CLOCK_DIV_64); set_tris_a(0b00011001); zero(); //DELAY_MS(1000); while(1) { // DELAY_MS(10); //pwmd(); getad(); mdelay(); }} |
digital voltmeter using microcontroller:
pic16f676 example c code:
for more Engineering Projects click below link
give me full circuit diagram