TECHNICAL UPDATES
 
Products Updates
 

Link for Analog Devices VisualDSP++®
For Embedded Software Programmers developing with VisualDSP++ who want to automate their verification tasks and reuse existing MATLAB/Simulink models as test benches for embedded code (hand written or automatically generated) running on Analog Devices DSPs, Link for Analog Devices VisualDSP++® offers the ability to automate verification of VisualDSP++ projects from MATLAB and Simulink. Unlike other manual solutions, Link for Analog Devices VisualDSP++ enables the embedded software engineer to use MATLAB scripts and Simulink models to automate testing and verification of embedded code on Analog Devices DSPs supported by VisualDSP++ platform.

For Algorithm Developers and Systems Engineers working in Simulink who want to use automatic code generation for rapid prototyping on Analog Devices DSPs, Link for Analog Devices VisualDSP++® offers the ability to generate projects for VisualDSP++ and to perform processor-in-the-loop simulations from Simulink models using code generated by Real-Time Workshop Embedded Coder. Unlike manually coding projects in VisualDSP++, Link for Analog Devices VisualDSP++ automates the task of generating C code from Simulink models and creating VisualDSP++ projects with the generated C code that can be compiled, executed, and tested on Analog Devices DSP supported by VisualDSP++ platform.

For more information about Link for Analog Devices VisualDSP++®, please visit the following URL:
http://www.mathworks.com/products/visualdsp/


Simulink® Design Verifier

For embedded system developers using Simulink or Stateflow who find it difficult to develop complete tests for executable specifications of their components, Simulink Design Verifier is an automatic test generator and
property prover that significantly reduce the effort required to verify your design.

Unlike time-consuming, manual test development, Simulink Design Verifier uses formal methods to automatically generate tests that guarantee complete structural and functional test coverage.

Unlike other test generators on the market, Simulink Design Verifier takes advantage of Simulink's production code technology to provide an integrated tool chain for producing fully tested and verified embedded code.

For more information about Simulink Design Verifier, please visit the following URL:
http://www.mathworks.com/products/sldesignverifier/

 
 
Tips and Techniques
 

Multithreaded Computation in MATLAB
If you are currently using a multiprocessor or multicore system, you can now enable multithreaded computation to improve MATLAB computation performance. By default, multithreaded computation is not enabled; to enable it, use MATLAB preferences. The preference automatically detects the number of CPUs on your system and recommends the number of threads based on that.

Enabling Multithreaded Computation
To enable multithreaded computation, follow these steps:

  1. Select File > Preferences > General > Multithreading. The General Multithreading Preferences panel opens.
  2. On the General Multithreading Preferences panel, select Enable multithreaded computation. Specify the Maximum number of computational threads.

Accepting the Automatic option is recommended-MATLAB automatically sets the value to the actual number of computational cores on your system.

Note that if your system uses hyperthreading (where one processor is logically configured as two), MATLAB sets the value to 1. If you choose Manual, enter the maximum number of threads you want to set; use a positive integer not greater than 16.

Selecting a number other than the recommended value might increase performance for some computations, but might decrease performance for others.

 

Debugging MATLAB M-files from the MATLAB Command Prompt

What Debugging Tools Are Available at the MATLAB Command Prompt?
This section describes how to make use of functions to debug programs from the MATLAB command prompt. There are altogether seven topics and in the e-newsletter issue, we will look at the fifth topic. The rest of the topics will be covered in subsequent e-newsletter issues.

Topics
1. Setting, Clearing, and Querying Breakpoints
2. Moving from Workspace to Workspace
3. Executing Your Code Using the DBSTEP Function
4. Displaying Status Messages Periodically
5. Using the TRY/CATCH Block to Capture Errors
6. Using the ERROR Function with the LASTERR and RETHROW Functions
7. The WHICH Function

Topic 5: Using the TRY/CATCH Block to Capture Errors
There's one scenario that you don't want the failure of one line of your code to cause your entire program to fail even though you know it will fail under certain circumstances. The way to allow this line of code to execute but capture the error if it occurs is to use a TRY/CATCH block. The line of code to be executed will be the TRY section of the block, while the error handling code makes up the CATCH block.

For example, in the sample code above, MATLAB will attempt to open a file, read the first few characters, and close the file. The TRY/CATCH block handles the case where the file you specify does not exist or there is a problem opening it.

Call it with the name of a text file (test.txt) as the input argument, first 5 characters was returned correctly as the answer. Then call it with a string that is not the filename of a text file (test1.txt) on your system as input, if the TRY/CATCH block did not exist, the attempt to open the nonexistent file would return an error -- with TRY/CATCH, you can handle that scenario. Another scenario that could cause problems is if the call to FSCANF function in the example file failed and terminated execution of the example. Without the TRY/CATCH block, the file you opened would remain open, potentially causing it to become corrupted or even causing your operating system to run out of file handles. By using the TRY/CATCH block, you can clean up open files and other resources you have used even if the code you are using causes an error during its execution.

 
 
EVENTS & TRAINING
 

Learn and do more with MATLAB & Simulink

'Test and Measurement using MATLAB' training workshop

Workshop Highlights:
This one day hands-on workshop is designed to cover real-time interfaces of MATLAB for data acquisition and instrument control, including:

  • Acquiring measured data from a data acquisition device
  • Communicating with an external instrument via its GPIB
  • Using the Data Acquisition Toolbox to perform computations and analyses of acquired data
  • Using synchronized analog I/O and digital I/O

