{"id":194,"date":"2010-04-26T12:18:40","date_gmt":"2010-04-26T16:18:40","guid":{"rendered":"http:\/\/ammonsengineering.com\/blog\/2010\/04\/pendulum-model\/"},"modified":"2010-04-26T12:38:27","modified_gmt":"2010-04-26T16:38:27","slug":"pendulum-model","status":"publish","type":"post","link":"https:\/\/ammonsengineering.com\/blog\/2010\/04\/pendulum-model\/","title":{"rendered":"Pendulum model"},"content":{"rendered":"<p>I am still having trouble figuring out how to model the cart.\u00a0 I have one equation that relates the PWM output to the torque, which can easily be converted to force.\u00a0 I have a second equation that relates force to the motion of the cart.\u00a0 If I knew all the coefficients in the equations, it would be pretty easy, but most of the coefficients are unknown at this point.\u00a0 Another problem is that the two equations are in different forms (Laplace and differential), so I can&#8217;t just set them equal to each other.<\/p>\n<p>I decided to look at the pendulum side of the model.\u00a0 I added a little code to the sine program to record data and oscillated the cart at 1600 msec\/cycle, which appears to be close to the natural frequency of the pendulum.\u00a0 The pendulum alternated between large and small oscillations several times.<\/p>\n<p>From the recorded data, I have cart position (x), cart speed (dx), pendulum position (T), and pendulum speed (dT).\u00a0 My first step was to heavily filter the data to eliminate noise, then calculate the accelerations of both (ddx, ddT).\u00a0 I also converted the units from counts to meters and radians.<\/p>\n<p>The equilibrium equation for the pendulum is:\u00a0 ddT = 1\/(I+L^2m) [Lm(ddx cosT &#8211; g sinT) &#8211; c dT]<\/p>\n<p>Since I don&#8217;t care about the individual constants, I simplified it to:\u00a0 ddT = A (ddx cosT &#8211; g sinT)\u00a0+\u00a0B dT]<\/p>\n<p>Using the collected data, I rearranged it to get a curve for (ddx cosT &#8211; g sinT), then used linear regression to get the best fit for the constants A and B.\u00a0 It gives me values of A=1.9217 and B=-0.024.<\/p>\n<p>The fit worked really well and the best fit curve almost exactly matches the ddT curve.\u00a0 I was going to post a plot comparing the fit data\u00a0to actual data, but they were so close that you can&#8217;t see the difference.\u00a0 This makes me pretty confident in this part of the model.\u00a0 It should be plenty close to the actual system for testing algorithms.\u00a0 Now I just need to figure out the cart model.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am still having trouble figuring out how to model the cart.\u00a0 I have one equation that relates the PWM output to the torque, which can easily be converted to force.\u00a0 I have a second equation that relates force to the motion of the cart.\u00a0 If I knew all the coefficients in the equations, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-194","post","type-post","status-publish","format-standard","hentry","category-software"],"_links":{"self":[{"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/posts\/194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/comments?post=194"}],"version-history":[{"count":2,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":195,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/posts\/194\/revisions\/195"}],"wp:attachment":[{"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/media?parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/categories?post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ammonsengineering.com\/blog\/wp-json\/wp\/v2\/tags?post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}