PSoC 5LP Operator Interface for the FIRST Robotics Competition Contents Overview ....................................................................................................................................................... 2 Getting Started.............................................................................................................................................. 2 Hardware .................................................................................................................................................. 2 Software .................................................................................................................................................... 3 USB Connections ....................................................................................................................................... 3 Power Considerations ............................................................................................................................... 4 Loading Firmware ..................................................................................................................................... 4 Using the CY8CKIT-59 as an HID Game Controller ........................................................................................ 8 USB Connection ........................................................................................................................................ 8 Pin Assignments ........................................................................................................................................ 8 Analog Inputs ............................................................................................................................................ 9 Digital Inputs (Buttons) ............................................................................................................................. 9 Digital Outputs (LEDs) ............................................................................................................................. 11 Using the CY8CKIT-59 for Other Applications ............................................................................................. 11 Additional Resources .................................................................................................................................. 12 PSoC Creator ........................................................................................................................................... 12 CY8CKIT-059 PSoC 5LP Prototyping Kit ................................................................................................... 13 CY8CKIT-049 PSoC 4 Prototyping Kit ....................................................................................................... 13 USB HID ................................................................................................................................................... 13 Developer Forums................................................................................................................................... 14 Page 1 of 15 Overview The CY8CKIT-059 PSoC 5LP Prototyping Kit is a small but very powerful system. It contains a PSoC (Programmable System on a Chip) 5LP device which brings together the features of an ARM Cortex M3 microcontroller, a programmable logic device, and many analog functions into one package. A programmable routing fabric between the peripherals and the pins allows any function to be mapped to any pin. The PSoC target device on the kit includes full speed USB device capability which makes it possible to use it to create a custom operator interface for the FRC. Cypress Semiconductor has created a firmware example so that the kit will enumerate as a USB game controller. With this firmware loaded into the PSoC 5LP, the FRC Driver Station is able to communicate with the prototyping kit as if it were a game controller. The example application provided below is configured with 8 analog inputs, 22 digital inputs (typically used for buttons or switches), and 12 digital outputs (typically used for indicators such as LEDs). Note: The CY8CKIT-059 is provided to rookie teams in 2016 and is available through the First Choice store. The CY8CKIT-049 that was introduced in the 2015 season does not have full speed USB capability. However, that kit is useful for other non-USB robot applications. The additional resources section below contains some links to information regarding the CY8CKIT-049. Getting Started Hardware CY8CKIT-059 PSoC 5LP Prototyping Kit Included in 2016 rookie KOPs Available in the First Choice Store Order from Cypress.com store Order from Digikey.com Order from Mouser.com USB A to Micro-B cable USB A male to USB A female extension cable (optional) Order from Amazon.com Order from Digikey.com Order from Mouser.com Page 2 of 15 Software Depending on what you want to do with the prototyping kit, there are several different software packages to choose from: In order to program the provided example Game Controller firmware, PSoC Programmer is required. This software is provided free by Cypress Semiconductor. It is also included in the NI FIRST Update. If you want to modify the firmware or create your own completely custom project, the PSoC Creator IDE can be used. This fully featured IDE is also provided free by Cypress Semiconductor. Note that the installer for PSoC Creator also includes PSoC Programmer so if you chose to install PSoC Creator, you do not need to install PSoC Programmer separately. The CY8CKIT-059 PSoC 5LP Prototyping Kit web site includes links to the kit documentation as well as an installer that contains the documentation, firmware examples, the kit schematic, and kit layout files. Note that there is a full installer which includes PSoC Creator and PSoC Programmer and a minimal installer which contains only the kit files. Purpose Program example game controller firmware to the kit View and modify the example game controller project or create your own custom project View kit documentation and design Web Site PSoC Programmer Direct Download Link PSoC Programmer PSoC Creator PSoC Creator (includes Programmer) CY8CKIT-059 CY8CKIT-059 (includes Creator and Programmer) CY8CKIT-059 (kit files only) USB Connections The CY8CKIT-059 actually contains two PSoC 5LP devices – one is the target device and the other is used to program and debug the target device. Both devices have USB capability. The target device connects to a standard USB Micro type-B connector (labeled PSoC USB) while the programmer device connects to a board edge connector (labeled KITPROG USB). This board edge connector can be plugged directly into a USB type-A socket with no cable required. Therefore, use the edge connector when you want to program the target device, and use the Micro type-B connector when you want to use the target device (i.e. when you are using the PSoC 5LP as a game controller). Note: a USB type-A male to USB type-A female extension cable can be used if the board is mounted in such a way to make it difficult to plug directly into a USB type-A socket. Page 3 of 15 Power Considerations The CY8CKIT-059 can be powered in three ways: 1. USB bus powered from the card edge connector 2. USB bus powered from the Micro-B connector 3. External 3.3V – 5.5V supplied at the VDD or VDDIO pins The kit will automatically draw power from the highest voltage supply so if an external supply is being used along with a USB connection then the external supply should be 5V or greater. It is recommended that not both USB connectors be attached at the same time to reduce the possibility of overloading one of the USB ports since all power will be drawn from whichever USB port is at a higher voltage. Loading Firmware In order to load the example project containing an HID game controller, follow the steps below. 1. Locate the project’s firmware file (CyController1.hex). This file is included in the NI FIRST Update and is available on the Cypress FIRST Robotics Competition forum page (http://www.cypress.com/forum/first-robotics-competition/) in the topic titled “PSoC 5LP Operator Interface for the FIRST Robotics Competition”. 2. Install PSoC Programmer if you have not already done so. 3. Connect the kit to a PC via the board edge connector (KITPROG USB). Drivers will be automatically installed. Wait for driver installation to complete before going to the next step. 4. Open PSoC Programmer. This can be found at: Start -> All Programs -> Cypress -> PSoC Programmer 3.23.1 -> PSoC Programmer 3.23.1 5. Once Programmer starts, it should connect to the KitProg automatically and power the board as shown in the figure below. If the kit is not connected, click on the KitProg in the Port Selection window. Page 4 of 15 Note: if you get a message that your programmer is out of date, go to the Utilities tab and click on Upgrade Firmware as shown below. Note: if the KitProg does not show up in the Port Selection window, see the Troubleshooting section. 6. Verify the programming parameters are as shown in the figure below. Note that the file path will be different than what is shown in the figure. You will select the file in the next step. Page 5 of 15 7. Chose File -> Load and navigate to the firmware file that you downloaded in step 1. 8. Chose File -> Program to program the firmware. You should see a programming succeeded message as seen in the figure below. 9. Remove the board edge connector the USB port before connecting a cable to the Micro-B connector. Page 6 of 15 Page 7 of 15 Using the CY8CKIT-59 as an HID Game Controller USB Connection Once the example firmware has been programmed into the kit, connect it to a PC using a USB type A to Micro B cable. Once drivers have installed, you will see the device appear as a joystick in the Driver Station software. Pin Assignments The example firmware provides 8 analog inputs, 22 digital inputs (typically used for buttons or switches), and 12 digital indicator outputs (typically used for LEDs). The pin assignments are illustrated in the figure. Connect USB here to program firmware Button 1 Button 2 Button 3 Button 4 Button 5 Button 6 Button 7 Button 8 Indicator 1 Indicator 2 Indicator 3 Indicator 4 Indicator 5 Indicator 6 Analog 1 (X) Analog 2 (Y) Analog 3 (Z) Analog 4 (RX) Analog 5 (RY) Analog 6 (RZ) Analog 7 (SLIDER) Analog 8 (DIAL) Button 22 Button 21 Button 20 Button 19 Button 18 Button 17 Indicator 7 Indicator 8 Indicator 9 Indicator 10 Indicator 11 Indicator 12 Button 16 Button 15 Button 14 Button 13 Button 12 Button 11 Button 10 Button 9 Connect USB here to use in the OI Note: the pin used for Button 10 (P2[1]) is connected to an LED on the board. That LED will turn on when Button 11 if pressed. This is normal behavior and can be ignored. If you don’t want the LED to light, you can either not use Button 11 in your design or you can remove the LED from the board. Removing that LED will not cause any functional issues with the board. Page 8 of 15 Analog Inputs Eight analog inputs are provided in the example firmware. These inputs accept analog inputs from GND to VDD which will correlate to 0% and 100% in the Driver Station. If the kit is powered by the USB bus power line, then the range will be from 0V to 5V. The standard names for analog inputs in game controllers are used for the 8 inputs: X, Y, Z, RX, RY, RZ, Slider, and Dial. Many different types of analog sensors are available but the most commonly used is a potentiometer (POT). A relatively high value potentiometer (e.g. 10K – 100K) should be used to reduce the current load on the system. For example, a 10K potentiometer connected to a 5V supply will consume: I = V/R = 5V/10K = 0.5mA The figure shows how a potentiometer would be connected to one of the 8 analog input pins. Digital Inputs (Buttons) The example firmware includes 22 digital inputs typically used for buttons or switches. The input pins on the PSoC are configured to have an internal pull-down resistor so when a button is not pressed, the pin will be pulled to ground. Therefore, the button must be connected to pull the pin high when it is closed as shown below. If you want an LED to turn on whenever a button is pressed or a switch is closed, it can be wired as shown below (some buttons have LEDs integrated in a single package). Use a current limiting resistor in series with the LED to prevent overloading the available system current. A larger resistor will reduce current consumption but will result in a dimmer LED. A typical resistor value of 1Kohm with a supply voltage of 5V will result in a current of 5mA and usually produces an acceptable LED brightness. Page 9 of 15 If you open the example project in PSoC Creator you will notice that the input pins are connected to schematic components called “Debouncer” – see the figure below. These are hardware debouncing circuits which prevent contact bounce on the buttons when they are pressed/released. Since PSoC has programmable digital resources available, it is possible to do the debouncing function in hardware which simplifies the firmware and frees the CPU to do other tasks. The ability to implement parts of the design using internal hardware is one of PSoC’s most powerful features. Page 10 of 15 Digital Outputs (LEDs) Digital outputs can be used for controlling indicators such as LEDs on the board. As mentioned above, a current limiting resistor should be included with each LED in order to reduce the current consumption. A typical connection for an LED is shown in the figure. Using the CY8CKIT-59 for Other Applications As mentioned previously, the PSoC 5LP contains a powerful ARM CPU, many analog functions (ADCs, DACs, Opamps, comparators, etc.), and many digital functions (PWMs, Timers, Counters, Debouncers, etc.) including fully programmable logic. Components are even provided for mixed analog and digital functions such as capacitive sensing (CapSense) which allows mechanical buttons to be replaced by touch sensors. Therefore, the applications for the PSoC 5LP are almost endless. It can be used for many purposes beyond the game controller example provided. If you want to explore additional uses for the PSoC 5LP device, check out the additional resources in the next section. There is a wealth of information ranging from application notes, video on-demand training, example projects, and community forums available for your use. If you want to see the full PSoC Creator project for the USB HID game controller, it can be found on the Cypress FIRST forum page at: http://www.cypress.com/forum/first-robotics-competition/ Look for the topic titled “PSoC 5LP Operator Interface for the FIRST Robotics Competition” To open the project: 1. Install PSoC Creator if you have not already done so. 2. Double click on the file “CyController.cywrk” inside the CyController directory. Page 11 of 15 Additional Resources PSoC Creator The PSoC Creator home page can be found at: http://www.cypress.com/products/psoc-creator. From this site there are many resource links including a link to a video training on demand page at http://www.cypress.com/training. A few useful introductory videos to get you started are: http://www.cypress.com/training/psoc-creator-101-lesson-1-introduction http://www.cypress.com/training/psoc-creator-101-lesson-2-introduction-psoc http://www.cypress.com/training/psoc-creator-101-lesson-3-getting-know-psoc-creator http://www.cypress.com/training/psoc-creator-101-lesson-4-let-s-get-led-blink-part-1 http://www.cypress.com/training/psoc-creator-101-lesson-5-let-s-get-led-blink-part-2 http://www.cypress.com/training/psoc-creator-101-lesson-6-let-s-get-capsense-working http://www.cypress.com/training/psoc-creator-101-lesson-7-ide-export http://www.cypress.com/training/psoc-creator-101-lesson-8-psoc-resources From inside PSoC Creator, you can find example projects by using the menu item File -> Example Project… From the window, you can filter for examples for a specific device familyy (PSoC 5LP for example) and for specific keywords. Each entry is a full PSoC Creator project including documentation. Page 12 of 15 CY8CKIT-059 PSoC 5LP Prototyping Kit The main web page for the CY8CKIT-059 can be found at: http://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lpprototyping-kit. A getting started with PSoC 4 application note can be found here: AN7759 – Getting Started with PSoC 5LP Several video training on demand videos specific to PSoC 5LP are also available: http://www.cypress.com/training/psoc-5-101-introduction-architecture-and-design http://www.cypress.com/training/psoc-5-102-introduction-system-resources http://www.cypress.com/training/psoc-5-103-introduction-digital-peripherals http://www.cypress.com/training/psoc-3-and-psoc-5-201-analog-peripherals CY8CKIT-049 PSoC 4 Prototyping Kit The PSoC 4 target device on the CY8CKIT-049 PSoC 4 Prototyping Kits do not support USB, but those devices still have an ARM processor, analog peripherals, digital peripherals (including fully programmable logic), and interconnect fabric. They are very capable of performing various monitoring and control tasks. The main web page for the CY8CKIT-049 can be found at: http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxxprototyping-kits A getting started with PSoC 4 application note can be found here: AN79953 – Getting Started with PSoC 4 Unlike the CY8CKIT-059, this kit does not have an integrated programmer. Instead it has a USB-Serial device that is used to bootload firmware to the PSoC 4 target device. If you are new to the concept of bootloading a useful application note can be found here: AN73854 – PSoC 3, PSoC 4, and PSoC 5LP Introduction to Bootloaders There is also an introductory video that shows how to use the kit including the bootloading process: http://www.cypress.com/video-library/PSoC-Software/psoc-creator-101-cy8ckit-049prototyping-kit-getting-started/108316 USB HID A few application notes to simplify getting started using USB in PSoC are listed below. Each of these has a detailed document as well as fully functional PSoC Creator projects. AN57473 - USB HID Basics with PSoC 3 and PSoC 5LP Page 13 of 15 AN58726 - USB HID Intermediate with PSoC 3 and PSoC 5LP AN82072 – PSoC 3 and PSoC 5LP USB Generic Data Transfer with Standard HID Drivers Note that many of the example projects are targeted to a PSoC 3 device. In order to use them with the CY8CKIT-059 it is necessary to change the target device. You can do this easily from Creator by using the menu item Project -> Device Selector. From the window that pops up, chose CY8C5888LTI-LP097 as the target device as shown below. Developer Forums PSoC has an active developer community with many forums on different topics. The forums can be accessed from http://www.cypress.com/forum. Many experienced developers as well as Cypress engineers frequent the forums so they are an excellent way to find information and get questions answered. Troubleshooting KitProg Restoration If the board does not show up in PSoC Programmer as a KitProg device when connected to the board edge connector as described in the “Loading Firmware” section, it is possible that the KitProg has been overwritten. To correct this problem follow the steps below. Page 14 of 15 1. If not already done, connect the kit a PC via the board edge connector (KITPROG USB) and open PSoC Programmer. 2. Navigate to the “Utilities” tab. 3. If the “Upgrade Firmware” button is active (not greyed out) click on it to restore the KitProg firmware. 4. If the “Upgrade Firmware” button is greyed out, remove the kit from the USB port and reconnect it while holding the reset button (labeled BOOT/RST). This will put the KitProg into bootloader mode. 5. Once the kit connects as a bootloader you should be able to click the “Upgrade Firmware” button. 6. When the firmware upgrade completes, disconnect and reconnect the kit without holding the reset button. Page 15 of 15