Commit 1dcc8961 authored by Thomas Pryor's avatar Thomas Pryor
Browse files
parents 36abcb10 0122cb27
// Place your settings in this file to overwrite default and user settings.
{
}
\ No newline at end of file
SoftwareSerial mySerial(3, 2); // 3 to tx, 2 to rx
Adafruit_GPS GPS(&mySerial);
#define GPSECHO true
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
#ifdef UDR0
if (GPSECHO)
if (c) UDR0 = c;
#endif
}
void useInterrupt(boolean v) {
if (v) {
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
usingInterrupt = true;
} else {
TIMSK0 &= ~_BV(OCIE0A);
usingInterrupt = false;
}
}
uint32_t timer = millis();
void initializeGPS()
{
GPS.begin(9600);
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
// uncomment this line to turn on only the "minimum recommended" data
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
// the parser doesn't care about other sentences at this time
// Set the update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
// For the parsing code to work nicely and have time to sort thru the data, and
// print it out we don't suggest using anything higher than 1 Hz
// Request updates on antenna status, comment out to keep quiet
GPS.sendCommand(PGCMD_ANTENNA);
// the nice thing about this code is you can have a timer0 interrupt go off
// every 1 millisecond, and read data from the GPS for you. that makes the
// loop code a heck of a lot easier!
useInterrupt(true);
delay(1000);
// Ask for firmware version
mySerial.println(PMTK_Q_RELEASE);
GPS.begin(9600);
}
float longitude = 0.0;
int longitudeDegrees = 0;
float longitudeMinutes = 0.0;
float latitude = 0.0;
int latitudeDegrees = 0;
float latitudeMinutes = 0.0;
void updateGPS()
// sends gps data over UDP to the rover
void sendGpsData()
{
if (GPS.newNMEAreceived()) {
if (!GPS.parse(GPS.lastNMEA()))
true; // we can fail to parse a sentence in which case we should just wait for another
}
if (timer > millis()) timer = millis();
if (millis() - timer > 2000) {
timer = millis(); // reset the timer
if (GPS.fix) {
Serial.println("Fixed"); //If the GPS is fixed, it sees 3 satellites and can track position, allowing it to use the functions below.
}
else
{
Serial.println("Not fixed");
}
longitude = GPS.longitude;
longitudeDegrees = longitude/100;
longitudeMinutes = (longitude/100 - longitudeDegrees)*100;
latitude = GPS.latitude;
latitudeDegrees = latitude/100;
latitudeMinutes = (latitude/100 - latitudeDegrees)*100;
}
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write("N" + GPS.latitude);
Udp.write("W" + GPS.longitude);
Udp.endPacket();
}
// HARDWARE: Arduino MEGA 2560
#include "Arduino.h"
#include "megaBoardDefine.h"
#include <Adafruit_GPA.h> // include this file in the Arduino libraries folder
#include <Servo.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <Servo.h>
#include <Wire.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
void setup()
{
Serial.println("STARTING");
attachDriveMotors();
attachArmMotors();
attachHandMotors();
......
// Apr 11, 2015. Husky Robotics, made by Electrical Team
// May 22, 2015. Husky Robotics, made by Electrical Team
#include "Arduino.h"
#include <Adafruit_GPA.h> // include this file in the Arduino libraries folder
#include <Servo.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <Wire.h>
// WIRELESS COMMUNICATION
// Port to listen for UDP connections on
const int UDP_PORT = 8888;
......@@ -21,15 +23,13 @@ int rightPower = 128;
int arm[3] = {1, 1, 1};
int hand[4] = {1, 1, 1, 1};
int misc[4] = {1, 1, 1, 1};
// Need Analog input with male pin
#define BAUD_RATE 9600
int potValue;
int sendValue;
// MOTOR CONSTANTS
// MOTOR CCONTROL
// Need PWM input with male pin for motor controller
// connect to RS232
Servo leftMotor;
......@@ -47,17 +47,21 @@ const int TALON_ARM[3] = {6, 7, 8}; // pins for motor control
#define SPEEDUP_FREQUENCY 1750 // For arm
#define SPEEDDOWN_FREWQUENCY 1250 // For arm
// SENSOR PINS
#define CURRENT_SENSOR_PIN A1 // connected to analog 1 for monitoring current on the big ass battery
#define COMPRESSOR_PIN A0 // connected to analog 0 for reading pressure
#define COMPRESSOR_CONTROL 23 // connected to digital 23 for increasing pressure on pneumatic suspension
// CONTROL AND LOGIC CONSTANTS
#define TIMEOUT 1000 // in milliseconds. This is to test to see if there is still wireless connection
#define MIN_FREQUENCY 1250
#define MAX_FREQUENCY 1750
// MIN AND MAX HAND SERVO VALUES
#define MIN_HAND 50
#define MAX_HAND 104
// GPS CONSTANTS AND VARIABLES
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment