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
Actuators/Hallsensor.h@3:92ba0254af87, 2013-03-07 (annotated)
- Committer:
- chrigelburri
- Date:
- Thu Mar 07 09:47:07 2013 +0000
- Revision:
- 3:92ba0254af87
- Child:
- 6:48eeb41188dd
bitte kommentare korriegieren;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrigelburri | 3:92ba0254af87 | 1 | #ifndef HALLSENSOR_H |
chrigelburri | 3:92ba0254af87 | 2 | #define HALLSENSOR_H |
chrigelburri | 3:92ba0254af87 | 3 | |
chrigelburri | 3:92ba0254af87 | 4 | #include "mbed.h" |
chrigelburri | 3:92ba0254af87 | 5 | |
chrigelburri | 3:92ba0254af87 | 6 | /** |
chrigelburri | 3:92ba0254af87 | 7 | * @author Christian Burri |
chrigelburri | 3:92ba0254af87 | 8 | * |
chrigelburri | 3:92ba0254af87 | 9 | * @section LICENSE |
chrigelburri | 3:92ba0254af87 | 10 | * |
chrigelburri | 3:92ba0254af87 | 11 | * Copyright © 2013 HSLU Pren Team #1 Cruising Crêpe |
chrigelburri | 3:92ba0254af87 | 12 | * All rights reserved. |
chrigelburri | 3:92ba0254af87 | 13 | * |
chrigelburri | 3:92ba0254af87 | 14 | * @section DESCRIPTION |
chrigelburri | 3:92ba0254af87 | 15 | * |
chrigelburri | 3:92ba0254af87 | 16 | * Interface to count the Hallsensor input from a EC-Motor. |
chrigelburri | 3:92ba0254af87 | 17 | * |
chrigelburri | 3:92ba0254af87 | 18 | */ |
chrigelburri | 3:92ba0254af87 | 19 | class Hallsensor |
chrigelburri | 3:92ba0254af87 | 20 | { |
chrigelburri | 3:92ba0254af87 | 21 | |
chrigelburri | 3:92ba0254af87 | 22 | public: |
chrigelburri | 3:92ba0254af87 | 23 | |
chrigelburri | 3:92ba0254af87 | 24 | /** |
chrigelburri | 3:92ba0254af87 | 25 | * Constructor of the class <code>Hallsensor</code>. |
chrigelburri | 3:92ba0254af87 | 26 | * |
chrigelburri | 3:92ba0254af87 | 27 | * Reads the current values on Hall1 , Hall2 and Hall3 to determine the |
chrigelburri | 3:92ba0254af87 | 28 | * initial state. |
chrigelburri | 3:92ba0254af87 | 29 | * Attaches the encode function to the rise/fall interrupt edges of |
chrigelburri | 3:92ba0254af87 | 30 | * Hall1, Hall2 and Hall3. |
chrigelburri | 3:92ba0254af87 | 31 | * @param hall1 mbed pin for Hall1 input. |
chrigelburri | 3:92ba0254af87 | 32 | * @param hall2 mbed pin for Hall2 input. |
chrigelburri | 3:92ba0254af87 | 33 | * @param hall3 mbed pin for Hall3 input. |
chrigelburri | 3:92ba0254af87 | 34 | */ |
chrigelburri | 3:92ba0254af87 | 35 | Hallsensor(PinName hall1, PinName hall2, PinName hall3); |
chrigelburri | 3:92ba0254af87 | 36 | |
chrigelburri | 3:92ba0254af87 | 37 | /** |
chrigelburri | 3:92ba0254af87 | 38 | * Reset the encoder. |
chrigelburri | 3:92ba0254af87 | 39 | * Sets the pulses and revolutions count to zero. |
chrigelburri | 3:92ba0254af87 | 40 | */ |
chrigelburri | 3:92ba0254af87 | 41 | void reset(void); |
chrigelburri | 3:92ba0254af87 | 42 | |
chrigelburri | 3:92ba0254af87 | 43 | /** |
chrigelburri | 3:92ba0254af87 | 44 | * Read the number of pulses recorded by the encoder. |
chrigelburri | 3:92ba0254af87 | 45 | * @return Number of pulses which have occured, given in [count] |
chrigelburri | 3:92ba0254af87 | 46 | */ |
chrigelburri | 3:92ba0254af87 | 47 | int getPulses(void); |
chrigelburri | 3:92ba0254af87 | 48 | |
chrigelburri | 3:92ba0254af87 | 49 | /** |
chrigelburri | 3:92ba0254af87 | 50 | * Read the number of revolutions recorded by the encoder. |
chrigelburri | 3:92ba0254af87 | 51 | * @return Number of revolutions which have occured on the index channel. |
chrigelburri | 3:92ba0254af87 | 52 | */ |
chrigelburri | 3:92ba0254af87 | 53 | int getRevolutions(void); |
chrigelburri | 3:92ba0254af87 | 54 | |
chrigelburri | 3:92ba0254af87 | 55 | private: |
chrigelburri | 3:92ba0254af87 | 56 | |
chrigelburri | 3:92ba0254af87 | 57 | /** |
chrigelburri | 3:92ba0254af87 | 58 | * Update the pulse count. |
chrigelburri | 3:92ba0254af87 | 59 | * Called on every rising/falling edge of Hall 1-3. |
chrigelburri | 3:92ba0254af87 | 60 | * Reads the state of the channels and determines whether a pulse forward |
chrigelburri | 3:92ba0254af87 | 61 | * or backward has occured, updating the count appropriately. |
chrigelburri | 3:92ba0254af87 | 62 | */ |
chrigelburri | 3:92ba0254af87 | 63 | void encode(void); |
chrigelburri | 3:92ba0254af87 | 64 | |
chrigelburri | 3:92ba0254af87 | 65 | InterruptIn hall1_; |
chrigelburri | 3:92ba0254af87 | 66 | InterruptIn hall2_; |
chrigelburri | 3:92ba0254af87 | 67 | InterruptIn hall3_; |
chrigelburri | 3:92ba0254af87 | 68 | |
chrigelburri | 3:92ba0254af87 | 69 | int prevState_; |
chrigelburri | 3:92ba0254af87 | 70 | int currState_; |
chrigelburri | 3:92ba0254af87 | 71 | |
chrigelburri | 3:92ba0254af87 | 72 | volatile int pulses_; |
chrigelburri | 3:92ba0254af87 | 73 | |
chrigelburri | 3:92ba0254af87 | 74 | }; |
chrigelburri | 3:92ba0254af87 | 75 | |
chrigelburri | 3:92ba0254af87 | 76 | #endif /* Hallsensor_H */ |