7/30/2019
Basys MX3 Reference Manual [Reference.Digilentinc]
https://reference.digilentinc.com/reference/microprocessor/basys-mx3/reference-manual?_ga=2.68739409.1349070004.1564406803-1961480359.…
34/52
All servos come with three wires: power, ground, and control. Pulses are sent via the control wire and a pulse-width modulation signal
controls the direction and degree of rotation. Usually servos are designed with limited rotation angles like 60º, 90°, 180°, and so on.
Using the control signals exposed by the two servo connectors, called S0_PWM and S1_PWM, the PIC32 can command the servos attached
to the two connectors. Since the control should use the PWM functionality, these pins need to be mapped over output compare modules
OC5 and OC4.
Each servo motor connector exposes the barrel voltage (5V) together with the GND (). This means using the servo headers requires that an
external power supply is connected to the barrel power connector.
Table 15.1 below shows the content of the two servo headers, providing details on S0_PWM and S1_PWM signals.
Table 15.1. Servo header connectivity.
Connector
Label on the
Servo
Connector
Signal
Name
PIC32 pin
Description
SERVO 0
PWM
S0_PWM
AN8/RPB8/CTED10/RB8
The control signal for servo 0
VBAR
VBAR
The power VBAR (5V) and GND () provided from the
external power supply (using the barrel connector), to be
used for servo 0
GND ()
GND ()
SERVO 1
PWM
S1_PWM
RPA15/RA15
The control signal for servo 1
VBAR
VBAR
The power VBAR (5V) and GND () provided from the
external power supply (using the barrel connector), to be
used for servo 1
GND ()
GND ()
The S0_PWM and S1_PWM pins will be used as digital output pins:
The corresponding TRIS bit must be set to 0:
TRISBbits.TRISB8 = 0;
TRISAbits.TRISA15 = 0;
The ANSEL bit corresponding to S0_PWM should be set to 0:
ANSELBbits.ANSB8 = 0;
Servo motor driver functionality is implemented in the SRV library of the Basys MX3 library pack. Implementation features include:
RB8 is mapped to OC5
RPB8R = 0x0B; // 1011 = OC5
RA15 is mapped to OC4
RPA15R = 0x0B; // 1011 = OC4
OC5 and OC4 are properly configured, together with associated Timer 3
Configuration functions are implemented for each servo. These functions configure OC5RS or OC4RS according to the desired duty.
If users want to control the servos without the SRV library, they must implement their own servo control functionality.
15.1. Connectivity
15.2. Functionality
15.3. Shared Pins