<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>engunneer&#039;s projects &#187; FIRST Robotics</title>
	<atom:link href="http://www.engunneer.com/content/blog/category/first-robotics/feed" rel="self" type="application/rss+xml" />
	<link>http://www.engunneer.com/content</link>
	<description>engunneer&#039;s archive of projects and pictures</description>
	<lastBuildDate>Thu, 10 May 2012 03:35:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>PID explained</title>
		<link>http://www.engunneer.com/content/blog/pid-explained</link>
		<comments>http://www.engunneer.com/content/blog/pid-explained#comments</comments>
		<pubDate>Tue, 28 Feb 2012 16:20:46 +0000</pubDate>
		<dc:creator>engunneer</dc:creator>
				<category><![CDATA[FIRST Robotics]]></category>

		<guid isPermaLink="false">http://engunneer.com/content/?p=238</guid>
		<description><![CDATA[The topic of PID often comes up when I talk with FIRST teams. This post is how I explain it to students. I was recently explaining it in a post on Chief Delphi, so I decided to turn it into a blog post while I was at it. The basic idea for PID is that [...]]]></description>
			<content:encoded><![CDATA[<p>The topic of PID often comes up when I talk with FIRST teams. This post is how I explain it to students. I was recently explaining it in a post on Chief Delphi, so I decided to turn it into a blog post while I was at it.</p>
<p>The basic idea for PID is that it corrects for errors. if you make a PID loop based on position, it will move your motors such that the position is what you want. you can replace the word position with the words velocity, angle, and even acceleration or motor current. you can also loop multiple parts of your motion. (i.e. Loop position and velocity), but for FIRST, you usually only need to put a loop around one thing.</p>
<p>Let&#8217;s use position for discussion, which is easiest to visualize. First, you need a way to measure your position (an encoder can be used for position or velocity, the gyro or an accelerometer can measure angular data.). The difference between the position you are in, and the position you want to be in, is your error. PID acts on this error to try and make it 0.</p>
<p>In a typical machine tool (like a CNC machine (Hey look, FIRST applies to the real world <img src='http://www.engunneer.com/content/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )), you want to position an axis. Say the axis is currently at zero, and you want to move it a meter. Your commanded position is 1m, and your actual is 0m, making your error +1m. (The sign is important!). Proportional Gain is a number we multiply by the error to get a motor command. Sometimes this is a speed (engineering unis such as m/s), or in our case, it is a motor command in the range of -1 to +1. Let&#8217;s say our proportional gain is 0.5. 0.5(gain)*1m(error) = 0.5(command), which moves our motor towards where it is supposed to go.</p>
<p>For the sake of discussion, let&#8217;s say our motor is geared such that a command of 1 means the mechanism in question is moving at 1m/s. That is also the top speed of the motion, since the command cannot be greater than 1.</p>
<p>PID loops execute repeatedly in your Periodic tasks, so they occur with a fixed time base. To demonstrate, I&#8217;ve put this together as an excel worksheet, and posted it to here -&gt; <a href="http://engunneer.com/content/wp-content/uploads/2012/02/PID-worksheet.xls">PID worksheet</a>. The sheet lets you play with some different PID settings, and lets you look at how the mechanism will move based on the commanded velocity. It&#8217;s not taking friction or even acceleration into account, but it gives the basic idea of how PID works.</p>
<p>The D (derivative) gain is applied to the difference between the error last cycle, and this cycle. It can be used to slow down the movement if it is approaching the target to quickly.</p>
<p>Integral Gain (I) is applied to the total sum of all errors. It is common to not accumulate errors if the error is too large, or to limit the accumulation to a certain value, or to clear out the accumulator when you are in position. The job of I is to take care of small position errors that occur when the P gain alone is not enough to overcome friction or some other limiting mechanical feature.</p>
<p>The sum of the P I and D values are added together to create the motor command. The gains have to be tuned to get the response you want. If P I or D are too large, the system will oscillate. If the signs are wrong, the system will run away. If I is not controlled a bit, it can overshoot significantly. Most FIRST mechanisms work just fine using P, PI, or PD modes. P mode means that I and D gains are 0. PD means I is 0, and PI means that D is 0.</p>
<p>PID does not always need to be reactive. In general terms, there is a further thing you can add called FeedForward, which you can apply to either velocity or acceleration, as the case may be. The basic idea with Feedforward is that you know you&#8217;ll be moving in a certain direction anyway, so give a little boost to your velocity or acceleration, then let the rest of PID react once you get going. You can see this on the second sheet of the workbook.</p>
<p>If you have any questions, please post a comment!</p>
<div class="googlePlusOneButton"><g:plusone href="http://www.engunneer.com/content/blog/pid-explained"  size="standard"   annotation="none"  ></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.engunneer.com/content/blog/pid-explained/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated Shot simulation (Still no Drag or Magnus effect)</title>
		<link>http://www.engunneer.com/content/blog/updated-shot-simulation-still-no-drag-or-magnus-effect</link>
		<comments>http://www.engunneer.com/content/blog/updated-shot-simulation-still-no-drag-or-magnus-effect#comments</comments>
		<pubDate>Fri, 17 Feb 2012 17:12:58 +0000</pubDate>
		<dc:creator>engunneer</dc:creator>
				<category><![CDATA[FIRST Robotics]]></category>

		<guid isPermaLink="false">http://engunneer.com/content/?p=232</guid>
		<description><![CDATA[I got a request to add the second angle option to the macro calculated angle section. In theory, there are two launch angles that hit the same target. I biased towards the highest one, because the margin of error for making the basket is wider. I also noticed that the macro section assumed the ball [...]]]></description>
			<content:encoded><![CDATA[<p>I got a request to add the second angle option to the macro calculated angle section. In theory, there are two launch angles that hit the same target. I biased towards the highest one, because the margin of error for making the basket is wider.</p>
<p>I also noticed that the macro section assumed the ball launched from 36&#8243; off the floor (set on the third sheet), so I changed it to take the h_0 setting from the top of the first page, so all charts assume the same launch height.</p>
<p>Here&#8217;s the updated spreadsheet:<a href="http://engunneer.com/content/wp-content/uploads/2012/02/shot-simulation-macro.xls">shot simulation (macro)</a></p>
<p>The biggest thing to keep in mind is that there is still no Drag (Air resistance) or Magnus effect (increased range due to backspin). I&#8217;m hoping the two effects somewhat cancel each other out, but they will both be significant in the real world.</p>
<div class="googlePlusOneButton"><g:plusone href="http://www.engunneer.com/content/blog/updated-shot-simulation-still-no-drag-or-magnus-effect"  size="standard"   annotation="none"  ></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.engunneer.com/content/blog/updated-shot-simulation-still-no-drag-or-magnus-effect/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FIRST 2012 Ball Trajectory Spreadsheet</title>
		<link>http://www.engunneer.com/content/blog/first-2012-ball-trajectory-spreadsheet</link>
		<comments>http://www.engunneer.com/content/blog/first-2012-ball-trajectory-spreadsheet#comments</comments>
		<pubDate>Tue, 10 Jan 2012 05:07:28 +0000</pubDate>
		<dc:creator>engunneer</dc:creator>
				<category><![CDATA[FIRST Robotics]]></category>
		<category><![CDATA[calculator]]></category>
		<category><![CDATA[FIRST]]></category>
		<category><![CDATA[FRC 2151]]></category>

		<guid isPermaLink="false">http://engunneer.com/content/?p=201</guid>
		<description><![CDATA[It&#8217;s the time of year for FIRST again, and this year&#8217;s game (Rebound Rumble) is looking like it&#8217;s going to be pretty exciting. This year, I&#8217;m helping Team 2151, the Monty Pythons. I made a spreadsheet to help with planning a shooting mechanism, and to help with testing or writing code. The spreadsheet is broken [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the time of year for FIRST again, and this year&#8217;s game (Rebound Rumble) is looking like it&#8217;s going to be pretty exciting. This year, I&#8217;m helping Team 2151, the Monty Pythons.</p>
<p>I made a spreadsheet to help with planning a shooting mechanism, and to help with testing or writing code.</p>
<p>The spreadsheet is broken up into different sections. The first section has the basic parameters to calculate what velocity is needed for a given set of shot parameters. Set the cells that are green to your values, and the first orange boxes will show the velocity needed for each of the three hoop levels. If the angle of the ball entering the hoop is too shallow, the box will turn red. The h0 (robot shooter height) parameter is used for all the sections, so make sure you set this accurately before going down to the other sections.</p>
<p><a href="http://engunneer.com/content/wp-content/uploads/2012/01/section1.png" rel="lightbox[201]"><img class="aligncenter size-medium wp-image-204" title="section1" src="http://engunneer.com/content/wp-content/uploads/2012/01/section1-300x178.png" alt="" width="300" height="178" /></a></p>
<p>The next section calculates a the velocity needed for a variety of shooting angles for a given range. This does not check to see if the shot is too shallow. The first section can be used to look at any individual shot to see if it passes the shallowness test. There is an inverted chart off to the right that swaps the X and Y axes, which gives a different view of the data. The left chart can be used to find a desired velocity for a given range and angle, where the right chart can help you choose an angle to go with your known velocity.</p>
<p><a href="http://engunneer.com/content/wp-content/uploads/2012/01/section2.png" rel="lightbox[201]"><img class="aligncenter size-medium wp-image-205" title="section2" src="http://engunneer.com/content/wp-content/uploads/2012/01/section2-300x197.png" alt="" width="300" height="197" /></a></p>
<p>The next section is useful for robots with a fixed shooting angle. It calculates the velocity needed to make baskets at a variety of ranges. There is an inverted chart off to the right that swaps the X and Y axes, which gives a different view of the data. The left chart can be used to find a desired velocity, while the right chart can be used to see what range you&#8217;d get out of your current velocity.</p>
<p><a href="http://engunneer.com/content/wp-content/uploads/2012/01/section3.png" rel="lightbox[201]"><img class="aligncenter size-medium wp-image-206" title="section3" src="http://engunneer.com/content/wp-content/uploads/2012/01/section3-300x197.png" alt="" width="300" height="197" /></a></p>
<p>The last section is only in the macro version of the spreadsheet. It is designed for robots with a fixed firing velocity (such as a pneumatic launcher). It calculates (using an iteration macro) the needed angle of launch for a fixed velocity and a variety of ranges.</p>
<p><a href="http://engunneer.com/content/wp-content/uploads/2012/01/section4.png" rel="lightbox[201]"><img class="aligncenter size-medium wp-image-207" title="section4" src="http://engunneer.com/content/wp-content/uploads/2012/01/section4-300x197.png" alt="" width="300" height="197" /></a></p>
<p>The most useful part of this is for estimating a formula to use in the robot code. The math itself is non-trivial to rearrange.</p>
<p>Hopefully this spreadsheet is useful to other teams, so I am posting them here. <a href="http://engunneer.com/content/wp-content/uploads/2012/01/shot-simulation-macro1.xls">shot simulation (macro)</a></p>
<p><a href="http://engunneer.com/content/wp-content/uploads/2012/01/shot-simulation-no-macro.xls">shot simulation (no macro)</a></p>
<p>Please let me know what you think below</p>
<p>UPDATE (10AM): I added some trendlines to the last graph in the macro version. Now you can specify what range to look at and it will give you a cubic formula for a trendline for each hoop. The trendline will get messed up if you don&#8217;t have enough velocity to make the range (blank results in the orange boxes). if you ever get an error message (if the macro fails to find a result), you may have to go to sheet 3 and change cells in the B10 to D22 range to 89 to get it working again. Basically, if the GoalSeek Function can&#8217;t find a result, it can make an error pop up. I try to prevent the most common errors, but asking for longer ranges is more likely to have issues. </p>
<p>Be sure to check results back up in the first section to make sure the angles are still valid. The first section can also be used for checking the human player parameters needed to make a shot. set the range to 54 or 56 feet, set the angle high enough to clear the 8 foot alliance wall, and then see what sorts of velocities are needed to make the shot.</p>
<p>UPDATE (10:10AM): I fixed a bug with the entry angle lookup code.<br />
UPDATE (10:40AM): I added the height of the apex of the curve to section 1.</p>
<div class="googlePlusOneButton"><g:plusone href="http://www.engunneer.com/content/blog/first-2012-ball-trajectory-spreadsheet"  size="standard"   annotation="none"  ></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://www.engunneer.com/content/blog/first-2012-ball-trajectory-spreadsheet/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

