November 27, 2009 rev 1.1 Freescale Race Challenge 2010 Slot Car Equipment Milan Brejl Freescale Semiconductor, Rožnov p.r., Czech Republic Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. Freescale Semiconductor, Inc. 2008.
FRC2010 Slot Car Equipment Equip the standard slot car by electronics and control algorithm to make it a self-driving slot car Take benefits of: FRC2010 Participant Package Code Warrior Special Suit free software development tools Quick Start on-line resources: trainings, software template, etc. Your creativity, skillfulness and enthusiasm! 2
FRC2010 Slot Car Features Reference design slot car features 3-axis acceleration measurement using accelerometer MMA7361 4-quadrant DC motor control using monolithic H-bridge MC33931 USB connection miniusb connector slot car connected to the PC behaves as a mass storage device copy.s19 file in to program your application into Flash no debugger provided (although BDM port available on extension header) microsd card slot runtime storage of data (microsd card not provided) easy transfer to PC for analysis and algorithm development 4 LEDs control using PWM original Carrera Audi R8 head and bread LEDs changeover detection 3
Every registered FRC2010 participant obtains: Slot car Carrera Audi R8 Unpopulated PCB Devices Microcontroller MCF51JM64 Accelerometer MMA7361 H-Bridge MC33931 miniusb connector microsd card slot 8.000MHz Crystal 1A Bridge Rectifier DB106S 3.3V Linear Voltage Regulator LP2951 FRC2010 Participant Package 4
Slot Car Electronic Equipment - PCB PCB design files (Eagle 5.1.0): http://hw.cz/files/frc2010slotcarhw.zip Populate the provided PCB resistors, capacitors and diodes are not provided use line filter from the original car PCB line filter 5
Bill Of Materials Slot Car Electronic Equipment - PCB provided not provided Self-Driven Slot Car v2.1 BOM -------------------------------------------------------------------------------- Part Value Package Source -------------------------------------------------------------------------------- IC4 MCF51JM64VLH LQFP64 Freescale http://www.freescale.com/files/32bit/doc/data_sheet/mcf51jm128.pdf IC3 MMA7361LR1 LGA14 Freescale http://www.freescale.com/files/sensors/doc/data_sheet/mma7361l.pdf IC2 MC33931VW HSOP44 Freescale http://www.freescale.com/files/analog/doc/data_sheet/mc33931.pdf IC1 LP2951CDM-3.3R2G MICRO8 ON Semi http://www.onsemi.com/pub/collateral/lp2950-d.pdf IC5 MICRO_SD microsd http://www.gme.cz/cz/index.php?product=823-036 CON8 MINI-USB-SCHIELD 32005-301 http://www.gme.cz/cz/index.php?product=832-177 B1 DB106S DBS http://www.gme.cz/cz/index.php?product=924-009 Q1 8MHz HC49UP http://www.gme.cz/cz/index.php?product=970-023 L1 SF0905 DB-1S line filter from the original Carrera Audi R8 PCB -------------------------------------------------------------------------------- JP1 JUMPER JP2 D1,D2 MBRS130LT3G SMB D3,D4 1N4148 MICROMELF-W R1,R2 62k R0603 R3,R4 12k R0603 R5,R9,R12,R17 10k R0603 R6 270R R0603 R7 1M R0603 R8 0R R0603 R10,R11 220R R0603 R13,R14 33R R0603 R15,R16 27R R0603 R18 330k R0603 C1 100uF SMC_C C2,C3 1uF SMC_A C4,C5 (100nF)? C0603 C6 100nF C0603 C7 1uF SMC_A C8 33nF C0603 C9,C10 5pF C0603 C11,C12,C13 100nF C0603 C14 4.7uF SMC_A C15 0.47uF C0805 C16 100nF C1206 C17 100nF C0603 C18,C19,C20 3n3 C0603 6
Slot Car Electronic Equipment - Installation 1. Remove the traction magnets they are not allowed 7
Slot Car Electronic Equipment - Installation 2. Dismount the bodywork from the chassis 8
Slot Car Electronic Equipment - Installation 3. Unplug all connectors 4. Remove the original PCB Line Filter to be used on the new PCB 9
Slot Car Electronic Equipment - Installation 5. Use a knife to cut out two protrusions 10
Slot Car Electronic Equipment - Installation 6. Install the populated PCB in, use the original screw 11
Slot Car Electronic Equipment - Installation 9. Connect original LEDs, motor, power and external capacitor 12
Slot Car Electronic Equipment - Installation 8. Connect external capacitor (prevents from MCU reset on changeovers) 13
Slot Car Electronic Equipment - Installation 9. Make holes in the body for miniusb connector and microsd card 14
Slot Car Electronic Equipment Schematic
Datasheets Slot Car Electronic Equipment - Datasheets Microcontroller MCF51JM64 http://www.freescale.com/files/32bit/doc/ref_manual/mcf51jm128rm.pdf Accelerometer MMA7361 http://www.freescale.com/files/sensors/doc/data_sheet/mma7361l.pdf H-Bridge MC33931 http://www.freescale.com/files/analog/doc/data_sheet/mc33931.pdf miniusb connector http://www.gme.cz/_dokumentace/dokumenty/832/832-177/dsh.832-177.1.pdf microsd card slot http://www.soselectronic.com/a_info/resource/f/2900_serie.pdf 8.000MHz Crystal http://www.gme.cz/_dokumentace/dokumenty/970/970-023/dsh.970-023.1.pdf 1A Bridge Rectifier DB106S http://www.gme.cz/_dokumentace/dokumenty/924/924-009/dsh.924-009.1.pdf 3.3V Linear Voltage Regulator LP2950 http://www.onsemi.com/pub_link/collateral/lp2950-d.pdf 16
Development Tools Compiler Freescale Code Warrior for Microcontrollers Special Suite (free) http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=cw-microcontrollers editor compiler & linker simulator Debugger no hardware debugger provided, use USB Bootloader to program your application into the MCU Trainings Control Algorithm Development Introduction to CodeWarrior http://www.freescale.com/webapp/sps/site/training_information.jsp?code=wbt_24571 Learn Programming with C http://www.freescale.com/webapp/sps/site/training_information.jsp?code=tp_c_programming 17
Control Algorithm Development USB Bootloader Enables to program MCU flash memory via USB preflashed to every MCF51JM64 provided with the participant package 1. Connect car to PC via USB Mass Storage Device and new disk letter appears contains READY.TXT (0 bytes) file 2. Copy your application.s19 file in The bootloader programs it to flash 3. Disconnect, put car on track 18
Slot Car Application Working in Bootloader Framework After reset, based on the power source, either the Bootloader or the User Application is started: USB power Bootloader runs Track power User Application runs Coexistance of Bootloader and User Application 1. Use the provided Linker Command File (.lcf) to keep the memory limits for the user application: MEMORY { bootcode (RX) : ORIGIN = 0x00000410, LENGTH = 0x000033F0 code (RX) : ORIGIN = 0x00003A00, LENGTH = 0x0000C600 vectorram (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00000200 userram (RWX) : ORIGIN = 0x00800200, LENGTH = 0x00003E00 } 0x0000 0x0410 0x39FF 0x3A00 Flash Bootloader Interrupt Table Bootloader (13kB) User Application (51kB) 2. Redirect Interrupt Vectors into RAM, because Interrupt Vector Table in Flash is occupied by the Bootloader use the provided routine: RedirectInterruptVectorsToRAM(); 3. Include interrupt handlers into a table in ramvector.c, include its prototype in ramvector.h 0xFFFF RAM Application Interrupt Table Application usage (15.5kB) 19
Slot Car Application Quick Start Template Slot car embedded application quick start template Available for download at http://hw.cz/files/frc2010-slotcarapp.zip Created under USB Bootloader framework Includes MCU and slot car hardware initialization Simple application: car runs, all analog values and measured and logged on SD card X and Y accelerations are filtered by two different filter types (suitable or not?). Head lights indicate the detection of a right or a left curve, based on simple thresholding of X-acceleration. Break lights indicate detection of a curve beginning, based on a simple thresholding of Y-acceleration. 4 interrupts: 0.5 ms TPM interrupt to update PWM duty cycle and start conversion of all analog inputs ADC interrupt to handle sequence of conversions 10 ms periodic RTC interrupt for data logging KBI interrupt can be used to check power outage on crossover track piece Macros SET_LED_xy_ON/OFF control LEDs GET_SWITCH_STATE read switch position MOTOR_ENABLE/DISABLE, SET_MOTOR_VOLTAGE(x) control the motor START_CONV(channel), READ_ADC_SAMPLE use the ADC and more SD card driver supporting SD/SDHC, FAT/FAT32, using f_open, f_printf, f_close, etc. port of ChaN s FAT File System Module to ColdFire v1 20
Slot Car Application Analyzing logged data in Excel Quick Start Application logs all analog inputs into a CSV file, which can be opened in Excel f_printf(&file,"%d;%d;%d;%d;%d;%d\n", timecounter, accxfilt, accyfilt, accz, trackvoltage, motorcurrent); Files names are automatically incremented numbers File dates are fixed 21
Slot Car Application Analyzing logged data in Matlab Use Matlab CSV Import Wizard 1. 2. 3. >> plot(timecounter, [accxfilt accyfilt accz]); 22
Training Track Modify connection piece so that the hand controller is not used The track is continuously powered by the a power supply voltage 23