{"id":245,"date":"2017-09-28T07:44:19","date_gmt":"2017-09-28T07:44:19","guid":{"rendered":"https:\/\/blogs.mathworks.com\/student-lounge\/?p=245"},"modified":"2017-09-28T07:49:27","modified_gmt":"2017-09-28T07:49:27","slug":"racecar-small-workflow-professional","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/student-lounge\/2017\/09\/28\/racecar-small-workflow-professional\/","title":{"rendered":"Racecar: Small &#8211; Workflow: Professional"},"content":{"rendered":"<p>In today\u2019s blog post I am happy to introduce\u00a0<a href=\"https:\/\/www.linkedin.com\/in\/josenicolasavendano\/\">Jose Avendano Arbelaez<\/a>, a first-time guest in this blog. We have been collaborating on a nice hardware-software demo including a (model) racecar.<\/p>\n<p>&#8212;<\/p>\n<p>This article is particularly suited for automotive student teams, but it is clearly not exclusive to them. All models related to the demo have been published on the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63857-remote-control-racecar-using-simulink%C2%AE-and-texas-instruments-c2000\">MATLAB Central File Exchange<\/a> and two instructional videos have been released: <a href=\"https:\/\/www.mathworks.com\/videos\/matlab-and-simulink-racing-lounge-remote-control-racecar-part-1-programming-ecus-using-simulink-hardware-support-1504893165359.html\">#1<\/a>, <a href=\"https:\/\/www.mathworks.com\/videos\/matlab-and-simulink-racing-lounge-remote-control-racecar-part-2-integrating-can-data-into-your-simulation-1505944509937.html\">#2<\/a>. With this blog post, I am going to share our desired learning outcomes and some background information.<\/p>\n<h1>Why?<\/h1>\n<p>Vehicle modeling has proven to give teams a competitive advantage in student competitions. This can be combined with <a href=\"https:\/\/www.mathworks.com\/solutions\/model-based-design.html\">model-based design<\/a> to simulate and prototype systems in an optimal manner. Model-based design involves stages like defining requirements, modeling the system, deploying onto microcontrollers and testing all connected through the same modeling approach. This saves time and increases the quality of the final product. We decided to show how to apply\u00a0all stages of product development\u00a0to reach the ready-to-race car.<\/p>\n<h1>Our Approach<\/h1>\n<p>Since we couldn\u2019t show these features implemented on a full-size vehicle we decided to go with a small-scale version. Our RC racecar demo shows how easy it is to deploy vehicle dynamics controllers that you have previously designed and validated using Simulink. In this case, the <a href=\"https:\/\/www.mathworks.com\/hardware-support\/ti-c2000.html\">Texas Instruments C2000 hardware support package<\/a> was a good interface to the actuators and sensors that we had available in our car. MATLAB and Simulink also enable testing of our design. For this, we implemented CAN communication, a functionality\u00a0of the<a href=\"https:\/\/www.mathworks.com\/products\/vehicle-network.html\"> Vehicle Network Toolbox<\/a>, to both acquire data through Simulink and use the logged data directly in simulations.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/RC_mode_racecar.jpg\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"768\" class=\"aligncenter size-large wp-image-248\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/RC_mode_racecar-1024x768.jpg\" alt=\"\" \/><\/a><\/p>\n<h1>Programming the ECU using\u00a0Simulink Hardware Support Packages<\/h1>\n<p>As mentioned before, to get the Simulink model to interact with actual hardware we used the <a href=\"https:\/\/www.mathworks.com\/hardware-support\/ti-c2000.html\">TI C2000 Support package for Embedded Coder<\/a>. One of the biggest time-saving features of Simulink is that it can automatically generate code for different hardware platforms, including many low-cost solutions. For our application, the C2000 support package was fully integrated with the Texas Instruments development tools.<\/p>\n<p>Making some hardware drivers using the Simulink blocks provided by the support package, meant that we could evaluate the behavior of the car in a matter of minutes. This is done by just clicking the \u201cBuild\u201d button, and from there we could evaluate the actual car\u2019s behavior in a matter of minutes. Check out the video for a detailed explanation of the process and the algorithms.<\/p>\n<p><strong>[VIDEO]<\/strong>\u00a0MATLAB and Simulink Racing Lounge \u201c<a href=\"https:\/\/www.mathworks.com\/videos\/matlab-and-simulink-racing-lounge-remote-control-racecar-part-1-programming-ecus-using-simulink-hardware-support-1504893165359.html\">Remote Control Racecar, Part 1: Programming ECUs Using Simulink Hardware Suppor<\/a>t\u201c<\/p>\n<p><div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"5569410396001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div><\/p>\n<h1>Implementing the CAN Network<\/h1>\n<p>Other than simulations and algorithm deployment, model-based design is used for other stages of development such as testing and verification as well as validation. We decided to use the hardware to show a couple of workflows that can streamline testing and validation procedures. This meant showing how to acquire data from the car\u00a0in driving tests, and showing how it can be integrated to further validation workflows. Obviously, our demo is a drastic simplification of the full programming required for a commercial vehicle. Real vehicles are mostly composed of independent modules controlling individual components such as the engine, transmission, ABS brakes, etc.<\/p>\n<p>Keeping in mind scalability and relatability of the demo for an audience of automotive engineers, we decided to set up our data acquisition through a CAN network within the ECU. Showcasing the <a href=\"https:\/\/www.mathworks.com\/help\/vnt\/ug\/vehicle-network-toolbox-supported-hardware.html\">CAN devices support<\/a>\u00a0and how to\u00a0connect to CAN from Simulink made the most sense.\u00a0Teams will frequently use this type of workflow for programming the vehicle\u2019s control modules that interfaces with the CAN network.\u00a0Using Simulink supported CAN devices, e.g. allows to set up a data logger that acquires data from the car during real-time driving tests. Later, it could be replayed through a virtual CAN channel in existing simulations to perform plant validation and other analysis. For details on these implementations and more info on integrating CAN networks into simulations, check out the video below.<\/p>\n<p><strong>[VIDEO]<\/strong>\u00a0MATLAB and Simulink Racing Lounge \u201c<a href=\"https:\/\/www.mathworks.com\/videos\/matlab-and-simulink-racing-lounge-remote-control-racecar-part-2-integrating-can-data-into-your-simulation-1505944509937.html\">Remote Control Racecar, Part 2: Integrating CAN Data into Your Simulation<\/a>&#8220;<\/p>\n<p><div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"5582831635001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div><\/p>\n<h1>Conclusion<\/h1>\n<p>The main purpose of this demonstration was to show Simulink functionality that can help you to save development time, reduce overall costs and improve the performance of your designs. In this case, we moved away from simulations and showcased code generation and deployment as well as integration of CAN networks. Make sure to browse through the <a href=\"https:\/\/www.mathworks.com\/hardware-support\/home.html\">hardware support packages<\/a> available for Simulink and MATLAB and consider using similar workflows to speed up and optimize your development efforts.<\/p>\n<p>Thanks to Kvaser for providing a <a href=\"https:\/\/www.kvaser.com\/product\/kvaser-blackbird-v2\/\">Kvaser Blackbird V2<\/a>, which made it possible for use to show all of the functionality wirelessly.\u00a0This allowed students to drive the car and experience self-tuned control algorithms.<\/p>\n<p>Feel free to download the files from the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/63857-remote-control-racecar-using-simulink%C2%AE-and-texas-instruments-c2000\">File Exchange submission<\/a> for details on the models and make sure to also check out <a href=\"https:\/\/www.facebook.com\/groups\/racinglounge\/permalink\/1923976804516194\/\">this video<\/a> of the car.<\/p>\n<p>I hope this post gave you a good idea of the advantages of implementing model-based design on everything from small to large-scale projects and the impact it can have on easily adding or interfacing with some custom electronics. I am looking forward to any comments or interesting applications that you may have for these workflows.<\/p>\n<p>&#8212; Jose<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"thumbnail thumbnail_asset asset_overlay video\"><a href=\"https:\/\/blogs.mathworks.com\/student-lounge\/2017\/09\/28\/racecar-small-workflow-professional\/?dir=autoplay\"><img decoding=\"async\" src=\"https:\/\/cf-images.us-east-1.prod.boltdns.net\/v1\/static\/62009828001\/5ada11a3-a53f-4f36-a5db-4fdf15e47061\/c77230a3-fd7a-4cf6-9df6-dd2f740b9ac5\/1280x720\/match\/image.jpg\" onError=\"this.style.display ='none';\"\/><\/p>\n<div class=\"overlay_container\">\n      <span class=\"icon-video icon_color_null\"><time class=\"video_length\">17:14<\/time><\/span>\n      <\/div>\n<p>      <\/a><\/div>\n<p>In today\u2019s blog post I am happy to introduce\u00a0Jose Avendano Arbelaez, a first-time guest in this blog. We have been collaborating on a nice hardware-software demo including a (model)&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/student-lounge\/2017\/09\/28\/racecar-small-workflow-professional\/\">read more >><\/a><\/p>\n","protected":false},"author":151,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,8,10,11,12],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/245"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/users\/151"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":11,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/245\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}