Commit addbe7b2 authored by Thomas Pryor's avatar Thomas Pryor
Browse files

Update

parent 995ecd3d
// Mar 7, 2015. Husky Robotics, made by Electrical Team
// Using the PMW to communicate to the MDC2230 motor controller
// Dual motor, only forwards and backwards
//#include <Arduino.h>
//#include "megaBoardDefine.h"
void writeToDriveMotors()
{
if(networkStatus == 1) {
// Refresh timeout
timeLastPacket = millis();
// Process new values;t
leftMotor.writeMicroseconds(map(leftPower, 0, 255, MIN_FREQUENCY, MAX_FREQUENCY));
rightMotor.writeMicroseconds(map(rightPower, 255, 0, MIN_FREQUENCY, MAX_FREQUENCY));
//Serial.println("WRITTEN");
}
}
void attachDriveMotors()
{
// Attach the driving motors
leftMotor.attach(MOTOR_PIN_L);
rightMotor.attach(MOTOR_PIN_R);
}
int dirToMicroseconds(int dir) {
if(dir == 0) {
return MIN_FREQUENCY;
}
if(dir == 2) {
return MAX_FREQUENCY;
}
return NEUTRAL_FREQUENCY;
}
void driveMotorFullSpeed() {
// For Joystick
// potValue = analogRead(potPin);
// For motor current testing
potValue = 1023;
// PWM have pulse seconds from 1000 microseconds to 2000
sendValue = map(potValue, 0, 1023, 1250, 1750);
if (sendValue < 1480 || sendValue > 1520)
{
leftMotor.writeMicroseconds(sendValue);
rightMotor.writeMicroseconds(sendValue);
} else {
leftMotor.writeMicroseconds(1500);
rightMotor.writeMicroseconds(1500);
}
// delay(10);
}
//#include <SPI.h> // needed for Arduino versions later than 0018
//#include <Ethernet.h>
//#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
//#include "megaBoardDefine.h"
// PWM output ports
/*
const int LEFT_MOTOR_PWM = 3;
const int RIGHT_MOTOR_PWM = 5;
*/
// Port to listen for UDP connections on
//const int UDP_PORT = 8888;
// ROBOTEQ constants
const int ROBOTEQ_MIN_FREQUENCY = 1250;
const int ROBOTEQ_MAX_FREQUENCY = 1750;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
//byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
//IPAddress ip(192, 168, 1, 177);
// buffers for receiving and sending data
//char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
//char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
//EthernetUDP Udp;
void udpToPwm()
{
int packetSize = Udp.parsePacket();
if (packetSize) { // if there's data available, read a packet
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i = 0; i < 4; i++) {
Serial.print(remote[i], DEC);
if (i < 3) {
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
int *buffer;
for (int i = 0; i < packetSize; i++) {
readByteAsInt(packetBuffer[i], buffer, 1);
}
Serial.println("Contents:");
Serial.println(packetBuffer);
Serial.println("Converted:");
for (int i = 0; i < packetSize; i++) {
Serial.println(buffer[i]);
}
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
delay(10);
}
/*
Editor: http://www.visualmicro.com
visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: Arduino Mega w/ ATmega2560 (Mega 2560), Platform=avr, Package=arduino
*/
#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __AVR_ATmega2560__
#define ARDUINO 164
#define ARDUINO_MAIN
#define __AVR__
#define __avr__
#define F_CPU 16000000L
#define __cplusplus
#define ARDUINO_ARCH_AVR
#define ARDUINO_AVR_MEGA2560
#define __inline__
#define __asm__(x)
#define __extension__
//#define __ATTR_PURE__
//#define __ATTR_CONST__
#define __inline__
//#define __asm__
#define __volatile__
#define GCC_VERSION 40801
#define volatile(va_arg)
typedef void *__builtin_va_list;
#define __builtin_va_start
#define __builtin_va_end
//#define __DOXYGEN__
#define __attribute__(x)
#define NOINLINE __attribute__((noinline))
#define prog_void
#define PGM_VOID_P int
#define NEW_H
/*
#ifndef __ATTR_CONST__
#define __ATTR_CONST__ __attribute__((__const__))
#endif
#ifndef __ATTR_MALLOC__
#define __ATTR_MALLOC__ __attribute__((__malloc__))
#endif
#ifndef __ATTR_NORETURN__
#define __ATTR_NORETURN__ __attribute__((__noreturn__))
#endif
#ifndef __ATTR_PURE__
#define __ATTR_PURE__ __attribute__((__pure__))
#endif
*/
typedef unsigned char byte;
extern "C" void __cxa_pure_virtual() {;}
#include <arduino.h>
#include <pins_arduino.h>
#undef F
#define F(string_literal) ((const PROGMEM char *)(string_literal))
#undef cli
#define cli()
#define pgm_read_byte(address_short)
#define pgm_read_word(address_short)
#define pgm_read_word2(address_short)
#define digitalPinToPort(P)
#define digitalPinToBitMask(P)
#define digitalPinToTimer(P)
#define analogInPinToBit(P)
#define portOutputRegister(P)
#define portInputRegister(P)
#define portModeRegister(P)
#include <roverCode.ino>
#include <CurrentSensor.ino>
#include <MotorControllerCommunication.ino>
#include <UDPtoDualPWM.ino>
#include <armControl.ino>
#include <compressor.ino>
#include <handControl.ino>
#include <megaBoardDefine.h>
#include <receiveOverEthernet.ino>
#endif
<VisualMicro>
<Program Name="roverCode" Ext=".ino" Location="C:\Users\OAPfive\Documents\Arduino\roverCode">
<Platform Name="arduino16x" Package="arduino" Platform="avr" Architecture="avr">
<Board Name="mega_atmega2560" Description="Arduino Mega w/ ATmega2560 (Mega 2560)" CoreFolder="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" VariantFullPath="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" McuIdePath="C:\Program Files (x86)\Arduino" McuSketchBookPath="C:\Users\OAPfive\Documents\Arduino" name="Arduino Mega w/ ATmega2560 (Mega 2560)" vid.0="0x2341" pid.0="0x0010" vid.1="0x2341" pid.1="0x0042" vid.2="0x2A03" pid.2="0x0010" vid.3="0x2A03" pid.3="0x0042" upload.tool="avrdude" upload.maximum_data_size="8192" bootloader.tool="avrdude" bootloader.low_fuses="0xFF" bootloader.unlock_bits="0x3F" bootloader.lock_bits="0x0F" build.f_cpu="16000000L" build.core="arduino" build.variant="mega" build.board="AVR_MEGA2560" menu.cpu.atmega2560="ATmega2560 (Mega 2560)" menu.cpu.atmega2560.upload.protocol="wiring" menu.cpu.atmega2560.upload.maximum_size="253952" menu.cpu.atmega2560.upload.speed="115200" menu.cpu.atmega2560.bootloader.high_fuses="0xD8" menu.cpu.atmega2560.bootloader.extended_fuses="0xFD" menu.cpu.atmega2560.bootloader.file="stk500v2/stk500boot_v2_mega2560.hex" menu.cpu.atmega2560.build.mcu="atmega2560" menu.cpu.atmega2560.build.board="AVR_MEGA2560" menu.cpu.atmega1280="ATmega1280" menu.cpu.atmega1280.upload.protocol="arduino" menu.cpu.atmega1280.upload.maximum_size="126976" menu.cpu.atmega1280.upload.speed="57600" menu.cpu.atmega1280.bootloader.high_fuses="0xDA" menu.cpu.atmega1280.bootloader.extended_fuses="0xF5" menu.cpu.atmega1280.bootloader.file="atmega/ATmegaBOOT_168_atmega1280.hex" menu.cpu.atmega1280.build.mcu="atmega1280" menu.cpu.atmega1280.build.board="AVR_MEGA" runtime.ide.path="C:\Program Files (x86)\Arduino" build.system.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr\system" runtime.ide.version="164" originalid="mega" tools.atprogram.cmd.path="%AVRSTUDIO_EXE_PATH%\atbackend\atprogram" tools.atprogram.cmd.setwinpath="true" tools.atprogram.program.params.verbose="-v" tools.atprogram.program.params.quiet="-q" tools.atprogram.program.pattern="&quot;{cmd.path}&quot; -d {build.mcu} {program.verbose} {program.extra_params} program -c -f &quot;{build.path}\{build.project_name}.hex&quot;" tools.atprogram.program.xpattern="&quot;{cmd.path}&quot; {AVRSTUDIO_BACKEND_CONNECTION} -d {build.mcu} {program.verbose} {program.extra_params} program -c -f &quot;{build.path}\{build.project_name}.hex&quot;" version="1.6.7" compiler.warning_flags="-w" compiler.warning_flags.none="-w" compiler.warning_flags.default="" compiler.warning_flags.more="-Wall" compiler.warning_flags.all="-Wall -Wextra" compiler.path="{runtime.tools.avr-gcc.path}/bin/" compiler.c.cmd="avr-gcc" compiler.c.flags="-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD" compiler.c.elf.flags="{compiler.warning_flags} -Os -Wl,--gc-sections" compiler.c.elf.cmd="avr-gcc" compiler.S.flags="-c -g -x assembler-with-cpp" compiler.cpp.cmd="avr-g++" compiler.cpp.flags="-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD" compiler.ar.cmd="avr-ar" compiler.ar.flags="rcs" compiler.objcopy.cmd="avr-objcopy" compiler.objcopy.eep.flags="-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0" compiler.elf2hex.flags="-O ihex -R .eeprom" compiler.elf2hex.cmd="avr-objcopy" compiler.ldflags="" compiler.size.cmd="avr-size" build.extra_flags="" compiler.c.extra_flags="" compiler.c.elf.extra_flags="" compiler.S.extra_flags="" compiler.cpp.extra_flags="" compiler.ar.extra_flags="" compiler.objcopy.eep.extra_flags="" compiler.elf2hex.extra_flags="" recipe.c.o.pattern="&quot;{compiler.path}{compiler.c.cmd}&quot; {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.cpp.o.pattern="&quot;{compiler.path}{compiler.cpp.cmd}&quot; {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.S.o.pattern="&quot;{compiler.path}{compiler.c.cmd}&quot; {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.ar.pattern="&quot;{compiler.path}{compiler.ar.cmd}&quot; {compiler.ar.flags} {compiler.ar.extra_flags} &quot;{build.path}/{archive_file}&quot; &quot;{object_file}&quot;" recipe.c.combine.pattern="&quot;{compiler.path}{compiler.c.elf.cmd}&quot; {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o &quot;{build.path}/{build.project_name}.elf&quot; {object_files} &quot;{build.path}/{archive_file}&quot; &quot;-L{build.path}&quot; -lm" recipe.objcopy.eep.pattern="&quot;{compiler.path}{compiler.objcopy.cmd}&quot; {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} &quot;{build.path}/{build.project_name}.elf&quot; &quot;{build.path}/{build.project_name}.eep&quot;" recipe.objcopy.hex.pattern="&quot;{compiler.path}{compiler.elf2hex.cmd}&quot; {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} &quot;{build.path}/{build.project_name}.elf&quot; &quot;{build.path}/{build.project_name}.hex&quot;" recipe.size.pattern="&quot;{compiler.path}{compiler.size.cmd}&quot; -A &quot;{build.path}/{build.project_name}.elf&quot;" recipe.size.regex="^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*" recipe.size.regex.data="^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*" recipe.size.regex.eeprom="^(?:\.eeprom)\s+([0-9]+).*" tools.avrdude.path="{runtime.tools.avrdude.path}" tools.avrdude.cmd.path="{path}/bin/avrdude" tools.avrdude.config.path="{path}/etc/avrdude.conf" tools.avrdude.upload.params.verbose="-v" tools.avrdude.upload.params.quiet="-q -q" tools.avrdude.upload.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;" tools.avrdude.program.params.verbose="-v" tools.avrdude.program.params.quiet="-q -q" tools.avrdude.program.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;" tools.avrdude.erase.params.verbose="-v" tools.avrdude.erase.params.quiet="-q -q" tools.avrdude.erase.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m" tools.avrdude.bootloader.params.verbose="-v" tools.avrdude.bootloader.params.quiet="-q -q" tools.avrdude.bootloader.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i&quot; -Ulock:w:{bootloader.lock_bits}:m" build.usb_manufacturer="&quot;Unknown&quot;" build.usb_flags="-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'" vm.platform.root.path="C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\arduino16x" upload.protocol="wiring" upload.maximum_size="253952" upload.speed="115200" bootloader.high_fuses="0xD8" bootloader.extended_fuses="0xFD" bootloader.file="stk500v2/stk500boot_v2_mega2560.hex" build.mcu="atmega2560" ide.hint="Arduino 1.6 Ide" ide.location.key="Arduino16x" ide.location.ide.winreg="Arduino 1.6.x Application" ide.location.sketchbook.winreg="Arduino 1.6.x Sketchbook" ide.location.sketchbook.preferences="sketchbook.path" ide.location.preferences="%VM_APPDATA_ROAMING%\arduino15\preferences.txt" ide.location.preferences_fallback="%VM_APPDATA_ROAMING%\arduino\preferences.txt" ide.default.version="160" ide.default.package="arduino" ide.default.platform="avr" ide.multiplatform="true" ide.includes="arduino.h" ide.platformswithoutpackage="false" ide.includes.fallback="wprogram.h" ide.extension="ino" ide.extension.fallback="pde" ide.versionGTEQ="160" ide.exe="arduino.exe" ide.hosts="atmel" ide.url="http://arduino.cc/en/Main/Software" vm.debug="true" software="ARDUINO" ssh.user.name="root" ssh.user.default.password="arduino" ssh.host.wwwfiles.path="/www/sd" build.working_directory="{runtime.ide.path}" ide.appid="arduino16x" location.sketchbook="C:\Users\OAPfive\Documents\Arduino" build.core.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" build.core.parentfolder.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores" build.core.coresparentfolder.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr" vm.core.include="arduino.h" vm.boardsource.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr" runtime.platform.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr" vm.platformname.name="avr" build.arch="AVR" build.variant.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" vm.runtime.compiler.showwarnings="true" serial.port.file="COM6" serial.port="COM6" includes=" -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries\Ethernet\src&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries\Servo\src&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries&quot; -I&quot;C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers&quot; -I&quot;C:\Users\OAPfive\Documents\Arduino\libraries&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\utility&quot;" build.path="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560" build.project_name="roverCode" build.variant.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" archive_file="core.a" object_file="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560\Wire\utility\twi.c.o" source_file="C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\utility\twi.c" />
</Platform>
<Compile IsDebugStart="1" IsCompiled="0" ConfigurationName="Debug" StopOnError="False" OptimiseLibs="True" OptimiseCore="True" BuildPath="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560" IncludeDebug="0" IncludesDebug="0" SketchName="roverCode" CompilerErrors="1" />
<Debug DebugEnabled="0" EnableBreak="1" />
<VCCodeModel>
<VCCodeMacros />
</VCCodeModel>
</Program>
</VisualMicro>
\ No newline at end of file
<VisualMicro>
<Program Name="roverCode" Ext=".ino" Location="C:\Users\OAPfive\Documents\Arduino\roverCode">
<Platform Name="arduino16x" Package="arduino" Platform="avr" Architecture="avr">
<Board Name="mega_atmega2560" Description="Arduino Mega w/ ATmega2560 (Mega 2560)" CoreFolder="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" VariantFullPath="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" McuIdePath="C:\Program Files (x86)\Arduino" McuSketchBookPath="C:\Users\OAPfive\Documents\Arduino" name="Arduino Mega w/ ATmega2560 (Mega 2560)" vid.0="0x2341" pid.0="0x0010" vid.1="0x2341" pid.1="0x0042" vid.2="0x2A03" pid.2="0x0010" vid.3="0x2A03" pid.3="0x0042" upload.tool="avrdude" upload.maximum_data_size="8192" bootloader.tool="avrdude" bootloader.low_fuses="0xFF" bootloader.unlock_bits="0x3F" bootloader.lock_bits="0x0F" build.f_cpu="16000000L" build.core="arduino" build.variant="mega" build.board="AVR_MEGA2560" menu.cpu.atmega2560="ATmega2560 (Mega 2560)" menu.cpu.atmega2560.upload.protocol="wiring" menu.cpu.atmega2560.upload.maximum_size="253952" menu.cpu.atmega2560.upload.speed="115200" menu.cpu.atmega2560.bootloader.high_fuses="0xD8" menu.cpu.atmega2560.bootloader.extended_fuses="0xFD" menu.cpu.atmega2560.bootloader.file="stk500v2/stk500boot_v2_mega2560.hex" menu.cpu.atmega2560.build.mcu="atmega2560" menu.cpu.atmega2560.build.board="AVR_MEGA2560" menu.cpu.atmega1280="ATmega1280" menu.cpu.atmega1280.upload.protocol="arduino" menu.cpu.atmega1280.upload.maximum_size="126976" menu.cpu.atmega1280.upload.speed="57600" menu.cpu.atmega1280.bootloader.high_fuses="0xDA" menu.cpu.atmega1280.bootloader.extended_fuses="0xF5" menu.cpu.atmega1280.bootloader.file="atmega/ATmegaBOOT_168_atmega1280.hex" menu.cpu.atmega1280.build.mcu="atmega1280" menu.cpu.atmega1280.build.board="AVR_MEGA" runtime.ide.path="C:\Program Files (x86)\Arduino" build.system.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr\system" runtime.ide.version="164" originalid="mega" tools.atprogram.cmd.path="%AVRSTUDIO_EXE_PATH%\atbackend\atprogram" tools.atprogram.cmd.setwinpath="true" tools.atprogram.program.params.verbose="-v" tools.atprogram.program.params.quiet="-q" tools.atprogram.program.pattern="&quot;{cmd.path}&quot; -d {build.mcu} {program.verbose} {program.extra_params} program -c -f &quot;{build.path}\{build.project_name}.hex&quot;" tools.atprogram.program.xpattern="&quot;{cmd.path}&quot; {AVRSTUDIO_BACKEND_CONNECTION} -d {build.mcu} {program.verbose} {program.extra_params} program -c -f &quot;{build.path}\{build.project_name}.hex&quot;" version="1.6.7" compiler.warning_flags="-w" compiler.warning_flags.none="-w" compiler.warning_flags.default="" compiler.warning_flags.more="-Wall" compiler.warning_flags.all="-Wall -Wextra" compiler.path="{runtime.tools.avr-gcc.path}/bin/" compiler.c.cmd="avr-gcc" compiler.c.flags="-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD" compiler.c.elf.flags="{compiler.warning_flags} -Os -Wl,--gc-sections" compiler.c.elf.cmd="avr-gcc" compiler.S.flags="-c -g -x assembler-with-cpp" compiler.cpp.cmd="avr-g++" compiler.cpp.flags="-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD" compiler.ar.cmd="avr-ar" compiler.ar.flags="rcs" compiler.objcopy.cmd="avr-objcopy" compiler.objcopy.eep.flags="-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0" compiler.elf2hex.flags="-O ihex -R .eeprom" compiler.elf2hex.cmd="avr-objcopy" compiler.ldflags="" compiler.size.cmd="avr-size" build.extra_flags="" compiler.c.extra_flags="" compiler.c.elf.extra_flags="" compiler.S.extra_flags="" compiler.cpp.extra_flags="" compiler.ar.extra_flags="" compiler.objcopy.eep.extra_flags="" compiler.elf2hex.extra_flags="" recipe.c.o.pattern="&quot;{compiler.path}{compiler.c.cmd}&quot; {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.cpp.o.pattern="&quot;{compiler.path}{compiler.cpp.cmd}&quot; {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.S.o.pattern="&quot;{compiler.path}{compiler.c.cmd}&quot; {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} &quot;{source_file}&quot; -o &quot;{object_file}&quot;" recipe.ar.pattern="&quot;{compiler.path}{compiler.ar.cmd}&quot; {compiler.ar.flags} {compiler.ar.extra_flags} &quot;{build.path}/{archive_file}&quot; &quot;{object_file}&quot;" recipe.c.combine.pattern="&quot;{compiler.path}{compiler.c.elf.cmd}&quot; {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o &quot;{build.path}/{build.project_name}.elf&quot; {object_files} &quot;{build.path}/{archive_file}&quot; &quot;-L{build.path}&quot; -lm" recipe.objcopy.eep.pattern="&quot;{compiler.path}{compiler.objcopy.cmd}&quot; {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} &quot;{build.path}/{build.project_name}.elf&quot; &quot;{build.path}/{build.project_name}.eep&quot;" recipe.objcopy.hex.pattern="&quot;{compiler.path}{compiler.elf2hex.cmd}&quot; {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} &quot;{build.path}/{build.project_name}.elf&quot; &quot;{build.path}/{build.project_name}.hex&quot;" recipe.size.pattern="&quot;{compiler.path}{compiler.size.cmd}&quot; -A &quot;{build.path}/{build.project_name}.elf&quot;" recipe.size.regex="^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*" recipe.size.regex.data="^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*" recipe.size.regex.eeprom="^(?:\.eeprom)\s+([0-9]+).*" tools.avrdude.path="{runtime.tools.avrdude.path}" tools.avrdude.cmd.path="{path}/bin/avrdude" tools.avrdude.config.path="{path}/etc/avrdude.conf" tools.avrdude.upload.params.verbose="-v" tools.avrdude.upload.params.quiet="-q -q" tools.avrdude.upload.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;" tools.avrdude.program.params.verbose="-v" tools.avrdude.program.params.quiet="-q -q" tools.avrdude.program.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{build.path}/{build.project_name}.hex:i&quot;" tools.avrdude.erase.params.verbose="-v" tools.avrdude.erase.params.quiet="-q -q" tools.avrdude.erase.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m" tools.avrdude.bootloader.params.verbose="-v" tools.avrdude.bootloader.params.quiet="-q -q" tools.avrdude.bootloader.pattern="&quot;{cmd.path}&quot; &quot;-C{config.path}&quot; {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} &quot;-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i&quot; -Ulock:w:{bootloader.lock_bits}:m" build.usb_manufacturer="&quot;Unknown&quot;" build.usb_flags="-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'" vm.platform.root.path="C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\arduino16x" upload.protocol="wiring" upload.maximum_size="253952" upload.speed="115200" bootloader.high_fuses="0xD8" bootloader.extended_fuses="0xFD" bootloader.file="stk500v2/stk500boot_v2_mega2560.hex" build.mcu="atmega2560" ide.hint="Arduino 1.6 Ide" ide.location.key="Arduino16x" ide.location.ide.winreg="Arduino 1.6.x Application" ide.location.sketchbook.winreg="Arduino 1.6.x Sketchbook" ide.location.sketchbook.preferences="sketchbook.path" ide.location.preferences="%VM_APPDATA_ROAMING%\arduino15\preferences.txt" ide.location.preferences_fallback="%VM_APPDATA_ROAMING%\arduino\preferences.txt" ide.default.version="160" ide.default.package="arduino" ide.default.platform="avr" ide.multiplatform="true" ide.includes="arduino.h" ide.platformswithoutpackage="false" ide.includes.fallback="wprogram.h" ide.extension="ino" ide.extension.fallback="pde" ide.versionGTEQ="160" ide.exe="arduino.exe" ide.hosts="atmel" ide.url="http://arduino.cc/en/Main/Software" vm.debug="true" software="ARDUINO" ssh.user.name="root" ssh.user.default.password="arduino" ssh.host.wwwfiles.path="/www/sd" build.working_directory="{runtime.ide.path}" ide.appid="arduino16x" location.sketchbook="C:\Users\OAPfive\Documents\Arduino" build.core.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" build.core.parentfolder.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores" build.core.coresparentfolder.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr" vm.core.include="arduino.h" vm.boardsource.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr" runtime.platform.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr" vm.platformname.name="avr" build.arch="AVR" build.variant.vmresolved="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" vm.runtime.compiler.showwarnings="true" serial.port.file="COM6" serial.port="COM6" includes=" -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries\Ethernet\src&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries\Servo\src&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire&quot; -I&quot;C:\Program Files (x86)\Arduino\libraries&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries&quot; -I&quot;C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers&quot; -I&quot;C:\Users\OAPfive\Documents\Arduino\libraries&quot; -I&quot;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\utility&quot;" build.path="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560" build.project_name="roverCode" build.variant.path="C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" archive_file="core.a" object_file="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560\Wire\utility\twi.c.o" source_file="C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\utility\twi.c" />
</Platform>
<Compile IsDebugStart="1" IsCompiled="0" CompilerErrors="0" ConfigurationName="Debug" StopOnError="False" OptimiseLibs="True" OptimiseCore="True" BuildPath="C:\Users\OAPfive\AppData\Local\V.Micro\Arduino\Builds\roverCode\mega_atmega2560" />
<Debug DebugEnabled="0" EnableBreak="1" />
</Program>
</VisualMicro>
\ No newline at end of file
......@@ -21,7 +21,7 @@ void writeToArmMotors()
void armRiseAndBack() {
for(int i = 0; i < 3; i++) {
armMotor[i].writeMicroseconds(SPEEDUP_FREQUENCY);
Serial.println(TALON_ARM[i]);
//Serial.println(TALON_ARM[i]);
delay(5000);
armMotor[i].writeMicroseconds(SPEEDDOWN_FREWQUENCY);
delay(5000);
......
void compressorPressureCheck()
{
int pressureValue = analogRead(COMPRESSOR_PIN) * 0.363;
//Serial.println(pressureValue);
if(pressureValue < 125) {
digitalWrite(COMPRESSOR_CONTROL, HIGH);
}
else if(pressureValue > 165) {
digitalWrite(COMPRESSOR_CONTROL, LOW);
}
}
void attachHandMotors()
{
for (int i; i <= 2; i++) {
handMotor[i].attach(HAND[i]);
}
for (int i; i <= 2; i++){
pinMode(GRIPPER[i], OUTPUT);
}
digitalWrite(GRIPPER[0], HIGH);
}
void writeToHandMotors()
{
for(int i = 0; i < 3; i++) {
Serial.print("Hand: ");
int segments = 3;
for(int i = 0; i < segments; i++) {
/*Serial.print("Hand: ");
Serial.print(i);
Serial.println(hand[i]);
Serial.println(hand[i]);*/
delay(20);
if(hand[i] == 0 || hand[i] == 2) {
if(hand[i] == 0 && handPos[i] < 180) {
handPos[i] += 5;
if(hand[i] == 0 && handPos[i] < MAX_HAND) {
handPos[i] += 1;
}
else if(handPos[i] > 0) {
handPos[i] -= 5;
else if(hand[i] == 2 && handPos[i] > MIN_HAND) {
handPos[i] -= 1;
}
handMotor[i].write(handPos[i]);
}
}
if(hand[segments] == 0){
digitalWrite(GRIPPER[1], HIGH);
digitalWrite(GRIPPER[2], LOW);
Serial.println("Close");
} else if (hand[segments] == 2){
digitalWrite(GRIPPER[1], LOW);
digitalWrite(GRIPPER[2], HIGH);
Serial.println("Open");
} else {
digitalWrite(GRIPPER[1], LOW);
digitalWrite(GRIPPER[2], LOW);
Serial.println("Hold");
}
}
......@@ -6,7 +6,6 @@
#include <EthernetUdp.h>
#include <Wire.h>
// WIRELESS COMMUNICATION
// Port to listen for UDP connections on
const int UDP_PORT = 8888;
......@@ -20,7 +19,7 @@ int networkStatus = 1;
int leftPower = 128;
int rightPower = 128;
int arm[3] = {1, 1, 1};
int hand[3] = {1, 1, 1};
int hand[4] = {1, 1, 1, 1};
int misc[4] = {1, 1, 1, 1};
// Need Analog input with male pin
......@@ -29,7 +28,6 @@ int misc[4] = {1, 1, 1, 1};
int potValue;
int sendValue;
// MOTOR CONSTANTS
// Need PWM input with male pin for motor controller
......@@ -41,14 +39,14 @@ Servo rightMotor;
int handPos[3] = {90, 90, 90};
// Need PWM input with male pin for the direct arm motor controller
Servo armMotor[3];
Servo handMotor[4];
const int HAND[4] = {28, 27, 26, 25}; // pins for motor control
Servo handMotor[3];
const int GRIPPER[3] = {31, 33, 35}; // Pins for opening/closing the grippers.
const int HAND[3] = {2, 4, 9}; // pins for motor control
const int TALON_ARM[3] = {6, 7, 8}; // pins for motor control
#define NEUTRAL_FREQUENCY 1500
#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
......@@ -58,3 +56,8 @@ const int TALON_ARM[3] = {6, 7, 8}; // pins for motor control
#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
//#include <SPI.h> // needed for Arduino versions later than 0018
//#include <Ethernet.h>
//#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
//#include "megaBoardDefine.h"
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
//byte mac[] = {
// 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
//};
//IPAddress ip(192, 168, 1, 177);
boolean hasIP = false;
unsigned int localPort = 8888; // local port to listen on
// Recieved Data
// buffers for receiving and sending data
//char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
//char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
//EthernetUDP Udp;
void receiveWirelessData()
{
//Serial.print("Network Status: ");
//Serial.println(networkStatus);
networkStatus = processNetworkData();
}
void initializeWireless()
{ // begin wireless communication
Serial.begin(BAUD_RATE);
Ethernet.begin(mac, ip);
Udp.begin(UDP_PORT);
timeLastPacket = millis();
Serial.println("INITIALIZED");
}
void readByteAsInt(byte data, int* buffer, byte bufferSize)
{
byte mask = 0x03;
for(byte i = 0; i < bufferSize; i++) {
*buffer = data & mask;
data >>= 2;
buffer++;
}
}
void receiveOverEthernet() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize) {
//Serial.print("Received packet of size ");
//Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i = 0; i < 4; i++) {
Serial.print(remote[i], DEC);
if (i < 3) {
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
int *buffer;
for (int i = 0; i < packetSize; i++) {
readByteAsInt(packetBuffer[i], buffer, 1);
}
Serial.println("Contents:");
Serial.println(packetBuffer);
Serial.println("Converted:");
for (int i = 0; i < packetSize; i++) {
Serial.println(buffer[i]);
}
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
delay(10);
}
// parses the raw data from the received packet to a writeable format for the motors
int processNetworkData() {
//Serial.println("CHECKING");
//Serial.println(freeRam());
// Check size of available packet
int packetSize = Udp.parsePacket();
//Serial.print("Packet size: ");
//Serial.println(packetSize);
// Process packet if available
if(packetSize == 5) {
hasIP = true;
//printPacketInfo(packetBuffer);
//Serial.println("GOOD");
// read the packet into packetBufffer
Udp.read(packetBuffer, 96);
// Process packet into values
leftPower = ((unsigned char)packetBuffer[0]) & 0xFFFF;
rightPower = ((unsigned char)packetBuffer[1]) & 0xFFFF;
readByteAsInt(packetBuffer[2], arm, 3);
readByteAsInt(packetBuffer[3], hand, 4);
readByteAsInt(packetBuffer[4], misc, 4);
printPacketValues();
return 1;
}
return 0;
}
void printPacketValues() {
/* Serial.print("Left: ");
Serial.println(leftPower);
Serial.print("Right: ");
Serial.println(rightPower);
for(int i = 0; i < 3; i++)
{
Serial.print("Arm:");
Serial.println(arm[i]);
}*/
/*for(int i = 0; i < 3; i++)
{
Serial.print("Hand:");
Serial.println(hand[i]);
}*/
/*
for(int i = 0; i < 4; i++)
{
Serial.print("Misc:");
Serial.println(misc[i]);
}*/
}
// check to see if there is still a live wireless connection. If not, stop all motors.
void timeoutCheck()
{
if(millis() - timeLastPacket >= TIMEOUT) {
// Serial.println("TIMEOUT");
leftMotor.writeMicroseconds(NEUTRAL_FREQUENCY);
rightMotor.writeMicroseconds(NEUTRAL_FREQUENCY);
}
}
// HARDWARE: Arduino MEGA 2560
#include "Arduino.h"
#include "megaBoardDefine.h"
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <Servo.h>
#include <Wire.h>
void setup()
{
Serial.println("STARTING");
attachDriveMotors();
attachArmMotors();
attachHandMotors();
initializeWireless();
}
void loop()
{
overCurrentCheck();
timeoutCheck();
compressorPressureCheck();
receiveWirelessData();
writeToDriveMotors();
writeToArmMotors();
writeToHandMotors();
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "roverCode", "roverCode.vcxproj", "{5A4675E1-E679-4943-B6EA-541F00D37C0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A4675E1-E679-4943-B6EA-541F00D37C0F}.Debug|Win32.ActiveCfg = Debug|Win32
{5A4675E1-E679-4943-B6EA-541F00D37C0F}.Debug|Win32.Build.0 = Debug|Win32
{5A4675E1-E679-4943-B6EA-541F00D37C0F}.Release|Win32.ActiveCfg = Release|Win32
{5A4675E1-E679-4943-B6EA-541F00D37C0F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">