University Programs Knowledge Base

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

University Programs Knowledge Base

Labels

Discussions

Sort by:
Take some time to get yourself familiar with C programming before you continue on the programming tutorial. Here is a list of topics that you should be comfortable with, and a couple of good tutorials below. Topics included: Program Structure Commenting Variables Keywords Data Types Decimal, Binary and Hexadecimal Equivalents ASCII Text/Number Conversion Math Operators Increment & Decrement Shift Logical Operators Bitwise Operators Loops If Statement Switch Statement Functions Recursion Local Variables vs. Global Arrays Pointers Typdef, struct and union Preprocessor Directives Static, const and Volatile Keywords Tutorial 1: PSU Intro to C for Embedded Design   From PSU Freescale Cup Senior Design Course Tutorial 2: Learning Programming with C This Freescale course consists of a collection of lessons that will introduce you to the fundamentals of programming using the C programming language. Coding for Readability Sometimes when a project has the ability to grow with new features, it is best to code in modules. This allows one to easily take a more modular approach to designing their program. Despite the fact that C does not support Classes like C++ does, you can create structures that can be addressed globally with little code, which is especially useful for microcontroller based projects. An example of a structure which will be made global: This goes in the globals.h file typedef struct {   unsigned char ServoPWM;   char ServoAngle;   unsigned char DrivePWM;   int TimeOut;   int Current;   int Speed; } sMotor; extern volatile sMotor Motor; This will go in any other file that we want our structure to be accessible from #include <Globals.h> volatile sMotor Motor; This is how to address the variable in the structure #include <Globals.h> volatile sMotor Motor; If you decided to have two distinguishable motors you could do this in the globals.h extern volatile sMotor Motor1; extern volatile sMotor Motor2; Then do this in the other files volatile sMotor Motor1; volatile sMotor Motor2; Helpful Hints In developing an algorithm to detect the line position, we found two basic errors in the coding practice which caused catastrophic errors in line detection. Both of these tips are very basic coding practice. First, when using C code, it usually benefits the user to initialize all variables to some value, especially if computations are involved. Often times when the value wasn't initialized it would seem to acquire a wrong value seemingly from nowhere. Secondly, when doing calculations with arrays, make sure to do calculations with array indices that actually exist. Many times we would make the mistake in our loops of trying to use an index that wasn't assigned a value. Therefore it would acquire an unknown value from memory that caused errors in our calculations.
View full article
This document is addressed to the participants and visitors that will join us for The Freescale Cup 2015 Worldwide Finals 2015 The Freescale Cup 2015 Worldwide Finals will be held on 14-15 September 2015 at the Fraunhofer Institute for Integrated Circuits (Fraunhofer IIS) in Erlangen, Germany. Full address is: Fraunhofer IIS Am Wolfsmantel 33 91058 Erlangen Germany Google Maps location The attendees official guide is now online at https://community.nxp.com/docs/DOC-106164 Agenda of the event for the participants (subject to change): Sunday September 13th: Arrival at Hotels Get together in the evening (approximate time 18:00) at A&O Hostel Monday September 14th: 8:30: Departure from Hotel for City Tour 11:30: Prepare for departure for Fraunhofer IIS 12:00: Buses depart for Fraunhofer IIS 13:00: Lunch 14:00: Opening session 15:00: Start of Practice 17:30: High School and Innovation Challenge Demos 18:00: End of Practice - Start of the evening event 21:00: End of evening event - boarding buses for return to hotel Tuesday September 15th: 8:00: Buses depart for Fraunhofer IIS 9:00: Practice 13:00: Technical Inspection & Lunch 14:30: Final Race 16:00: Awards Ceremony 17:30: Buses depart for Awards Dinner 20:30: Buses depart for Hotel The event will be presented via LiveCast by the Fraunhofer IIS. URL is http://www2.iis.fraunhofer.de/freescale/  Hotel information: Students Hotel: Nuremberg Hostel - Stay at the A&O Hostel & Hotel Nuremberg  Google Maps Location Professors and Press Hotel: NH Nürnberg City Center hotel in Nuremberg Bahnhofstr. 17-19 | NH Hotel Group Google Maps Location Freescale will cover the cost of travel, accommodation and meals for the event for all Freescale Cup qualified teams and one faculty advisor per the rules in place. For Visa invitation letters, please contact marion.thierry@freescale.com or flavio.stiffan@freescale.com Travel booking will be organized by your regional Freescale University Program contact. Please have your faculty advisor get in touch with them for more information
View full article
1. Overview 2. Hardware 3. Set up the Hardware: Line Scan Camera/Microcontroller Hardware Setup 4. Build the Code 5. Download/Debug/Run 6.Example Code Functions ImageCapture(); ReadADCChannel() Initialize the ADC Header File Definitions Initialize the GPIO Other Tutorials: This tutorial covers the details of obtaining data from the line scan camera on the Kinetis K40 using the TWR-K40X256-KIT evaluation board. General details of the line scan camera not related to the Kinetis can be found in the general Line Scan Camera Theory article. This tutorial will help students familiarize themselves with how to interface the camera with the microcontroller, how to configure GPIO pins to create clock signals and also how to utilize the microcontroller's ADC to read the data from the camera. Outside of control algorithms, configuring the camera is one of the more complex tasks necessary to create a Freescale Cup Vehicle. 1.  Overview In this exercise students will access the line scan camera, create a clock signal and create the initialization pulse which tells the camera to begin the exposure period. This tutorial will not describe line recognition or line following algorithms - these concepts are beyond its scope. Students will: Create the code using Codewarrior Build a project Download the code to the board connect the microcontroller to the camera. Run the program view the camera data, clock and Si pulse on an oscilloscope view the data from the camera in the CodeWarrior Debugger for verification purposes   To successfully complete this exercise, the following software and hardware are required: The K40 Tower card, TWR-K40x256 CodeWarrior for Microcontrollers Freescale Line Scan Camera Motor Board Tower Prototyping board Soldering Iron Solder Tower Elevators USB Cord 2. Hardware   Read the Line Scan Camera Overview article for general information on the camera, ADC, and GPIO microcontroller configuration settings. 3. Set up the Hardware: Line Scan Camera/Microcontroller Hardware Setup It is crucial for an engineer to have the proper test equipment and tools for the job. In this case, without an oscilloscope, students will not be able to verify whether the proper signals are being sent to the camera. 4. Build the Code If there is 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 errors are encountered, look in the Problems view and resolve them. For now ignore any warnings. 5. Download/Debug/Run Download the code to your board, once this process is complete resume the project so that the code runs. If you want more information on how to complete this step see the download debug run section of the Kinetis Blinking Led tutorial. 6.Example Code What will happen: the function ImageCapture() is called in main.c with a pointer to the first element in the array. This function completes the processes necessary to capture images using the camera. To become more familiar with Pointers and Arrays - navigate to the C Programming Tutorial. Knowledge of Pointers and Arrays is a pre-requisite for understanding the Camera Code. Functions The camera code utilizes the following function: within main.c ImageCapture(&Line.RawCameraData[0]); is called to initiate the step of capturing an image into the first position of the array. ImageCapture(); from Camerainterface.c This function captures the images by creating the SI Pulse, and clock signals, capturing the data into an Array using the ADC features of the K40. It calls the function ReadADCChannel() at the proper time which then inputs data from the camera AO line. void ImageCapture(int * ImageData){//this is a pointer to a single character in memory   unsigned char i;   TAOS_SI_HIGH;   TAOS_EXPOSURE_DELAY;   TAOS_CLK_HIGH;   TAOS_EXPOSURE_DELAY;   TAOS_SI_LOW;   TAOS_EXPOSURE_DELAY;   ImageData[0] = (int)ReadADCChannel(19);// inputs data from camera (first pixel)   TAOS_CLK_LOW;   for(i=1;i<128;i++)   {   TAOS_EXPOSURE_DELAY;   TAOS_EXPOSURE_DELAY;   TAOS_CLK_HIGH;   TAOS_EXPOSURE_DELAY;   TAOS_EXPOSURE_DELAY;   ImageData[i] = (int)ReadADCChannel(19); // inputs data from camera (one pixel each time through loop)   TAOS_CLK_LOW;   }   TAOS_EXPOSURE_DELAY;   TAOS_EXPOSURE_DELAY;   TAOS_CLK_HIGH;   TAOS_EXPOSURE_DELAY;   TAOS_EXPOSURE_DELAY;   TAOS_CLK_LOW;  } ReadADCChannel() from readADC.c this function does the analog to digital conversion and returns a value between 0 and 255. It takes the proper ADC channel, in this case 19. Channel 19 corresponds to analog input pin ADC1_DM0 (see page 117 in the K40 Sub-Family Reference Manual). unsigned char ReadADCChannel(unsigned char Channel)   {   ADC1_SC1A = Channel;   while((ADC1_SC1A & ADC_SC1_COCO_MASK) == 0)   {   }   return ADC1_RA;    } Initialize the ADC Before utilizing the ADC it must be calibrated and initialized. The details for how to do this can be found in Chapter 19 Using Peripheral Delay Block (PDB) to Schedule Analog to Digital Converter (ADC) Conversions of the Kinetis Peripheral Module Quick Reference manual. The PDB portions of the code have been removed for the Cup Car Demo Code. Header File Definitions from k40_TOWER_BOARD_SUPPORT.h The following code enables the GPIO on the two pins: #define TAOS_CLK_LOC (1<<28) #define TAOS_SI_LOC (1<<18) Initialize the GPIO From K40_TOWER_BOARD_SUPPORT.c The InitK40GPIO Function sets up the ports for use: Relevant code SIM_SCGC5 = SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK; //CLK and SI signal PORTC_PCR18 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; PORTE_PCR28 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK; //Make Sure the GPIO is setup to be an output GPIOC_PDDR |= LED_E1_LOC | LED_E2_LOC | LED_E3_LOC | TAOS_SI_LOC; GPIOE_PDDR |= TAOS_CLK_LOC; GPIOB_PDDR |= LED_E4_LOC; Other Tutorials: K40:Blinking LED Tutorial K40:Drive DC Motor Tutorial K40:Turning a Servo Tutorial   
View full article
Getting Started with the NXP CUP These pages help you with the question of how to achieve the goal of creating an autonomous vehicle that quickly navigates around a track (timed race) and solves precision tasks (Figure 8, Speed limit zone, Obstacle avoidance) 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 NXP 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… Course Material from the NXP CUP professors and supporters: Thanks to our professors and NXP CUP supporters we created an exclusive starter kit. It includes lecture material, information on the car, useful tips on the board etc. Download the file below and dive into a huge support portfolio! ARC Ingenierie Files - The Champions Board! ARC Ingenierie has been very generous in providing us with their PCB layout and Gerber files to produce your own NXP CUP board. They also provided sample code and drivers plus instructions (in French) to get you started. How cool is that?! Many thanks to ARC, this is much appreciated! Download the files below. If you want to build your own board, please contact us. When do so please keep in mind to give credit to ARC university. All boards should have "HE-ARC Ingenierie" inscription.   Further support links: Information on Line Scan Camera Use The Book of Eli - Microcontrollers, robotics and warp drives Microcontrollers MCU 101 - C Programming for Embedded Systems NXP CUP Shield for the FRDM KL25Z
View full article
Hardware Servos are specialized dc motors geared to produced high-torques and set at specific angles vs rotating continously. The ability to position the servo at a specific angle over and over makes them ideal for robotics, radio controlled car and other various applications. A typical servo will have range of motion from 180-270 degrees. Most modern servos have a three wire interface, red (V+), black (ground), and white (control). To control a servo you must send it a variable length commands (pulse) in 20ms increments. This type of control is called Pulse Width Modulation. Pulse Width Modulation is a square wave with a set period. By changing the width controlling the proportion of on versus off time, you can obtain a digital ratio from 0-100%. That ratio of on versus off time is called the duty cycle. A microcontroller generates a PWM signal using a timer. The time from the beginning of one sequence to the next is called the period. The main timer registers include: Counter, Modulo, Count Initialization Value, Channel Value, FTM Status & Control, and Channel Status & Control. The Counter will count up from the Count Initialization Value and reset after reaching Modulo. One tradeoff of the design is the Modulo value we set. It represents the count value of a full duty cycle and also the resolution of our servo control. Setting a higher Modulo value allows for more precise variation in the servo, i.e. more accurate steering. The downside is that a higher value requires more time per cycle. It is necessary to configure a timer module for the drive motor separate from the servo because they each require different clock frequencies. Another tradeoff of pulse width modulation is whether it is edge-aligned or center-aligned. Edge-aligned PWM, where the channel is cleared at counter overflow and set at channel match, is simpler to implement in hardware. Center-aligned PWM, where the counter counts up and down, is more difficult to implement but does not give as much noise interference when the channel matches. Servos have 3 wires coming out of them: Ground: Black, Brown Power: Red PWM Signal: White, Yellow, Orange Spec Sheet for Servo used in Freescale Cup Futaba-S-3010 Creating the PWM Signal Much of what is needed to create this signal is discussed in the Motor Control tutorial. Click here to review how to configure a PWM signal on your microcontroller. The same microcontroller configuration utilized to drive a motor can be modified slightly to rotate the arm of a servo. Since the Servo and motor require different clock frequencies, it is necessary to configure a timer module for the servo separate from the motor. Freescale Cup participants will configure the timer modules to output signals that control a steering Servo via varying the Duty Cycle of a PWM signal. Microcontroller Reference Manual: Timer Information You will find high level information about Timer usage in several different areas of a reference manual. See the reference-manual article for more general information. Relevant Chapters: Introduction: Timer modules - 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: Timers Signal Multiplexing: Port control and interrupts Methods of controlling steering angles Construct a look-up table One way of controlling the steering angles is to construct a look-up table. The input of the look-up table can be the shift distance(in pixels) from the center, and the output could be the steering angles. The look-up table can be put into an excel file. So when you want to use it, just copy and paste the table into your code file. Here is an example of how to construct a look-up table. 1. Set up basic parameters of your car: height of camera(h), angle of camera(theta), velocity of car(v), servo delay(s).. 2. Draw a graph to help you develop a function between your input parameters and your output steering angles 3. Put all paraments into excel. So if you want to change any parameters in the future it will be very convenient. 4. Copy and paste look-up table into code file Note: depending on how you define your parameters, the look-up table may not work as well as you expected. Experiments show that the look-up table works well when the shift distance is small( small turns) and the car tends to go off track when the shift distance is big(sharp turns). Poportional Control (P Control) You can map your servo angle based directly on your line location. Take the derivative of the camera signal and use the derivative peaks as the edges of the line. Take the location of each peak and subtract them from each other to get the line width. Taking the min line peak plus line width will give you the location of the line. Now take that location and map it to your servo. We made Camera.Lock = loc and using this we made Motor.ServoAngle = Camera.Lock»1; This made our line location map directly to our servo and it seemed to work well for us. Additional Theory Training Resources Freescale Motor Control Tutorial Freescale Lecture 1: Introduction and Motor Basics Freescale Lecture 2: Pulse Width Modulaiton Freescale Lecture 3: Control Design Freesacle Lecture 4: Speed and Position Freescale Lecture 5: MPC5607B Overview
View full article
MathWorks is a proud global sponsor of The NXP Cup If you are a member of a NXP Cup team, you have access to a complimentary Software License for MATLAB / Simulink. Visit the NXP Cup - MathWorks Deutschland website to learn more about the Software offering.  Examples for using Simulink in the NXP Cup are packaged with the Simulink Coder Support Package for  FRDM-KL25Z available from the Hardware Support Page.  Additional examples for reading and analyzing live data from the Line Scan Camera are available in the NXP Cup Companion App available on the MATLAB File Exchange.  Additionally, there is an example which uses the Simulink Coder product from MathWorks to target the FRDM-KL25Z. Feel free to use the forum on MATLAB Answers or here below to ask your questions about MATLAB use with The NXP Cup.  You can also email roboticsarena@mathworks.com with any questions.
View full article
The first step of starting your TFC project is to get to know your microcontroller. This article serves you as an introduction of Qorivva MPC560xB microcontroller. Qorivva MPC5604B Summary The Qorivva MPC560xB/C/D family of 32-bit microcontrollers (MCUs) includes the latest in integrated devices for automotive electronics applications. These scalable Power Architecture® devices are supported by an enablement ecosystem that includes software drivers, operating systems and configuration code to help you quickly implement your designs.  For the Freescale Cup Challenge, we have provided Tutorials, example code and projects which are based on the trk-mpc5604b StarterTRAK evaluation board. Which Chip do you have? The chipset mounted on the boards for the Freescale Cup can vary. Always validate your chipset to know it's full capabilities. MPC560xB Product Information Page Difference's At-a-Glance: 5604B = 512MB Flash; no DMA 5606B = 1MB Flash; Has 16-Channel DMA 5607B = 1.5Mb Flash; Has 16-Channel DMA Getting Started Presentation Getting Started with MPC5600B.pptx (2Mb) Important Resources: e200z0 Core Reference Manual TRK-MPC5604B User's Manual TRK-MPC5604BQuick Reference Guide TRK-MPC5604B Schematics Reference manual Freescale's Qorivva MPC560xB Page Power.Org
View full article
The Freescale Cup has been around the world for the last 9 years. Over 23,000 students work each year on intelligent cars to make then run around the track at fast speed. Find more information on the community. Select the region you are part on and engage in the next season of the challenge.
View full article
This video will examine how can design speed sensing into their vehicle platform.   An example of magnet and sensor placement is shown.
View full article
One of the finalist vehicles for the Freescale Cup China 2012 event. In 2012, we switched the black lines to the outer edges for a new challenge twist for the students to adapt to.
View full article
Compilation of views taken during The Freescale Cup 2015 Worldwide Finals held at the Fraunhofer IIS during the event opening. Credit: Fraunhofer IIS
View full article
Footage taken using the Fraunhofer IIS Eagle Cam attached to the Car from the Politecnico of Torino on the final track layout. Credit: Fraunhofer IIS
View full article
Watch the video highlights of the Freescale Cup Worldwide Finals 2015 for the training sessions. Credit: Fraunhofer IIS
View full article
Footage from the technical inspection taken during The Freescale Cup 2015 Worldwide Finals. Credit: Fraunhofer IIS         
View full article
Second part in the series showing tips and tricks to getting the most of your line scan camera.
View full article
How to install a servo horn.  More specifically for the Freescale Cup kit. [no audio]
View full article
Footage highlights of the Freescale Cup Worldwide finals race 2015. Credit: Fraunhofer IIS
View full article
Video footage highlights taken during The Freescale Cup Worldwide Finals 2015 Award Ceremony Credit: Fraunhofer IIS
View full article
Clip provided by: Hanyang University Korea One of the challenges of the Korea event is to have the cars self-park. This car is using the S12XE chipset.
View full article
Here is a short update via video of the activities done at the University Programs demo area at the Embedded World 2014 Exhibition that was held on 25-27 March 2014 in Nuremberg (Germany).
View full article