{"id":204,"date":"2012-03-08T15:35:30","date_gmt":"2012-03-08T23:35:30","guid":{"rendered":"http:\/\/research.engineering.ucdavis.edu\/biosport\/?p=204"},"modified":"2014-06-18T15:21:52","modified_gmt":"2014-06-18T23:21:52","slug":"robotic-bike-steer-calibration","status":"publish","type":"post","link":"https:\/\/research.engineering.ucdavis.edu\/biosport\/robotic-bike-steer-calibration\/","title":{"rendered":"Robotic bike steer calibration"},"content":{"rendered":"<p>by Kenneth Lyons<\/p>\n<p>Overview and results of a calibration routine for determining the position of the index line on the steer encoder.<\/p>\n<div>\n<div id=\"parent-fieldname-text\">\n<p>&nbsp;<\/p>\n<div>\n<p>For the last few weeks, I have been working with Luke to produce a steer calibration program to run on the robotic bike. Much of this time involved me getting up to speed with how to actually program the STM32 and dealing with voltage comparator issues.<\/p>\n<p>The rotary encoder for tracking the steer angle has an index line which occurs once per full revolution. This is useful because we can take this incremental encoder and use it to find the steer angle at all times as opposed to only knowing angular velocity based on sequences of ticks and their timing.\u00a0<\/p>\n<p>The basic strategy is to put the bike on a fixture designed to hold the front fork at zero steer. We start the program, which initializes the steer tick count to zero and then waits for an interrupt from the encoder index line. While the program waits, we remove the fixture and rotate the front fork back and forth across the index line so that we can determine exactly where it is. We can then read the data obtained each time the interrupt was triggered to pinpoint the location of the index line. Assuming the front fork encoder stays fixed (i.e. the steering assembly is not taken apart), we can hard-code the number of ticks to the index line into subsequent programs so we know the steer angle at all times.\u00a0An actual program might begin by initializing the steer count to zero (even though the steer angle may not be zero), then wait for the index line to trigger an interrupt. At the exact location this interrupt occurs, the steer count can be reset to the hard-coded value obtained from the calibration. After this, we know that zero steer is actually at zero.<\/p>\n<p>The source code for the steer calibration program can be found on github:<\/p>\n<p><a href=\"https:\/\/github.com\/hazelnusse\/roboticbicycle\/blob\/steercalibration\/MCP\/src\/steer_calibration.cc\">https:\/\/github.com\/hazelnusse\/roboticbicycle\/blob\/steercalibration\/MCP\/src\/steer_calibration.cc<\/a><\/p>\n<p>&nbsp;<\/p>\n<p dir=\"ltr\">On to the results. Two runs were performed; one for each configuration of the steer fixture. \u00a0The\u00a0experimental procedure was as follows:<\/p>\n<p dir=\"ltr\">1) Secure the steer fixture into the dropouts by first tightening the front\u00a0axle nuts, then the rear axle nuts.<\/p>\n<p dir=\"ltr\">2) Start the program from restart to ensure TIM3-&gt;CNT == 0 while the fork is\u00a0rigidly held &#8220;straight&#8221; by the fixture.<\/p>\n<p dir=\"ltr\">3) Loosen the front axle nuts and drop the front end of the fixture out of the\u00a0front fork dropouts.<\/p>\n<p dir=\"ltr\">4) First turn the fork to the right, approximately 10 degrees, then back past\u00a0straight ahead to\u00a0about 10 degrees to the left. \u00a0Repeat the procedure 9 more\u00a0times.<\/p>\n<p dir=\"ltr\">5) Verify the encoder count and pinstate data was properly recorded in memory.<\/p>\n<p dir=\"ltr\">6) Issue the following command to gdb:\u00a0<\/p>\n<\/div>\n<pre>dump binary memory <em>filename<\/em> <em>start_addr<\/em> <em>end_addr<\/em><\/pre>\n<div>\n<p dir=\"ltr\">where\u00a0<em>start_addr<\/em>\u00a0and\u00a0<em>end_addr<\/em>\u00a0correspond to the pinstate and ticks arrays.<\/p>\n<\/div>\n<div>\n<p dir=\"ltr\">7) Verify the size of the file on disk matches the size of the data in memory.<\/p>\n<p dir=\"ltr\">8) Write a Python script to read the data file and report the data in human-readable format.<\/p>\n<p dir=\"ltr\">9) Verify the Python script reads the data properly and that it matches what\u00a0is displayed by gdb.<\/p>\n<p dir=\"ltr\">10) Flip the steer fixture upside down and repeat steps 1-9, ensuring you save\u00a0the data to a\u00a0different filename.<\/p>\n<p dir=\"ltr\">\u00a0<\/p>\n<p dir=\"ltr\">Here is a plot that shows the results of the calibration:<\/p>\n<p dir=\"ltr\"><a href=\"http:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-205\" alt=\"interrupt_tick_plot\" src=\"http:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot-300x226.png\" width=\"300\" height=\"226\" srcset=\"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot-300x226.png 300w, https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot-199x150.png 199w, https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot-150x113.png 150w, https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-content\/uploads\/sites\/24\/2014\/06\/interrupt_tick_plot.png 812w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<dl>\n<dt><\/dt>\n<dd>A graphical depiction of the data obtained from the steer calibration experiment.<\/dd>\n<\/dl>\n<p dir=\"ltr\">It is not simply a horizontal line for each run because the interrupt is triggered on the rising and falling edges of the index line. While it seems like a difference of 9 ticks between the two runs is significant, this is actually a very small fraction of a degree. It\u2019s actually rather surprising how close the two sets are.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>by Kenneth Lyons Overview and results of a calibration routine for determining the position of the index line on the steer encoder. &nbsp; For the last few weeks, I have been working with Luke to produce a steer calibration program to run on the robotic bike. Much of this time \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/research.engineering.ucdavis.edu\/biosport\/robotic-bike-steer-calibration\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-204","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/posts\/204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/comments?post=204"}],"version-history":[{"count":1,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/posts\/204\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/posts\/204\/revisions\/206"}],"wp:attachment":[{"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/media?parent=204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/categories?post=204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/research.engineering.ucdavis.edu\/biosport\/wp-json\/wp\/v2\/tags?post=204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}