marvin:ecp1
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
marvin:ecp1 [2009/01/28 13:22] – rieper | marvin:ecp1 [2009/01/29 09:52] – deva | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <texit info> | ||
+ | author=Johnny Rieper, Bent Bisballe Nyeng and Kasper Sohn | ||
+ | title=Marvin - The Balancing Robot. | ||
+ | </ | ||
======Lab Report 1 - Gyroscope Communication====== | ======Lab Report 1 - Gyroscope Communication====== | ||
Line 14: | Line 18: | ||
=====Analysis===== | =====Analysis===== | ||
+ | |||
+ | |||
====Analogue to digital conversion and limitations==== | ====Analogue to digital conversion and limitations==== | ||
- | The main problem when dealing with sensors is that the real world is continuous | + | The main problem when dealing with sensors is that the real world is continuous and when we want to interpret these data it has to be digitized |
The gyroscope utilizes the ADC so that it is possible to get readings from the gyroscope. | The gyroscope utilizes the ADC so that it is possible to get readings from the gyroscope. | ||
====Gyroscope==== | ====Gyroscope==== | ||
- | The gyroscope used is sold by HiTechnic (([[http:// | + | The gyroscope used has been purchased from HiTechnic (([[http:// |
- | [{{ : | + | {{ : |
- | The gyroscope is produced to work seamless with the Lego NXT Brick. It connects to the NXT using a standard wire and utilizes the analogue interface. The gyroscope contains a single axis gyroscopic sensor that detects rotation and returns a value representing the number of degrees per second of rotation. The gyroscope sensor measures up to +/- 360 degrees per second of rotation and these readings will be signed if the correct offset is used. | + | The gyroscope is produced to work seamless with the LEGO NXT Brick. It connects to the NXT using a standard wire and utilizes the analogue interface. The gyroscope contains a single axis gyroscopic sensor that detects rotation and returns a value representing the number of degrees per second of rotation. The gyroscope sensor measures up to +/- 360 degrees per second of rotation and these readings will be signed if the correct offset is used. |
As not all gyroscopes are identical there will be some minor differences in the offset, but the manual that came along with the gyroscope, indicates this to be around 620. This is the offset value has to be subtracted from the readings from the gyroscope in order to get a signed reading. \\ | As not all gyroscopes are identical there will be some minor differences in the offset, but the manual that came along with the gyroscope, indicates this to be around 620. This is the offset value has to be subtracted from the readings from the gyroscope in order to get a signed reading. \\ | ||
- | The sensor can be read 300 times per second, which correspond to a sample rate of 300 Hz.\\ | + | The sensor can be read 300 times per second |
+ | |||
+ | The gyroscope operates in relative values, which means that it can not tell where e.g. upright is. One have to " | ||
- | The gyroscope operates | + | The axis of measurement is in the vertical plane with the gyroscope |
- | The axis of measurement is in the vertical plane with the gyroscope sensor positioned with the black end cap facing upwards. A picture is shown below.\\ | + | {{ : |
- | [{{ : | + | |
- | The right placement of the gyroscope can be seen from the [[#Building the robot|building instructions]] | + | The correct |
=====Building the robot===== | =====Building the robot===== | ||
====Preliminary considerations==== | ====Preliminary considerations==== | ||
- | Our primary goal is to make a balancing robot, and therefore it would be nice to eliminate the possible | + | Our primary goal is to make a balancing robot, and therefore it would be nice to eliminate the possibility |
====The Build==== | ====The Build==== | ||
Line 43: | Line 50: | ||
The finished robot can be seen in the picture below. | The finished robot can be seen in the picture below. | ||
- | {{ : | + | {{ : |
- | One thing worth noting is that the ultrasonic sensor is shifted slightly to the left. This is because it is important that the gyroscopes | + | One thing worth noting is that the ultrasonic sensor is shifted slightly to the left. This is because it is important that the gyroscopes |
- | {{ : | + | {{ : |
====Peripheral Connections==== | ====Peripheral Connections==== | ||
Line 59: | Line 66: | ||
| DC Motor Left * | PWM | % | int8 | 500 | B | | | DC Motor Left * | PWM | % | int8 | 500 | B | | ||
| DC Motor Right * |PWM | % | int8 | 500 | C | | | DC Motor Right * |PWM | % | int8 | 500 | C | | ||
- | *The rotary encoders and DC Motors (left and right respectively) utilizes the same port | + | *The rotary encoders and DC Motors (left and right respectively) utilizes the same port. |
- | + | ====Pros and Cons About the Design==== | |
- | ====Pros and Cons About This Design==== | + | As mentioned earlier, this is a well documented and working design. This is of great importance, because we can eliminate this as a factor of error later on. Another issue that have proven important in our experiments is the ability to easily remove the battery for recharging. This may not seem important |
- | As mentioned earlier, this is a well documented and working design. This is of great importance, because we thus can eliminate this as a factor of error later on. Another issue that have proven important in our experiments is the ability to easily remove the battery for recharging. This may not seem that important, but the characteristics of the voltage applied to the motors vary greatly with the charge level of the battery, and therefore the behaviour of the motors | + | In the group we discussed what effect the wheel diameter will have on the robot. Wheels with a larger diameter will travel |
- | In the group we discussed what effect the wheel diameter will have on the robot. Wheels with a larger diameter will travel longer than smaller wheels for the same amount of power applied to the motor on which the wheel is attached. We thought | + | |
A thing worth mentioning is the construction of the wheel mounting point and wheelbase which can be seen on the picture below | A thing worth mentioning is the construction of the wheel mounting point and wheelbase which can be seen on the picture below | ||
- | + | ^ Wheel mounting on Marvin^ | |
- | {{: | + | |{{: |
This construction provides a rigid frame that will prevent structural wobbling. This is important because of the sudden movements forward and backward motions a balancing robot evidently will make. | This construction provides a rigid frame that will prevent structural wobbling. This is important because of the sudden movements forward and backward motions a balancing robot evidently will make. | ||
Line 75: | Line 81: | ||
We used the standard wheels throughout testing, but found these to have to much friction when driven on rugged carpet. Although they have a cleverly designed mounting point we found that this was not necessary in our implementation and opted to go with the wheels shown below. | We used the standard wheels throughout testing, but found these to have to much friction when driven on rugged carpet. Although they have a cleverly designed mounting point we found that this was not necessary in our implementation and opted to go with the wheels shown below. | ||
- | {{ : | + | {{ : |
- | The standard wheels sometimes got stuck in the carpet causing the robot to loose balance. Therefore we switched these with someone of similar diameter, but with a much more slick surface. These had sufficient traction, but did not cause the robot to get stuck in the carpet. | + | =====Implementation===== |
- | {{ : | ||
- | |||
- | =====Implementation===== | ||
====Numerical Readings from the Gyroscope==== | ====Numerical Readings from the Gyroscope==== | ||
- | A gyroscope measures | + | A gyroscope measures |
- | In order to to a discrete integration we simply need to look at a simple recursive difference equation, which in this case will be a running sum. Recall | + | In order to do a discrete integration we simply need to look at a simple recursive difference equation, which in this case will be a running sum. Recall |
- | Integration:< | + | Integration: |
- | First Difference: < | + | First difference: <latex> |
Each sample in the output signal is a sum of weighted samples from the input. The reason for pointing out the first order derivative as well is that they (of course) are closely related which becomes clear in the illustration below. (([[http:// | Each sample in the output signal is a sum of weighted samples from the input. The reason for pointing out the first order derivative as well is that they (of course) are closely related which becomes clear in the illustration below. (([[http:// | ||
{{: | {{: | ||
- | There are many types of algorithms for numerical integrations that are far more advanced and all of them or based on some kind of interpolation technique, but for now we will rely on the simplest form which is the running sum. As an alternative we will implement another solution known as the trapezoidal integration that utilizes a first order polynomial to interpolate between sampled values, hence forming a trapezoidal between every two samples. An illustration of this and further discussion on the topic may be found on wikipidea(([[http:// | + | There are many types of algorithms for numerical integrations that are far more advanced and all of them or based on some kind of interpolation technique, but for now we will rely on the simplest form which is the running sum. |
====Programming==== | ====Programming==== | ||
Line 100: | Line 102: | ||
{{ : | {{ : | ||
- | This class wraps the gyroscope sensor, and offers readouts as angle velocities, or as integrated angle velocities over time (angles).\\ | + | This class wraps the gyroscope sensor, and offers readouts as either |
The angle velocities can be read raw from the sensor port, but must be subtracted with an offset defining the stand-still gyroscope. This value is according to the documentation approximately 620, but may vary from gyroscope to gyroscope. We made some experiments and found the value 595.5 to be pretty accurate.\\ | The angle velocities can be read raw from the sensor port, but must be subtracted with an offset defining the stand-still gyroscope. This value is according to the documentation approximately 620, but may vary from gyroscope to gyroscope. We made some experiments and found the value 595.5 to be pretty accurate.\\ | ||
This value is however not accurate enough when run over a large quantity of time, which will make the integration drift, thereby making Marvin unable to keep its balance.\\ | This value is however not accurate enough when run over a large quantity of time, which will make the integration drift, thereby making Marvin unable to keep its balance.\\ | ||
The solution was to use the measured value as an initial value, and then use a weighted average of all measured angles over time, where the last measured angle is weighted very low. We tested the solution with a variety of values, and found the value 0.999999 to be pretty good (one might think the having a static 595.5 might do the same, but experiments show otherwise). | The solution was to use the measured value as an initial value, and then use a weighted average of all measured angles over time, where the last measured angle is weighted very low. We tested the solution with a variety of values, and found the value 0.999999 to be pretty good (one might think the having a static 595.5 might do the same, but experiments show otherwise). | ||
- | These constants are hardcoded | + | These constants are hard coded into the program with the following names and values: |
^ Variable | ^ Variable | ||
Line 110: | Line 112: | ||
| a | 0.999999 | | | a | 0.999999 | | ||
- | For the integration over time algorithm we use a simple sum multiplied by the delta time since last call. This delta time is acquired by calling the '' | + | For the integration over time algorithm we use a simple sum multiplied by the delta time since last call. This delta time is acquired by calling the '' |
In the following excerpt from the '' | In the following excerpt from the '' | ||
Line 152: | Line 154: | ||
</ | </ | ||
The full source code for this class can be found in the file '' | The full source code for this class can be found in the file '' | ||
+ |
marvin/ecp1.txt · Last modified: 2009/01/29 11:03 by rieper