<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>FRDM-KL25Z : how to operate it with the Arduino Motor Shield</title><link>https://community.element14.com/products/manufacturers/nxp/w/documents/26475/frdm-kl25z-how-to-operate-it-with-the-arduino-motor-shield</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>FRDM-KL25Z : how to operate it with the Arduino Motor Shield</title><link>https://community.element14.com/products/manufacturers/nxp/w/documents/26475/frdm-kl25z-how-to-operate-it-with-the-arduino-motor-shield</link><pubDate>Tue, 09 Nov 2021 17:52:41 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:3ba917b0-845d-4fba-8d3d-e9c1f2027667</guid><dc:creator>MAb</dc:creator><comments>https://community.element14.com/products/manufacturers/nxp/w/documents/26475/frdm-kl25z-how-to-operate-it-with-the-arduino-motor-shield#comments</comments><description>Current Revision posted to Documents by MAb on 11/9/2021 5:52:41 PM&lt;br /&gt;
&lt;p style="margin:0;font-size:12px;font-family:Verdana;color:#333333;"&gt;&lt;span style="font-weight:inherit;font-style:inherit;font-size:15px;font-family:tahoma, arial, helvetica, sans-serif;color:#ff6600;"&gt;&lt;em style="font-weight:inherit;font-family:inherit;"&gt;This tutorial was extracted from Erich Styger&amp;#39;s blog&lt;span class="Apple-converted-space" style="font-weight:inherit;font-style:inherit;font-family:inherit;"&gt;&lt;span class="Apple-converted-space" style="font-weight:inherit;font-style:inherit;font-family:inherit;"&gt;&lt;span class="Apple-converted-space" style="font-weight:inherit;font-style:inherit;font-family:inherit;"&gt;&lt;span class="Apple-converted-space" style="font-weight:inherit;font-style:inherit;font-family:inherit;"&gt;&lt;span class="Apple-converted-space" style="font-weight:inherit;font-style:inherit;font-family:inherit;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a class="jive-link-external-small" href="http://mcuoneclipse.wordpress.com/" rel="nofollow" style="font-weight:inherit;font-style:inherit;font-family:inherit;color:#355491;text-decoration:underline;" target="_blank"&gt;http://mcuoneclipse.wordpress.com&lt;/a&gt;.&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0;font-size:12px;font-family:Verdana;color:#333333;"&gt;&lt;a href="/servlet/JiveServlet/downloadImage/102-54862-1-160635/Freescale.bmp" style="font-weight:inherit;font-style:inherit;font-family:inherit;color:#592d5f;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/175x85/__key/communityserver-wikis-components-files/00-00-00-01-14/contentimage_5F00_29236.bmp"&gt;&lt;img alt="image" src="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-01-14/contentimage_5F00_29236.bmp" style="max-height: 85px;max-width: 175px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="/servlet/JiveServlet/downloadImage/102-54862-1-160636/Kinetis-L.jpg" style="font-weight:inherit;font-style:inherit;font-family:inherit;color:#592d5f;"&gt;&lt;span&gt;&lt;a href="https://community.element14.com/resized-image/__size/87x85/__key/communityserver-wikis-components-files/00-00-00-01-14/contentimage_5F00_29237.jpg"&gt;&lt;img loading="lazy" alt="image" src="https://community-storage.element14.com/communityserver-components-secureimagefileviewer/communityserver/wikis/components/files/00/00/00/01/14/contentimage_29237.jpg-87x85.jpg?sv=2016-05-31&amp;amp;sr=b&amp;amp;sig=e2WutOKWgA%2FwQPYCkF7eIqxwQjvCcubQRPhjod5%2FulE%3D&amp;amp;se=2026-09-16T23%3A59%3A59Z&amp;amp;sp=r&amp;amp;_=lw3vl9FqzfR9tHJgP7g6Lg==" style="max-height: 85px;max-width: 87px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The great thing with the Freedom FRDM-KL25Z board is its compatibility with Arduino Shields: a great set of board available at very reasonable prices. I had my hands on the Adafruit Data Logger shield, and now it was time to use the original &lt;a class="jive-link-external-small" href="http://arduino.cc/en/Main/ArduinoMotorShieldR3" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="Arduino Motor Shield R3"&gt;Arduino Motor Shield R3&lt;/a&gt;.&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="http://mcuoneclipse.files.wordpress.com/2012/12/motor-side.png" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank"&gt;&lt;img loading="lazy" alt="Freedom FRDM-KL25Z with Arduino Motor Shield and Arexx Chassis" class="jiveImage wp-image-5593" height="332" src="http://mcuoneclipse.files.wordpress.com/2012/12/motor-side.png?w=584&amp;amp;h=332" style="border-color:#eeeeee;padding:6px;" title="Freedom FRDM-KL25Z with Arduino Motor Shield and Arexx Chassis" width="584" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="wp-caption-text" style="margin:0;font-family:Georgia, serif;font-size:12px;font-style:inherit;font-weight:inherit;margin-bottom:0.6em;padding-top:10px;padding-bottom:5px;padding-left:40px;color:#666666;"&gt;Freedom FRDM-KL25Z with Arduino Motor Shield and Arexx Chassis&lt;/p&gt;&lt;p style="margin:0;padding:0px;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;I already had an &lt;a class="jive-link-external-small" href="http://www.arexx.com/arexx.php?cmd=goto&amp;amp;cparam=p_robot_chassis" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="Arexx Robo Chassis"&gt;Arexx Robo Chassis&lt;/a&gt; available: a simple platform with two DC motors. So I added the FRDM-KL25Z with the Arduino Motor Shield R3 on top of it:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="http://mcuoneclipse.files.wordpress.com/2012/12/motor-top.png" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank"&gt;&lt;img loading="lazy" alt="Top View with Arduino Motor Shield on top of Freedom board and motor chassis" class="jiveImage wp-image-5592 size-full" src="http://mcuoneclipse.files.wordpress.com/2012/12/motor-top.png?w=584" style="border-color:#eeeeee;padding:6px;" title="Top View with Arduino Motor Shield on top of Freedom board and motor chassis" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="wp-caption-text" style="margin:0;font-family:Georgia, serif;font-size:12px;font-style:inherit;font-weight:inherit;margin-bottom:0.6em;padding-top:10px;padding-bottom:5px;padding-left:40px;color:#666666;"&gt;Top View with Arduino Motor Shield on top of Freedom board and motor chassis&lt;/p&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Power Supply&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The battery pack (4 AAA NiMH rechargeable batteries) provide 5V to the motor shield. That 5V is powering the FRDM-KL25Z through trace on the Motor Shield. There is an outstanding issue: the Motor Shield expects that the CPU board provides both 3.3V and 5V. 3.3V is provided, but the FRDM-KL25Z only provides 5V is either the KL25Z or the K20 is USB powered. So for now I need to power the system as well with a USB cable until I find a different solution.&lt;/p&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Current Sensing&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The shield provides two analog pins for motor current sensing. According to the documentation 3.3V should be full-scale for 2A. However, I’m measuring around 60 mV even with no current. It is not clear to me from the shield schematics if the analog signal depens on the AREF signal or not: the problem could be because the Freedom board does *not* route that signal to the header without hardware modification. So not sure where I am now with this, as I’m measuring the wrong values.&lt;/p&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Console/Shell Interface&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;To manually control the motor, I have added a &lt;a class="jive-link-external-small" href="http://mcuoneclipse.com/2012/08/05/a-shell-for-the-freedom-kl25z-board/" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="A Shell for the Freedom KL25Z Board"&gt;simple shell&lt;/a&gt; interface:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="http://mcuoneclipse.files.wordpress.com/2012/12/shell-interface.png" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank"&gt;&lt;img loading="lazy" alt="Shell Interface" class="jiveImage wp-image-5596 size-full" src="http://mcuoneclipse.files.wordpress.com/2012/12/shell-interface.png?w=584" style="border-color:#eeeeee;padding:6px;" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="wp-caption-text" style="margin:0;font-family:Georgia, serif;font-size:12px;font-style:inherit;font-weight:inherit;margin-bottom:0.6em;padding-top:10px;padding-bottom:5px;padding-left:40px;color:#666666;"&gt;Shell Interface&lt;/p&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;That way I can manually control the motors and get status information:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="http://mcuoneclipse.files.wordpress.com/2012/12/shell-motor-commands-and-status.png" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank"&gt;&lt;img loading="lazy" alt="Shell Motor Commands and Status" class="jiveImage size-full wp-image-5598" height="333" src="http://mcuoneclipse.files.wordpress.com/2012/12/shell-motor-commands-and-status.png?w=584&amp;amp;h=333" style="border-color:#eeeeee;padding:6px;" width="584" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="wp-caption-text" style="margin:0;font-family:Georgia, serif;font-size:12px;font-style:inherit;font-weight:inherit;margin-bottom:0.6em;padding-top:10px;padding-bottom:5px;padding-left:40px;color:#666666;"&gt;Shell Motor Commands and Status&lt;/p&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Processor Expert&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The CodeWarrior for MCU10.3 project is using Processor Expert components to abstract from the hardware, and runs &lt;a class="jive-link-external-small" href="http://mcuoneclipse.com/2012/08/18/freertos-v7-2-0-released/" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="FreeRTOS V7.2.0 released"&gt;FreeRTOS&lt;/a&gt;:&lt;/p&gt;&lt;p style="margin:0;"&gt;&lt;a href="http://mcuoneclipse.files.wordpress.com/2012/12/motor-processor-expert-components.png" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank"&gt;&lt;img loading="lazy" alt="Arduino Motor Processor Expert Components" class="jiveImage wp-image-5600 size-full" src="http://mcuoneclipse.files.wordpress.com/2012/12/motor-processor-expert-components.png?w=584" style="border-color:#eeeeee;padding:6px;" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="wp-caption-text" style="margin:0;font-family:Georgia, serif;font-size:12px;font-style:inherit;font-weight:inherit;margin-bottom:0.6em;padding-top:10px;padding-bottom:5px;padding-left:40px;color:#666666;"&gt;Arduino Motor Processor Expert Components&lt;/p&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Motor Driver&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The motor driver functionality is in Motor.c and Motor.h. The interface is as below:&lt;/p&gt;&lt;p style="margin:0;padding:0px;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;color:#373737;"&gt;&amp;nbsp;&lt;/p&gt;&lt;div class="syntaxhighlighter cpp" style="font-family:inherit;font-style:inherit;font-weight:inherit;"&gt;&lt;table border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="gutter" style="border:0px solid black;"&gt;&lt;div class="number1 alt2 line index0"&gt;1&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number2 alt1 index1 line" style="margin:0;"&gt;2&lt;/p&gt;&lt;p class="number3 index2 alt2 line" style="margin:0;"&gt;3&lt;/p&gt;&lt;p class="index3 number4 alt1 line" style="margin:0;"&gt;4&lt;/p&gt;&lt;p class="index4 alt2 number5 line" style="margin:0;"&gt;5&lt;/p&gt;&lt;p class="index5 alt1 line number6" style="margin:0;"&gt;6&lt;/p&gt;&lt;p class="number7 alt2 index6 line" style="margin:0;"&gt;7&lt;/p&gt;&lt;p class="index7 number8 alt1 line" style="margin:0;"&gt;8&lt;/p&gt;&lt;p class="number9 alt2 line index8" style="margin:0;"&gt;9&lt;/p&gt;&lt;p class="alt1 line index9 number10" style="margin:0;"&gt;10&lt;/p&gt;&lt;p class="alt2 index10 number11 line" style="margin:0;"&gt;11&lt;/p&gt;&lt;p class="alt1 number12 line index11" style="margin:0;"&gt;12&lt;/p&gt;&lt;p class="number13 alt2 line index12" style="margin:0;"&gt;13&lt;/p&gt;&lt;p class="index13 number14 alt1 line" style="margin:0;"&gt;14&lt;/p&gt;&lt;p class="index14 number15 alt2 line" style="margin:0;"&gt;15&lt;/p&gt;&lt;p class="number16 index15 alt1 line" style="margin:0;"&gt;16&lt;/p&gt;&lt;p class="number17 index16 alt2 line" style="margin:0;"&gt;17&lt;/p&gt;&lt;p class="index17 alt1 line number18" style="margin:0;"&gt;18&lt;/p&gt;&lt;p class="alt2 index18 line number19" style="margin:0;"&gt;19&lt;/p&gt;&lt;p class="number20 alt1 index19 line" style="margin:0;"&gt;20&lt;/p&gt;&lt;p class="alt2 index20 line number21" style="margin:0;"&gt;21&lt;/p&gt;&lt;p class="alt1 index21 number22 line" style="margin:0;"&gt;22&lt;/p&gt;&lt;p class="alt2 number23 index22 line" style="margin:0;"&gt;23&lt;/p&gt;&lt;p class="number24 alt1 line index23" style="margin:0;"&gt;24&lt;/p&gt;&lt;p class="index24 number25 alt2 line" style="margin:0;"&gt;25&lt;/p&gt;&lt;p class="index25 number26 alt1 line" style="margin:0;"&gt;26&lt;/p&gt;&lt;p class="number27 index26 alt2 line" style="margin:0;"&gt;27&lt;/p&gt;&lt;p class="number28 index27 alt1 line" style="margin:0;"&gt;28&lt;/p&gt;&lt;p class="alt2 index28 line number29" style="margin:0;"&gt;29&lt;/p&gt;&lt;p class="number30 alt1 index29 line" style="margin:0;"&gt;30&lt;/p&gt;&lt;p class="number31 index30 alt2 line" style="margin:0;"&gt;31&lt;/p&gt;&lt;p class="index31 alt1 line number32" style="margin:0;"&gt;32&lt;/p&gt;&lt;p class="alt2 index32 number33 line" style="margin:0;"&gt;33&lt;/p&gt;&lt;p class="number34 alt1 index33 line" style="margin:0;"&gt;34&lt;/p&gt;&lt;p class="number35 alt2 line index34" style="margin:0;"&gt;35&lt;/p&gt;&lt;p class="index35 number36 alt1 line" style="margin:0;"&gt;36&lt;/p&gt;&lt;p class="index36 number37 alt2 line" style="margin:0;"&gt;37&lt;/p&gt;&lt;p class="number38 index37 alt1 line" style="margin:0;"&gt;38&lt;/p&gt;&lt;p class="number39 index38 alt2 line" style="margin:0;"&gt;39&lt;/p&gt;&lt;p class="number40 index39 alt1 line" style="margin:0;"&gt;40&lt;/p&gt;&lt;p class="number41 index40 alt2 line" style="margin:0;"&gt;41&lt;/p&gt;&lt;p class="number42 index41 alt1 line" style="margin:0;"&gt;42&lt;/p&gt;&lt;p class="index42 alt2 line number43" style="margin:0;"&gt;43&lt;/p&gt;&lt;p class="index43 alt1 line number44" style="margin:0;"&gt;44&lt;/p&gt;&lt;p class="alt2 number45 index44 line" style="margin:0;"&gt;45&lt;/p&gt;&lt;p class="number46 alt1 line index45" style="margin:0;"&gt;46&lt;/p&gt;&lt;p class="index46 number47 alt2 line" style="margin:0;"&gt;47&lt;/p&gt;&lt;p class="index47 number48 alt1 line" style="margin:0;"&gt;48&lt;/p&gt;&lt;p class="number49 index48 alt2 line" style="margin:0;"&gt;49&lt;/p&gt;&lt;p class="number50 index49 alt1 line" style="margin:0;"&gt;50&lt;/p&gt;&lt;p class="index50 number51 alt2 line" style="margin:0;"&gt;51&lt;/p&gt;&lt;p class="number52 index51 alt1 line" style="margin:0;"&gt;52&lt;/p&gt;&lt;p class="number53 index52 alt2 line" style="margin:0;"&gt;53&lt;/p&gt;&lt;p class="index53 alt1 line number54" style="margin:0;"&gt;54&lt;/p&gt;&lt;p class="alt2 index54 line number55" style="margin:0;"&gt;55&lt;/p&gt;&lt;p class="alt1 number56 index55 line" style="margin:0;"&gt;56&lt;/p&gt;&lt;p class="alt2 number57 line index56" style="margin:0;"&gt;57&lt;/p&gt;&lt;p class="index57 number58 alt1 line" style="margin:0;"&gt;58&lt;/p&gt;&lt;p class="index58 number59 alt2 line" style="margin:0;"&gt;59&lt;/p&gt;&lt;p class="index59 number60 alt1 line" style="margin:0;"&gt;60&lt;/p&gt;&lt;p class="index60 number61 alt2 line" style="margin:0;"&gt;61&lt;/p&gt;&lt;p class="index61 number62 alt1 line" style="margin:0;"&gt;62&lt;/p&gt;&lt;p class="number63 index62 alt2 line" style="margin:0;"&gt;63&lt;/p&gt;&lt;p class="number64 index63 alt1 line" style="margin:0;"&gt;64&lt;/p&gt;&lt;p class="alt2 index64 line number65" style="margin:0;"&gt;65&lt;/p&gt;&lt;p class="alt1 index65 line number66" style="margin:0;"&gt;66&lt;/p&gt;&lt;p class="alt2 number67 line index66" style="margin:0;"&gt;67&lt;/p&gt;&lt;p class="number68 alt1 line index67" style="margin:0;"&gt;68&lt;/p&gt;&lt;p class="index68 number69 alt2 line" style="margin:0;"&gt;69&lt;/p&gt;&lt;p class="index69 number70 alt1 line" style="margin:0;"&gt;70&lt;/p&gt;&lt;p class="number71 alt2 line index70" style="margin:0;"&gt;71&lt;/p&gt;&lt;p class="index71 number72 alt1 line" style="margin:0;"&gt;72&lt;/p&gt;&lt;p class="index72 number73 alt2 line" style="margin:0;"&gt;73&lt;/p&gt;&lt;p class="number74 index73 alt1 line" style="margin:0;"&gt;74&lt;/p&gt;&lt;p class="number75 index74 alt2 line" style="margin:0;"&gt;75&lt;/p&gt;&lt;p class="index75 alt1 line number76" style="margin:0;"&gt;76&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code" style="border:0px solid black;"&gt;&lt;p class="container" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;div class="number1 alt2 line index0"&gt;&lt;code class="cpp comments"&gt;/*&lt;/code&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number2 alt1 index1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* Motor.h&lt;/code&gt;&lt;/p&gt;&lt;p class="number3 index2 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*&lt;/code&gt;&lt;/p&gt;&lt;p class="index3 number4 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Author: Erich Styger&lt;/code&gt;&lt;/p&gt;&lt;p class="index4 alt2 number5 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="index5 alt1 line number6" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number7 alt2 index6 line" style="margin:0;"&gt;&lt;code class="cpp preprocessor"&gt;#ifndef MOTOR_H_&lt;/code&gt;&lt;/p&gt;&lt;p class="index7 number8 alt1 line" style="margin:0;"&gt;&lt;code class="cpp preprocessor"&gt;#define MOTOR_H_&lt;/code&gt;&lt;/p&gt;&lt;p class="number9 alt2 line index8" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="alt1 line index9 number10" style="margin:0;"&gt;&lt;code class="cpp preprocessor"&gt;#include &amp;amp;quot;PE_Types.h&amp;amp;quot;&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index10 number11 line" style="margin:0;"&gt;&lt;code class="cpp preprocessor"&gt;#include &amp;amp;quot;FSSH1.h&amp;amp;quot;&lt;/code&gt;&lt;/p&gt;&lt;p class="alt1 number12 line index11" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number13 alt2 line index12" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;typedef&lt;/code&gt; &lt;code class="keyword cpp bold"&gt;enum&lt;/code&gt; &lt;code class="cpp plain"&gt;{&lt;/code&gt;&lt;/p&gt;&lt;p class="index13 number14 alt1 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;MOT_DIR_FORWARD,&amp;nbsp; &lt;/code&gt;&lt;code class="cpp comments"&gt;/*!&amp;amp;lt; Motor forward direction */&lt;/code&gt;&lt;/p&gt;&lt;p class="index14 number15 alt2 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;MOT_DIR_BACKWARD&amp;nbsp; &lt;/code&gt;&lt;code class="cpp comments"&gt;/*!&amp;amp;lt; Motor backward direction */&lt;/code&gt;&lt;/p&gt;&lt;p class="number16 index15 alt1 line" style="margin:0;"&gt;&lt;code class="cpp plain"&gt;} MOT_Direction;&lt;/code&gt;&lt;/p&gt;&lt;p class="number17 index16 alt2 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="index17 alt1 line number18" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;typedef&lt;/code&gt; &lt;code class="cpp plain"&gt;int8_t MOT_SpeedPercent; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* -100%...+100%, where negative is backward */&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index18 line number19" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number20 alt1 index19 line" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;typedef&lt;/code&gt; &lt;code class="keyword cpp bold"&gt;struct&lt;/code&gt; &lt;code class="cpp plain"&gt;MOT_MotorDevice_ {&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index20 line number21" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="color1 cpp bold"&gt;bool&lt;/code&gt; &lt;code class="cpp plain"&gt;brake; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* if brake is enabled or not */&lt;/code&gt;&lt;/p&gt;&lt;p class="alt1 index21 number22 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;MOT_SpeedPercent currSpeedPercent; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* our current speed in %, negative percent means backward */&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 number23 index22 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;uint16_t currPWMvalue; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* current PWM value used */&lt;/code&gt;&lt;/p&gt;&lt;p class="number24 alt1 line index23" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;LDD_TError (*SetRatio16)(LDD_TDeviceData*, uint16_t);&lt;/code&gt;&lt;/p&gt;&lt;p class="index24 number25 alt2 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;LDD_TDeviceData *PWMdeviceData; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* LDD device handle for PWM */&lt;/code&gt;&lt;/p&gt;&lt;p class="index25 number26 alt1 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt; &lt;code class="cpp plain"&gt;(*DirPutVal)(LDD_TDeviceData *, &lt;/code&gt;&lt;code class="color1 cpp bold"&gt;bool&lt;/code&gt;&lt;code class="cpp plain"&gt;); &lt;/code&gt;&lt;code class="cpp comments"&gt;/* function to set direction bit */&lt;/code&gt;&lt;/p&gt;&lt;p class="number27 index26 alt2 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;LDD_TDeviceData *DIRdeviceData; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* LDD device handle for direction */&lt;/code&gt;&lt;/p&gt;&lt;p class="number28 index27 alt1 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt; &lt;code class="cpp plain"&gt;(*BrakePutVal)(LDD_TDeviceData *, &lt;/code&gt;&lt;code class="color1 cpp bold"&gt;bool&lt;/code&gt;&lt;code class="cpp plain"&gt;); &lt;/code&gt;&lt;code class="cpp comments"&gt;/* function to enable/disable brake */&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index28 line number29" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;LDD_TDeviceData *BRAKEdeviceData; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* LDD device handle for brake pin */&lt;/code&gt;&lt;/p&gt;&lt;p class="number30 alt1 index29 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;uint16_t currentValue; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* current AD current sensor value */&lt;/code&gt;&lt;/p&gt;&lt;p class="number31 index30 alt2 line" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;uint16_t offset; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* current AD sensor offset value */&lt;/code&gt;&lt;/p&gt;&lt;p class="index31 alt1 line number32" style="margin:0;"&gt;&lt;code class="spaces cpp"&gt;&amp;nbsp; &lt;/code&gt;&lt;code class="cpp plain"&gt;LDD_TDeviceData *SNSdeviceData; &lt;/code&gt;&lt;code class="cpp comments"&gt;/* LDD current AD device handle */&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index32 number33 line" style="margin:0;"&gt;&lt;code class="cpp plain"&gt;} MOT_MotorDevice;&lt;/code&gt;&lt;/p&gt;&lt;p class="number34 alt1 index33 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number35 alt2 line index34" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="index35 number36 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Sets the PWM value for the motor.&lt;/code&gt;&lt;/p&gt;&lt;p class="index36 number37 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] motor Motor handle&lt;/code&gt;&lt;/p&gt;&lt;p class="number38 index37 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] val New PWM value.&lt;/code&gt;&lt;/p&gt;&lt;p class="number39 index38 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="number40 index39 alt1 line" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt; &lt;code class="cpp plain"&gt;MOT_SetVal(MOT_MotorDevice *motor, uint16_t val);&lt;/code&gt;&lt;/p&gt;&lt;p class="number41 index40 alt2 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number42 index41 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="index42 alt2 line number43" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Return the current PWM value of the motor.&lt;/code&gt;&lt;/p&gt;&lt;p class="index43 alt1 line number44" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] motor Motor handle&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 number45 index44 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \return Current PWM value.&lt;/code&gt;&lt;/p&gt;&lt;p class="number46 alt1 line index45" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="index46 number47 alt2 line" style="margin:0;"&gt;&lt;code class="cpp plain"&gt;uint16_t MOT_GetVal(MOT_MotorDevice *motor);&lt;/code&gt;&lt;/p&gt;&lt;p class="index47 number48 alt1 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number49 index48 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="number50 index49 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Change the direction of the motor&lt;/code&gt;&lt;/p&gt;&lt;p class="index50 number51 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] motor Motor handle&lt;/code&gt;&lt;/p&gt;&lt;p class="number52 index51 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] dir Direction to be used&lt;/code&gt;&lt;/p&gt;&lt;p class="number53 index52 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="index53 alt1 line number54" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt; &lt;code class="cpp plain"&gt;MOT_SetDirection(MOT_MotorDevice *motor, MOT_Direction dir);&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index54 line number55" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="alt1 number56 index55 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 number57 line index56" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Returns the direction of the motor&lt;/code&gt;&lt;/p&gt;&lt;p class="index57 number58 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] motor Motor handle&lt;/code&gt;&lt;/p&gt;&lt;p class="index58 number59 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \return Current direction of the motor&lt;/code&gt;&lt;/p&gt;&lt;p class="index59 number60 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="index60 number61 alt2 line" style="margin:0;"&gt;&lt;code class="cpp plain"&gt;MOT_Direction MOT_GetDirection(MOT_MotorDevice *motor);&lt;/code&gt;&lt;/p&gt;&lt;p class="index61 number62 alt1 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number63 index62 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="number64 index63 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Shell command line parser.&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 index64 line number65" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] cmd Pointer to command string&lt;/code&gt;&lt;/p&gt;&lt;p class="alt1 index65 line number66" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[out] handled If command is handled by the parser&lt;/code&gt;&lt;/p&gt;&lt;p class="alt2 number67 line index66" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \param[in] io Std I/O handler of shell&lt;/code&gt;&lt;/p&gt;&lt;p class="number68 alt1 line index67" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="index68 number69 alt2 line" style="margin:0;"&gt;&lt;code class="cpp plain"&gt;uint8_t MOT_ParseCommand(&lt;/code&gt;&lt;code class="keyword cpp bold"&gt;const&lt;/code&gt; &lt;code class="cpp plain"&gt;unsigned &lt;/code&gt;&lt;code class="color1 cpp bold"&gt;char&lt;/code&gt; &lt;code class="cpp plain"&gt;*cmd, &lt;/code&gt;&lt;code class="color1 cpp bold"&gt;bool&lt;/code&gt; &lt;code class="cpp plain"&gt;*handled, &lt;/code&gt;&lt;code class="keyword cpp bold"&gt;const&lt;/code&gt; &lt;code class="cpp plain"&gt;FSSH1_StdIOType *io);&lt;/code&gt;&lt;/p&gt;&lt;p class="index69 number70 alt1 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="number71 alt2 line index70" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;/*!&lt;/code&gt;&lt;/p&gt;&lt;p class="index71 number72 alt1 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;* \brief Initialization function.&lt;/code&gt;&lt;/p&gt;&lt;p class="index72 number73 alt2 line" style="margin:0;"&gt;&lt;code class="cpp comments"&gt;*/&lt;/code&gt;&lt;/p&gt;&lt;p class="number74 index73 alt1 line" style="margin:0;"&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt; &lt;code class="cpp plain"&gt;MOT_Init(&lt;/code&gt;&lt;code class="keyword cpp bold"&gt;void&lt;/code&gt;&lt;code class="cpp plain"&gt;);&lt;/code&gt;&lt;/p&gt;&lt;p class="number75 index74 alt2 line" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="index75 alt1 line number76" style="margin:0;"&gt;&lt;code class="cpp preprocessor"&gt;#endif /* MOTOR_H_ */&lt;/code&gt;&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 style="font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:0.8125em;color:#000000;"&gt;Summary&lt;/h2&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;It was very easy to use the Motor Shield with the help of &lt;a class="jive-link-external-small" href="http://mcuoneclipse.com/2012/09/25/codewarrior-for-mcu10-3-beta-is-now-available/" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="CodeWarrior for MCU10.3 beta is now available"&gt;CodeWarrior for MCU10.3&lt;/a&gt; and Processor Expert. The basic functionality with the exception of current sensing works and with the shell interface it is easy to explore and add further functionality. I still have an ultrasonic sensor to integrate :-).&lt;/p&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;The CodeWarrior project and sources are available from &lt;a class="jive-link-external-small" href="http://www.steinerberg.com/EmbeddedComponents/Examples/FreedomBoard/Freedom_Motor.zip" rel="nofollow ugc noopener" style="font-family:inherit;font-style:inherit;font-weight:inherit;color:#1982d1;" target="_blank" title="Freedom Motor Shield Example Application"&gt;this link&lt;/a&gt;.&lt;/p&gt;&lt;p style="margin:0;font-family:&amp;#39;Helvetica Neue&amp;#39;, Helvetica, Arial, sans-serif;font-size:15px;margin-bottom:1.625em;color:#373737;"&gt;Happy Motoring &lt;a href="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1129645325g"&gt;&lt;img loading="lazy" alt=":-)" class="jiveImage wp-smiley" src="http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif?m=1129645325g" style="border-style:none;" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: Freescale Tagged Content, freescale, kinetis, frdm, frdm_kl25z, freesacledocs&lt;/div&gt;
</description></item></channel></rss>