Practical Robotics Modular Robot Library

Dependents:   ModularRobot

Committer:
jah128
Date:
Sat Nov 26 17:28:53 2016 +0000
Revision:
0:8a2dd255c508
Child:
1:a6728adaf7e7
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:8a2dd255c508 1
jah128 0:8a2dd255c508 2
jah128 0:8a2dd255c508 3 #ifndef ROBOT_H
jah128 0:8a2dd255c508 4 #define ROBOT_H
jah128 0:8a2dd255c508 5
jah128 0:8a2dd255c508 6 #include "mbed.h"
jah128 0:8a2dd255c508 7 #include "led.h"
jah128 0:8a2dd255c508 8 #include "sensors.h"
jah128 0:8a2dd255c508 9 #include "motors.h"
jah128 0:8a2dd255c508 10 #include "calibration.h"
jah128 0:8a2dd255c508 11
jah128 0:8a2dd255c508 12 #define LED_ADDRESS 0xC0
jah128 0:8a2dd255c508 13 #define ADC_ADDRESS 0x90
jah128 0:8a2dd255c508 14
jah128 0:8a2dd255c508 15 // To update sensors 10 times a second (8 x 0.0125 = 0.1)
jah128 0:8a2dd255c508 16 #define SENSOR_TICKER_PERIOD 0.0125
jah128 0:8a2dd255c508 17
jah128 0:8a2dd255c508 18 // H-Bridge should work at upto 100kHz (10uS) but note it seems to behave unusually at frequencies close to but above this
jah128 0:8a2dd255c508 19 // Slower speeds work a bit faster but noisier
jah128 0:8a2dd255c508 20 #define MOTOR_PWM_PERIOD_US 400
jah128 0:8a2dd255c508 21
jah128 0:8a2dd255c508 22 #define USE_STALL_OFFSET 1
jah128 0:8a2dd255c508 23 #define STALL_OFFSET 0.22
jah128 0:8a2dd255c508 24
jah128 0:8a2dd255c508 25 extern I2C primary_i2c;
jah128 0:8a2dd255c508 26 extern AnalogIn vin_battery;
jah128 0:8a2dd255c508 27 extern Serial pc;
jah128 0:8a2dd255c508 28 extern Led led;
jah128 0:8a2dd255c508 29 extern Sensors sensors;
jah128 0:8a2dd255c508 30 extern Motors motors;
jah128 0:8a2dd255c508 31 extern volatile char i2c_lock;
jah128 0:8a2dd255c508 32
jah128 0:8a2dd255c508 33 class Robot
jah128 0:8a2dd255c508 34 {
jah128 0:8a2dd255c508 35 public:
jah128 0:8a2dd255c508 36
jah128 0:8a2dd255c508 37 /**
jah128 0:8a2dd255c508 38 * Main initialisation routine: setup the robot, the I2C interfaces, start system timers etc.
jah128 0:8a2dd255c508 39 *
jah128 0:8a2dd255c508 40 */
jah128 0:8a2dd255c508 41 void init(void);
jah128 0:8a2dd255c508 42
jah128 0:8a2dd255c508 43 /**
jah128 0:8a2dd255c508 44 * Get the uptime for the MBED
jah128 0:8a2dd255c508 45 *
jah128 0:8a2dd255c508 46 * @return The amount of time in seconds that the MBED has been active since last reset
jah128 0:8a2dd255c508 47 */
jah128 0:8a2dd255c508 48 float get_uptime(void);
jah128 0:8a2dd255c508 49
jah128 0:8a2dd255c508 50 /**
jah128 0:8a2dd255c508 51 * Get the battery voltage
jah128 0:8a2dd255c508 52 *
jah128 0:8a2dd255c508 53 * The battery voltage is passed through a 7.5V Zener diode, then into a 1:1 potential divider. This
jah128 0:8a2dd255c508 54 * allows a voltage in the approximate range 7.5 to 13.8V to be measured.
jah128 0:8a2dd255c508 55 *
jah128 0:8a2dd255c508 56 * @return The current voltage reading for the battery
jah128 0:8a2dd255c508 57 */
jah128 0:8a2dd255c508 58 float get_battery_voltage(void);
jah128 0:8a2dd255c508 59
jah128 0:8a2dd255c508 60 private:
jah128 0:8a2dd255c508 61 void _update_minutes(void);
jah128 0:8a2dd255c508 62 };
jah128 0:8a2dd255c508 63
jah128 0:8a2dd255c508 64
jah128 0:8a2dd255c508 65 #endif