The Construction and Forestry Division of John Deere is employing model-based design on several 2008 production programs, including a crawler tractor program. One hundred percent of the application code is automatically generated using The MathWorks’ Real-Time Workshop embedded coder, which generates the entire algorithm portion of the application (85 to 90%) and automatically includes the required interfaces to the rest of the operating system code. Unlike function-based code generation, application-based automatic code generation outputs the complete executable, including the John Deere Operating System (JDOS) services and fault codes.
For the crawler tractor, Deere used model-based design to implement advanced functions that synchronize the left and right crawler speeds for even tracking and include added functions that smooth the starting and stopping motion.
By developing an application-based automatic code generation environment, Deere reduced the amount of hand integration required for automatic code generation. As part of this effort, the company kept the automatically generated code better synchronized with the production software while reducing maintenance issues. Finally, John Deere developed a single model for the complete application that was used for both on-target rapid prototyping and production code deployment.
A basic JDOS Library was created to read and write variables and handle fault codes. It uses a VAR Manager that gives access to all existing I/O variables. These variables are read into the model from a header file and are available to the model developer via the ReadVar, WriteVar Mask. If the model requires a new variable, the user can add the variable to the list via the VAR Manager interface. A header file is automatically recreated during the code-generation process to keep the model algorithm code synchronized with the operating system and I/O code.
For the JDOS model, an input-handler subsystem scales the shaft speed signal appropriately for use later in the ground-speed equation subsystem. Prior to scaling, the input handler uses a custom block (input chooser), which was built by Deere to determine whether the application environment is a simulator or embedded system.
If the application is for simulation or rapid prototyping, then specially prepared simulation inputs are accessed and used to execute and test the algorithm. If the application is for code generated and running on the embedded system, then the actual CAN messages are accessed and processed. By using an input selector technique, Deere was able to use a single model for multiple purposes, including simulation, rapid prototyping, and production.
By selecting this option, the full production build process included the Simulink Model Advisor being invoked to check if the model is suitable for production, C code generation for the algorithm with JDOS interfaces and header files, the JDOS code being linked in, and the complete executable being cross-compiled and built.
Using this master build technique enabled Deere to use the model as the primary maintenance mechanism for its entire production software process. The code builds the same way every time by generating the same number of files with the same interfaces.
One of the main benefits to using model-based design is that it lets Deere reduce the need for expensive rapid-prototyping hardware ($30,000 vs. $200). For example, Deere’s rapid prototyping can mainly be done on a simple ST10 development board instead of a powerful real-time system simulator. Prototyping directly on the target eliminates the need for creating custom bypass controllers, which add delays to the program and latencies to the I/O and data processing, making it difficult to estimate the algorithm’s true target performance.
By using application-focused model-based design, Deere now ensures that the early algorithm designs are quickly tested in a production hardware environment, which imposes CPU and memory limitations on the model designer. This testing promotes good modeling practices and helps ensure that algorithms can make it into the field.
The current model-based design focus at Deere also includes: improving functionality of the JDOS Library; establishing modeling design guidelines (starting with the MathWorks Automotive Advisory Board guidelines); automatically configuring the automatic code generation environment with existing code and I/O drivers; integrating the Deere CAN calibration protocol protocol into JDOS; and utilizing more model validation and verification tools.
Deere focused its development process on using single models for multiple purposes and controlling the entire production build process with a single source—the model—leveraging model-based design with automatic code generation in a way that greatly facilitated maintenance and configuration management for its production workflows.
The company is currently using on-target rapid prototyping and production code generation for several production-intent programs. It says that using on-target rapid prototyping instead of traditional rapid prototyping on real-time computers has saved time and reduced costs. By reusing the models for production deployment on embedded ECUs, Deere gained additional returns on its model-based design investments.
This article was written for SAE Off-Highway Engineering by Tom Erkkinen, Embedded Applications, The MathWorks, and Scott Breiner, System Engineer, John Deere.