In-house or customized training is also available on request, please contact Activemedia at 6742-8173 for details. Other relevant training courses provided by Activemedia include:

- Comprehensive MATLAB
- Advanced MATLAB Programming Techniques
- Building GUIs with MATLAB
- Applying Image Processing Techniques with MATLAB and SIMULINK
- Applying Neural Network with MATLAB

 
 
Visit www.activemedia.com.sg or Contact us at:
Singapore:
(65) 6742 8173
enquiry@activemedia.com.sg
Malaysia:
(60) 3 7880 8522
enquiry@activemedia.com.my
Thailand:
(66) 2 612 9390-1
info@activemedia.in.th
 
 
Customer Applications
 

Land Rover Vehicles Achieve EPA Certification with MathWorks Tools for Embedded Code Generation and add2 Target Hardware

To enable four-wheel drive vehicles to pass emissions tests requiring two-wheel drive operation
Use MathWorks tools to design, simulate, generate, and implement a MICROGen-based system to emulate the vehicle's transfer case controller
• Emissions certification achieved
• Development time cut by 75%
• Reusable solution implemented
 


How can you force a vehicle built to operate in four-wheel drive to operate in two-wheel drive? Guidelines set by emissions certification agencies can require four-wheel drive vehicle manufacturers to answer this question. In many emissions testing procedures, the vehicle must run on a dynamometer, which requires two wheels to remain motionless while the remaining two drive wheels spin. For a vehicle that always runs in four-wheel drive, this mode of operation is impossible.


Testing a Land Rover vehicle in a laboratory environment.

When faced with this problem for Land Rover vehicles, Jaguar and Land Rover used MathWorks tools and MICROGen target hardware from add2 Limited to emulate the controller for the transfer case in the transmission. This solution enabled Jaguar and Land Rover to operate the vehicle in two-wheel drive and achieve emissions certification from the Environmental Protection Agency (EPA) and other agencies without a problem.

 

Challenge

To test the vehicle on a two-wheel dynamometer, engineers removed one of the vehicle's prop shafts. This change, however, caused problems in the vehicle's control systems as they sensed two wheels spinning and two wheels motionless-a situation that typically occurs only during a real-world catastrophic failure. In particular, the vehicle's transfer case controller is a fully electronic system that would not function properly in this mode of operation.

Because they were departing from the intended production specification, Jaguar and Land Rover needed to replace the transfer case controller to stop the control systems from entering a different operating mode and essentially destroying the clutch. They also needed to emulate the signals from the transfer case controller to the CAN bus so that the rest of the car believed the controller was still operating normally.

Jaguar and Land Rover initially considered contacting the transfer case controller manufacturer to create a one-off version of the controller. This costly approach would have required a minimum of 12 weeks, forcing Jaguar and Land Rover to postpone scheduled emissions tests.

 

Solution

A team of three engineers from add2, Jaguar, and Land Rover used Simulink®, Real-Time Workshop® Embedded Coder, and Embedded Target for Motorola® MPC555 to design, simulate, test, and implement a MICROGen-based system. With this system, Jaguar and Land Rover now operate Land Rover vehicles in two-wheel drive for emissions testing, saving weeks in development time.

The team used Simulink to create a high-level model of the transfer case controller, including input from and output to a CAN bus. They then ran simulations in Simulink to verify that all output signals were responding correctly to input events.

Using Real-Time Workshop Embedded Coder and Embedded Target for Motorola MPC555, the group then automatically generated code from their Simulink model and deployed it to the MICROGen target hardware, which is a generic target with integrated signal conditioning for rapid control prototyping, communications gateway, and smart data-logging applications. The engineers disconnected the vehicle's original transfer case controller and installed the new MICROGen emulator for on-vehicle testing.

During testing, the engineers would note any faults that were raised by other control systems in the vehicle. They then used Simulink to modify the models, before regenerating the code and running additional tests. Updates to the MICROGen code were done in the vehicle, enabling some design iterations to be completed in fewer than ten minutes.

Once the team ran the car reliably in two-wheel drive, they conducted extensive tests to ensure no more faults occurred. The vehicle then underwent emissions certification testing.
Jaguar and Land Rover have since applied this approach for a number of certifying authorities and continue to expand its use on Land Rover models.

 

Results

  • Emissions certification achieved. MathWorks and add2 products enabled Jaguar and Land Rover to depart from the vehicle's intended production specification. All vehicle systems see the valid CAN signals as expected. As a result, Jaguar and Land Rover can confidently present the emissions test results to certification authorities around the world. This approach has been used in successful certification tests for Japan and for the EPA in the U.S.
     
  • Development time cut by 75%. The transfer case controller manufacturer needed 12 weeks to produce a first version, which would likely require additional time to make it work properly. MathWorks tools and MICROGen enabled the team to complete the whole project in fewer than three weeks, enabling them to meet their scheduled test dates.
     
  • Reusable solution implemented. Jaguar and Land Rover can rapidly reuse their solution on new vehicles. The first system was developed for the Land Rover LR3, and has been subsequently applied in much less time to the Range Rover Sport and Range Rover. For their investment in a solution for one car, the team has three and potentially many more applications.

Products Used

Embedded Target for Motorola® MPC555
Real-Time Workshop®
Real-Time Workshop® Embedded Coder
Simulink®