Servo and Motor Controller Date: August 0, 00 Description: The servo motor controller drives three R/C servomotors and one brushless DC motor. All four motors are controlled by PWM signals sent from a PIC F microcontroller. The PWM signal to the brushless motor is used to toggle on/off an Allegro A9 three-phase PWM motor driver. The servo controller regulates the shaft velocity of the brushless motor with encoder feedback, which is decoded by an HCTL000 quadrature decoder. An in-circuit serial programming connector is provided on the PCB to allow for in board reprogramming of the PIC micro-controller. PCB Block Diagram: R/C Servo R/C Servo R/C Servo Serial Comms Microcontroller (PICF) PWM motor Driver (A9) -Phase Brushless Motor V Logic Supply Hall Sensors V Motor Supply Quadrature Decoder (HCTL000) Encoder Feedback Power Consumption: Logic Supply: V (max current:. A) Motor Supply: V (operates between V 0V, max current: A) Data Interface: TTL-level -wire serial
Control System: The DC motor sends out encoded position signals to the quadrature decoder chip. The microcontroller reads the position feedback information from the decoder and converts it into a velocity reading. This velocity data is then compared to the desired speed and an error signal is generated, which is used to calculate the PD compensation. Desired Speed - Controller (PICF) Plant (Motor) Shaft Velocity Encoder Circuit Schematics: J J J Serv omotor Serv omotor Serv omotor C00 C0 pf C pf ENABLE Y CRYSTAL/SM 9 0 U Vpp RB RA0/AN0 RB RA/AN RB RA/AN/VREF- RB RA/AN/VREF+ RB RA/T0CK RB RA/AN/SS/LVDIN RB/INT VSS RB0/INT0 OSC/CLK 0 9 OSC/CLO0/RA VSS RC0/TOSO/TCLKL RC/RX/DT RC/TOSI/CCP RC/TX/CK RC/CCP RC/SDO RC/SCK/SCL RC/SDI/SDA PICF 9 J 0 HEADER x/m signal_groud C0.uF.uF J RX TX GND RS(TTL) DIR C00 U Output enable Vcc GND Output MX0 Oscillator C00.uF U CHA D0 CHB D D CLK D D OE D 0 RST D 9 SEL D GND HCTL000.uF Schematic : Logic Section C C C C 0.mF J v GND A B Z C C C Motor Signals
signal_groud Hall Sensors C C C R K R K + C mf R9 0K R 0K R 0K 9 0 9 0 GND GND HA+ HA- HB+ HB- HC+ HC- REF GND GND GND BRAKE SENSE SR OUTA HBIAS VBB LSS OUTB GNDa GND PFD PFD BLANK EXTMODE 0 ENABLE 9 DIR Vreg OSC GND0 GND9 GND SLEEP CP 0 CP 9 Vcp OUTC TACH VBB LSS GND GND R K ENABLE DIR C0 0.mF C 0.mF VBB C9 0.mF/00V + C mf R C 0.Ohm 0.mF/00V VBB D0 D D DIODE SCHOTTKY J VBB J J DIODE SCHOTTKY D D D9 MOTOR Motor Power Logic Power Schematic : Power Section
PCB Drawings Figure : PCB Layout Top
Figure : PCB Layout Bottom
Bill of Materials: # per Name Value Footprint Notes Vendor Part # Board C uf, 00V Cylinder Electrolytic Digi-Key P9-ND C, C9, C, C0, C 0.uF, 0V SM/C_0 Ceramic XR Digi-Key 99---ND C uf, 00V Cylinder Electrolytic Digi-Key P9-ND C0, C pf, 0V SM/C_0 Ceramic Digi-Key PCC0CQCT-ND C00, C0, C00, C00 0.uF, 0V SM/C_0 Ceramic XR Digi-Key 99-0--ND D, D, D9, D0, D, D Diode, 00V, A SM/D Fast Recovery Digi-Key FRBDICT-ND J Connector x mm ICSP connector Digi-Key J, J, J, J, J Connector x mm J Connector x mm J, J Connector x mm V motor power Digi-Key Brushless motor -phase power Digi-Key H0-ND (Recepticle) H0-ND (Header) Brushless motor logic and encoder feedback Digi-Key H-ND (Header) H0-ND (Recepticle) H0-ND (Header) IC socket pin Holds half HCTL00 Digi-Key AE90-ND R, R K SM/R 0 % /W Digi-Key P.00KLCT-ND R, R, R9 0K SM/R 0 % /W Digi-Key -0.0KLCT-ND R 0.Ohm Radial Current-Sense Res Digi-Key FR0-ND R K SM/R 0 % /W Digi-Key -.0KLCT-ND U HCTL000 Through hole Quadrature Decoder U 0MHz OSC SMD HSM9H Digi-Key CW0-ND U PIC F SOIC pin Microcontroller Digi-Key PICF-I/SO-ND Y 0MHz Crystal SMT Can ATS00SM Digi-Key CTX0-ND V, 0W, Shinano Kenshi Brushless Motor Encoder LA0-00E-NL Resettable fuse.a V SMD MF-SMCT-ND
Overview of Code: The program for the PIC is broken up into the three sections: Main program, Low Priority Interrupt Service Routine, High Priority Interrupt Service Routine INITIALIZATION Configuration Bits: Oscillator set to HS (0MHz) Disable all other bit word settings Configuration Variables: Motor speed Max = -00rpm to 00rpm Motor PWM period = FF ( clock cycles) Max motor duty cycle = 000 Fin position = 000 to 000 (000 is initialized position) Baud Rate =.k Internal clock = 0MHz MAIN PROGRAM While loop overview: Processing Command: No Command is sent: Wait for new command to be sent Poll motor speed and correct if necessary Send out PWM signals to three fins Returns motor speed and PWM signals Once command is received from DimmPC it is searched for each element Format of command: axxxxbxxxxcxxxxmxxxx (All or portions of the command may be sent) Each element is saved into a variable to be implemented in the ISR s If x is sent new speeds are not returned If e is sent speeds are returned Until a new command is received the speed is continuously polled and updated After each speed check, the speed and PWM signal is returned to the user. HIGH PRIORITY INTERRUPT Triggered by Fins Flag: step cycle: Set fin a high, Set fin a low Set fin b high, Set fin b low Set fin c high, Set fin c low One step is implement each ISR is called due to Triggered by command: When a command is received, the receive buffer triggers this ISR The ISR then saves and receives the data into a command buffer The received command flag is set so the main while loop will process the command when ISR exits LOW PRIORITY INTERRUPT Triggered by Motor Flag: Reads the decoder chip and exits ISR (repeats 0 times) Read decoder 0 times (multiple reads decreases error) Convert data to rpm (freq of 0 th read = 0.Hz) Compare with goal speed to get speed error Calculate speed comp based on error Update duty cycle and direction Triggered by Communication Error: If no command has been received in the past two seconds, the motor speed is set to zero and the fins are set to 000 (center). This is a fail safe to stop the AUV in the event that there is a communication problem between the DimmPC and the motor control card.
PCB Pictures