servo and motor controller - autonomous systems and controls lab
TRANSCRIPT
Servo and Motor Controller Date: August 10, 2004 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 18F252 micro-controller. The PWM signal to the brushless motor is used to toggle on/off an Allegro A3936 three-phase PWM motor driver. The servo controller regulates the shaft velocity of the brushless motor with encoder feedback, which is decoded by an HCTL2000 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: Power Consumption: Logic Supply: 5V (max current: 1.75 A) Motor Supply: 24V (operates between 15V – 50V, max current: 3A) Data Interface: TTL-level 3-wire serial
Microcontroller (PIC18F252)
R/C Servo
R/C Servo
R/C Servo
PWM motor Driver (A3936)
3-Phase Brushless
Motor
Quadrature Decoder (HCTL2000)
Serial Comms
5V Logic Supply
24V Motor Supply
Hall Sensors
Encoder Feedback
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. Circuit Schematics:
C120
22pF
C121
22pFVCC
VCC
J6
RS232(TTL)
123
RX
TX
GND
DIR
C22
0.22mF
C3
C1
C2
U23
HCTL2000
D0 1
CLK2
SEL3OE4
RST5
CHB6 CHA7
GN
D8
D7 9D6 10D5 11D4 12D3 13D2 14D1 15
VCC
16
C400.1uF
J14
Serv oMotor1
123
J15
Serv oMotor2
123
J16
Serv oMotor3
123
C500
.1uF
VCC
J4
Motor Signals
12345678
5v
GND
A
B
Z
C1
C2
C3
ENABLE
VCC
J1
HEADER 5x2/M
246810
13579
VCC
C300
.1uFU35
PIC18F252
Vpp1
RA0/AN02
RA1/AN13
RA2/AN2/VREF-4
RA3/AN3/VREF+5
RA4/T0CK16
RA5/AN4/SS/LVDIN7
VSS18
OSC1/CLK19
OSC2/CLO0/RA610
RC0/T1OSO/T1CLKL11
RC1/T1OSI/CCP212
RC2/CCP113
RC3/SCK/SCL14
RB1/INT1 22
RB0/INT021
VDD 20
VSS219
RC7/RX/DT 18
RC6/TX/CK17
RC5/SDO 16
RC4/SDI/SDA15
RB7 28
RB627
RB5 26
RB425
RB3 24
RB223
signal_groud
C301
.1uF
U26
MX045 Oscillator
Output enable1
GND2Vcc 4
Output 3
Y1CRYSTAL/SM
Schematic 1: Logic Section
Controller (PIC18F252)
Plant (Motor)
Desired Speed
Shaft Velocity
Encoder
-
R1351K
VDD
R710K
VDD
VDD
VBB
R810K
VDD
R910K
C110.22mF
VDD
VDD
+ C61 mF
J5
Motor Power
12
J7
Logic Power
12
VBB
C3
C2
C1
Hall Sensors
signal_groud
R120.25OhmC7
0.22mF/100V
D9
GND11
GND22
HA+3
HA-4
HB+5
HB-6
HC+7
HC-8
VDD9
REF10
GND311
GND412
GND513
BRAKE14
SENSE15
SR16
OUTA17
HBIAS18
VBB119
LSS120
OUTB21
GND5a22
GND1144
PFD143
PFD242
BLANK41
EXTMODE40
ENABLE39
DIR38
Vreg37
OSC36
GND1035
GND934
GND833
SLEEP32
CP231
CP130
Vcp29
OUTC28
TACH27
VBB226
LSS225
GND724
GND623
D8D7DIODE SCHOTTKY
J2
MOTOR
123
VBB
ENABLE
+ C833 mF
D10
DIODE SCHOTTKY
DIR
D11 D12
C200.22mF
R52K
R62K
VDD
C90.22mF/100V
Schematic 2: Power Section
PCB Drawings
Figure 1: PCB Layout – Top
Figure 2: PCB Layout – Bottom
Bill of Materials:
Name Value Footprint Notes Vendor Part # # per Board
C6 1uF, 100V Cylinder Electrolytic Digi-Key P5589-ND 1C7, C9, C11, C20, C22 0.22uF, 50V SM/C_1206 Ceramic X7R Digi-Key 399-1251-1-ND 5C8 33uF, 100V Cylinder Electrolytic Digi-Key P5595-ND 1C120, C121 22pF, 50V SM/C_402 Ceramic Digi-Key PCC220CQCT-ND 2C300, C301, C400, C500 0.1uF, 50V SM/C_805 Ceramic X7R Digi-Key 399-1170-1-ND 4D7, D8, D9, D10, D11, D12 Diode, 100V, 1A SM/D Fast Recovery Digi-Key FR1BDICT-ND 6J1 Connector 5x2 2mm ICSP connector Digi-Key 1J2, J6, J14, J15, J16 Connector 3x1 2mm
Brushless motor 3-phase power Digi-Key
H2084-ND (Recepticle)H2106-ND (Header) 5
J4 Connector 8x1 2mm
Brushless motor logic and encoder feedback Digi-Key H2133-ND (Header) 1
J5, J7 Connector 2x1 2mm 24V motor power Digi-Key H2083-ND (Recepticle)H2105-ND (Header) 2
IC socket 8 pin Holds half HCTL200 Digi-Key AE8908-ND 2
R5, R6 2K SM/R 402 1% 1/16W Digi-Key P2.00KLCT-ND 2
R7, R8, R9 10K SM/R 402 1% 1/16W Digi-Key 311-10.0KLCT-ND 3
R12 0.25Ohm Radial Current-Sense Res Digi-Key 15FR250-ND 1R13 51K SM/R 402 1% 1/16W Digi-Key 311-51.0KLCT-ND 1U23 HCTL2000 Through hole Quadrature Decoder 1U26 10MHz OSC SMD HSM938H Digi-Key CW303-ND 1U35 PIC 18F252 SOIC 28 pin Microcontroller Digi-Key PIC18F252-I/SO-ND 1Y1 10MHz Crystal SMT Can ATS100SM Digi-Key CTX508-ND 1
Brushless Motor 24V, 40W, Encoder
Shinano Kenshi LA052-040E-3NL1 1
Resettable fuse 1.25A 15V SMD MF-SM123CT-ND 1
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 (10MHz) Disable all other bit word settings Configuration Variables: Motor speed Max = -3200rpm to 3200rpm Motor PWM period = FF (255 clock cycles) Max motor duty cycle = 1000 Fin position = 3000 to 5000 (4000 is initialized position) Baud Rate = 57.6k Internal clock = 10MHz MAIN PROGRAM While loop overview: 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 Processing Command: 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 No Command is sent: 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: 6 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 10 times) Read decoder 10 times (multiple reads decreases error) Convert data to rpm (freq of 10th read = 10.1Hz) 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 4000 (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