Pic16f877 based projects pic microcontroller pdf pic. The pic microcontroller has the registers adcon0 and adcon1 that control the conversion. The port pins can be configured as analog inputs or as digital io according to the value in adcon1 register. A trisa 0xff or 0b11111111 will complete the set up of the port setting the port as input.
However due to me trying to display the result of the adc on the lcd i am unable to configure the adcon1 register. Multiple choice questions and answers on microcontrollers and applicationspart4. Pwm using pic microcontroller example in mplab xc8 and mikroc. Adresh and adresl or will be returned to a variable if highlevel languages are used with the result right or left justified according to the register adcon1. How do we know what is the binary valuerepresentation of the analog. Pic microcontroller analog to digital converter tutorial. When the adc function is selected for a pin,then other digital signals are disconnected from the adc input pins. Pic16f877a microcontroller pic16f877a specifications pic16f877a pin diagram pic16f877a block diagram pwm using pic16f877a c code pwm inverter using pic microcontroller control dc motor speed using pic16f877a pic16f877a circuit diagram pic16f877a connect to 16 pin lcd.
The microcontroller clock is generated by an external 10mhz crystal. On power on of the pic or after a reset, all ports become inputs. The complete code for this digital thermometer using lm35 and pic microcontroller is given at the end. The 16f877a is a capable microcontroller that can do many tasks because it has a large enough programming memory large in terms of sensor and control projects 8k words and 368 bytes of ram. Objective questions and answers on microcontrollers and applications. After finding a spare pin ra5 my next step was to set up the adcon1 register. They are also very powerful and many are capable of speeds up to 64 mips using the internal oscillator block. Pic16f877a introduction, pinout, features, examples, datasheet. Pic microcontrollers are a very useful and versatile tool for use in many electronic projects. Multiple choice questions and answers on microcontrollers.
To define the type of an io pin, you use the tris register. The tris and port registers microchip pic microcontroller. Pwm using pic microcontroller with examples, in this tutorial, you will learn to generate a pwm signal with the help of pic microcontroller pic16f877a. Ive already familiar with 16f84a now i found a problem with 16f877a. This is enough to do many different projects see links at. The adfm bit 7 of adcon1 register electronics forum. This part of the pic16f877 tutorial focuses on inputoutput ports and tris registers of the perepheral interphase controller.
After introducing the pic16f877 and its programming, this book covers the fundamental techniques and advanced level techniques of embedded systems programming in a general sense. The adcon module located within the pic microcontroller has a resolution of tenbit length. The pic16f877a is a 40pin dip microcontroller which microchip describes. Adcon1 is the register that defines which porta pins are used for digital inputoutput and which are used by the ad module. Analogtodigital converter the pic18 microcontroller. Apart from a large number of digital io lines, the pic16f887 contains 14 analog inputs. As with any register, the status register can be the destination for any instruction. Led is turn on according to the specific range of voltage. First at all i try to write very simple program with it. Pic16f877a mini development board has 3 smd leds connected to port pins rb1, rb2 and rb3 via jumpers j1, j2 and j10 respectively.
An analog, or timevarying, signal is continually sampled at equal time intervals at a. Each of the registers has its own address and memory locations. Therefore, the converter can divide the analog input voltage between 0v and 5v to 2 10 levels, which are 1024 levels. Analog to digital converter using pic16f877a microcontroller beginners guide. We have managed to blink a led, use interrupts and timers with the pic16f84a. Pic16f877tutorialinputouput ports and tris registers. Adc analog to digital converter module is offered in many of pic mcu models. A register is a place inside the pic which used to read or write the dataprogram. Before going to the circuit diagram and embedded program, let me figure out some details about adc in pic and also adc and inbuilt library functions in mikro c. Analogtodigital converter atd, adc, ad converts analog voltage values to digital values. This article is a part of our tutorial on pic16f877, where this section focuses on the inputoutput ports and tris registers of pic16f877. Although the maximum part of code remains the same, the only difference is compiler setting and how to create a new project.
Analog to digital converter using pic18f4550 analog to digital converters are electronic devices widely used in todays digital world as most of the realtime signals are analog ones while the daytoday devices of the contemporary world are mostly digital devices which can process only digital signals. When adfm is 1, the result will be right justified, ie most significant bits of adresh will be read as 0. Dear all the adfm bit 7 of adcon1 register is used for result justification. Pic16f877a adc tutorial analog to digital converter. For different ports there are different registers such as trisa, trisb etc.
These addresses are normally denoted by using hexadecimal numbers. If the status register is the destination for an instruction that. Two 8 bit register adresh and adresl are provided to store the 10bit result of ad conversion, thus we needt use 6 bits. The first section is a single bit, adfm, this is the result format selection bit, and selects if the output is right justified bit set or left justified bit cleared.
The adc on the pic16f877a has 10bits of resolution, so of course a single register that has 8 bits is not enough to contain the 10bits result. Additionally, the pic18f4550 was an awesome device a decade ago when it was first introduced. The result value of the conversion will be stored in a double register. The pic16f877a is a 40pin dip microcontroller which microchip describes as powerful based on having a 200 nanosecond instruction speed. The code below will continuously sample a voltage on channel 4 of the ad converter and display the 10bit result in a 16bit format ie, 0x0000 0x03ff on the lcd screen. Nov 12, 2015 the adc module of pic 16f877a has 4 registers. From this block diagram you can easily understand the working of adc channel selection and. In this tutorial we will be discussing only the pwm part of ccp. But i cant i connect the vdd and mclr with power supply 5v and vss with ground. Interfacing pic microcontroller with 7segment display. We can say that the resolution of this component is very high. Seven segment display interfacing with pic using mikroc pro compiler.
Configure analog pins voltage reference and digital io adcon1. All lines configured as digital io at the power up the adc module is in off state then no need to force it off, anyway if you like to set it look at the adcon0 register bit 0 and force it to 0 bit adon. The adcon0 and adcon1 registers with their corresponding bits are shown. Digital thermometer using lm35 and pic microcontroller. Charles kim department of electrical and computer engineering howard university. Sep 25, 20 come on lets start pic microcontroller programming. In this project, we will sense the temperature using lm35 and display it on 16. The below table shows the registers associated with pic16f877a adc. The microchip name, logo, pic, picmicro, picmaster, picstart, pro mate, keeloq, seeval, mplab and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u. Pic16f877a microcontroller based projects list pic. The status register is of most importance to programming the pic, it contains the arithmetic status of the alu arithmetic logic unit, the reset status and the bank select bit for data memory.
Pic microcontroller picf877a adc tutorial using mplab and xc8. The output voltage is proportional to celsius temperature scale and changes by 10mv. Adresh and adresl are just the registers where the adc stores the result of the conversion. We have 12 output pins from the module out of which 8 is used to display the characters and four is used to select one display out of four. Analog to digital converter using pic16f877a microcontroller. Pic16f877a datasheet pdf microcontrollers microchip.
Here we have used pic microcontroller pic16f877a and the schematic for the circuit is shown below. This paper describes a formal component language, used to support automated componentbased program development. The pic microcontroller consists of 8channels, 10bit analog to digital converter. The 10 bit value is loaded in ccpr1l and ccp1con registers. Adcon1 %0000 right justifies 10bit value of x in 16bit word. Reference manual should be considered a comple mentary document to. Interfacing pic microcontroller with 7segment display mikroc projects this post shows how to interface pic16f887 microcontroller with 7segment display in order to build a simple 4digit counter which counts from 0 to 9999. Using adc module of pic microcontroller hi tech c electrosome. As you are only using the port in digital io mode, set adcon1 to a value of either 0x06 or 0x07 which makes all the pins digital. We will provide pulse width modulation examples with mikroc and mplab xc8 compiler. Lastly, the most important part of the adc configuration is to select the mode for each analog channel. Microcontrollers are very useful especially when it comes to communicate with other devices, such as sensors, motors, switches, memory and even other microcontroller. There is a register named as tris which controls the direction of ports.
The adc pin can be enabled by configuring the corresponding acon1 register. The analog channel can be changed in between conversions by writing to the adcs bits of the adcon1 register. Just make sure you wait 5us before starting your conversion so the analog value is correctly sampled. Introduction to pic microcontrollers and its architecture. Timer 2 runs from 0 upto the value loaded in pr2 register. Ill admit that the datasheet is very confusing especially for beginners like me. The components, referred to as templates, are machine processable, meaning that. The operation of each pin is selected by clearingsetting the appropriate control bits in the adcon1 andor cmcon registers. I just want to ask how to correctly initialize a port in pic16f877a cause its my first time using usually i used pic16f84a due to more inputs a shift to pic16f877a but my problem is that i cannot correctly initialize porta of pic16f877a due to the adc function sharing with the port. Adresh and adresl h is the high byte while l is the low byte. Its old and microchip itself is not recommending it for new designs but its features and price make it still a popular microcontroller. The code is selfexplained with comment lines and just involves the concept of interfacing a lcd with pic.
The operation of the ad converter is controlled by these special function registers. Jul 10, 20 adcon1 register pic 16f877a adfm is the adc result format select bit. But for fosc8, we need to set the adcs2 bit in adcon1 also. Adcon is one of the registers that controls the operation of the ad converter. Apr 27, 2019 the pwm signal generated by pic 16f877 provides 10bit resolution. The lm35 outputs an analog voltage proportional to the temperature. Pic16f877a more microcontroller features microcontroller. The adc on the pic16f877a has 10bits of resolution, so of course a. Adcon1 select ad input channel adcon0 select ad conversion clock adcon0. Functional description of pic16f877a functions and interfaces. As usual initialize the configuration bits and lets start with the void main inside the void main we have to initialize our adc by using the adcon1 register and adcon0 register. Initially this was developed for supporting pdp computers to control its peripheral devices, and therefore, named as a peripheral interface device. The memory of the pic is divided into a series of registers. If we set a bit of the tris register to 0, the corresponding port bit will act as the digital output.
Adcon1 pic16f877 hi im currently trying to get the adc working on the picdem 2 board. The pic16f877a has a 10bit adc whose results are stored in two registers. The adfm bit determines how the result of the adc is justified. This section discusses an example of sevensegment display interfacing with pic16f877a microcontroller using mikroc for pic compiler. Ad control register 0 adcon0 ad control register 1 adcon1 ad result high register adresh ad result low register adresl ad control register 0 adcon0 the adcon0 register, shown in below image, controls the operation of the ad module i. Connecting 4digit seven segment module with pic microcontroller. I have serached the net for the source of this acronym with no avail. The adcon1 register configures the functions of the port pins. Lm35 temperature sensor is accurate and cheaper and doesnt require any external calibration. In this tutorial, we are making a digital thermometer using pic microcontroller and lm35 temperature sensor. Ad result low register adresl ad control register 0 adcon0 ad control register 1 adcon1 learn more about adc in pic microcontroller here code and explanation. They all need to be converted into digital data before being processed by the microcontroller. My program is very simple when i press the push buttom which connects with rb0, the led will blink. The program for using adc with pic microcontroller is very simple, we just have to understand these four registers and then reading any analog voltage will be simple.
Adds 0 in the 6 most significant bits of the word, shifting the 10bit value of x to the right. The sample code given below toggles the leds in fixed intervals. The term pic stands for peripheral interface controller. Ad result low register adresl ad control register 0 adcon0 ad control register 1 adcon1 learn more about adc in pic microcontroller here. This is done to avoid driving an output pin directly to the vdd or vss. Pic microcontroller was developed in the year 1993 by microchip technology. Pic adc analog to digital conversion microcontroller. Adcon1 register, look around page 128 in the 16f877a. There are much better parts available today for the same price. The intcon register is a readable and writable register which contains the various enable bits for all interrupt sources. Sadly, thats almost all we can do with that microcontroller as it lacks features that most microcontrollers or an arduino has. Adcon1 is really a little more complicated, although its only split into two sections.
Analogtodigital conversion adc is necessary because, while embedded systems deal with digital values, their surroundings typically involve many analog signals such as, temperature, speed, pressure, the output of a microphone, etc. The pic16f877a features 256 bytes of eeprom data memory, self programming, an icd, 2 comparators, 8 channels of 10bit analogtodigital ad converter, 2 capturecomparepwm functions, the synchronous serial port can be configured as either 3wire serial peripheral interface spi or the 2wire interintegrated circuit i. When converting from analog signal to digital signal microcontroller with a larger amount of bits has a higher resolution and better accuracy. If any jumper is left open, then the corresponding port pin can be used independently. The lower bits of the converter are stored in adresl 8 bits, and the upper bits are stored in the adresh register. Jul 19, 2018 pic16f877a datasheet pdf microcontrollers microchip, pic16f877a pdf, pic16f877a pinout, pic16f877a data, circuit, output, ic, pic16f877a schematic.
This produces a single instruction cycle time of 0. I dont knwo which pic you are planning to use but if you read the chapter in the datasheet on the ad converter it will tell you which bits have to be clearedset to make the port pins digital io. Nov 09, 2012 heres one temperature sensor thermometer circuit that you can easily build. The 8msb bits are stored in ccprxl and remeining 2bits in ccpxcon register. Heres one temperature sensor thermometer circuit that you can easily build. For pic the preferable compiler is mikro c pro which can be downloaded from their website. The meaning of intcon might be though this is only me thinking inturrpt control register. This powerful 200 nanosecond instruction execution yet easytoprogram only 35 single word instructions cmos flashbased 8bit microcontroller packs microchips powerful pic architecture into an 40 or 44pin package and is upwards compatible with the pic16c5x, pic12cxxx and pic16c7x. Earlier, i calculated that fosc8 is adequate, so i selected it in adcon0. There are two tris registers, the trisa and the trisb that corresponds to the 8 pins of each port set, the a and the b.
412 482 1021 1052 327 1182 1364 1182 291 1032 30 693 111 1422 878 1175 446 630 1457 754 278 1027 1130 400 521 27 1258 316