Home / Pic16f877a Datasheet

Pic16f877a Datasheet

Author: admin15/11

Basic Servo Motor Controlling with Microchip PIC Microcontroller. February 1. 7, 2. Robotics. The servo motor is widely used in model hobbyist such as airplane RC model for moving the rudder, ailerons, elevators and acceleration control or in the car RC model for steering and acceleration control. In this tutorial we will learn how to control the servo motor as well as the simple close loop control algorithm for this servo motor. The servo motor basically is a high quality geared DC motor equipped with electronic circuit for controlling the DC motor rotation direction and position. Currently there are two types of servo motor available on the market, the first one is called standard servo and the other one is called continues servo standard servo can rotate to maximum clockwise or counterclockwise of 1. The Servo Motor. The servo motor use PWM signal for controlling the DC motor unlike normal PWM usually used in ordinary DC motor this PWM signal is not use for controlling the rotation speed, instead it is use for controlling the motor direction or position. Most servo motor will work well on 5. Ill admit that the datasheet is very confusing especially for beginners like me. In this post, Ill attempt to summarize everything I know about the ADC on a. Hz of PWM frequency this mean the PWM signal should have a period of 2. The electronic circuit inside the servo motor will response to the PWM signal width the 0. PWM width will make the servo motor to turn clockwise CW, the 1. PWM width will make the servo motor to turn counterclockwise CCW. For the standard servo the 1. PWM width will turn the servo motor to its center. The exact PWM width is depend on the servo motor types and brands on this tutorial we will use the Parallax Continues Servo which using 1ms and 2ms respectively. KSAcxGtWG84/hqdefault.jpg' alt='Pic16f877a Datasheet' title='Pic16f877a Datasheet' />The Parallax servo motor consists of three wires colored with White, Red and Black. The Red and Black wires go to the Vcc and Gnd, while the White wire is use to feed the PWM signal from the PIC 1. Now we are going to see how to interface this sensor with microchip pic16f877a. There are some descriptions of how this sensor work in the above link A brief. This powerful 200 nanosecond instruction execution yet easytoprogram only 35 single word instructions CMOS FLASHbased 8bit microcontroller pa. F6. 90 microcontroller IO port. Driving the servo motor using PIC 1. F6. 90 microcontroller might be simple as you thing at the first time we just use the PIC PWM peripheral to do the job you could learn of how to use the PIC PWM peripheral on the article H Bridge Microchip PIC Microcontroller PWM Motor Controller posted on this blog, but looking at the PIC 1. F6. 90 datasheet with the 8 Mhz of internal frequency clock use in this tutorial and using maximum prescaler of 1. TIMER2 the minimum PWM frequency we could achieve can be calculated using this formula PWM period PR2 1 x 4 x Tosc x TMR2 prescaler value second. Using maximum PR2 register value of 0x. FF 2. 55 decimal, we will get this result PWM period 2. PWM frequency 1 PWM period 1 0. Hz. The 4. 88. 2. Hz frequency is still too high from the servo motor working frequency of 5. Hz therefore this leads us to these three methods bellow Keep using the PIC PWM peripheral and lower the operation frequency by setting the OSCCON register and PR2 register until it meets the servo motor frequency requirement. This approach will secrify the program execution speed as we will operate the PIC Microcontroller with the 5. Secondly, we create our own PWM function to mimic the PWM signal as follow turn on the PORT, make some 2 ms delay, turn off the PORT, and make some 1. This approach is what I called a dirty method which is not the efficient way to do it, so we just drop this method. The third approach is to use the PIC 1. F6. 90 microcontroller TIMER0 with the interrupt to actually generate the PWM signal as the TIMER0 have wider prescaler to choose comparing to the TIMER2, but unfortunately the PWM peripheral on the PIC 1. F6. 90 only work with TIMER2 not TIMER0. Therefore we will make this TIMER0 as our PWM base generator for driving the servo motor on this tutorial. The principal we learn here could be applied to the other type of PIC Microcontroller or AVR Microcontroller as well. Instead of just demonstrating the servo motor to rotate clockwise and counterclockwise, I decide to make it more challenging and attractive by putting the LDR light dependent resistor as the light sensor to our servo motor and make this servo motor to behave as the light seeking machine hey this sound like we are touching the robotics field hmm yes isnt it cool, as we know most of the embedded robotics hobbyist widely use the servo motor for robots arms, walkers robots, light seeking robot know also as photovore robot and many more. The LDR Light Dependent ResistorBy just looking at the name, is clear that this is the type of resistor that its resistance depends on the light intensity its also called photoresistor, made from the Cadmium Sulfide Cd. Caps A Crack. S one of the semiconductor material. The LDR will response to light it received, the brightest the light the smaller its resistance and vise versa on the complete darkness the LDR resistance will become very high about 1. K Ohm for the LDRs I use in this tutorialFrom the above circuit diagram we connect serially the LDR with the 1. K trimport and use it as the voltage divider circuit to the PIC 1. F6. 90 analog input AN4 and AN5 you could learn about Basic Resistor Circuit posted in this blog therefore the variation on the light intensity received by the LDR will result on the variation of the voltage level to the PIC analog input port. Because of the LDR resistance vary widely among the types and brands, therefore we use the trimport and I suggest that you preset it to about 5 K Ohm on the first time and later on you can adjust it as needed. Graffiti Studio 3.0. The LDR pairs will be functioned as the light sensor that controlled the servo motor position toward the light source therefore to get the maximum performance we put these two LDRs inside the paper tube in such a way that their position is about 4. The Light Seeking Head Construction. One of my favorite construction material is to use a thick paper yes its a paper for fast prototyping as its easy to cut, bend, light weight and quiet strong our seeking light head project use just a thick paper to demonstrate the servo motor concept or what we usually called it as the proof of concept POC so lets do the cut and paste and of course you could experiment with any kind of head forms or faces as you like and these following pictures can be use as the starter. Mirc Music. The following is the list of hardware and software used in this tutorial 1. Thick paper, scissor, glue, duct tape and spray paint for our light seeking head. One continues servo motor in this project Iam using Parallax continues servo3. Two LDR4. Two Trimport 1. K5. PICJazz 1. 6F6. Jazz. Mate 2. 57. V power board, the 5 volt switching power supply. Microchip PICKit. Programmer. 8. Microchip MPLAB IDE v. HITEC PICC Lite PICC Lite Version 9. PL1. Now lets take a look at the C code that makes this thing happen. File Name servo. Version 1. Description Servo Motor Controller. Using TIMER0 for Generating Servo PWM. Author RWB. Target PICJazz 1. F6. 90 Board. Compiler HITECT PICC Lite Version 9. PL1. IDE Microchip MPLAB IDE v. Programmer PICKit. Last Updated 0. Jan 2. PIC Configuration Bit. INTIO Using Internal RC No Clock. WDTDIS Wacthdog Timer Disable. PWRTEN Power Up Timer Enable. MCLREN Master Clear Enable. UNPROTECT Code Un Protect. UNPROTECT Data EEPROM Read Un Protect. BORDIS Borwn Out Detect Disable.

Pic16f877a DatasheetCopyright © 2017.