Digilent MX4cK User Manual

CCeerreebboott MMXX44ccKK™
RReeffeerreennccee MMaannuuaal
Revision: December 15, 2011 Note: This document applies to REV C of the board.
™ BBooaarrdd
l
Overview
The Cerebot MX4cK is a microcontroller development board based on the Microchip PIC32MX460F512L, a member of the 32-bit PIC32 microcontroller family. It is compatible with Digilent’s line of Pmod™ peripheral modules, and is suitable for use with the Microchip MPLAB® IDE tools. The Cerebot MX4cK is also compatible for use with the chipKIT™ MPIDE development environment. ChipKIT and MPIDE is a PIC32 based system compatible with many existing Arduino™ code examples, reference materials and other resources.
The Cerebot MX4cK is designed to be easy to use and suitable for use by anyone from beginners to advanced users for experimenting with electronics and embedded control systems. A built in programming/debugging circuit compatible with the Microchip MPLAB® IDE is provided on the board, so no additional hardware is required for use with MPLAB. The kit contains everything needed to start developing embedded applications using either the MPLAB® IDE or the MPIDE.
The Cerebot MX4cK provides 74 I/O pins that support a number of peripheral functions, such as USB controller, UART, SPI and I2C™ ports as well as five pulse width modulated outputs and five external interrupt inputs. Fifteen of the I/O pins can be used as analog inputs in addition to their use as digital inputs and outputs.
The Cerebot MX4cK can be powered via USB, or an external power supply that may be either an AC-DC power adapter, or batteries.
1300 Henley Court | Pullman, WA 99163
(509) 334 6306 Voice and Fax
Cerebot MX4cK Circuit Diagram
Doc: 502-220 page 1 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
Functional Description
The Cerebot MX4cK is designed for embedded control and robotics control applications as well as for general microprocessor experimentation. Firmware suitable for many applications can be downloaded to the Cerebot MX4cK’s programmable PIC32 microcontroller.
Features of the Cerebot MX4cK include:
a PIC32MX460F512L microcontroller
support for programming and
debugging within the Microchip MPLAB development environment
nine Pmod connectors for Digilent peripheral module boards
eight hobby RC servo connectors
USB 2.0 Device, Host, and OTG
support
two push buttons
four LEDs
multiple power supply options, including
USB powered
ESD protection and short circuit protection for all I/O pins.
Features of the PIC32MX460F512L include:
512KB internal program flash memory
32KB internal SRAM memory
USB 2.0 compliant full-speed On-The-
Go (OTG) controller with dedicated DMA channel
two serial peripheral interfaces (SPI)
two UART serial interfaces
two I2C serial interfaces
five 16-bit timer/counters
five timer capture inputs
five compare/PWM outputs
sixteen 10-bit analog inputs
two analog comparators
The Cerebot MX4cK has a number of input/output connection options, and is specially designed to work with the Digilent Pmod™ line of peripheral modules to provide a
www.digilentinc.com page 2 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
variety of input and output functions. For more information, see www.digilentinc.com. In addition to the Pmod connectors, the board provides eight connectors for RC hobby servos, two push button switches, and four LEDs, as well as providing connections for two I2C busses. A serial EEPROM and a 12-bit digital to analog converter are provided on one of the I2C busses.
The Cerebot MX4cK features a flexible power supply system with a number of options for powering the board as well as powering peripheral devices connected to the board. It can be USB powered via either the debug USB port or the USB device port, or it can be powered from an external power supply or batteries.
Programming Tools
The Cerebot MX4cK can be used with either the Microchip MPLAB® development environment or the chipKIT MPIDE development environment. When used with the MPLAB IDE, in-system-programming and debugging of firmware running on the PIC32MX460 microcontroller is supported using an on-board programming/debugging circuit licensed from Microchip.
The Cerebot MX4cK is immediately useable with either the MPLAB IDE or the chipKIT MPIDE. No additional hardware is required to use the board with the Microchip MPLAB tools.
Using the Cerebot MX4cK with Microchip Development Tools
The Microchip MPLAB® IDE or the MPLAB® X IDE can be used to program and debug code running on the Cerebot MX4cK board using a built-in programming/debugging circuit licensed from Microchip.
The MPLAB programs can be freely downloaded from the Microchip web site. These software suites include a free evaluation
Cerebot MX4cK Reference Manual
copy of the Microchip C32 compiler for use with the PIC32 microcontroller family. The licensed debugger is compatible with the MPLAB IDE version 8.63 or later.
When creating a new project, use the “Configure.Select Device…” menu to specify the PIC32 device being used. Ensure that the device is set to PIC32MX460F512L.
In order to use the on-board program/debug circuit it must be selected as the debugger or programmer within the MPLAB IDE. Use the “Debugger.Select Tool” menu, or the “Programmer.Select Tool” menu, and select “Licensed Debugger” as the programmer or debugger.
The licensed debugger interface uses USB connector J9, labeled DEBUG. Connector J9 is a USB micro-B connector. Use a USB-A to micro-B cable (provided with the board) to connect to an available USB port on the PC.
When the licensed debugger is selected as the programming or debugging device, the MPLAB IDE will check the version number of the firmware running on the debugger and offer to update it if is out of date with the version of MPLAB being used.
The in-system programming/debugging interface uses two pins on the PIC32 microcontroller. The PIC32 devices support two alternate pin pairs for this interface: PGC1/PGD1 or PGC2/PGD2. PIC32 devices use PGC2/PGD2 by default. The Cerebot MX4ck is designed to use PGC2/PGD2. It is not normally necessary to select the use of PGC2/PGD2 for the debugging interface, as this should occur automatically.
If for some reason, it is necessary to select the correct pins for the programming/debugging interface, this can done using configuration variables set using the
#pragma config
statement. The following statement can be
used to configure the microcontroller for use with the on-board licensed debugger circuit:
#pragma config ICESEL = ICS_PGx2
The MPLAB IDE may report an error indicating that the device is not configured for debugging until the first time a program is loaded onto the board.
The MCLR pin on the PIC32 microcontroller is used by the hardware programming/debugging interface to reset the processor. This same pin is used by the USB serial converter to reset the processor when using the MPIDE. It is possible that the reset function from the USB serial interface can interfere with correct operation of the Microchip programming and debugging tools. If this happens, jumper JP8 can be used to disconnect the USB serial converter reset circuit. Remove the shorting block from JP8 to disable the reset circuit. If the shorting block has been removed, it is necessary to reinstall it on JP8 in order to use the Cerebot MX4cK board with the MPIDE again.
Using the Microchip development tools to program the Cerebot MX4cK will erase the chipKIT boot loader. To use the board with the chipKIT MPIDE again, it is necessary to program the boot loader back onto the board. The programming file for the boot loader programmed into the board by Digilent at the factory is available for download from the product page for the Cerebot MX4cK on the Digilent web site. Additionally, the boot loader source code is available in the chipKIT project repository at www.github.com/chipKIT32/pic32-
Arduino-Bootloader.
To reprogram the boot loader using MPLAB, perform the following steps:
Use the “Configure.Select Device …” menu to select the PIC32MX460F512L
Use the “Programmer.Select Programmer” menu to select the “Licensed Debugger”.
www.digilentinc.com page 3 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
Use the “File Import…” dialog box to navigate to and select the boot loader programming downloaded from the Digilent web site. The file name will be something like: chipKIT_Bootloader_MX4cK.hex
Use the “Programmer.Program” command to program all memories on the device.
Using the Cerebot MX4cK with the chipKIT MPIDE
ChipKIT and the MPIDE is a PIC32 based hardware and software system compatible
many existing Arduino™
code examples, reference materials and other resources. The MPIDE development platform was produced by modifying the Arduino™ IDE and is fully backward compatible with the Arduino IDE. The Cerebot MX4cK board is designed to be fully compatible with the chipKIT MPIDE system, version 20111209 or later.
The MPIDE uses a serial communications port to communicate with a boot loader running in the target board. The serial port on the MX4cK board is implemented using an FTDI FT232R USB serial converter. Before attempting to use the MPIDE to communicate with the MX4cK, the appropriate USB device driver must be installed.
The USB serial converter on the Cerebot MX4cK board uses USB connector J8, labeled UART on the board. This connector is a micro­USB. Use a standard USB-A to mini-B cable (provided with the board) to connect the board to an available USB port on the PC.
In the MPIDE, use the “Tools.Board” command to select the Cerebot MX4cK from the list of available boards. Use the “Tools.Serial Port” command to choose the appropriate serial port from the list of available serial ports on the PC.
When the MPIDE needs to communicate with the MX4cK board, the PIC32 microcontroller is reset and starts running the boot loader. The MPIDE then establishes communications with
www.digilentinc.com page 4 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
with
the boot loader and downloads the program to the board.
When the MPIDE opens the serial communications connection on the PC, the DTR pin on the FT232R chip is driven low. This pin is coupled through a capacitor to the MCLR pin on the PIC32 microcontroller. Driving the MCLR line low resets the microcontroller, restarting execution with the boot loader.
Once the MPIDE has established communication with the boot loader, it transfers the user’s program to the boot loader, which programs it into the flash memory in the Microcontroller.
The automatic reset action when the serial communications connection is opened can be disabled. To disable this operation, remove the shorting block from jumper JP8. The shorting block is reinstalled on JP8 to restore operation with the MPIDE.
Two red LEDs (LD7 and LD8) will blink when data is being sent or received between the Cerebot MX4cK and the PC over the serial connection.
The header connector J7 provides access to the other serial handshaking signals provided by the FT232R. Connector J7 is not loaded at the factory but can be installed by the user to access these signals.
Additional Reference Documentation
For additional information about the Cerebot MX4cK board and the use and operation of the PIC32MX460F512L microcontroller, refer to the following documents in addition to this reference manual.
The Cerebot MX4cK Schematic, available on the Cerebot MX4cK product page on the Digilent web site: www.digilentinc.com
Cerebot MX4cK Reference Manual
The PIC32MX3XX/4XX Family Data Sheet and the PIC32MX Family Reference Manual available from the Microchip web site:
www.microchip.com
Additional reference material for the chipKIT MPIDE system is included in the MPIDE software download, and on-line in the chipKIT wiki. Help with questions and problems using the board with the chipKIT MPIDE software can also be obtained in the chipKIT forums:
www.github.com/chipKIT32 (software
download)
www.chipKIT.org/wiki www.chipKIT.org/forum
www.digilentinc.com page 5 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
Board Hardware Description
The following describes the various hardware features of the Cerebot MX4cK board and the PIC32XM460F512L microcontroller.
Power Supply
Switch SW1, in the lower left corner of the board is the power switch. Place this switch in the ON position to turn on board power and in the OFF position to turn off board power.
The Cerebot MX4cK may be USB powered via either the USB debug port, the USB UART port, or the USB device port. Alternatively, the board may be powered via dedicated, “external”, power supply connectors.
Jumper block J12 is used to select the power source used to provide power to the board. This jumper block provides the following four positions:
USB – power is supplied by USB device connector J15. This is used when the Cerebot MX4cK is used to implement a USB bus powered device.
EXT – Power is supplied by one of the external power connectors.
DBG – Power is supplied by DEBUG USB connector J9.
URT – Power is supplied by UART USB connector J8.
Place the shorting block in the appropriate position on J12 for the desired power source for the board.
The Cerebot MX4cK is rated for external power from 3.6 to 12 volts DC. Using a voltage outside this range could damage the board and connected devices. If operating the board at a voltage higher than 5V, it is necessary to remove the shorting block on jumper JP10 to protect the USB load switch, which is limited to a maximum voltage of 5.5V. When operating
from any of the three USB sources, the input voltage will be 5V.
The output of power select jumper block J12 is connected to the VIN power bus. The VIN power bus supplies power to Q3, a PFET load switch, and IC9, the voltage regulator for the licensed debugger circuit. The licensed debugger circuit is powered as soon as the power switch is turned on. Power to the rest of the board is controlled by Q3. The main board power supply is enabled by bringing the gate of Q3 low. When Q3 is turned on, the unregulated power bus BRD_VU is powered.
If the licensed debugger is connected to an active USB port, it enumerates with the host computer and once it has successfully been enumerated, it turns on the main board power supply by driving the PWR_ON signal high.
If the licensed debugger is not connected to an active USB port, the PWR_ON signal is ignored and board power is turned on immediately by the power switch via transistor Q4.
The main board power supply is a switch mode voltage regulator implemented using a Microchip MCP16301 switch mode step-down regulator. This regulator provides 3.3V at up to 600 mA with approximately 96% efficiency. This powers the main board regulated power bus BRD_3V3
There are three connectors on Cerebot MX4cK for connecting an external power supply: J13, J14, and J18.
The barrel connector, J13, is useful for desktop development and testing where using USB or battery power is not suitable. J13 is the connector used by the AC adapter optionally available from Digilent, or other sources. J13 is a 2.5mm x 5.5mm coaxial connector wired with the center terminal as the positive voltage.
www.digilentinc.com page 6 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
Connector J14 is a two-pin male header that provides easy battery or battery-pack connection. Digilent has both two-cell and four-cell AA battery holders with two pin connectors available for connection to J14.
Connector J18 is a screw terminal connector for an alternative power supply connection for use with higher current battery packs, bench supplies or other power sources where use of a hard wired power supply is desirable.
Connectors J13, J14, and J18 are wired in parallel and connect to the “External Power” position on the Power Select jumper block J12. A shorting block should be placed on the “EXT” position of J12 when using this option for board power. Only one of these three power connectors should be used at a time. If multiple power supplies are connected simultaneously, damage to the board or the power supplies may occur.
The Cerebot MX4cK has a second screw terminal connector, J5 that supplies power to the servo power bus, VS, to power the RC hobby servo connectors. This allows servos to be powered from a separate power supply than the one powering the electronics on the Cerebot MX4cK. This can be useful when using servos that draw large amounts of power.
Jumper JP1 can be used to connect the Cerebot MX4cK unregulated power bus BRD_VU to the servo power bus, VS. When no shorting block is installed on JP1, the BRD_VU and VS busses are separate. When a shorting block is on JP1, the two busses are joined and the BRD_VU bus can be powered in any of the previously indicated ways, or from connector J5.
The Cerebot MX4cK can provide power to any peripheral modules attached to the Pmod
that can be powered by either unregulated voltage, BRD_VU, or regulated voltage, BRD_3V3, by setting the voltage jumper block to the desired position. The I2C power connectors only provide regulated voltage, BRD_3V3.
The PIC32 microcontroller and on-board I/O devices operate at a supply voltage of 3.3V provided by the BRD_3V3 bus. The PIC32 microcontroller will use approximately 55mA when running at 80MHz. The remaining current is available to provide power to attached Pmod and I2C devices.
Power Supply Monitor Circuit
The Cerebot MX4cK microcontroller can measure the power supply voltage on the BRD_VU and VS power busses using the provided power supply monitor circuits. This feature is especially useful when using batteries because it allows the microcontroller firmware to determine the charge state of the battery and potentially notify the user when a battery supply is low.
Each power supply monitor circuit is made up of a voltage divider that divides the power bus voltage by four, and a filter capacitor to stabilize the voltage. Jumper JP4 enables the supply monitor circuit for BRD_VU power bus, and jumper JP2 enables the supply monitor circuit for the VS power bus. The analog to digital converter built into the PIC32 microcontroller is used to measure the power supply voltages. ADC channel 8 is used to measure BRD_VU and ADC channel 9 is used to measure VS.
When using the Cerebot MX4cK with the chipKIT MPIDE, these are accessed using the analogRead() function using analog input A6 to read BRD_VU and A7 to read VS.
connectors and to I2C devices powered from the I2C daisy chain connectors, J2 and J6. Each Pmod connector provides power pins
www.digilentinc.com page 7 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
Pmod™ Connectors
The Cerebot MX4cK has nine connectors for connecting Digilent Pmod peripheral modules. The Pmod connectors, labeled JA–JF and JH– JK, are 2x8 right-angle, female pin header connectors. Each connector has an associated power select jumper block labeled JPA–JPF and JPH–JPK.
Digilent Pmods are a line of small peripheral modules that provide various kinds of I/O interfaces. The Pmod product line includes such things as button, switch and LED modules, connector modules, LCD displays, high current output drivers, various kinds of RF interfaces, and many others.
There are two styles of Pmod connector: six­pin and twelve-pin. Both connectors use standard pin headers with 100mil spaced pins. The six-pin connectors have the pins in a 1x6 configuration, while the twelve-pin connectors use a 2x6 configuration. All of the Pmod connectors on the Cerebot MX4cK are twelve pin connectors.
The six-pin connectors provide four I/O signals, ground and a switchable power connection. The twelve-pin connectors provide eight I/O signals, two power and two ground pins. The twelve-pin connectors have the signals arranged so that one twelve-pin connector is equivalent to two of the six-pin connectors. Pins 1–4 and 7–10 are the signal pins, pins 5 and 11 are the ground pins and pins 6 & 12 are the power supply pins.
The pin numbering that Digilent uses on the twelve-pin Pmod connectors is non-standard. The upper row of pins are numbered 1–6, left to right (when viewed from the top of the board), and the lower row of pins are numbered 7–12, left to right. This is in keeping with the convention that the upper and lower rows of pins can be considered to be two six­pin connectors stacked. When viewed from the end of the connector, pin 1 is the upper right
pin and pin 7 is immediately below it (closer to the PCB).
Each Pmod connector has an associated power select jumper. These are used to select the power supply voltage supplied to the power supply pin on the Pmod connector. They are switchable between either the unregulated power supply, BRD_VU, or the 3.3V main board supply, BRD_3V3. Place the shorting block in the 3V3 position for regulated 3.3V and in the VU position to use the unregulated supply.
Each signal pin on the Pmod connectors is connected to an input/output pin on the PIC32 microcontroller. Each pin has a 200 ohm series resistor and an ESD protection diode. The series resistor provides short circuit protection to prevent damaging the I/O block in the microcontroller if the pin is inadvertently shorted to VDD or GND, or two outputs are shorted together. The ESD protection diode protects the I/O block from damage due to electro-static discharge.
Although ESD protection is provided between the connector pins and the microcontroller pins, ESD safe handling procedures should be followed when handling the circuit board. The pins on the microcontroller and other circuits on the board are exposed and can be damaged through ESD when handling the board.
Digilent Pmod peripheral modules can either be plugged directly into the connectors on the Cerebot MX4cK or attached via cables. Digilent has a variety of Pmod interconnect cables available.
See the Pinout Tables in Appendix C, for more information about connecting peripheral modules and other devices to the Cerebot MX4cK. These tables describe the mapping between pins on the PIC32MX460 microcontroller and the pins on the various connectors.
www.digilentinc.com page 8 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
The PIC32 microcontroller can source or sink a maximum of 18mA on all digital I/O pins. However, to keep the output voltage within the specified input/output voltage range (VOL 0.4V, VOH 2.4V) the pin current must be restricted to +7/-12mA. The maximum current that can be sourced or sunk across all I/O pins simultaneously is +/-200mA. The maximum voltage that can be applied to any digital I/O pin is 5.5V. For more detailed specifications, refer to the PIC32MX3XX/4XX Family Data Sheet.
Digital Inputs and Outputs
The Cerebot MX4cK board provides access to 72 of the I/O pins from the PIC32 microcontroller via the Pmod connectors. Two additional I/O pins can be accessed via the I2C connector, J6. Any of the pins on the Pmod or I2C connectors can be individually accessed for digital input or output. Note that when the I2C signals on J6 are being used for I2C communications, they are not available for general purpose I/O. Note that the signals on I2C connector J2 are shared with pins 1 & 2 of Pmod connector JF.
On PIC32 microcontrollers, the input/output pins are grouped into I/O Ports and are accessed via peripheral registers in the microcontroller. There are seven I/O Ports numbered A–G and each is 16 bits wide. Depending on the particular PIC32 microcontroller, some of the I/O Ports are not present, and not all 16 bits are present in all I/O Ports.
Each I/O Port has four control registers: TRIS, LAT, PORT, and ODC. The registers for I/O Port A are named TRISA, LATA, PORTA and ODCA. The registers for the other I/O Ports are named similarly.
The TRIS register is used to set the pin direction. Setting a TRIS bit to 0 makes the pin
an output. Setting the TRIS bit to 1 makes the pin an input.
The LAT register is used to write to the I/O Port. Writing to the LAT register sets any pins configured as outputs. Reading from the LAT register returns the last value written.
The PORT register is used to read from the I/O Port. Reading from the PORT register returns the current state of all of the pins in the I/O Port. Writing to the PORT register is equivalent to writing to the LAT register.
PIC32 microcontrollers allow any pin set as an output to be configured as either a normal totem-pole output or as an open-drain output. The ODC register is used to control the output type. Setting an ODC bit to 0 makes the pin a normal output and setting it to 1 makes the pin a open drain output.
Refer to the PIC32MX3XX/4XX Family Data Sheet, and the PIC32 Family Reference Manual, Section 12, IO Ports, for more detailed information about the operation of the I/O Ports in the microcontroller.
The chipKIT MPIDE system uses logical pin numbers to identify digital I/O pins on the connectors. These pin numbers start with pin 0 and are numbered up consecutively.
On the Cerebot MX4cK, pin numbers 0–71 are used to access the pins on the Pmod connectors and pin numbers 72 and 73 are used for the two signal pins on the I2C connector, J6. The pin numbers are assigned so that connector JA pin 1 (JA-01) is digital pin 0, JA pin 2 (JA-02) is digital pin 1, and so on.
Pins 0-7 are on connector JA, pins 8-15 on JB, pins 16-23 on JC, pins 24-31 and so on. Refer to the tables in Appendix C for detailed information about the pin mapping between Pmod connector, logical pin number, and PIC32 microcontroller pin number and pin function.
www.digilentinc.com page 9 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
When using the Cerebot MX4cK with the chipKIT MPIDE the functions pinMode(), digitalRead(), and digitalWrite() are used for digital pin I/O.
The pinMode() function is used to set the pin direction. Pin direction can be set to: INPUT, OUTPUT, or OPEN. OPEN is used for open­drain and implies output.
The digitalRead() and digitalWrite() functions are used to read or write the pins. DigitalRead() returns the current state of the specified pin, and digitalWrite is used to set the state of an output pin. The pin state can be either HIGH or LOW.
PIC32MX460 Pin 20
Pin 20 on the PIC32MX460 has multiple functions. It provides the VBUSON signal when the board is being used to implement a USB host. It also provides the positive input for analog comparator 1, analog to digital converter input AN5, change notice interrupt CN7 and bit 5 of general I/O Port B. In order to support all of these different functions, jumper block J16 is used to select the routing of this pin.
Normally, the shorting block will be in the JJ-8 position. This connects microcontroller pin 20 to Pmod connector JJ pin 8. This allows the use of most functions of this pin.
When the board is being used as a USB host, the shorting block is placed in the VBUSON position to allow use of the VBUSON signal to control power to the USB bus.
Placing the shorting block in the DAC position connects the output of IC3, the MCP4725 digital to analog converter to microcontroller pin 20. This allows use of the DAC output to be used as a programmable reference for analog comparator 1.
Push Buttons and LEDs
The Cerebot MX4cK board provides two push button switches for user input and four LEDs for output. The buttons, BTN1 and BTN2 are connected to I/O pins TRCLK/RA6 and TRD3/RA7 respectively. To read the buttons, pins 6 and 7 of I/O Port A must be set as inputs by setting the corresponding bits in the TRISA register. The button state is then obtained by reading the PORTA register. When a button is pressed, the corresponding bit will be high (‘1’). Note that the microcontroller pins used by the buttons are shared with pins 3 & 4 of Pmod connector JF.
The four LEDs are connected to bits 10-13 of I/O Port B. LED 1 is connected to bit 10, LED 2 is connected to bit 11, and so on. These four bits are also shared with pins 1-4 of Pmod connector JK. To use the LEDs, set the desired bits as outputs by clearing the corresponding bits in the TRISB register. The state of an LED is set by writing values to the LATB register. Setting a bit to 1 will illuminate the LED and setting the bit to 0 will turn it off.
When using the MPIDE and the chipKIT system, the buttons are accessed using digitalRead() and the LEDs using digitalWrite(). Use the following pins to access them:
BTN1 – PIN_BTN1, pin 42, RA6
BTN2 – PIN_BTN2, pin 43, RA7
LD1 – PIN_LED1, pin 64, RB10
LD2 – PIN_LED2, pin 65, RB11
LD3 – PIN_LED3, pin 66, RB12
LD4 – PIN_LED4, pin 67, RB13
RC Servo Connectors
The Cerebot MX4cK provides eight 3-pin RC hobby servo connectors, labeled S1-S8, for direct control of servos in robotics and embedded hardware actuator applications. The connectors share the I/O pins with Pmod connector JC. Individual I/O pins may be
www.digilentinc.com page 10 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Cerebot MX4cK Reference Manual
accessed through the JC connector if they're not being used to control a servo.
RC Servos use a pulse width modulated signal, PWM, to control the servo position. The 16-bit timers in the PIC32 microcontroller have the ability to generate PWM signals using the output compare registers. However, it is also possible to use timer interrupts to accomplish this same thing. Using timer interrupts allows a single timer to be used to control the signal timing for all eight servo connectors.
The servo connectors on the Cerebot MX4cK board are intended to be driven using timer interrupts rather than directly by the pulse width modulators in the internal timers. This frees the pulse width modulators for other uses, such as DC motor speed control. Digilent has a reference design available that illustrates using timer interrupts to control
A common power bus (BRD_VU) for the Cerebot MX4cK and servos
Separate on-board power busses for the Cerebot MX4cK (BRD_VU) and the servos (VS)
An on-board power bus for the Cerebot MX4cK (BRD_VU) and an external power bus for servos
For the first case above: Install a shorting block on jumper JP1 to connect the VS servo power bus to the BRD_VU power bus. The servo power bus is then powered from the same source as the BRD_VU power bus. Powering a large number of servos from USB power is not recommended. Pin header jumpers and shorting blocks such as JP1 are rated for a maximum of 2A of current. USB power (J12 in the USB, DBG, or URT positions) should only be used to power a couple of servos to avoid exceeding the 500mA that a USB device is allowed to use.
signal timing for the PWM signals to control RC servos.
When using the chipKIT MPIDE development environment, the Servo library can be used to drive servos attached to these connectors. The symbols PIN_S1 through PIN_S8 can be used to specify the servo connectors being used.
The following give the correspondence between servo connector, MPIDE digital pin number, and microcontroller I/O Port register and bit position:
S1 – PIN_S1, digital pin 16, RG12
S2 – PIN_S2, digital pin 17, RG13
S3 – PIN_S3, digital pin 18, RG14
S4 – PIN_S4, digital pin 19, RG15
S5 – PIN_S5, digital pin 20, RG0
S6 – PIN_S6, digital pin 21, RG1
S7 – PIN_S7, digital pin 22, RF0
S8 – PIN_S8, digital pin 23, RF1
There are three options for supplying power to the servo connections:
For the second case above: Remove the shorting block from jumper JP2 to make the VS servo power bus independent from the BRD_VU bus. Attach the servo power supply to screw terminal connector J5.
Finally, for very high servo current applications, a separate power bus external to the Cerebot MX4cK can be used to provide servo power. In this case, remove the shorting block on JP1, tie the external servo power bus ground to the Cerebot MX4cK ground through the ground terminal on J10, and use pin 1 on the servo connectors to bring the servo control signals out to the servos. The servo power and ground connections are made off-board.
The on-board servo power bus can be used to provide a maximum of 2A to each servo connector and 5A total to all servo connectors.
5V Signal Compatibility
The PIC32 microcontroller operates at 3.3V. And the I/O pins provide 3.3V logic levels. It is possible, in some circumstances, to use the
www.digilentinc.com page 11 of 35
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
Loading...
+ 24 hidden pages