marvin:ecp1
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
marvin:ecp1 [2009/01/28 15:10] – deva | marvin:ecp1 [2009/01/29 11:03] (current) – rieper | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
<texit info> | <texit info> | ||
author=Johnny Rieper, Bent Bisballe Nyeng and Kasper Sohn | author=Johnny Rieper, Bent Bisballe Nyeng and Kasper Sohn | ||
Line 11: | Line 10: | ||
=====Goal===== | =====Goal===== | ||
- | Make robot able to communicate with gyroscope. | + | Make Marvin |
=====Plan===== | =====Plan===== | ||
Line 18: | Line 17: | ||
* Find or create a class for the gyroscope communication. | * Find or create a class for the gyroscope communication. | ||
- | =====Analysis===== | + | =====Theory===== |
- | ====Analogue to digital conversion | + | |
- | The main problem when dealing with sensors is that the real world is continuous | + | |
+ | ====Analogue to Digital Conversion | ||
+ | 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 in relative values, which means that it can not tell where e.g. upright is. One have to " |
- | 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 axis of measurement is in the vertical plane with the gyroscope sensor positioned with the black end cap facing upwards, as illustrated in thye figure |
- | [{{ : | + | |
- | The right placement | + | {{ : |
- | =====Building | + | The correct placement of the gyroscope can be seen in the [[#Building the robot|building instructions]] |
- | ====Preliminary considerations==== | + | |
- | Our primary goal is to make a balancing robot, and therefore it would be nice to eliminate the possible of failure due to a bad build. This is the reason why we chose to re-use the instructions provided as seen in the building manual(([[http:// | + | |
- | ====The Build==== | + | ====Building the Robot==== |
+ | ===Preliminary considerations=== | ||
+ | Our primary goal is to make a balancing robot, and therefore it would be nice to eliminate the possibility of failure due to a bad build. This is the reason why we chose to re-use the instructions provided as seen in the building manual(([[http:// | ||
+ | |||
+ | ===The Build=== | ||
The build is pretty straight forward, as the building instructions is well written and also accompanied by photos. One thing to note though, is that the robot is fairly symmetric, so building instructions is only provided for one side of the robot and it is up to the builder to mirror the other side. This is however no problem because of the good photos.\\ | The build is pretty straight forward, as the building instructions is well written and also accompanied by photos. One thing to note though, is that the robot is fairly symmetric, so building instructions is only provided for one side of the robot and it is up to the builder to mirror the other side. This is however no problem because of the good photos.\\ | ||
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 64: | 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==== | |
- | + | 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 | |
- | ====Pros and Cons About This Design==== | + | In the group we discussed what effect the wheel diameter will have on the robot. Wheels with a larger diameter will travel |
- | 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 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 | ||
Line 81: | 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: < |
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 107: | 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 117: | 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 159: | 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