Revision 766
added I term to current control, had weird issues with battery #4 where the current reading dops down to 26 for some reason. After this happens, unloaded voltage on bat (through multimeter) reads >6, even though it seemed discharged before. I am doubting it was fully discharged, maybe the 5 minutes actually forced too much current in?
analog.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project |
|
2 | 3 |
* |
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
3 | 28 |
* @file analog.h |
4 | 29 |
* @brief Contains functions and definitions for using the ADC |
5 | 30 |
* |
... | ... | |
17 | 42 |
#ifndef _ANALOG_H |
18 | 43 |
#define _ANALOG_H |
19 | 44 |
|
45 |
#include <inttypes.h> |
|
46 |
|
|
20 | 47 |
/** |
21 | 48 |
* @addtogroup analog |
22 | 49 |
* @{ |
... | ... | |
43 | 70 |
/** @brief Analog port 9 **/ |
44 | 71 |
#define AN9 0x09 |
45 | 72 |
/** @brief Analog port 10 **/ |
46 |
#define AN10 0x0a
|
|
73 |
#define AN10 0x0A
|
|
47 | 74 |
/** @brief Analog port 11 **/ |
48 |
#define AN11 0x0b
|
|
75 |
#define AN11 0x0B
|
|
49 | 76 |
/** @brief Analog port 12 **/ |
50 |
#define AN12 0x0c
|
|
77 |
#define AN12 0x0C
|
|
51 | 78 |
/** @brief Analog port 13 **/ |
52 |
#define AN13 0x0d
|
|
79 |
#define AN13 0x0D
|
|
53 | 80 |
/** @brief Analog port 14 **/ |
54 |
#define AN14 0x0e
|
|
81 |
#define AN14 0x0E
|
|
55 | 82 |
/** @brief Analog port 15 **/ |
56 |
#define AN15 0x0f
|
|
83 |
#define AN15 0x0F
|
|
57 | 84 |
|
85 |
/** @brief BOM_PORT analog port for BOM **/ |
|
86 |
#define BOM_PORT AN0 |
|
58 | 87 |
/** @brief EXT_MUX analog port **/ |
59 | 88 |
#define EXT_MUX AN7 |
60 | 89 |
/** @brief Analog port for the wheel **/ |
... | ... | |
62 | 91 |
/** @brief Analog port for the battery voltage detector **/ |
63 | 92 |
#define BATT_PORT AN11 |
64 | 93 |
|
65 |
/** @brief Initialize analog ports. **/ |
|
66 |
void analog_init(void); |
|
67 |
/** @brief Read an 8-bit number from an analog port. **/ |
|
94 |
#define ADC_START 1 |
|
95 |
#define ADC_STOP 0 |
|
96 |
|
|
97 |
#define ADMUX_OPT 0x60 |
|
98 |
|
|
99 |
|
|
100 |
/** @brief Initialize analog ports. Will start running a loop |
|
101 |
if start_conversion is ADC_START.**/ |
|
102 |
void analog_init(int start_conversion); |
|
103 |
/** @brief starts the analog loop. Doesn't do anything if the loop is already running. **/ |
|
104 |
void analog_start_loop(void); |
|
105 |
/** @brief Stops the analog loop. Doesn't do anything if the loop is already stopped. **/ |
|
106 |
void analog_stop_loop(void); |
|
107 |
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/ |
|
68 | 108 |
unsigned int analog8(int which); |
69 |
/** @brief Read a 10-bit number from an analog port. **/ |
|
109 |
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/
|
|
70 | 110 |
unsigned int analog10(int which); |
71 | 111 |
/** @brief Read the position of the wheel. **/ |
72 | 112 |
int wheel(void); |
113 |
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog8. **/ |
|
114 |
unsigned int analog_get8(int which); |
|
115 |
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog10. **/ |
|
116 |
unsigned int analog_get10(int which); |
|
73 | 117 |
|
118 |
|
|
74 | 119 |
/**@}**/ //end group |
75 | 120 |
|
76 | 121 |
#endif |
122 |
|
Also available in: Unified diff