Revisar Pic Encoder Motor

of 48
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Document Description
AN857 Brushless DC Motor Control Made Easy Author: Ward Brown Microchip Technology Inc. get device and exercise the code directly from the MPLAB® environment. The final code can then be ported to one of the smaller, less expensive, PICmicro microcontrollers. The porting takes minimal effort because the instruction set is identical for all PICmicro 14-bit core devices. It should also be noted that the code was bench tested and optimized for a Pittman N2311A011 brushless DC motor. Other motors wer
Document Share
Document Tags
Document Transcript
   2002 Microchip Technology Inc.DS00857A-page 1 AN857 INTRODUCTION This application note discusses the steps of developingseveral controllers for brushless motors. We cover sen-sored, sensorless, open loop, and closed loop design.There is even a controller with independent voltage andspeed controls so you can discover your motor’s char-acteristics empirically.The code in this application note was developed withthe Microchip PIC16F877 PICmicro  ®  Microcontroller, inconjuction with the In-Circuit Debugger (ICD). Thiscombination was chosen because the ICD is inexpen-sive, and code can be debugged in the prototype hard-ware without need for an extra programmer oremulator. As the design develops, we program the tar-get device and exercise the code directly from theMPLAB  ®  environment. The final code can then beported to one of the smaller, less expensive,PICmicro microcontrollers. The porting takes minimaleffort because the instruction set is identical for allPICmicro 14-bit core devices.It should also be noted that the code was bench testedand optimized for a Pittman N2311A011 brushless DCmotor. Other motors were also tested to assure that thecode was generally useful. Anatomy of a BLDC Figure1is a simplified illustration of BLDC motor con-struction. A brushless motor is constructed with a per-manent magnet rotor and wire wound stator poles.Electrical energy is converted to mechanical energy bythe magnetic attractive forces between the permanentmagnet rotor and a rotating magnetic field induced inthe wound stator poles. FIGURE 1:SIMPLIFIED BLDC MOTOR DIAGRAMS Author:Ward Brown Microchip Technology Inc. N  S   ACaabbccB comcomcom NNSS 110010011101100001 N     S     S    N     6341 25 ACBcbacom Brushless DC Motor Control Made Easy  AN857 DS00857A-page 2  2002 Microchip Technology Inc. In this example there are three electromagnetic circuitsconnected at a common point. Each electromagneticcircuit is split in the center, thereby permitting the per-manent magnet rotor to move in the middle of theinduced magnetic field. Most BLDC motors have athree-phase winding topology with star connection. Amotor with this topology is driven by energizing 2phases at a time. The static alignment shown inFigure2, is that which would be realized by creating anelectric current flow from terminal A to B, noted as path1 on the schematic inFigure1. The rotor can be madeto rotate clockwise 60 degrees from the A to B align-ment by changing the current path to flow from terminalC to B, noted as path 2 on the schematic. The sug-gested magnetic alignment is used only for illustrationpurposes because it is easy to visualize. In practice,maximum torque is obtained when the permanent mag-net rotor is 90 degrees away from alignment with thestator magnetic field.The key to BLDC commutation is to sense the rotorposition, then energize the phases that will produce themost amount of torque. The rotor travels 60 electricaldegrees per commutation step. The appropriate statorcurrent path is activated when the rotor is 120 degreesfrom alignment with the corresponding stator magneticfield, and then deactivated when the rotor is 60 degreesfrom alignment, at which time the next circuit is acti-vated and the process repeats. Commutation for therotor position, shown inFigure1, would be at the com-pletion of current path 2 and the beginning of currentpath 3 for clockwise rotation. Commutating the electri-cal connections through the six possible combinations,numbered 1 through 6, at precisely the right momentswill pull the rotor through one electrical revolution.In the simplified motor ofFigure1, one electrical revo-lution is the same as one mechanical revolution. Inactual practice, BLDC motors have more than one ofthe electrical circuits shown, wired in parallel to eachother, and a corresponding multi-pole permanent mag-netic rotor. For two circuits there are two electrical rev-olutions per mechanical revolution, so for a two circuitmotor, each electrical commutation phase would cover30 degrees of mechanical rotation. Sensored Commutation The easiest way to know the correct moment to com-mutate the winding currents is by means of a positionsensor. Many BLDC motor manufacturers supplymotors with a three-element Hall effect position sensor.Each sensor element outputs a digital high level for 180electrical degrees of electrical rotation, and a low levelfor the other 180 electrical degrees. The three sensorsare offset from each other by 60 electrical degrees sothat each sensor output is in alignment with one of theelectromagnetic circuits. A timing diagram showing therelationship between the sensor outputs and therequired motor drive voltages is shown inFigure2. FIGURE 2:SENSOR VERSUS DRIVE TIMING A +V-VFloat B +V-VFloat C +V-VFloatHLHLHL Sensor ASensor BSensor C 6 5 4 3 2 16......1 Code 101 001 011010 110 100101 001   2002 Microchip Technology Inc.DS00857A-page 3 AN857 The numbers at the top ofFigure2correspond to thecurrent phases shown inFigure1. It is apparent fromFigure2that the three sensor outputs overlap in sucha way as to create six unique three-bit codes corre-sponding to each of the drive phases. The numbersshown around the peripheral of the motor diagram inFigure1represent the sensor position code. The northpole of the rotor points to the code that is output at thatrotor position. The numbers are the sensor logic levelswhere the Most Significant bit is sensor C and the LeastSignificant bit is sensor A.Each drive phase consists of one motor terminal drivenhigh, one motor terminal driven low, and one motor ter-minal left floating. A simplified drive circuit is shown inFigure3. Individual drive controls for the high and lowdrivers permit high drive, low drive, and floating drive ateach motor terminal. One precaution that must betaken with this type of driver circuit is that both high sideand low side drivers must never be activated at thesame time. Pull-up and pull-down resistors must beplaced at the driver inputs to ensure that the drivers areoff immediately after a microcontoller RESET, when themicrocontroller outputs are configured as high imped-ance inputs.Another precaution against both drivers being active atthe same time is called dead time control. When an out-put transitions from the high drive state to the low drivestate, the proper amount of time for the high side driverto turn off must be allowed to elapse before the low sidedriver is activated. Drivers take more time to turn offthan to turn on, so extra time must be allowed to elapseso that both drivers are not conducting at the sametime. Notice inFigure3that the high drive period andlow drive period of each output, is separated by a float-ing drive phase period. This dead time is inherent to thethree phase BLDC drive scenario, so special timing fordead time control is not necessary. The BLDC commu-tation sequence will never switch the high-side deviceand the low-side device in a phase, at the same time.At this point we are ready to start building the motorcommutation control code. Commutation consists oflinking the input sensor state with the correspondingdrive state. This is best accomplished with a state tableand a table offset pointer. The sensor inputs will formthe table offset pointer, and the list of possible outputdrive codes will form the state table. Code developmentwill be performed with a PIC16F877 in an ICD. I havearbitrarily assigned PORTC as the motor drive port andPORTE as the sensor input port. PORTC was chosenas the driver port because the ICD demo board alsohas LED indicators on that port so we can watch theslow speed commutation drive signals without anyexternal test equipment.Each driver requires two pins, one for high drive andone for low drive, so six pins of PORTC will be used tocontrol the six motor drive MOSFETS. Each sensorrequires one pin, so three pins of PORTE will be usedto read the current state of the motor’s three-outputsensor. The sensor state will be linked to the drive stateby using the sensor input code as a binary offset to thedrive table index. The sensor states and motor drivestates fromFigure2are tabulated inTable1. FIGURE 3:THREE PHASE BRIDGE To A -V M +V M A HighcontrolA LowcontrolTo B -V M +V M B HighcontrolB LowcontrolTo C -V M +V M C HighcontrolC Lowcontrol  AN857 DS00857A-page 4  2002 Microchip Technology Inc. TABLE 1:CW SENSOR AND DRIVE BITS BY PHASE ORDER SortingTable1by sensor code binary weight results inTable2. Activating the motor drivers, according to a state table built fromTable2, will cause the motor ofFigure1to rotate clockwise. TABLE 2:CW SENSOR AND DRIVE BITS BY SENSOR ORDER Counter clockwise rotation is accomplished by driving current through the motor coils in the direction opposite of thatfor clockwise rotation.Table3was constructed by swapping all the high and low drives ofTable2. Activating the motor coils, according to a state table built fromTable3,will cause the motor to rotate counter clockwise. Phase numbers inTable3are preceded by a slash denoting that the EMF is opposite that of the phases inTable2. TABLE 3:CCW SENSOR AND DRIVE BITS The code segment for determining the appropriate drive word from the sensor inputs is shown inFigure4. PinRE2RE1RE0RC5RC4RC3RC2RC1RC0PhaseSensorCSensorBSensorAC HighDriveC LowDriveB HighDriveB LowDriveA HighDriveA LowDrive 1 101000110 2 100100100 3 110100001 4 010001001 5 011011000 6 001010010 PinRE2RE1RE0RC5RC4RC3RC2RC1RC0PhaseSensorCSensorBSensorAC HighDriveC LowDriveB HighDriveB LowDriveA HighDriveA LowDrive 6 001010010 4 010001001 5 011011000 2 100100100 1 101000110 3 110100001 PinRE2RE1RE0RC5RC4RC3RC2RC1RC0PhaseSensorCSensorBSensorAC HighDriveC LowDriveB HighDriveB LowDriveA HighDriveA LowDrive  /6 001100001  /4 010000110  /5 011100100  /2 100011000  /1 101001001  /3 110010010
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!