This program is for an autonomous robot for the competition at the Hochschule Luzern. http://cruisingcrepe.wordpress.com/ We are one of the 32 teams. http://cruisingcrepe.wordpress.com/ The postition control is based on this Documentation: Control of Wheeled Mobile Robots: An Experimental Overview from Alessandro De Luca, Giuseppe Oriolo, Marilena Vendittelli. For more information see here: http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf
Fork of autonomous Robot Android by
ActuatorsSensor/MaxonESCON.h@39:a4fd6206da89, 2013-06-10 (annotated)
- Committer:
- chrigelburri
- Date:
- Mon Jun 10 14:40:37 2013 +0000
- Revision:
- 39:a4fd6206da89
- Parent:
- 38:d76e488e725f
V1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrigelburri | 0:31f7be68e52d | 1 | #ifndef _MAXON_ESCON_H_ |
chrigelburri | 0:31f7be68e52d | 2 | #define _MAXON_ESCON_H_ |
chrigelburri | 0:31f7be68e52d | 3 | |
chrigelburri | 0:31f7be68e52d | 4 | #include "Hallsensor.h" |
chrigelburri | 0:31f7be68e52d | 5 | #include "defines.h" |
chrigelburri | 0:31f7be68e52d | 6 | |
chrigelburri | 0:31f7be68e52d | 7 | /** |
chrigelburri | 0:31f7be68e52d | 8 | * @author Christian Burri |
chrigelburri | 0:31f7be68e52d | 9 | * |
chrigelburri | 38:d76e488e725f | 10 | * @copyright Copyright (c) 2013 HSLU Pren Team #1 Cruising Crêpe |
chrigelburri | 0:31f7be68e52d | 11 | * All rights reserved. |
chrigelburri | 0:31f7be68e52d | 12 | * |
chrigelburri | 11:775ebb69d5e1 | 13 | * @brief |
chrigelburri | 0:31f7be68e52d | 14 | * |
chrigelburri | 3:92ba0254af87 | 15 | * This class implements the driver for the Maxon ESCON servo driver. |
chrigelburri | 11:775ebb69d5e1 | 16 | * For more information see the Datasheet: |
chrigelburri | 3:92ba0254af87 | 17 | * <a href="http://escon.maxonmotor.com">http://escon.maxonmotor.com</a> |
chrigelburri | 38:d76e488e725f | 18 | * |
chrigelburri | 38:d76e488e725f | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
chrigelburri | 38:d76e488e725f | 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
chrigelburri | 38:d76e488e725f | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
chrigelburri | 38:d76e488e725f | 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
chrigelburri | 38:d76e488e725f | 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
chrigelburri | 38:d76e488e725f | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
chrigelburri | 38:d76e488e725f | 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
chrigelburri | 0:31f7be68e52d | 26 | */ |
chrigelburri | 0:31f7be68e52d | 27 | class MaxonESCON |
chrigelburri | 0:31f7be68e52d | 28 | { |
chrigelburri | 0:31f7be68e52d | 29 | |
chrigelburri | 2:d8e1613dc38b | 30 | private: |
chrigelburri | 0:31f7be68e52d | 31 | |
chrigelburri | 11:775ebb69d5e1 | 32 | /** @brief To Enable the amplifier */ |
chrigelburri | 2:d8e1613dc38b | 33 | DigitalOut _enb; |
chrigelburri | 11:775ebb69d5e1 | 34 | /** @brief Duty Cycle to set the speed */ |
chrigelburri | 0:31f7be68e52d | 35 | PwmOut _pwm; |
chrigelburri | 11:775ebb69d5e1 | 36 | /** @brief Hallsensor Class */ |
chrigelburri | 0:31f7be68e52d | 37 | Hallsensor* _hall; |
chrigelburri | 11:775ebb69d5e1 | 38 | /** @brief Ready output from ESCON */ |
chrigelburri | 0:31f7be68e52d | 39 | DigitalIn _isenb; |
chrigelburri | 11:775ebb69d5e1 | 40 | /** @brief Actual speed from ESCON analog Output 1 */ |
chrigelburri | 0:31f7be68e52d | 41 | AnalogIn _actualSpeed; |
chrigelburri | 11:775ebb69d5e1 | 42 | /** @brief increment the Hallpattern */ |
chrigelburri | 0:31f7be68e52d | 43 | int _pulses; |
chrigelburri | 0:31f7be68e52d | 44 | |
chrigelburri | 0:31f7be68e52d | 45 | public: |
chrigelburri | 0:31f7be68e52d | 46 | |
chrigelburri | 11:775ebb69d5e1 | 47 | /** |
chrigelburri | 11:775ebb69d5e1 | 48 | * @brief Create a motor control object. |
chrigelburri | 6:48eeb41188dd | 49 | * @param enb DigitalOut, set high for enable |
chrigelburri | 6:48eeb41188dd | 50 | * @param isenb DigitalIn, high for enable |
chrigelburri | 6:48eeb41188dd | 51 | * @param pwm PwmOut pin, set the velocity |
chrigelburri | 6:48eeb41188dd | 52 | * @param actualSpeed AnalogIn filtered signal for ActualSpeed from Motor |
chrigelburri | 6:48eeb41188dd | 53 | * @param hall The object of the hallsensor from Motor |
chrigelburri | 6:48eeb41188dd | 54 | */ |
chrigelburri | 0:31f7be68e52d | 55 | MaxonESCON(PinName enb, |
chrigelburri | 0:31f7be68e52d | 56 | PinName isenb, |
chrigelburri | 0:31f7be68e52d | 57 | PinName pwm, |
chrigelburri | 0:31f7be68e52d | 58 | PinName actualSpeed, |
chrigelburri | 0:31f7be68e52d | 59 | Hallsensor *hall); |
chrigelburri | 0:31f7be68e52d | 60 | |
chrigelburri | 11:775ebb69d5e1 | 61 | /** |
chrigelburri | 11:775ebb69d5e1 | 62 | * @brief Set the speed of the motor with a pwm for 10%..90%. |
chrigelburri | 6:48eeb41188dd | 63 | * 50% PWM is 0rpm. |
chrigelburri | 15:cb1337567ad4 | 64 | * Caclulate from [1/s] in [1/min] and the factor of the ESCON. |
chrigelburri | 6:48eeb41188dd | 65 | * @param speed The speed of the motor as a normalised value, given in [1/s] |
chrigelburri | 6:48eeb41188dd | 66 | */ |
chrigelburri | 0:31f7be68e52d | 67 | void setVelocity(float speed); |
chrigelburri | 0:31f7be68e52d | 68 | |
chrigelburri | 11:775ebb69d5e1 | 69 | /** |
chrigelburri | 11:775ebb69d5e1 | 70 | * @brief Return the speed from ESCON. |
chrigelburri | 15:cb1337567ad4 | 71 | * 0 rpm is defined in the analog input as 1.65V |
chrigelburri | 6:48eeb41188dd | 72 | * @return speed of the motor, given in [1/s] |
chrigelburri | 6:48eeb41188dd | 73 | */ |
chrigelburri | 0:31f7be68e52d | 74 | float getActualSpeed(void); |
chrigelburri | 0:31f7be68e52d | 75 | |
chrigelburri | 11:775ebb69d5e1 | 76 | /** |
chrigelburri | 11:775ebb69d5e1 | 77 | * @brief Set the period of the pwm duty cycle. |
chrigelburri | 6:48eeb41188dd | 78 | * Wrapper for PwmOut::period() |
chrigelburri | 6:48eeb41188dd | 79 | * @param period Pwm duty cycle, given in [s]. |
chrigelburri | 6:48eeb41188dd | 80 | */ |
chrigelburri | 0:31f7be68e52d | 81 | void period(float period); |
chrigelburri | 0:31f7be68e52d | 82 | |
chrigelburri | 11:775ebb69d5e1 | 83 | /** |
chrigelburri | 15:cb1337567ad4 | 84 | * @brief Set the motor to a enable sate. |
chrigelburri | 6:48eeb41188dd | 85 | * @param enb <code>false</code> for disable <code>true</code> for enable. |
chrigelburri | 6:48eeb41188dd | 86 | */ |
chrigelburri | 3:92ba0254af87 | 87 | void enable(bool enb); |
chrigelburri | 0:31f7be68e52d | 88 | |
chrigelburri | 11:775ebb69d5e1 | 89 | /** |
chrigelburri | 11:775ebb69d5e1 | 90 | * @brief Tests if the servo drive is enabled. |
chrigelburri | 11:775ebb69d5e1 | 91 | * @return <code>true</code> if the drive is enabled, |
chrigelburri | 6:48eeb41188dd | 92 | * <code>false</code> otherwise. |
chrigelburri | 6:48eeb41188dd | 93 | */ |
chrigelburri | 0:31f7be68e52d | 94 | bool isEnabled(void); |
chrigelburri | 0:31f7be68e52d | 95 | |
chrigelburri | 11:775ebb69d5e1 | 96 | /** |
chrigelburri | 15:cb1337567ad4 | 97 | * @brief Return the number of pulses. |
chrigelburri | 6:48eeb41188dd | 98 | * @return Pulses, given in [count] |
chrigelburri | 6:48eeb41188dd | 99 | */ |
chrigelburri | 0:31f7be68e52d | 100 | int getPulses(void); |
chrigelburri | 0:31f7be68e52d | 101 | |
chrigelburri | 11:775ebb69d5e1 | 102 | /** |
chrigelburri | 15:cb1337567ad4 | 103 | * @brief Set the pulses of the motor, given in [count] |
chrigelburri | 6:48eeb41188dd | 104 | * @return Pulses, given in [count] |
chrigelburri | 6:48eeb41188dd | 105 | */ |
chrigelburri | 0:31f7be68e52d | 106 | int setPulses(int setPos); |
chrigelburri | 0:31f7be68e52d | 107 | }; |
chrigelburri | 0:31f7be68e52d | 108 | |
chrigelburri | 0:31f7be68e52d | 109 | #endif |