University Programs Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

University Programs Knowledge Base

Labels

Discussions

Sort by:
MCU101 (Theory Topics)   Know Your Microcontrollers   Blink LED   Drive a DC Motor   Turn a Servo   https://community.nxp.com/docs/DOC-1030   Navigating Technical Documentation   C programming for Embedded System Software Tools CodeWarrior Software Development Tools & IDE CodeWarrior Beginners Tutorial (videos)   TRK-MPC 5604B Hardware Setup   Creating a new bareboard project   Debugging a bareboard project   Importing projects and merging code   Discussion of the header files (part 1)   Discussion of the header files (part 2) Qorivva Specific (with Code) Beginners Hands-on Tutorials Blink LED Drive DC Motor Turn A Servo Line Scan Camera Hardware https://community.nxp.com/docs/DOC-1016 DIY Camera Mounting Wiring Connections for TRK-MPC5604b Batteries Advanced Tutorial Series Push-Buttons   I2C Sensors using Kinetis K40 Miscellaneous Topics PCB design tips
View full article
This tutorial covers the details of Blinking an LED on the TRK-MPC5604B: MPC5604B StarterTRAK evaluation board. It will introduce the evaluation board, and some basic CodeWarrior features. Overview Hardware Set up the Software Development Environment A. Download and Install Codewarrior B. Download and Install Drivers Sample Code Serial Debugging: I made the hardware modifications for serial debugging: I did not make the hardware modifications for serial debugging: Download/Debug/Run Learning Step: LED Code Description Functions Blink the LED(s): Other Qorivva Tutorials Useful Links to Technical Data Overview In this exercise students will run sample code and build an application which enables testing of the Qorivva TRK-MPC5604B board. Students will: Configure the Software Development Environment Configure the evaluation board hardware Learn how to open CodeWarrior project example files Build a project Download and run the code on TRK-MPC5604B board Learn how to utilize the GPIO Peripheral to blink a LED   To successfully complete this exercise, students will need the following board and development environment. TRK-MPC5604B evaluation board CWX-MPC-5500P-EX: Evaluation: CodeWarrior for MPC55xx/MPC56xx Microcontrollers V2.8 (Classic) RAppID initialization Tool P&E Micro Driver Software Hardware Read the MCU 101: LEDs article for general information on LED circuits. The LED's are located on the board and visible in the board schematic on page 4 as below: This schematic is found here. Set up the Software Development Environment There are several steps necessary to prepare the evaluation board and PC for microcontroller programming and development. Interfacing the evaluation board with a PC requires downloading and installing the CodeWarrior IDE, as well as the device drivers for programming the microcontroller via USB. A. Download and Install Codewarrior Before completing this example project, download and install CodeWarrior for MPC56xx 2.8 or the latest version. B. Download and Install Drivers In addition to CodeWarrior, it may (needs verified) be necessary to install one or both of the following tools: RAppID initialization tool- RAppID comes on the DVD provided with your evaluation board. In the main directory of the DVD, click on the "TRK_MPC5604B.html" file to open the DVD interface which provides user manuals, software, schematics and documentation for the evaluation board. P&E Microcomputer Systems, Inc drivers- P&E is a a computer driver for the TRK-MPC5604B device, enabling evaluation board programming via USB through the CodeWarrior debug OSJTAG interface. This driver can be downloaded here Because this isn't found on the disk. Sample Code To use the Hyperterminal communications features described in the following sections and in the attached sample code you must populate the U5 on your TRK-MPC5604B board. Qorivva Sample Code Download Serial Debugging: To use hyperterminal style debugging through the Serial port you must populate U5 with a RS232 transceiver and C55. I made the hardware modifications for serial debugging: From the Start menu Run the hyper terminal by using All programs> Accessories> Communications> HyperTerminal and make COMx properties port s ettings as Baud rate 115200, Data bits 8, Parity None, Stop bits 1 and Flow control None. 8. In the project menu select make (or F7) you will get few warning messages. I did not make the hardware modifications for serial debugging: In the project menu select MAKE (or F7) you will get few warning messages and can ignore them. Next select Debug option (or F5) from project menu. The debug window opens with few sub windows such as Code, Status and CPU etc. To run the program, select the Source GO menu button. Note: Much of the code in the sample file is utilized to send and receive messages serially. Some quick, minor changes can be applied as follows: Open main.c within the for loop, remove or comment out all the code. Now, manually call the specific function desired, in this case: for (; ; )      {           LED();      } Download/Debug/Run In sample.mcp project manager window target selection window is set to the default RAM. This means the code runs in the RAM. This target option can be changed using the drop down menu to internal_FLASH. This means the code runs in the flash and this code can run without debugger when the board is powered up. You can select either RAM target or internal_FLASH target for the following test procedure. If you select internal_FLASH target you can test the standalone operation of the board. If you encounter errors, look in the Problems view and resolve them. You can ignore any warnings. If the project builds correctly, it is time to download to the board and watch it work. Ensure that the USB cable that came with the board connects the board to the host computer’s USB port. There are multiple ways to issue the Debug command. Right click the project in the projects view and choose Debug As->CodeWarrior Download. Alternatively, y go to the Run menu and choose Debug (F11). Learning Step: LED Code Description Within the sample code, there is a for loop which calls a switch statement. With working hyper-terminal and proper serial connector interface into a PC, entering the numerical characters "1" - "9" into the hyper-terminal will call each separate function initiating the following actions Blinks Leds & outputs text strings to hyperterminal Calls the Switch function - which sends text strings to hyperterminal indicating which switch has been pressed Calls the Servo function which sweeps the servo back and forth; sends text strings to hyperterminal Calls the motor function which enables and disables the left motor; sends status text strings to hyperterminal Calls the motor function which enables and disables the right motor; sends status text strings to hyperterminal Calls the Camera function which sends the correct signals to the camera and reads the data; sends status text strings to hyperterminal Calls the Left_Motor_Current function; sends status text strings to hyperterminal Calls the Right_Motor_Current function; sends status text strings to hyperterminal   (hyperterminal code documentation needs verified ) TransmitData("\n\r**The Freescale Cup**");         TransmitData("\n\r*********************");         TransmitData("\n\r1.Led\n\r");         TransmitData("2.Switch\n\r");         TransmitData("3.Servo\n\r");         TransmitData("4.Motor Left\n\r");         TransmitData("5.Motor Right\n\r");         TransmitData("6.Camera\n\r");         TransmitData("7.Left Motor Current\n\r");         TransmitData("8.Right Motor Current");         TransmitData("\n\r**********************"); option = ReadData(); option = 1;     switch(option)         {             case '1':                 LED();             break;             case '2':                 SWITCH();             break;             case '3':                 SERVO();             break;             case '4':                 MOTOR_LEFT();             break;             case '5':                 MOTOR_RIGHT();             break;             case '6':                 CAMERA();             break;             case '7':                 LEFT_MOTOR_CURRENT();             break;             case '8':                 RIGHT_MOTOR_CURRENT();             break;             default:             break;          } As visible from the schematic - the LED's are accessed via the following ports. Hardware Chip Port/Pin Comment LED1 PE4 LED2 PE5 LED3 PE6 LED4 PE7 Functions The following function is utilized in the code to blink the LED's This function is located in main.c void LED(void) {    SIU.PCR[68].R = 0x0200;  /* Program the drive enable pin of LED1 (PE4) as output*/    SIU.PCR[69].R = 0x0200;  /* Program the drive enable pin of LED2 (PE5) as output*/    SIU.PCR[70].R = 0x0200;  /* Program the drive enable pin of LED3 (PE6) as output*/    SIU.PCR[71].R = 0x0200;  /* Program the drive enable pin of LED4 (PE7) as output*/    TransmitData("****Led Test****\n\r");    TransmitData("All Led ON\n\r");    Delayled();    SIU.PGPDO[2].R |= 0x0f000000;  /* Disable LEDs*/    SIU.PGPDO[2].R &= 0x07000000;  /* Enable LED1*/    TransmitData("Led 1 ON\n\r");    Delayled();    SIU.PGPDO[2].R |= 0x08000000;  /* Disable LED1*/    SIU.PGPDO[2].R &= 0x0b000000;  /* Enable LED2*/    TransmitData("Led 2 ON\n\r");    Delayled();    SIU.PGPDO[2].R |= 0x04000000;  /* Disable LED2*/    SIU.PGPDO[2].R &= 0x0d000000;  /* Enable LED3*/    TransmitData("Led 3 ON\n\r");    Delayled();    SIU.PGPDO[2].R |= 0x02000000;  /* Disable LED3*/    SIU.PGPDO[2].R &= 0x0e000000;  /* Enable LED4*/    TransmitData("Led 4 ON\n\r");    Delayled();    SIU.PGPDO[2].R |= 0x01000000;  /* Disable LED4*/ } Code Details: SIU - System Integration Unit PCR - Port Configuration Register PGPDO - Parallel GPIO Pad Data Output Registers : definition From viewing the user manual, under Functional port pin descriptions, it is Blink the LED(s): Within the main find the infinite for loop. for ( ; ; )      {      } loop of Main.c, remove all code, and add the LED's with the following function: for(;;) { LED(); } To alter the behavior of the LEDs, change the function itself, or pull specific code from the function and insert it within loops of a program for testing purposes. LED's are often used for testing important parts of an algorithm. By connecting an oscilloscope to a LED, it is possible to test the duration of a key algorithm, or to verify if signal timing is as expected along with the visual cue. Other Qorivva Tutorials Qorivva: Drive DC Motor Tutorial Qorivva: Turning A Servo Qorivva: Line Scan Camera Tutorial Useful Links to Technical Data TRK-MPC5064B Freescale Webpage TRK-MPC5064B Freescale Reference Manual TRK-MPC5064B Freescale Schematic
View full article
A great exercise when first starting with a new microcontroller is to get LEDs to turn-on, flash, or dim. Depending upon the configuration of your circuit, a LED (light-emitting diode) is accessed by toggling a GPIO or 'General Purpose Input Output pin either high or low. GPIO pins can be configured either as an input (read) or output (write). A high signal is often referred to as "Asserted" or a logic "1" and a low signal designated as Negated or logic "0". The input and output voltage range for GPIO pins is typically limited to the supply voltage of the evaluation board. Usage To optimize functionality in small packages, physical microcontroller pins have several functions available via signal multiplexing. Internally, a pin will have several wires connected to it via a multiplexer (wiki) or MUX. A multiplexer selects between several inputs and sends the selected signal to its output pin. The Signal Multiplexing chapter of your reference manual illustrates which device signals are multiplexed on which external pin. The Port Control block controls which signal is present on the external pin. The configuration registers within a microcontroller require proper configuration to select the GPIO as an input or output. The same GPIO pins utilized to blink a LED can be wired to read a signal coming from an external device such as the input from a hall effect sensor. Freescale Cup participants will configure GPIO pins as outputs to control the line-scan-camera via timed pulses and clock type signals. Read/Write In write mode, the GPIO pin can be set, cleared, or toggled via software initiated register settings. To determine which pin on the microcontroller is connected to a LED and how to access it from software, refer to the schematic of the microcontroller board. This pin will have numeric or alfanumeric value as well as an descriptive designation such as PTC7. Microcontroller Reference Manual: GPIO Information You will find high level information about GPIO usage in several different areas of a reference manual. See thereference-manual article for more general information. Relevant Chapters: Introduction: Human-machine interfaces - lists the memory map and register definitions for the GPIO System Modules: System Integration Modules (SIM) - provides system control and chip configuration registers Chip Configuration: Human-Machine interfaces (HMI). Signal Multiplexing: Port control and interrupts Human-Machine Interfaces: General purpose input/output Hardware As stated before, internal registers control whether a pin is high or low. Determining the polarity or orientation of your LED is important because this will let you know whether to set the associated pin in the HIGH or LOW state. The evaluation boards from Freescale all provide LED circuits like the one shown below. LED Circuit The circuit in figure (1) demonstrates a simple way to to power a LED. The circuit consists of connecting in a LED, resistor (which limits the current) and voltage source in series. LED's are semiconductors which convert current to light. When they are forward biased (turned on), electron and holes will recombine with no change in momentum, emitting a photon or light wave. Choosing the resistor is simple if you know the operating current requirements for your LED which are determined by reading the LED datasheet or specification document. R = (Vs - VL)/ IL Where V s is the power supply voltage, and V L is the Voltage Drop across the LED, and I L is the desired current through the LED.
View full article
Option #1 Camera Mount Designed by Eli Hughes of WaveNumber LLC. You can order these parts through Shapeway.com which 3D prints on demand. You can choose from all sorts of materials depending on how much you want to spend. Option #2 To attach the camera we found useful to prepare two metal L-shaped pieces made from aluminium. With the help of black plastic distance posts (already available in the kit) and these metal stands, you may freely change the position of the camera over the surface. You may use following files to cut the required shapes (drawing was made using the QCad program): Preview (.pdf) CAD file (.dxf)
View full article
All, The date is getting closer: 28-30 August in Seoul, South Korea. Here is the official agenda (subject to last minute modifications) and more information: Location: Olympic Gymnasium at Hanyang University in Seoul Dates: 28-30 August 2014 Hotel location: Hotel Prima http://www.prima.co.kr  / Address •536, Dosan-daero, Gangnam-gu Seoul, Seoul, Korea /  Phone +82-2-6006-9201 Agenda Date Time Event Location 28-Aug-2014 Arrival at airport Transfer to Hotel and free time Hotel Prima 29-Aug-2014 7:30 - 8:30 Breakfast Hotel Prima " 8:30 Meet in the lobby for departure Hotel Prima " 9:00 - 12:00 City Tour " 12:00 - 13:00 Lunch " 13:00 - 13:30 Transfer to Hanyang University " 13:30 - 17:00 Practice on Practice tracks Hanyang University - Olympic Gymnasium " 17:00 - 17:10 Presentation: History of the Intelligent Car Competition Hanyang University - Olympic Gymnasium " 17:10 - 17:30 Teams' Introduction Hanyang University - Olympic Gymnasium " 17:30 - 17:40 Rules and Information Hanyang University - Olympic Gymnasium " 17:40 - 18:00 Q&A Hanyang University - Olympic Gymnasium " 18:00 - 18:30 Transfer to dinner " 18:30 - 20:30 Dinner " 20:30 - 21:00 Transfer to Hotel Prima Hotel " 21:00 Free Time 30-Aug-2014 7:30 - 8:30 Breakfast Prima Hotel " 8:30 Meet in the lobby for departure Prima Hotel " 8:30 - 9:00 Transfer to Hanyang University Prima Hotel " 9:00 - 9:30 Registration and technical inspection Hanyang University - Olympic Gymnasium " 9:30 - 12:00 Practice on Practice tracks Hanyang University - Olympic Gymnasium " 12:00 - 13:00 Working Lunch (lunch boxes) Hanyang University - Olympic Gymnasium " 13:00 - 13:15 Keynote by VIP Hanyang University - Olympic Gymnasium " 13:15 - 13:30 Introduction of The Worldwide Freescale Cup Championship Hanyang University - Olympic Gymnasium " 13:30 - 15:00 Finals Race Hanyang University - Olympic Gymnasium " 15:00 - 15:30 Awards Ceremony Hanyang University - Olympic Gymnasium " 15:30 - 15:40 Introduction of The Worldwide Freescale Cup 2015 in Germany Hanyang University - Olympic Gymnasium " 15:40 - 16:30 Transfer to Tour and Dinner " 16:30 - 20:00 City Tour and Dinner " 20:00 - 20:30 Transfer to Hotel Prima Hotel " 20:30 Free Time 31-Aug-2014 Check out and Transfer to Airport
View full article
This page will guide you through the attachment of the servo to the Freescale Cup chassis.   The servo steers the vehicle and is controlled using Pulse-width modulation . Video Tutorial (no sound): Step-by-Step: (Click any image to enlarge) Servo Plate Inside the kit are various mounting options for different servo manufacturers. Look for the bushing of the servo that you are using. You will need the three pieces shown below. You will screw this into the servo. Pieces are notched, so assembly is straight forward. Remove the screw and black servo plate. Mount the yellow servo plate assembly to the servo as shown below. Make sure to add the small yellow washer (pictured below) in between the servo plate and the screw. Tighten well, a servo produces a good amount of torque and will slip if not tight. Steering Bar Assembly Assemble the short arm. Assemble the long arm.   Putting the Two Together Attach the short arm to the yellow bracket. First, insert the bearing into the control arm. This allows the joint to flex and move. Screw this assembly into the servo plate. Attach the long arm to the yellow bracket. Mounting the Servo Motor Attach the motor mount blocks to the back of the servo on both sides. Screw in the attachment blocks from the bottom of the car. Words of Wisdom Be sure to have servo motor in the 0 degree position before securing the control arms. Failure to do so will result in not being utilize the full range of motion. Do not change the position of the steering servomotor by hand. The position of the steering servomotor should be changed through electrical input only. Don’t move the steering servo motor beyond the maximum limit of the movement and this will damage the servo motor
View full article
  Overview: The NXP Cup is a global competition where student teams build, program, and race a model car around a track for speed. The fastest car to complete the track without derailing, wins. The creation of this autonomous car requires: Embedded software programming and basic circuit creation using NXP parts included in the entry kit Students to create motor control hardware and software to propel and steer their intelligent car Students must also interface to a camera to navigate the car through the race course by following the guide line. This competition lends itself well to use in senior design/capstone project courses.  The contest time frame can fit within the average 3-4 month semester.  Most development work can be done easily within that timeline. History: The NXP Cup Challenge is a collaborative, competitive, and hands-on way for students to learn about embedded systems and control. The NXP Cup, formerly known as the Smart Car Race began in 2003 in Korea at Hanyang University hosting 80 teams of students. Since that time the competition has spread to China, India, Malaysia, Latin America, North America, and most recently Europe in 2012, impacting more than 500 schools and 15,000 students a year. In 2010 it took the name of the Freescale Cup followed by NXP Cup after the most recent merger in December 2015.
