mbed robotracer for education.

Robotracer (line follower robot ) using stepper motor.

/media/uploads/hayama/cimg8463.jpg

/media/uploads/hayama/mbedrobotracer-manual-english.pdf

/media/uploads/hayama/mbedrobotracer-manual-japanese.pdf

/media/uploads/hayama/eagle-design-robotracer.zip

movie -> https://www.youtube.com/watch?v=INwun8gSds4

(for competition->) https://www.youtube.com/watch?v=l_gP2pUt4w0

Committer:
hayama
Date:
Wed Oct 02 01:09:55 2013 +0000
Revision:
1:200aad416161
Parent:
0:da22b0b4395a
mbed robotracer for education.
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hayama 0:da22b0b4395a 1 /* mbed Microcontroller Library
hayama 0:da22b0b4395a 2 * Copyright (c) 2006-2013 ARM Limited
hayama 0:da22b0b4395a 3 *
hayama 0:da22b0b4395a 4 * Licensed under the Apache License, Version 2.0 (the "License");
hayama 0:da22b0b4395a 5 * you may not use this file except in compliance with the License.
hayama 0:da22b0b4395a 6 * You may obtain a copy of the License at
hayama 0:da22b0b4395a 7 *
hayama 0:da22b0b4395a 8 * http://www.apache.org/licenses/LICENSE-2.0
hayama 0:da22b0b4395a 9 *
hayama 0:da22b0b4395a 10 * Unless required by applicable law or agreed to in writing, software
hayama 0:da22b0b4395a 11 * distributed under the License is distributed on an "AS IS" BASIS,
hayama 0:da22b0b4395a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
hayama 0:da22b0b4395a 13 * See the License for the specific language governing permissions and
hayama 0:da22b0b4395a 14 * limitations under the License.
hayama 0:da22b0b4395a 15 */
hayama 0:da22b0b4395a 16 #ifndef MBED_ANALOGOUT_H
hayama 0:da22b0b4395a 17 #define MBED_ANALOGOUT_H
hayama 0:da22b0b4395a 18
hayama 0:da22b0b4395a 19 #include "platform.h"
hayama 0:da22b0b4395a 20
hayama 0:da22b0b4395a 21 #if DEVICE_ANALOGOUT
hayama 0:da22b0b4395a 22
hayama 0:da22b0b4395a 23 #include "analogout_api.h"
hayama 0:da22b0b4395a 24
hayama 0:da22b0b4395a 25 namespace mbed {
hayama 0:da22b0b4395a 26
hayama 0:da22b0b4395a 27 /** An analog output, used for setting the voltage on a pin
hayama 0:da22b0b4395a 28 *
hayama 0:da22b0b4395a 29 * Example:
hayama 0:da22b0b4395a 30 * @code
hayama 0:da22b0b4395a 31 * // Make a sawtooth output
hayama 0:da22b0b4395a 32 *
hayama 0:da22b0b4395a 33 * #include "mbed.h"
hayama 0:da22b0b4395a 34 *
hayama 0:da22b0b4395a 35 * AnalogOut tri(p18);
hayama 0:da22b0b4395a 36 * int main() {
hayama 0:da22b0b4395a 37 * while(1) {
hayama 0:da22b0b4395a 38 * tri = tri + 0.01;
hayama 0:da22b0b4395a 39 * wait_us(1);
hayama 0:da22b0b4395a 40 * if(tri == 1) {
hayama 0:da22b0b4395a 41 * tri = 0;
hayama 0:da22b0b4395a 42 * }
hayama 0:da22b0b4395a 43 * }
hayama 0:da22b0b4395a 44 * }
hayama 0:da22b0b4395a 45 * @endcode
hayama 0:da22b0b4395a 46 */
hayama 0:da22b0b4395a 47 class AnalogOut {
hayama 0:da22b0b4395a 48
hayama 0:da22b0b4395a 49 public:
hayama 0:da22b0b4395a 50
hayama 0:da22b0b4395a 51 /** Create an AnalogOut connected to the specified pin
hayama 0:da22b0b4395a 52 *
hayama 0:da22b0b4395a 53 * @param AnalogOut pin to connect to (18)
hayama 0:da22b0b4395a 54 */
hayama 0:da22b0b4395a 55 AnalogOut(PinName pin) {
hayama 0:da22b0b4395a 56 analogout_init(&_dac, pin);
hayama 0:da22b0b4395a 57 }
hayama 0:da22b0b4395a 58
hayama 0:da22b0b4395a 59 /** Set the output voltage, specified as a percentage (float)
hayama 0:da22b0b4395a 60 *
hayama 0:da22b0b4395a 61 * @param value A floating-point value representing the output voltage,
hayama 0:da22b0b4395a 62 * specified as a percentage. The value should lie between
hayama 0:da22b0b4395a 63 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
hayama 0:da22b0b4395a 64 * Values outside this range will be saturated to 0.0f or 1.0f.
hayama 0:da22b0b4395a 65 */
hayama 0:da22b0b4395a 66 void write(float value) {
hayama 0:da22b0b4395a 67 analogout_write(&_dac, value);
hayama 0:da22b0b4395a 68 }
hayama 0:da22b0b4395a 69
hayama 0:da22b0b4395a 70 /** Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
hayama 0:da22b0b4395a 71 *
hayama 0:da22b0b4395a 72 * @param value 16-bit unsigned short representing the output voltage,
hayama 0:da22b0b4395a 73 * normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
hayama 0:da22b0b4395a 74 */
hayama 0:da22b0b4395a 75 void write_u16(unsigned short value) {
hayama 0:da22b0b4395a 76 analogout_write_u16(&_dac, value);
hayama 0:da22b0b4395a 77 }
hayama 0:da22b0b4395a 78
hayama 0:da22b0b4395a 79 /** Return the current output voltage setting, measured as a percentage (float)
hayama 0:da22b0b4395a 80 *
hayama 0:da22b0b4395a 81 * @returns
hayama 0:da22b0b4395a 82 * A floating-point value representing the current voltage being output on the pin,
hayama 0:da22b0b4395a 83 * measured as a percentage. The returned value will lie between
hayama 0:da22b0b4395a 84 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
hayama 0:da22b0b4395a 85 *
hayama 0:da22b0b4395a 86 * @note
hayama 0:da22b0b4395a 87 * This value may not match exactly the value set by a previous write().
hayama 0:da22b0b4395a 88 */
hayama 0:da22b0b4395a 89 float read() {
hayama 0:da22b0b4395a 90 return analogout_read(&_dac);
hayama 0:da22b0b4395a 91 }
hayama 0:da22b0b4395a 92
hayama 0:da22b0b4395a 93 #ifdef MBED_OPERATORS
hayama 0:da22b0b4395a 94 /** An operator shorthand for write()
hayama 0:da22b0b4395a 95 */
hayama 0:da22b0b4395a 96 AnalogOut& operator= (float percent) {
hayama 0:da22b0b4395a 97 write(percent);
hayama 0:da22b0b4395a 98 return *this;
hayama 0:da22b0b4395a 99 }
hayama 0:da22b0b4395a 100
hayama 0:da22b0b4395a 101 AnalogOut& operator= (AnalogOut& rhs) {
hayama 0:da22b0b4395a 102 write(rhs.read());
hayama 0:da22b0b4395a 103 return *this;
hayama 0:da22b0b4395a 104 }
hayama 0:da22b0b4395a 105
hayama 0:da22b0b4395a 106 /** An operator shorthand for read()
hayama 0:da22b0b4395a 107 */
hayama 0:da22b0b4395a 108 operator float() {
hayama 0:da22b0b4395a 109 return read();
hayama 0:da22b0b4395a 110 }
hayama 0:da22b0b4395a 111 #endif
hayama 0:da22b0b4395a 112
hayama 0:da22b0b4395a 113 protected:
hayama 0:da22b0b4395a 114 dac_t _dac;
hayama 0:da22b0b4395a 115 };
hayama 0:da22b0b4395a 116
hayama 0:da22b0b4395a 117 } // namespace mbed
hayama 0:da22b0b4395a 118
hayama 0:da22b0b4395a 119 #endif
hayama 0:da22b0b4395a 120
hayama 0:da22b0b4395a 121 #endif