首页资源分类嵌入式系统 > Mototron Mannual(1)

Mototron Mannual(1)

已有 447888个资源

下载专区

上传者其他资源

嵌入式系统热门资源

本周本月全部

文档信息举报收藏

标    签:mototron

分    享:

文档简介

Mototron使用培训手册

文档预览

CHAPTER 1 : Intro to MotoHawk About MotoHawk 1 ECU555-80 Developer’s Kit 2 ECU555-128 Developer’s Kit 3 System Requirements 4 MATLAB™ Installation Procedure 4 Green Hills Software 5 Obtaining A License For Your MotoHawk Compiler 5 MotoHawk™ Installation Procedure 6 Creating an application in MATLAB™ 7 Building Your Application 8 Assembling Your Kit 9 Starting MotoTune 9 Checking MotoServer 9 Programming the Module 9 The Program ECU status pop up appears 10 Creating A Display 10 Checking Operation 11 First Application 11 Generating Embedded Code 11 Introducing a Gain Stage 15 MotoHawk Data Storage Blocks 16 MotoTune Options 17 Calibration and Probing Blocks 18 Gathering data 18 Throttle Control Challenge 22 Pin Number & Signal Name 22 Fault Detection on Throttle Pedal 24 MotoHawk Chapter 1 : Intro to MotoHawk : version 1.2 “...the difficult part of conjuring up the magic to control your engine or vehicle is still complex. MotoHawk just makes it simpler to implement the magic.” About MotoHawk MotoHawk makes it possible to run a Simulink model on a MotoTron module. MotoHawk allows you to access the Inputs and Outputs of the modules, schedule when to execute tasks, manipulate the memory usage of the module, create a calibration interface, and most importantly, allows a single step build of the entire application. MotoHawk extends Simulink and Real-Time Workshop Embedded Coder to generate code necessary to interface with the resources of the modules and control their behavior. The goal of MotoHawk is to let the user concentrate on solving the control problem rather than solving the programming problem. Programming an embedded module is notoriously difficult both in terms of coding as well as actually transporting the application into the module during reprogramming. MotoHawk addresses all of this to make the stuff that should be easy actually easy. Unfortunately, the difficult part of conjuring up the magic to control your engine or vehicle is still complex. MotoHawk just makes it simpler to implement the magic. Page 1 ECU555-80 Developer’s Kit P/N: ASM-HAWK-004C-D0 & ASM-HAWK-004D-D0 1. ECU555-80 Development Module 2. ECU555-80 MotoHawk™ Harness w/Main Power Relay and fuse 3. Power Switch Asm. w/SmartCraft™ Connector 4. SmartCraft™ to dual DB-9 Adapter (GMLAN) 5. SmartCraft™ to dual J1939 Adapter 6. USB to dual CAN Adapter 7. 6 port SmartCraft™ hub (2) 8. Optically isolated 4 port USB hub 9. Green Hills Software MULTI2000 compiler (except P/N: ASM-HAWK-004D-D0) 10. MotoTune™ Software 8 11. Security Dongle 12. Boot Key 13. MotoHawk™ Blockset for Simulink™ 14. 10’ SmartCraft™cable w/terminating resistors 11 15. SmartCraft™ terminating connector 16. MotoHawk™ Manual (this book) 17. 10’ Smartcraft Cable 62 9 7 17 4 5 14 10&13 7 15 12 3 1 MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 2 ECU555-128 Developer’s Kit P/N: ASM-HAWK-005C-D0 & ASM-HAWK-005D-D0 1. ECU555-128 Development Module 2. ECU555-128 MotoHawk™ Harness w/Main Power Relay and fuse 3. Power Switch Asm. w/SmartCraft™ Connector 4. SmartCraft™ to dual DB-9 Adapter (GMLAM) 5. SmartCraft™ to dual J1939 Adapter 6. USB to dual CAN Adapter 7. 6 port SmartCraft™ hub (2) 8. Optically isolated 4 port USB hub 9. Green Hills Software MULTI2000™ compiler (except P/N: ASM-HAWK-005D-D0) 10. MotoTune™ Software 8 11. Security Dongle 12. Boot Key 13. MotoHawk™ Blockset for Simulink™ 11 14. 10’ SmartCraft™ cable w/terminating resistors 15. SmartCraft™ terminating connector 16. MotoHawk™ Manual (this book) 17. 10’ Smartcraft Cable 6 2 14 MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 10&13 7 12 15 3 9 7 17 5 4 1 Page 3 System Requirements 1. Windows XP (any SP,) Windows 2000 (SP3 or SP4) Windows NT (SP5 or SP6a) 2. Pentium III or IV, Xeon, Pentium M, AMD Athlon, Athlon XP, Athlon MP 3. 345 MB disk space 4. 512 MB RAM (1 GB or more recommended) 5. 16, 24, or 32 bit OpenGL capable graphics adapter (strongly recommended) 6. Microsoft Windows supported graphics accelerator card, printer, and sound card 7. 1400x1050 display (min) (1600x1200 strongly recommended) MATLAB™ Installation Procedure Insert CD in drive. If the installer does not start automatically, click Start/Run and double click on Autorun.exe. Follow the instructions on the screen. Note: If you have a network license for your installation you will need to obtain a demo license from The Mathworks before arriving for training. Install all of the following: MATLAB Simulink Real Time Workshop Realtime Workshop Embedded Coder It is strongly recommended that you also install: Stateflow Stateflow Coder MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 4 Green Hills Software Insert CD in drive. Click Start/Run and double click Setup.exe. Follow on-screen instructions. Obtaining A License For Your MotoHawk Compiler Once you have completed installation of the compiler on the unit that you will be using to develop your application, you must generate a request for a license. Select Programs/MULTI200/PowerPC v3.6/ Licensing/License Request Generator. Select OK at the following screen. Each MotoHawk SDK includes one node locked license. Contact your sales representative if more are desired. Indicate which type of computer you have installed the compiler on and select Next. Initially, you will want to request an evaluation license — this will get you up-and-running quickly. Select Next. The next message window contains the License Agreement. Read it, then select Yes to continue. You must accept License Agreement in order to use the compiler. The next window contains the license request. Print or Save To File, then Send it. (An evaluation license will be sent to the e-mail address indicated in the Customer Information window, usually the same day.) Follow the instructions that accompany the license file. A hard copy of the License Agreement was included with your SDK. FAX a signed copy to (805)965-6343, Attn: Mickey Neal. A permanent license will be e-mailed to the address indicated in the Customer Information window (usually the next business day.) MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 5 MotoHawk™ Installation Procedure Log onto the MotoHawk.info web site and register. Have your instructor or sales representative upgrade your access level. (Log out and back in, once your access level has been updated.) Navigate to the “Downloads” section. Install downloads in the following order: Kvaser Drivers MotoServer MotoTune MotoHawk Follow installation instructions for each one. Note: It is recommended that you do not plug the adapter cable into the USB port prior to installing the Kvaser drivers. It is also recommended that you download the CAN King software — a useful tool when working with CAN networks. MotoHawk website MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 6 Creating an application in MATLAB™ Once you have completed the installation of your software, create a model to verify operation. Start MATLAB: Double click on the MATLAB icon on your desktop or select from the programs menu. The following screen will appear. At the command line type: motohawk_project (‘MyFirstProject’) Default Application Press the Enter key. the following window will open (Allow 1-2 minutes for the application to complete.) Take note of the: Target Definition Main Power Relay Trigger blocks These comprise a rudimentary system. The executable algorithms reside in the Triggered Subsystem (Foreground.) MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 7 The MATLAB window will look like this Building Your Application Press CTRL+B The MATLAB window should look like this If the message says “Successful MotoHawk Generation (No Build,)”check your Greens Hills Compiler installation: Type “motohawk_check_ghs” (a zero indicates that you have a problem with your Green Hills Compiler installation.) If you get an error, check with your instructor or e-mail the log file (MyFirstProject.log in this example) to: MotoHawk@MotoTron.com. A Technical Support Representative will contact you. Once you have successfully built your default application, open Windows Explorer and navigate to the C:\ECUFiles directory. You will see a number of subdirectories including Programs and TDBDLL. These subdirectories contain, respectively, the .srz and .dll files which are used by MotoTune to program the ECU. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 8 Assembling Your Kit Install your isolated USB hub and apply power. Insert your silver MotoTune dongle into the hub. Connect the USB to CAN adapter and wait for Windows to auto-detect it. When the New Hardware window appears select “No, not this time” and click on next. Then, let Windows automatically install the drivers. Connect the Development Harness to the module (see datasheet for proper positioning.) Connect Power branch to a 12 volt source (9V to 16 V, 3A min.) Attach the SmartCraft connector, USB to CAN adapter, and the power switch to the 6 position hub. Starting MotoTune From the Start menu (or desktop shortcut) select All Programs/MotoTools/MotoTune. The following window appears The name that was used to order your kit should appear at the top of the window. If it indicates [Unlicensed,] then you need to insert/reinsert the silver dongle. Checking MotoServer Right-click on the Satellite Dish icon for MotoServer. (Located on the system tray.) Select “Ports”. If not already listed, Add location PCM-1 as a CAN type port with Access Level 4, check the box on the list, and click on “Apply”. You are now ready to connect to the module. Programming the Module Turn power on and apply ECUP signal via power switch. Select File/Program, in the MotoTune window. The following pop-up appears This is the file created when you pressed CTRL+B. Double-click on the .srz file in the window. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 9 The Program ECU status pop up appears If the Program ECU status pop-up doesn’t advance to Connecting, check your CAN to USB and SmartCraft connections. If they are operational, turn power off. Install the BOOT KEY from your kit onto the SmartCraft hub. (ECU555-128 users will also need to move the fuse from the Normal socket to the BOOT socket to insure boot loader is invoked.) Double-click on the .srz file and apply power. If this does not work, check with your instructor or send an e-mail to: MotoHawk@MotoTron.com. When you see the Programming Successful message, you are ready to create a display for your application. Creating A Display In the MotoTune Window, select File/New/Online Display/ Calibration. Select Display on the pop-up and click on OK. The Create New Display window appears Give your display a meaningful name (ie. MyFirstProjectDisplay.) Select “Next” for default Row and Column settings. Select “Next” for default Status Bar and Tab Control settings. Use default Sheet1 by clicking on “Finish.” The following should appear Click on the “+” next to the MyFirstProject folder (listed on left side of the MotoTune window.) Open the: >Foreground folder >Controller folder >Plant folder Double-click on the Foreground block in your Simulink model. Note the one-to-one correspondence between the MotoTune folders and the subsystems in your model. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 10 Checking Operation Open the System folder, then the Performance folder. Drag each of the display variables onto the spreadsheet. Note that your system is running — these are its vital statistics. Cycle the power switch off, then back on. Note that the display values briefly disappear, then return. The Main Power Relay can be heard releasing and engaging. Close this model by clicking on the red “X” in the upper right hand corner. You will be prompted to save the model. We are done with this one — you may save or not. First Application Click the Simulink icon Simulink’s Library Browser appears These are the Simulink and MotoHaw blocks which, are used for creating your application models. In the MATLAB window, move up one level to the “work” directory. Create a new directory “MySecondProject” and double-click on it. In the library browser, click here A new model window opens. Note the status window in the lower left hand corner. It indicates ODE45 this stands for Ordinary Differential Equation 4th and 5th derivative (Dormand-Prince method,) which is the type of solver that will be used for simulations. Generating Embedded Code In order to generate embedded code we must change to a fixed-step discrete solver as follows: Select “Simulation” at the top of the window, then “Configuration (or Simulation) Parameters.” The following window appears Using the pull downs, change Type to Fixed-step, and Solver to Discrete (no continuous states.) MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Simulink Icon: located top of the MATLAB window. Page 11 Click on Apply and OK. In the library browser, click on MotoHawk. Drag the MotoHawk Target Definition block from the bottom of the list into your model. Double-click on the block and verify that the target module is correct for your kit (80 pin, 128 pin, etc). The Memory Layout should be DEV. Click on Apply and OK. From the Trigger Blocks library, drag a MotoHawk Trigger block into your model. Double-click on the block to open the dialog box and set the pull-down to FGND_RTI_PERIODIC. Click Apply and OK. From the Extra Development Blocks library, drag a Main Power Relay block into your model. (Default settings will serve our purposes for now) From the Ports & Subsystems library drag a Function-Call Subsystem block into your model. Double-click on this block and a new window appears. From the Sources library, drag the Sine Wave block from the bottom of the list into your model. Click on Sinks and drag a Scope block into your model Click on Math Operations and drag in a Gain block. Note the greater than (>) symbols on each block. These are Simulink ports, which are used to control the signal flow through your model. The Sine Wave block, being a signal source, has only one (output) port. Likewise the Scope block, being a sink, has only one (input) port, while the Gain block has one of each. More complex blocks will have more input or output ports or both. Select the Sine Wave block, hold down the CTRL key and click on the Gain block Notice how Simulink connects the two blocks. This technique can be used to “wire” the blocks to one another and is especially useful when wiring signals to or from consecutive ports on a block. Simulink will start at the top and work down either side (in or out) of the block. At the top level of your model, connect the trigger block to the subsystem block. Select File/Save As. Give your model a meaningful name (ie. MySecondProject) and click Save. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 12 Press CTRL + D. Notice that Simulink has generated an error message and highlighted the offending subsystem and block — informing us that “only constant or inherited (-1) sample times are allowed in triggered subsystems.” Double-click on the Sine Wave block to open its dialog box. At the bottom of the dialog box the Sample Time is zero. As you may have guessed this means continuous. Change it to -1 (inherited.) The subsystem will now inherit its sample time from the parent (level above,) which is FGND_RTI_PERIODIC or 5 milliseconds. Press CTRL + D again. No error messages are generated. Double-click on the scope — a pop-up window appears complete with grid and axis markings. Select Simulation/Start — a Sine wave appears. Double-click on the Gain block, change to 100. The small triangle in the middle of the window at the top can be used to start the simulation. Note that the Sine wave has changed. Click on the binoculars icon This will scale the display for your input automatically. Clicking on the name of the subsystem (Function-Call Subsystem) opens it for editing. Change the name to “Foreground.” Press CTRL + B MotoHawk builds your application. In the MotoTune Display Explorer pane, right-click on Display1 on [PCM-1.] Select “Save As” and give it a meaningful name (ie. ”MyFirstProjectDisplays”). Use pulldown to specify the folder. Note that while MyFirstProjectDisplays contains only MyFirstProjectDisplay, it may contain others that provide different views into the system. Right-click on MyFirstProjectDisplays and select Close. Currently, this is the only way to close one display and open another in MotoTune. Select File/Program and download MySecondProject into the module. Create a new display as above. (ie. “MySecondProjectDisplay.”) Drag in your System Performance variables and note, via your display and the Main Power Relay, that your application is running. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 13 Modifying the application Allows you to gain some control over its operation. Double-click on the Foreground block in your model, select the Sine wave generator and the gain block, press the delete key to remove these blocks. From the Calibration & Probing Blocks library, drag a motohawk_calibration block and a motohawk_probe block into your model. From the Extra Development Blocks library, drag in a motohawk_abs_time block. Double-click on the Calibration block and change the name to ‘TwoPi’ and value to 6.28318. The single quotes must be used. From the Math Operations library, drag in a Product block. Double-click on it and change the number of inputs to 3. Right-click on the TwoPi block and drag down. A duplicate block is added to your model. Double-click on the new block and change its name to “f” and its value to 1. Wire these 3 blocks to the inputs on the Product block. From the Math Operations library, drag in a Trigonometric Function block. If it is not already set to Sine, change it. Wire the output of the Product block to the input of the Trigonometric Function block. Wire the output of the Trigonometric Function block to the Scope block. Double-click on the Probe block and change its name to Sine. Place the cursor over the input port of the “Sine” Probe block. Notice that the cursor changes into a cross-hairs. Click on the port and drag to the wire connecting the Trigonometric Function block and the Scope. A connection dot appears on the wire and a wire connects to the Sine Probe block. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 MotoHawk Code Generation Toolbox Real Time Workshop (RTW) Development Blocks --------------------------------------------------------------------Copyright 2005 MotoTron, Inc. All Rights Reserved. Digital I/O Digital I/O Blocks Analog I/O Analog I/O Blocks Advanced Digital I/O Advanced Digital I/O Serial I/O Serial I/O Blocks CAN CAN Blocks Encoder Encoder Blocks Knock Knock Blocks Triggers Trigger Blocks Calibration & Probing Calibration & Probing Blocks Lookup Tables Lookup Tables Data Storage Data Storage Blocks Fault Management Fault Management Blocks Extra Development Blocks Extra Development Blocks Fixed-Point Blocks Fixed Point Blocks Model Info Fri May 20 18:19:39 2005 MotoHawk 0.7.1 MotoHawk (RTW) Target Definition Target: ECU555-80 (DEV) Stack Size: 6144 Heap Size: 4096 DLL Filename: MotoHawk__000 SRZ Filename: MotoHawk_lib_000 === Usage Stats === Total FLASH: 0 Total EEPROM: 0 Total RAM: 0 App FLASH: 0 App EEPROM: 0 App RAM: 0 motohawk_target_def Page 14 Your model should look similar to this Press CTRL + D (see that there are no errors.) Press CTRL + B (verify that the build is successful.) Close the display in the MotoTune Display Explorer pane as above and program the module with your modified application. Select File/New and create a new calibration. In the Calibration Explorer pane, Click on the “+” next to the MySecondProject folder. Double-click on Foreground. A Calibration sheet opens in the right hand pane of the MotoTune window. Create another display sheet and drag it down or to the side such that both are visible. You should be able to see the Sine value changing. Right-click on the cell containing the Sine value and select Properties. Click on Set Fast and verify that the Add to chart/ log box is checked. Click OK. Select Chart/Open Chart. A pop up appears displaying your Sine wave. In the Foreground sheet change the “f” value to 2. Note the frequency changes when the Enter key is pressed. Change “f” to 0.5 – observe change in chart. Occasionally, flat spots will appear on the chart – a result of Windows OS “garbage collection” and other operations, and is no cause for concern. Introducing a Gain Stage Select the wire connecting the Trigonometric Function block and the Scope and press the Delete key. Right-click on the TwoPi block and drag a copy to one side. Double-click on the new block and change the name to ‘Amplitude’ and the value to 10. Likewise, copy over the product block and change its Number of inputs to 2. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Two methods for introducing a gain stage Method 1 — add a Gain block from the Math Operations library. Method 2 — add a Product block from the same library and a Calibration block from the MotoHawk library. In the case of a Gain block; Real Time Workshop will allow us to change the Gain value during simulation but our objective is to generate embedded code. The RTW Embedded Coder treats a Gain block as a hard-coded constant which, precludes changes at run-time. Therefore, we will use the second approach; an “Amplitude” calibration block and a product block. Page 15 Connect the new calibration block and the Sine block to the product block inputs. Wire the product block output to the Scope and Sine probe block. Your model should look similar to this Press CTRL + D and verify that there are no errors. Then press CTRL + B to build it. Program the module with the new application. Set up your display and calibration windows in MotoTune as before. Open a chart for the Sine probe and verify the amplitude value. Now change the amplitude to 100. Note that the display is rescaled for the new value. If a Cosine signal of the same amplitude is also needed: Hold down the Shift key and select the Amplitude, Trigonometric Function, Product, and Sine Probe blocks from the Right side of the drawing. Right-click and drag down to copy them. Wire the blocks together as before, connecting the input of the Trigonometric Function to the output of the Product block on the Left. Change the Trigonometric Function to Cosine and rename the Probe block accordingly. Your model should look similar to this Press CTRL + D. Read the error message. Simulink is complaining that the name ‘Amplitude’ is not unique. We could rename this, but we know that the value is important and it would be convenient to be able to re-use it. The way to do this is to use the MotoHawk Data Storage blocks. MotoHawk Data Storage Blocks From the library, drag a motohawk_data_def block and a motohawk_data_read block into your model. Double-click on the motohawk_data_def block, change the name to ‘Amplitude’, change the Storage Class to constant, and verify that “Attach a VarDec for Visibility from MotoTune” is checked. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 16 Highlight the two calibration blocks called “Amplitude” and delete them. Double-click on the motohawk_data_read block, change the name to ‘Amplitude’, and drag it over to one of the loose wires left by the previous deletion. Right-click on the motohawk_data_read block and drag a copy over to the other loose wire. Press CTRL + D again. No errors should be generated. Build your model, program the module, and set up your display and calibration windows as before. (using the MotoHawk Data Storage blocks continued) Right-click on either the Sine or the Cosine value and set the properties to: >Fast >Add to chart/log >Apply to all Click OK. Select Chart, Open Chart and observe your signals. In the calibration pane change the Amplitude value and observe the changes in your signals. For calibration values that are used in only one place in the model, the motohawk_calibration block is a convenient means of introducing the variable. When a calibration is to be used in more than one place, a motohawk_data_ def block with motohawk_data_read blocks is best. Read More MotoTune Options Selecting Attach VarDec for Visibility from MotoTune expands the dialog box giving us more options. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Data Storage Blocks: A closer look Double-click on the motohawk_data_def block. A brief description of the block’s parameters appears at the top of the dialog box. In addition to the variable’s name, initial value, and storage class, we can specify a data type (click on the pull down to see them), and an Output Reference Data type (for pointer based operations.) The Storage Class Parameter... allows us to specify the type of resource that will be allocated for the variable. Constant, as the name implies... does not change unless a tool changes it. Volatile... will be re-initialized at power up. Non-volatile... will be preserved across a controlled shut-down/power-up cycle (when MPRD block or similar construct is included in the model). Attach VarDec for Visibility offers: a choice of which pane to view it in: Calibration or Display. the option to restrict Read and Write access level. whether to use uploaded calibration values from MotoTune. how to view the value: Number, Enumeration (on, off, running, stopped,) or Text. Select the Help button at the bottom of the dialog box to view remaining options. If the MPRD block is not used, a motohawk_store_nvmem must be included in a background subsystem in order to execute the transfer to EEPROM (with the caveat that there are a limited number of write cycles for the EEPROM devices.) Also, when a revised model is downloaded to the module, the values stored in EEPROM will be loaded into RAM unless the structure has changed or the RestoreNVFactoryDefaults function is invoked from the System\NonVolatile Storage folder in the Display pane. Example: You are adjusting calibration values and you decide to change the logic in your module (ie. change a greater-than to a greater-than-or-equal-to.) You can rebuild the application, reprogram the module, and pick up where you left off, without having to up-load the calibration. Page 17 Calibration and Probing Blocks Another useful block is the motohawk_override_abs block from the Calibration and Probing library. Drag one into your model and place it over the wire connecting the first product block to the trigonometric function blocks. Note: Simulink breaks the wire, making the necessary connections. Double-click on the block and give it a meaningful name (ie. “Angle_Override”.) Click on Apply and OK. Press CTRL + D and CTRL + B. Program the module and set up your Display and Calibration panes as before. Your model should look similar to this Drag the two new parameters from the Foreground\Angle_ Override folder into the Display spreadsheet. Start a chart for your Sine and Cosine waves. Set Angle_Override_new to 3.14. Click on the value for Angle_Override_ovr. A pull-down arrow appears next to the cell. Click on the pulldown and select override. Look at your chart to see the effect of this change after pressing Enter. As expected, the Sine value goes to 0 while the Cosine value goes to -1. The override is a display, not a calibration. Read more Gathering data We have seen how a data definition block is used to introduce a constant into the system. Now, look at how it can be used to gather data from our system. From the Ports & Subsystems library, drag in an enabled subsystem and delete the scopes. Double-click on the MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Display or Calibration... What’s the difference? Displays allow the Engineer or Technician to monitor or manipulate signals in the system to establish conditions necessary for testing or calibration. The changes made via Display variables are not saved in the .dis file and so do not persist past the MotoTune session. On the other hand, Calibration changes are saved in a .cal file and can be Merged with or Transfer Upgraded into another calibration (or .srz) file to create a new .cal (or .srz) file which contains the desired changes. Page 18 enabled subsystem and a new window opens up. Delete the output port and copy the input port by right-clicking on port 1. From the commonly used blocks library, drag in a constant block and a sum block. From the math operations library, drag in a math function block. From the discrete library drag, in a unit delay block. Right click to copy the constant block. Set the value of the new (constant1) block to 200. Double-click on the math function block and use the pull-down to select mod (modulo) function. Click on Apply and OK. Right click on the mod block and select format and flip block. Likewise flip the unit delay and constant1 blocks. Wire the constant and mod blocks to the sum block inputs. Wire the output of the sum block to the input of the unit delay block and the outputs of the unit delay and constant1 blocks to the inputs of the mod block. From the data storage blocks library, drag in a motohawk_ data_write block and make a copy of it. Double-click on the first data write blocks. Name it SineData. Using the pull down, set data structure to vector. Name the second data write block CosineData and make it a vector as well. Wire the idx input of each data write block to the output of the sum block. Wire input1 to the data input of the SineData block and input2 to the CosineData block. Your enabled subsystem should look like this Save file and close this window. In the Foreground window, right-click on the MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 19 Amplitude data definition block and make two copies. Double-click on the first copy, change the name to SineData, change the Storage Class to NonVolatile, and change MotoTune Window to Display. Place the following in the Initial Value box: zeros (1,200.) Click Apply and OK. Double-click on the second copy, change the name to CosineData, Storage Class to NonVolatile, and MotoTune Window to Calibration. Click Apply and OK. Place the following in the Initial Value box: ones (1,200.) Copy the ‘f’ calibration block and rename it. Log and set the initial value to zero. Wire the Sine signal to In1 and the Cosine signal to In2 of the enabled subsystem. Wire the Log block to the input at the top of the enabled subsystem. Your model should look like this Press CTRL - D. If there are no errors, press CTRL - B. Start MotoTune and create a new display and a new calibration. In the display pane expand MySecondProject and Foreground. Drag SineData into the worksheet. Note that all of the values have been set to zero. In the calibration pane, expand MySecondProject. Note the folder and sheet of paper, both named Foreground. Expand each to see their contents. The folder contains the CosineData vector array (another sheet of paper). The sheet of paper contains the scalar variables. Both have been defined in the Foreground layer of the model and the default group string was used. Confusing? Read more MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Two ways to get around the confusion: The first would be to utilize the Show MotoTune Group check box and explicitly name the MotoTune Group String. The other would be to place the data definition blocks in the enabled subsystem. The system designer needs to decide what is the best way to organize these data structures, a CTRL - B is required to generate a new DLL. Page 20 For now, double-click on the Foreground and the CosineData sheets of paper and arrange them in the window. Your window should look like this Note that the CosineData array contains all 1s. Changing the Log variable to 1 enables the subsystem that logs the data. The SineData array changes immediately, but the CosineData does not. Select Calibration-Refresh Volatile Map (or press F5) and the CosineData array is updated. The Sine Data array may be used to examine the Sine values and can be copied and pasted into a spreadsheet for analysis. If there is no need to edit the values offline (factory defaults are a good starting point for an adaptive algorithm,) the Display variable will suffice. If, however, the values are best customized based on which variety of installations it will be used on, then the Calibration variable is the one to use. We are done with this example — you may close it. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 21 Throttle Control Challenge The following example uses a slider potentiometer and an electronically controlled throttle assembly: (MotoTron P/N: VALV-ETC-002-00.) Table 1 lists the signals and their corresponding connector pin numbers. The Slider pot should be connected to XDRP, XDRG, and AN1M. POT1 and POT2 should be connected to AN2M and AN3M respectively. Consult the datasheet for your module to determine the appropriate wire number for each of the signals. At the Simulink command line, use the motohawk_project instruction to open a new project. Name it ThrottleControl. Double-click on the Foreground block and delete the Controller and Plant blocks. From the MotoHawk Analog I/O Blocks library, drag in a motohawk_gain block. Select “Allow I/O pin to be calibrated from MotoTune,” and name the block ThrottlePedal. Select AN1M from the pull down and click on “Apply” then “OK.” Drag in a Gain block and a motohawk_probe block. Wire the ThrottlePedal block to the Gain block and the Gain block to the motohawk_probe block. Set the Gain block Gain to 100/1023. Name your probe SetPoint. Press CTRL - D. Pin Number Signal Name 1 Motor- 2 XDRG 3 XDRP 4 Motor+ 5 POT2 6 POT1 Table 1: Electronic Throttle Connector Pinout Electronic Throttle/Slider Potentiometer Schematic MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 22 In MATLAB 7.0, the following error message appears MATLAB 7.0 supports a fixed point data type called ufix16_eng19 which requires a separate license. Other versions of MATLAB will issue a data type mis-match error. This is because MATLAB uses a default data type of double, while the data type for a particular resource is dependant on the hardware. In this instance, the A/D on the 555 is 10 bits, which fits into a unit16. Other resources have the following data types: Digital Inputs and Outputs are Boolean Frequency Inputs and Outputs are uint32 (scaled by 0.01Hz) Duty Cycle Inputs and Outputs are int16. Go to the top level of your model, double-click on the Target Definition block and click on the “Floating Point Data Type” pull down. The choices are: single (32 bits) double (64 bits) disabled These determine the way that memory will be allocated during code generation. The default is single (32 bits) and should not be changed unless greater resolution is required or the target processor does not support floating point operations. Return to the Foreground level of your model and drag a Data Type Conversion block in from the Signal Attributes library. Place it between the ThrottlePedal block and the Gain block. Press CTRL - D again. There should be no errors reported. From the Format menu select Port/Signal Displays and check Port Data Types. The data type appears adjacent to each wire. This is a convenient way to verify that your data types are consistent in your model. Make copies of the analog input, data type conversion, gain, and probe blocks. Highlight them and select Format-Flip Block (or CTRL - I ). Select AN2M for the analog input, name the probe Feedback. Drag in a motohawk_pwm block from the Analog I/O Blocks library and select H1 as the resource. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 23 Drag in a motohawk_calibration block. Name it ETC_ Frequency and set the Default Value to 5000. To make a proportional control like the one shown Add a summing block. Copy and modify the gain block and data conversion blocks. When you first wire in your blocks, the data type adjacent to each wire will indicate double (MATLAB’s default), but when you press CTRL - D they are updated to indicate the appropriate data type. Press CTRL - B to build your model and use MotoTune to download it to the module. Operate the Throttle Pedal slider and observe the behavior. This model is a simple proportional control. Realistically, a more complex control is required. Fault Detection on Throttle Pedal The next model introduces rudimentary fault detection on the Throttle Pedal Position sensor and adds an integrating term to the command signal. It also includes diagnostic probes and calibratable Proportional and Integral gains. Modify your drawing to look like the one shown. Press CTRL - D to check your model. Then build it using CTRL-B. Open a display and a calibration in MotoTune. Set up your probes and adjust the ETC_Frequency value until the high pitched sound can no longer be heard. Set the Integral Gain to zero and increase the proportional gain until the throttle plate exhibits ringing when operated. Open a chart and increase the Integral Gain until the traces for SetPoint and Feedback come together. The Error trace should be zero. MotoHawk Chapter 1 : Intro to MotoHawk: version 1.2 Page 24

Top_arrow
回到顶部
EEWORLD下载中心所有资源均来自网友分享,如有侵权,请发送举报邮件到客服邮箱bbs_service@eeworld.com.cn 或通过站内短信息或QQ:273568022联系管理员 高进,我们会尽快处理。