View full article
Getting Started with the Freescale Cup How to achieve the goal of creating an autonomous vehicle that quickly navigates around a track? Before continuing with this tutorial, students should take the time to choose which Freescale Microcontroller your team is going to use. The Introduction to Freescale Cup Training article has some details about how to choose your microcontroller. Although the concepts and end results are similar no matter which microcontroller you decide to utilize, much of the software implementation details will differ. What is a Microcontroller? For information on what a microcontroller is head to the microcontrollers article. Getting Started - Learn to Program a microcontroller First off, you are going to need to know C programming. For a crash-course head to c-programming-for-embedded-systems. The classic first application to learn how to program a microcontroller is to get through the process of Blinking an LED. This wiki contains a tutorial for each of the Cup microprocessors which simplifies the process of setting up the evaluation board, installing the Integrated Development Environment, and programming the board with a simple set of software which blinks a LED. The Blink a LED tutorial is the first of 4 tutorials designed to familiarize students with the process of designing a cup car. These four tutorials will introduce students to many of the fundamentals of robotics, the software used to control the locomotion and sensors on an autonomous line following vehicle, and provide example code which help simplify the process of creating a competitive entry in the Freescale Cup. Here is an outline of the Basic Microcontroller Programming Tutorial: Read the microcontroller article Choose a microcontroller Set up the development environment Set up the microcontroller evaluation board Program A LED move to the next tutorial…
View full article
Pulse-width modulation (PWM), is a technique utilized in robotics for controlling motors and servos. Through the use of internal counters, the microcontroller modulates the duty cycle of a square wave to control the amount of power delivered to a device. The Duty Cycle referes to the porportion of time the square wave is 'on' as compared to the repeating signal period. The higher the duty cycle the higher the power carried in the signal. Duty cycle is expressed as a percentage of time the signal is 'on', with 100% being consistently on. Configuring the Timer The generation of a PWM signal using is based on hardware comparisons between register values and free running hardware counters. The timer module offers similar hardware comparison in the form of output compare circuitry. The contents of a register are continually compared to the master free-running timer. When a match occurs, a hardware output event can be configured to take place and an interrupt can then call a service routine. Timer I/O The Timer I/O port control registers are located in the Port Integration Module (PIM). Each port can be configured on a pin-by-pin basis and each timer input capture/output compare channel is associated with a single pin. On reset, timer modules are disabled and the appropriate I/O port defaults to a high impedance input. The initial state of a pin can be defined by configuring the appropriate general purpose I/O pin as an output in the Data Direction Register (DDRT) and writing the Port Data Register (PTx) to the appropriate state. An external pull device is required to control the level during reset.Setting the Timer Enable (TEN) bit in the Timer System Control Register (TSCR1) enables the timer module. The output compare functionality is disabled in the default module reset state. In this mode, the Data Direction bits (DDRTx) control the I/O state of the pins while the Input Compare logic monitors transitions on the pins. Setting the appropriate bit in the Timer Input Capture/Output Compare Select (TIOS) register enables a timer channel for output compare, as needed for PWM generation. In output compare mode, the Output Mode (OMn) and Output Level (OLn) bits in the Timer Control Registers (TCTL1/2) simultaneously select the compare event action and enable the connection of the output compare output logic to the relevant pin. If the OMn:OLn control bits for a channel are both zero the DDRTx and PTx bits control the state of the I/O pin. Setting either (or both) of the OMn:OLn bits connects the output compare circuitry to the pin, over-riding the DDRTx and PTx settings. Following a reset, the output state for each output compare circuit is zero. For PWM generation, the OM bit is set (= 1) so that the output compare output follows the state of the associated OL bit on each compare event. The state of the OL bit is inverted every time the timer channel interrupt is serviced to produce a toggling output. Clearing or setting the TEN bit disables or enables the timer module respectively, but does not modify the contents of any other timer control registers or the state of the output compare output logic A number of considerations have to be made when configuring the timer module for PWM. From a high-level point of view, the main considerations are: • PWM Frequency • PWM Duty Cycle In order to generate the required PWM frequency, the bus clock frequency must be known, and the timer prescaler must be set. These values will depend on the range of PWM frequencies that will be generated and the degree of resolution of the PWM signal. Maximum resolution and PWM frequency are limited by the maximum timer clock frequency. Lower PWM frequencies are limited by the minimum timer clock frequency. This can sometimes result in a trade-off and can be evaluated as shown in Figure 1. Once the timer channel is configured, the PWM signal can be generated using the timer channel interrupt. This should be configured to call an interrupt service routine (ISR) to load the timer compare register with the appropriate compare value (mark or space). This is achieved by identifying whether the last action was a negative or a positive edge transition, switching the transition status and loading the compare register with the next appropriate value. References to the master timer count register can be avoided by simply adding consecutive mark and space values to the timer compare register on successive ISR function calls as shown in Figure 3. Timer roll-over is seamless when using unsigned integer addition. Using the previous compare value as a reference for generating the next compare value allows precise output timing even though the ISR latency may vary. Starting the PWM is a task that requires careful consideration. In order to start the PWM generation using the interrupt, it is necessary to configure the first compare event manually. It is necessary to configure a forced compare by setting a compare to switch the output pin to the first transition state. After the initial compare event, interrupts will handle the PWM generation. The HCS12 does not support hardware forced compare, but a forced compare can be configured by setting a normal compare a few cycles ahead of the current free-running timer value. The cycles are necessary to compensate for internal latency within the MCU. The number of cycles will vary depending on the core and module clocks. When stopping the PWM generation, it is important to consider runt pulses (pulses with width shorter than the prescribed mark or space ratio as appropriate). To avoid these pulses, disable the PWM generation by setting the appropriate local interrupt mask within the associated interrupt service routine. The appropriate state of the pin at stop time can be set by disabling the interrupt in either part of the ISR; either the rising or falling edge portion. Additional Tutorial Resource: Introduction to DC Motor Control - Part II Lecture 2: Pulse Width Modulation
View full article
http://www.gpdealera.com/cgi-bin/wgainf100p.pgm?I=FUTM0043  This is the Futaba Standard Size Ball Bearing High Torque Servo. This servo can produce high-current draw from your batteries. If using NiMH or LiPo batteries, make sure they are capable of delivering approximately 2A for each servo. FEATURES: Ideal for high-torque applications requiring a standard size servo Universal connector fits Futaba, Hitec, JR, KO Propo, Airtronics Z, and Tower Hobbies. Does not fit old Airtronics A plug w/out adapter Nylon gears One bearing pre-mounted on output shaft. INCLUDES: One Futaba standard size high torque servo with; One 1.4" (35mm) diameter round servo wheel One 1.5" (39mm) diameter 4 point servo wheel One 1.25" (32mm) diameter 6 point servo wheel Four 2mm x 11mm phillips screws Four rubber grommets & Four metal eyelets REQUIRES: Small phillips screwdriver to mount to surface SPECS: Speed: 0.20 sec/60° @ 4.8V 0.16 sec/60° @ 6.0V Torque: 72 oz-in (5.2 kg-cm) @ 4.8V and 90 oz-in (6.5 kg-cm) @ 6V Dimensions: 1.6 x 0.8 x 1.5" (1-9/16 x 13/16 x 1-1/2") (40 x 20 x 38mm) Weight: 1.5oz (1-7/16oz) (41g)
View full article
Overview Please check your local rules to confirm allowable voltage, battery chemistry and ampere-hour as these differ by region. This article is NOT a substitute for the rules. Batteries (nor Charger) are not included in the Freescale Cup kit due to global shipping complexities. Batteries can be hazardous if not stored, used and/or disposed of properly. Battery Specifications Tamiya Connector 7.2 Volts Less than or equal to 3000mAh (Check your Rules!) NiCd or NiMH Needs to have a Tamyia connector Sources of purchase   This format battery is fairly common in the radio controlled toy industry. Start your search at any local electronics store where Radio controlled toy's are sold. Retail Sources: Radio Shack (USA) - http://www.radioshack.com/product/index.jsp?productId=4273066 Fry's (USA) - http://www.frys.com/product/6468002?site=sr:SEARCH:MAIN_RSLT_PG   Online Sources All-Battery.com http://www.all-battery.com/nicd72v2400mahhighpowerbatterypackforrccarswithtamiyaconnector.aspx http://www.all-battery.com/Tenergy7.2V3000mAhRCCarNiMHBatteryPackwithCharger-91103.aspx Europe: use Conrad online stores Conrad energy NiMH Sub-C Racingpack 7.2 V / 2400 mAh Stecksystem Tamiya-Stecker im Conrad Online Shop | 206026 (Conrad Germany but same available form other sources)
View full article
This tutorial covers the details of Driving a motor on the on the Kinetis K40 using the TWR-K40x256-KIT evaluation board. Overview In this exercise students will utilize the sample project to turn a motor on and off using the TWR-K40x256-KIT evaluation board. Students will: Put together the car chassis Create a Sample Project Build the code Download and run the code on a Kinetis TWR-K40x256 board. Learn how the code works   To successfully complete this exercise students will need the following board and development environment. Kinetis TWR-K40x256 board Motor Driver Board Freescale Cup Chassis with the Motors connected 7.2v Nicad Battery CodeWarrior for Microcontrollers Recommend completing the the Blink LED Tutorial before undertaking this Tutorial Put together the Car Chassis:   There are several steps in this process: Build the Freescale Cup Car Chassis Hardware Design Step Review the Driving A DC Motor Article If needed, obtain background information on motors, timer modules, PWM signals and counters by navigating to the driving a DC motor article. Design and Implement The Hardware 1. You will need to connect the Tower K40 to the Motor Board via the TWR-PROTO or some other mechanism. 2. You will need to connect the Motor Board to the DC motors and Battery This link shows a video of the motors spinning. They start from Off and slowly pick up speed http://www.youtube.com/watch?v=kY2bRiICzwc&feature=relmfu Motor Controller Board This board takes the low-voltage, low-power "control" signals from the MCU and through an H-Bridge takes ahigh-voltage, high-power power supply (the battery) to drive the motors. Motor Board page. 1. Be careful with the wires connected to the motor. Constant flexing of the solder connection can result in joint failure. If this happens, just re-solder it. 2. The wires which protrude from the motors of The Freescale Cup Chassis are in the format of Insulated Crimp On Bullet Connectors. These can be found at Radio Shack if they are missing from the kit. Build the Code If you have more than one project in your project view, make sure the proper project is the focus. The most reliable way to do this is to right click the project and choose Build Project as shown below. You can also go to the Project menu and choose the same command. Learning Step: Motor Code Description Functions Variables The edge-aligned mode is selected when (QUADEN = 0), (DECAPEN = 0), (COMBINE 0), (CPWMS = 0), and (MSnB = 1). The EPWM period is determined by (MOD − CNTIN + 0x0001) and the pulse width (duty cycle) is determined by (CnV − CNTIN). The CHnF bit is set and the channel (n) interrupt is generated (if CHnIE = 1) at the channel (n) match (FTM counter = CnV), that is, at the end of the pulse width. This type of PWM signal is called edge-aligned because the leading edges of all PWM signals are aligned with the beginning of the period, which is the same for all channels within an FTM. Initialize the Motor void InitMotorPWM()  {     //Enable the Clock to the FTM1 Module     SIM_SCGC6 |= SIM_SCGC6_FTM1_MASK;     // PORTC_PCR4 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;   //Enable GPIO on on the pin -     //route the output of that channel 0 to the pin... (pick a different multiplexer value for routing the timer)     //ch 11.4.1 of the k40 reference manual is the pin control register     //For port c pin 1..   bits 10-8  Pin Mux Control...     PORTA_PCR8  = PORT_PCR_MUX(3)  | PORT_PCR_DSE_MASK;     PORTA_PCR9  = PORT_PCR_MUX(3)  | PORT_PCR_DSE_MASK;     // Choose EDGE-Aligned PWM:  selected when QUADEN=0, DECAPEN=0, COMBINE=0, CPWMS=0, and MSnB=1  (page 964)     // Properly set up Flex Timer Module     //FTM0_MODE[WPDIS] = 1; //Disable Write Protection - enables changes to QUADEN, DECAPEN, etc.      FTM1_MODE |= FTM_MODE_WPDIS_MASK;     //FTMEN is bit 0, need to set to zero so DECAPEN can be set to 0     FTM1_MODE &= ~1;      //Set Edge Aligned PWM     FTM1_QDCTRL &=~FTM_QDCTRL_QUADEN_MASK;      //QUADEN is Bit 1, Set Quadrature Decoder Mode (QUADEN) Enable to 0,   (disabled)     //FTM0_SC = 0x16; //Center Aligned PWM Select = 0, sets FTM Counter to operate in up counting mode,     //it is field 5 of FTMx_SC (status control) - also setting the pre-scale bits here   //   Also need to setup the FTM0C0SC channel control register  - Page 897   section 37.3.6   FTM1_CNT = 0x0; //FTM Counter Value - (initialize the CNT before writing to MOD)  (16 bit available - bits 0-15 are count)   FTM1_MOD = FTM1_MOD_VALUE; //Set the Modulo resister (16 bit available - bits 0-15), Mod is set to 24000   FTM1_CNTIN = 0; //Set the Counter Initial Value to 0   (pg 915)   //change MSnB = 1   FTM1_C0SC |= FTM_CnSC_ELSB_MASK;   FTM1_C0SC &= ~FTM_CnSC_ELSA_MASK;   FTM1_C0SC |= FTM_CnSC_MSB_MASK;   FTM1_C0V = FTM1_MOD_VALUE/2; //Set the Channel n Value to  (16 bit available - bits 0-15)   //Set the complimentary pinout   FTM1_C1SC |= FTM_CnSC_ELSB_MASK;   FTM1_C1SC &= ~FTM_CnSC_ELSA_MASK;   FTM1_C1SC |= FTM_CnSC_MSB_MASK;   FTM1_C1V = FTM1_MOD_VALUE/2;   FTM1_SC = FTM_SC_PS(0) | FTM_SC_CLKS(1);    // Interrupts   FTM1_SC |= FTM_SC_TOIE_MASK; //enable the interrupt mask   enable_irq(63);  // (79-16) Set NVIC location, but you still have to change/check NVIC file sysinit.c under Project Settings Folder } Set the PWM of the Motor void SetMotorPWM(float DutyCycle) {    //float compDuty = (float)100.0-DutyCycle;    FTM1_C0V =(int)((DutyCycle*.01)* (float)FTM1_MOD_VALUE);    FTM1_C1V =(int)((1.0-DutyCycle*.01)* (float)FTM1_MOD_VALUE); } Create Interrupt when motor functions are complete void MotorTick() { if (MotorTickVar < 0xff)//if motor tick less than 255 count up...    MotorTickVar++; //Clear the overflow mask if set    if(FTM1_SC & FTM_SC_TOF_MASK)    FTM1_SC &= ~FTM_SC_TOF_MASK;    //LED_E2_TOGGLE; // ends up being ___ Hz (correct) } Calling the Motor function The function SetMotorPWM(MotorPwm) turns the motor at the "MotorPwm" rate from 0-49 (backwards), 50 (stall) and 100 (forwards).
View full article
Connection Diagram for TRK-MPC5604B to Rev. 1 Motor Control "Shield" Board Connection Diagram for TRK-MPC5604B to Rev. 0 Motor Control Board For the TRK-MPC5604, connect the flat ribbon cable to PortB as seen in the picture below. Make the cable connections as shown below for dual motor with independent drive connection Make the cable connections as shown below for dual motor with series drive connection Make the cable connections as shown below for Single motor connection Protect your electronics 1. Try not to stop the wheels while in motion.  This can cause current spikes. 2. Don’t disconnect or connect any cable when board is powered [ON]. 3. Don’t discharge the battery below 5.5V 4. Don’t hit stationary objects
View full article
This tutorial covers the details of Driving a motor on the Qorivva TRK-MPC5604B: MPC5604B StarterTRAK evaluation board. Overview 1. Put together the Car Chassis: Motor Controller Board Version A. 2. Import the Sample Project 3. Build the Code 4. Download/Debug/Run 5. Learning Step: DC Motor Code Description Functions Motor_Right () & Motor_Left() Motor_Right_Current () & Motor_Left_Current() Sample Code Download Link Alternative Examples: Other Qorivva Tutorials: Useful Technical Links Overview In this exercise students will utilize the sample project to turn a DC motor on an off using the Qorivva TRK-MPC5604B board. Students will: Put together the car chassis Open the Sample Project Make changes to main.c to call the motor functions Build the Motor function code Download and run the code on a Qorivva TRK-MPC5604B board. Learn how the code works To successfully complete this exercise students will need the following board and development environment. Qorivva TRK-MPC5604B board. Freescale Cup Chassis (connector for the motor/board) Motor Drive Version A board Kit Cables and interconnects 7.2v Nicad Battery CodeWarrior for Microcontrollers V2.8 Recommend completing the the Blink LED Tutorial Motor Example code 1. Put together the Car Chassis:   There are several steps in this process: Build the Freescale Cup Car Chassis Add the Qorivva-Mpc560xb version components to the chassis The first step of this tutorial is to gain background information on background information on motors, timer modules, PWM signals and counters. To learn more about these general topics read the Drive A DC Motor overview article. You will need to connect your motor to the microcontroller via the Motor Drive board. This board is connected to the battery, and serves to power the motors. separate power source. This is an easy process using the provided Motor Controller Board. Motor Controller Board Version A. The Freescale Cup Motor Drive VA board uses the following connector type: white 3 pin connectors (for motor) (Molex 3-pin .100") white 2 pin connector (for battery) (Molex 2-pin .100") Schematics Wiring Connections for the TRK-MPC5604B 2. Import the Sample Project The next step is to import an existing project into your Workspace. in this case, the TRK-MPC5604B Sample project. Follow the instructions on the codewarrior project import page if you can't remember how to to import the project into CodeWarrior. 3. Build the Code If you have more than one project in your project view, make sure the proper project is the focus. The most reliable way to do this is to right click the project and choose Build Project as shown below. You can also go to the Project menu and choose the same command. If you encounter errors, look in the Problems view and resolve them. You can ignore any warnings. 4. Download/Debug/Run 5. Learning Step: DC Motor Code Description What will happen: This demo is setup for two motors (one left and one right). You will then independently turn on and off each motor Functions This file sets up the Pulse Width Modulation Timer Module for use by a DC Motor. It is set to utilize Edge-Aligned PWM, and this file properly configures the period, and pulse width for use by the other modules Motor_Right () & Motor_Left() void MOTOR_LEFT(void) {   TransmitData("****Left Drive Motor Test****\n\r");   SIU.PCR[16].R = 0x0200; /* Program the drive enable pin of Left Motor as output*/   SIU.PGPDO[0].R = 0x00008000; /* Enable Left the motors */   Delaywait();   SIU.PGPDO[0].R = 0x00000000; /* Disable Left the motors */ } void MOTOR_RIGHT(void) {   TransmitData("****Right Drive Motor Test****\n\r");   SIU.PCR[17].R = 0x0200; /* Program the drive enable pin of Right Motor as output*/   SIU.PGPDO[0].R = 0x00004000; /* Enable Right the motors */   Delaywait();   SIU.PGPDO[0].R = 0x00000000; /* Disable Right the motors */ } Motor_Right_Current () & Motor_Left_Current() void RIGHT_MOTOR_CURRENT(void) {   TransmitData("****Right Motor Current****\n\r");   SIU.PGPDO[0].R = 0x00004000; /* Enable Right the motors */   Delaywait();   for (i=0;i <10;i++)   {   ADC.MCR.B.NSTART=1; /* Trigger normal conversions for ADC0 */   while (ADC.MSR.B.NSTART == 1) {};   curdata = ADC.CDR[2].B.CDATA;   printserialsingned(curdata);    }   SIU.PGPDO[0].R = 0x00000000; /* Disable Right the motors */ } void LEFT_MOTOR_CURRENT(void) {   TransmitData("****Left Motor Current****\n\r");   SIU.PGPDO[0].R = 0x00008000; /* Enable Right the motors */   Delaywait();   for (i=0;i <10;i++)   {   ADC.MCR.B.NSTART=1; /* Trigger normal conversions for ADC0 */   while (ADC.MSR.B.NSTART == 1) {};   curdata = ADC.CDR[1].B.CDATA;   printserialsingned(curdata);    }   SIU.PGPDO[0].R = 0x00000000; /* Disable Right the motors */ } Sample Code Download Link Qorivva Sample Code Download Link Alternative Examples: Application Note 4251 and Software. Other Qorivva Tutorials: Qorivva: Blink a Led Tutorial Qorivva: Turning a Servo Tutorial Qorivva: Line Scan Camera Tutorial Useful Technical Links TRK-MPC5064B Freescale Webpage TRK-MPC5064B Freescale Reference Manual TRK-MPC5064B Freescale Schematic
View full article
One option for mounting the FRDM-KL25Z Freescale Freedom board to the car chassis. [no audio] Important Note:  Secure the wires coming from your motors!!  (I used a zip tie in the video)  If they are allowed to flex at the joint where the wire connects to the motor, it will eventually fail.
View full article
MCU 101 - Beginners Concepts https://community.nxp.com/docs/DOC-1241 Blink LED Drive a DC Motor Turn a Servo Line Scan Camera Glossary of Terms Software Tools CodeWarrior Software Development Tools & IDE (recommend you download the Special Edition) CodeWarrior Beginners Tutorial (videos)   TWR K40X256 Hardware setup   Creating a new bareboard project   Debugging a bareboard project   Importing projects and merging code   Discussion of the header files (part 1)   Discussion of the header files (part 2) (Code) Beginners Hands-on Tutorials Introduction to Microcontroller Programming Blink LED Drive DC Motor Turn A Servo LIne Scan Camera Sample Codes LED BLINK 96MHZ Hardware DIY Tower System Mounting DIY Camera Mounting Batteries Advanced Tutorial Series Push-Buttons https://community.nxp.com/docs/DOC-1034 Miscellaneous Topics Reading a Reference Manual PCB design tips
View full article
This tutorial will introduce you to I 2 C and provide a framework that you can use to start communicating with various devices that use I 2 C. This tutorial is meant for the Kinetis K40 and will probably not work on any other Kinetis chip. DISCLAIMER: This has not been fully tested and may not work for you and for all devices. The header file provided does not handle errors and should not be used for critical projects. 2C signaling I2C header file Example of I2C communication using Freescale MMA8452Q 3-axis accelerometer Introduction to I 2 C signaling I 2 C is a simple two wire communication system used to connect various devices together, such as Sensory devices and microprocessors using 8 bit packets. I 2 C requires two wires: the first is called SDA and is used for transferring data, the second is called SCL and it is the clock used to drive the data to and from devices. I 2 C uses an open drain design which requires a pull up resistor to logic voltage (1.8,3.3,5) on both SDA and SCL for proper operation. I 2 C is a master-slave system where the master drives the clock and initiates communication. The I 2 C protocol has 5 parts. The Start signal which is defined as pulling the SDA line low followed by pulling SCL low. The slave device address including the Read/Write bit The register address that you will be writing to/ reading from the data The acknowledgement signal which is sent from the receiving device after 8 bits of data has been transferred successfully. the Stop signal, which is defined by SDA going high before SCL goes high. 1. The start signal is sent from the Master to intiate communication on the bus. The start and stop signals are the only time that SDA can change out of sync with SCL. Once the start signal is sent no other device can talk on the bus until the stop signal is sent. If for whatever reason another device tries to talk on the bus then there will be an error and the K40 can detect this. 2. The slave device is a 7 bit (sometimes 10bit but this will not be covered in this tutorial) address provided by the device and is specific to the device. The type of data operation (read/write) is determined by the 8 th bit. A 1 will represent a write and a 0 a read operation. 3. The register addresses are provided by the device's specifications. 4. The data you will send to a device if you are writing or the data that you receive from the device when reading. This will always be 8 bits. 5. After 8 bits of data has been transferred successfully the receiving device will pull the SDA line low to signify that it received the data. If the transmitting device does not detect an acknowledgement then there will be an error. The K40 will be able to detect this. 6. The stop signal is sent from the Master to terminate communication on the bus. Some devices require this signal to operate properly but it is required if there will be more than one master on the bus (which will not be covered in this tutorial) I2C header file This header file only has functions for reading and writing one byte at a time. Most devices support reading and writing more than one byte at a time without sending the Stop signal. Typically the device will keep incrementing the register's address to the next one during read/writes when there is no stop signal present. See your device's user manual for more information. /* * i2c.h * * Created on: Apr 5, 2012 * Author: Ian Kellogg  * Credits: Freescale for K40-I2C example */  #ifndef I2C_H_  #define I2C_H_  #include "derivative.h"  #define i2c_EnableAck() I2C1_C1 &= ~I2C_C1_TXAK_MASK #define i2c_DisableAck() I2C1_C1 |= I2C_C1_TXAK_MASK  #define i2c_RepeatedStart() I2C1_C1 |= I2C_C1_RSTA_MASK  #define i2c_Start() I2C1_C1 |= I2C_C1_TX_MASK;\    I2C1_C1 |= I2C_C1_MST_MASK  #define i2c_Stop() I2C1_C1 &= ~I2C_C1_MST_MASK;\    I2C1_C1 &= ~I2C_C1_TX_MASK  #define i2c_EnterRxMode() I2C1_C1 &= ~I2C_C1_TX_MASK;\    I2C1_C1 |= I2C_C1_TXAK_MASK  #define i2c_write_byte(data) I2C1_D = data  #define i2c_read_byte() I2C1_D  #define MWSR 0x00 /* Master write */  #define MRSW 0x01 /* Master read */  /* * Name: init_I2C * Requires: nothing * Returns: nothing * Description: Initalizes I2C and Port E for I2C1 as well as sets the I2C bus clock */  void init_I2C()  {    SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK; //Turn on clock to I2C1 module    SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK; // turn on Port E which is used for I2C1    /* Configure GPIO for I2C1 function */    PORTE_PCR1 = PORT_PCR_MUX(6) | PORT_PCR_DSE_MASK;    PORTE_PCR0 = PORT_PCR_MUX(6) | PORT_PCR_DSE_MASK;    I2C1_F = 0xEF; /* set MULT and ICR This is roughly 10khz See manual for different settings*/    I2C1_C1 |= I2C_C1_IICEN_MASK; /* enable interrupt for timing signals*/  }  /* * Name: i2c_Wait * Requires: nothing * Returns: boolean, 1 if acknowledgement was received and 0 elsewise  * Description: waits until 8 bits of data has been transmitted or recieved */  short i2c_Wait() {    while((I2C1_S & I2C_S_IICIF_MASK)==0) {    }     // Clear the interrupt flag    I2C1_S |= I2C_S_IICIF_MASK;  }  /* * Name: I2C_WriteRegister * Requires: Device Address, Device Register address, Data for register * Returns: nothing * Description: Writes the data to the device's register */  void I2C_WriteRegister (unsigned char u8Address, unsigned char u8Register, unsigned char u8Data) {    /* shift ID in right position */    u8Address = (u8Address << 1)| MWSR;    /* send start signal */    i2c_Start();    /* send ID with W/R bit */    i2c_write_byte(u8Address);    i2c_Wait();    // write the register address    i2c_write_byte(u8Register);    i2c_Wait();    // write the data to the register    i2c_write_byte(u8Data);    i2c_Wait();    i2c_Stop();  }  /* * Name: I2C_ReadRegister_uc * Requires: Device Address, Device Register address * Returns: unsigned char 8 bit data received from device * Description: Reads 8 bits of data from device register and returns it */  unsigned char I2C_ReadRegister_uc (unsigned char u8Address, unsigned char u8Register ){    unsigned char u8Data;    unsigned char u8AddressW, u8AddressR;    /* shift ID in right possition */    u8AddressW = (u8Address << 1) | MWSR; // Write Address    u8AddressR = (u8Address << 1) | MRSW; // Read Address    /* send start signal */    i2c_Start();    /* send ID with Write bit */    i2c_write_byte(u8AddressW);    i2c_Wait();    // send Register address    i2c_write_byte(u8Register);    i2c_Wait();    // send repeated start to switch to read mode    i2c_RepeatedStart();    // re send device address with read bit    i2c_write_byte(u8AddressR);    i2c_Wait();    // set K40 in read mode    i2c_EnterRxMode();    u8Data = i2c_read_byte();    // send stop signal so we only read 8 bits    i2c_Stop();    return u8Data;  }  /* * Name: I2C_ReadRegister * Requires: Device Address, Device Register address, Pointer for returned data * Returns: nothing * Description: Reads device register and puts it in pointer's variable */  void I2C_ReadRegister (unsigned char u8Address, unsigned char u8Register, unsigned char *u8Data ){    /* shift ID in right possition */    u8Address = (u8Address << 1) | MWSR; // write address    u8Address = (u8Address << 1) | MRSW; // read address    /* send start signal */    i2c_Start();    /* send ID with W bit */    i2c_write_byte(u8Address);    i2c_Wait();    // send device register    i2c_write_byte(u8Register);    i2c_Wait();    // repeated start for read mode    i2c_RepeatedStart();    // resend device address for reading    i2c_write_byte(u8Address);    i2c_Wait();    // put K40 in read mode    i2c_EnterRxMode();    // clear data register for reading    *u8Data = i2c_read_byte();    i2c_Wait();    // send stop signal so we only read 8 bits    i2c_Stop();    }  #endif  Example of I2C communication using Freescale MMA8452Q 3-axis accelerometer This example is very simplistic and will do nothing more than read the WHO AM I register to make sure that I 2 C is working correctly. To see more check out the Freescale MMA8452Q Example /* Main. C */ #include <stdio.h> #include "derivative.h" /* include peripheral declarations */ #include "i2c.h" int main(void) {      // checking the WHO AM I register is a great way to test if communication is working      // The MMA8452Q has a selectable address which is either 0X1D or 0X1C depending on the SA0 pin      // For the MMA8452Q The WHO AM I register should always return 0X2A      if (I2C_ReadRegister_uc (0x1D,0x0D) != 0x2A {           printf ("Device was not found\n");      } else {           printf ("Device was found! \n");      } }
View full article
On this page you will find additional notes to chassis assembly you may find useful. Examples of components used are obtained from the http://www.soselectronic.com/ distributor. Cables To connect battery you will need cable shown at the image top right. You can use the cable provided with the car and add an appropriate connector to its end. This usually requires special crimping tool, so it may be more appropriate to buy the "Tamyia charging cable" (shown on the bottom left side of the image above), cut the banana ends and attach the connector to the board. If you search for the appropriate type of the connector, it is called usually Tamiya charging connector, Tamiya jack 6,3 mm (SOS code 70479) or similar. Another cable you have to assemble is a power supply cable for the microprocessor board. You will need approx. 10-15 cm long cable with the barrel jack (SOS code 3834) or similar on one end and 2-pin 2.54mm connector (e.g. SOS code 4934 + 4937) on the other end. NOTE: Never power the microprocessor board and interface boards from different power supplies! In such case the grounds on both boards are not connected and you can damage the board. The grey flat ribbon cable that interconnects the boards is for signals only, there is no common GND connection! Battery You may find (as we did) the provided cable strips too weak to hold the battery on the place. Replace them with the classic electricians cable strips (e.g. SOS code 67504). Also do not forget that the batteries need to be charged fully the first time you charge them or they will not be able to fully charge in the future. If you jump the gun because you want to test your code as soon as you can you will hurt yourself later as we found our battery was absolutely shot in later stages of our build. Motor wires To attach the motor to the interface board you may find (as we did) the cables too short. Then remove 6 screws on the bottom (see image on the left), open the motor box and desolder the short wires. Replace with approx. 15 cm long silicon cables at least 1mm2. End of the cables should be connected to the 3-pin connectors with the 3,9mm pitch (e.g. SOS order code 5914 ) - see image on the right. Again, the contacts should be attached using a special crimp tool. Camera To attach the camera we found useful to prepare two metal L-shaped pieces made from aluminium. With the help of black plastic distance posts (already available in the kit) and these metal stands, you may freely change the position of the camera over the surface. You may use following files to cut the required shapes (drawing was made using the QCad program): Preview (.pdf) CAD file (.dxf)   Base board There was no motherboard in the kit, so you will need to provide your own. To make life easier, we offer you our CAD files created with QCad program. You may use it to produce your board. We use plexiglass for ours, but any other plastic material is appropriate. The large hole in the middle is for cables from the servo. We attach the board to the car using the plastic standoffs (you will need them 55 mm long, so in our case, we used the combination of 40 + 15 mm) - see an example (SOS code 10260). To attach both the processor and interface boards the simillar 5mm plastic standoffs were used. Preview (.pdf) CAD file (.dxf) Getting all together Please, notice the orientation of cables, especially the power supplies. You may find useful following connection diagram. Enlarged Schematic (.png) NOTE: Never power the microprocessor board and interface boards from different power supplies! In such case the grounds on both boards are not connected and you can damage the board. The grey flat ribbon cable that interconnects the boards is for signals only, there is no common GND connection! Servo Motor connectors The parts provided are extremely flimsy and if you snap them in and the wheels are not perfectly straight the wheels will align wrong when the servo first turns on. First off just concentrate on one wheel at a time and we found it useful to have one person hold the wheel straight while the arm was in the proper position and then we used needle nose pliers to quickly and precisely snap the pieces into the wheel. Don't be afraid to use some muscle we hesitated a few times at first because it didn't look good but it was fine.
View full article
Official rules of the Global Freescale Cup! New in 2014 - Roll-out of leagues: Depending on region there will now be three leagues.  The Global race will only be stock league vehicles. Stock League - Racing using approved components, less customization allowed Custom League - Racing with less restrictions and custom hardware Innovation League - More than just racing.  Complete an objective or task to score points and win. Notes You can view this document in PDF format using the Action Menu bar. This rule set is for the Worldwide challenge.  Find your regional rules here The Worldwide challenge is only open to the stock (unmodified) challengers at this time. If you have ANY questions about these rules, post them in the comments section below.  If you have questions about regional rules, ask in your regional group. Section 1: Team Requirements A regional championship team must run a “stock” (unmodified) league to qualify. Four person maximum team size. A team may have only one graduate student. Cars will be designed and constructed by students ONLY.  Participants, advisers, and audience are expected to exhibit good sportsmanship. Any inappropriate behavior or cheating may result in disqualification. Section 2: Event Registration Entrants into the worldwide challenge are by invitation only. One invitation is extended to each regional champion team. One person from the regional champion team must register the entire team for the worldwide challenge within two weeks after the conclusion of the regional final.  Section 3: Equipment Requirements Each team shall use the same basic kit of parts as described below.  The following requirements are in place to keep the playing field level.  You must use one of the approved controller and motor driver boards.  If any standard component of the car model is damaged, then the same replacement component should be used. Mechanical The original and unaltered equipment must be used in the entry.  Outer tire treads and rim Drive - DC motors Transmission Ratio of Drive Motor Servo Motor Allowed modifications and restrictions: You may not change the wheel base (distance between wheels) No part of the car shall exceed dimensions of 250mm/9.85in (W) x 400mm/15.75in (L)x 305mm/12in.(H) You may drill holes and mount auxiliary pieces on the chassis assuming it is contained within the above dimensions. You may change the orientation of the servo motor and related linkages. You may add a "skin" to the car but it must be removable during inspection. You may adjust or remove springs, linkages, and other non-essential pieces. You may adhere the tread to the rim.   Electrical Battery (purchase separately) 7.2V, <=3000mAh, rechargeable NiCd or NiMH  Only one (1) battery at a time may be used to power the vehicle and any attached hardware You must use one of the approved boards below to control your car. Control System FRDM- series of boards The FRDM-KL25Z is included but not mandatory to use. TRK- series Kinetis based TWR- series High Voltage Motor Control and Interface TFC-SHIELD The TFC-SHIELD is included but not mandatory to use. The Dual Motor Control Board from Landzo technologies. Allowed modifications and restrictions: One processor - No auxiliary processor or other programmable device is allowed.  The car must use a optical sensor to navigate DC-DC boost circuit may not exceed battery voltage. Total capacity of all capacitors should not exceed 2000 uF. Sensor Limits You may use additional cameras.  Maximum of sixteen (16) sensors Examples of sensor count:  IR Transmitter/Receiver pair is 1 sensor A CCD sensor is 1 sensor The provided Line Scan Camera is 1 sensor A hall effect sensor on two rear wheels is 2 sensors An encoder mounted on one wheel is 1 sensor A display (is allowed) does not count as a sensor Section 4: Vehicle Inspection Before the race, the judges will perform a technical inspection of all entries. This includes vehicle specifications, dimensions, and equipment requirements listed in Section 3. All cars must be placed in the Inspection area on or before the designated time. Once in the Inspection Area, you may not touch car until you are called to race! In the event of any violations, the organizing committee may disqualify the corresponding team. Section 5: Timed Race Procedure Race order will be determined by a random drawing. When your team is called you may remove your car  from inspection area.  You will have two (2) minutes to prepare the car. Approved Adjustments - You may: Configure parameters via on-board interfaces. (Switches, Knobs, etc.) Alter the angle of your camera Change batteries  Disallowed Adjustments -You may not: Reprogram your processor Configure parameters via wired or wireless communications. There shall be only one team member on the track at any given time. (excludes testing times) Before the 2 minute expires you must signal “Ready” to the referee before starting car. After the referee confirms “Ready”, the vehicle should leave the starting area within 30 seconds. Teams have THREE attempts to complete ONE lap.  The FIRST (not the best) completed time will be recorded. Example: Attempt 1 – Vehicle goes to fast around a curve and goes off track.  Time is not recorded. Attempt 2 – Vehicle makes it around track successfully.  Time is recorded. Attempt 3 – Is forfeit because FIRST time (Attempt 2) has been recorded. After each attempt you have two minutes to make approved (see above) adjustments to vehicle. After the attempts, the team shall return the vehicle to inspection area. Event displays will post the times after each team races. Section 6: Race Day Schedule Practice Time - Prior to final race, a test track will be available. Final calibration may be made at this time.  This will be organized with team slots and/or “free-time”.   2. Reconfigure practice track to final track. Vehicle Inspection (see section 4) Timed Race Awards Ceremony Section 7: Event Personnel Organizing committee – A committee of senior judges and Freescale event organizers.  Will coordinate event day activities and mediate and resolve any disputes. Referees -  Responsible for on-track activities. This includes race track management such as starting and stopping vehicles, as well as timing and scorekeeping. Comprise up of of faculty, student, and/or Freescale and industry employees. Judges  - Interpret and enforce rule compliance.  This will be comprised of Freescale employees and members of contributing industry sponsors. Event Personnel shall not aid any one specific team. Communication shall be open to all teams and shall not disclose any information that might compromise the fairness of the competition. Section 8: Fouls, Failure and Disqualifications The rules will be interpreted by Freescale and the organizing committee of the event.             Foul, is a minor infraction, which results in time penalties. Failure, results in the current attempt time not being recorded. Subsequent attempts are allowed. Disqualification is a major infraction which results all times not being recorded. Referee will determine whether the racing car ran out of the race track and assign time penalties. Any of the following conditions will be considered a foul and will result in time penalty added: The race car fails to leave the starting area within 30 seconds after beginning of the race [+1 second]. The race car fails to stop 2 meters/6 feet or leaves the track after crossing the finish line [+1 second]. Any of the following conditions will be considered a failure and no time will be given: Three or more wheels leave the race surface. The racing team fails to get prepared for the attempt within the two (2) minutes allotment. The player touches the race car after the technical inspection without consent of the referee. The race car fails to finish within 120 seconds after leaving the starting area. Touching the car at any time between start and finish. "Start" - Once the vehicle crosses the starting line. "Finish" - Once the vehicle crosses the finish line. Any of the following conditions will be considered a disqualification:   Any off track equipment or behavior that may influence or impede cars.   Doing a Disallowed Modification anytime after Inspection. More than one team member in the playing field. Any cheating during the competition. Failure to pass the technical inspection. Equality and fairness will be ensured as much as possible on the condition of actual feasibility.  Disputes will be resolved by a vote of Freescale, members of the organizing committee, and judges. Section 9: Timing/Scoring Time will be captured using an electronic gate and/or handheld timer. Time starts and ends when the first part of the racing car breaks the start/finish line. Fouls will result in the time addition to the car’s lap time. Disqualifications and Failures will result in no score. Section 10: Parameters of the Racing Track A test track made from the same material as the final track will be made available on the day prior to the final race for calibration and design modifications. The actual layout of the final racing track will be unknown to competitors until competition day. Width of the racing track shall not be less than 600mm/23.65in. Material and dimensional specifications can be found on the community. Surface of the racing track is matte white, with a continuous black line (25mm/1in wide) on each edge of the track. The racing track can intersect with a crossing angle of 90°. The racing track can have inclines, declines,  and tunnels. The rules and conditions are subject to change by Freescale if necessary. Freescale reserves the right in their sole discretion to cancel, suspend and/or modify The Freescale Cup race at any time. These official rules are drawn up in the English language. If these official rules are provided in any other language and there is a conflict in the text, the English language text shall prevail. Freescale and the Freescale logo are trademarks or registered trademarks of Freescale Semiconductor, Inc. in the U.S. and other countries. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2014
View full article
This tutorial is meant to introduce you to the use of a push button. It will give an explanation and example code of how you could implement a push button. Push buttons can be a great way to set a number of different states. Push buttons are advantageous because you can change your code physically versus pulling up the debugger every time you want to make a little change. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Usage A button can have many different functions on your autonomous vehicle. Most notably the button has been used for testing to start, stop, or put your car in a configuration mode. Configuration mode would let you test to see if all the peripherals except the motors are working. This would help you test your camera data and servo angles without always having to run after your car. During your race you can even set your button to different speed states. Since you have two chance to traverse the track you may have a slower safer speed on one state and a faster speed the pushes the limit on another state. In the end, what you do with the button is up to you and the choices are unlimited. Description of Example Code Below there will be an example of how to implement a push button. This push button will be connected to PTA16. When reading this pin a high, "1" or 5V, is considered "OFF" and a low, "0" or 0V, is considered "ON." To reduce the effects of bounce and/or the chance of a false press, additional code has been added to filter the signal. This is done by checking the button every 10ms for 50ms. If the button has been pressed for 3 or more of the 5 times we will change the state, otherwise it will not be considered a "press." Button Initialization Here is the initialization code that can be put in a header such as "Button.h." #define BUTTONLENGTH 5   // Button's Defined State   // 0 means button not pressed   // 1 means button pressed short fButton = 0; short iButtonCount=0; short iButtonTimer=0;   // Button Triggered Start time short iButtonTime; void initButton() {   //turn on clock to Port A   SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;   // configure pin to be GPIO   PORTA_PCR16 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;   // configure PTA16 to be input   GPIOA_PDDR &= (0<<16);  } See GPIO for explanation of how these specific commands work. Button Implementation Below is an example of a function that implements the button function. This function can be stored in a header file "Button.h" along with the initialization code. To call this function you would just place "readButton();" in your 10ms Flextimer source code. Read comments for description of each line Void readButton () {                  short fButtonState  = 0;   // initializes the button state to "OFF"           iButtonCount++;            // increments button count      if (GPIOA_PDIR & (1<<16)) {                    // if button read as high then its off otherwise its on           fButtonState = 0;      } else {           fButtonState = 1;      }      if (fButtonState && ! fButton) {                          // if the button is pushed and it previously wasn't then start a count           iButtonTimer++;           if (iButtonTimer <= 1) {                                                             iButtonCount = 0;                                 // Reset the Button Count if the timer is less or equal to 1           }      } else if (! fButtonState && fButton) {           iButtonTimer++;           if ( iButtonTimer <= 1) {                iButtonCount = 0;                               // Reset the Button count if the timer is less or equal to 1           }      }      if ( iButtonCount > BUTTONLENGTH && iButtonTimer >0) {     // if button has been read for 50ms check to see if we passed the test!           if ( iButtonTimer > (3*BUTTONLENGTH/4) && fButton) {                // fButton = 0;           } else if (iButtonTimer > (3*BUTTONLENGTH/4) && ! fButton) {                fButton = 1;           }           iButtonCount = 0;           iButtonTimer = 0;     } }
View full article