Tuesday, December 24, 2013

IR Remote Demonstration

Final code used:
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
//IR code:
#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

//Servo Code
#include <Servo.h>
Servo servoA;
Servo servoB;
//const int servospeedA = 81 /*Check value */; //roughly mid value in 0-180 should be no motion
//const int servospeedB = 86 /*Check value */; //roughly mid value in 0-180 should be no motion

void setup()
{
  Serial.begin(9600);
//Servo Code:
servoA.attach(9);
servoB.attach(10);
//servoA.write(81);
//servoB.write(85);

//IR Code:
  irrecv.enableIRIn(); // Start the receiver
}//end void setup

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
//Servo code:
  if(results.value == 551485695){
    servoA.write(81);
    delay(100);
    servoA.write(0);
    delay(50);
  }
  if(results.value == 551518335){
  servoA.write(81);
  delay(100);
  servoA.write(180);
  delay(50);
  }
  if(results.value == 551499975){
  servoA.write(81);
  }
  
  if(results.value == 551502015){
  servoB.write(90);
  delay(100);
  servoB.write(0);
  delay(50);
  }
  if(results.value == 551534655){
  servoB.write(90);
  delay(100);
  servoB.write(180);
  delay(50);
  }
  if(results.value == 551506605){
  servoB.write(90);
  }
  //end if statement
/*if("(channel down) IR value is min"){
  servoA.write(0);
}//end if statement
 else(servoA.write(81));
  if statements controlling the motorspeeds need specifics on how to obtain high or low
 (up or down channel or volume signal) in order to write forward or backward speed to servo
 correctly. 

if("(volume up) IR value is max"){
  servoB.write(180);
}//end if statement
if("(volume down) IR value is min"){
  servoB.write(0);
}//end if statement
 else(servoB.write(86));
  */
}//end void loop

Wednesday, December 18, 2013

Sunday, December 15, 2013

Personal summary.
My main goal for the project was working on the physical parts. I created the chase out of k'nex and eventually reworked it 2 additional time. I did the solidworks for the tank track and with help from kevin made the gear in solidworks as well. I created the suspension out of legos and springs which I hot glued to the chase. Lastly I did the physical modifications to the servos to make them continous and mounted them and the ardunio to the chasy.
-Brendan McGonagle
Personal Summary

I purchased the servo motors and helped solve for the needed dimensions of the two driving gears for either tank tread chain. Additionally, I tested the servo motors once their potentiometers had been glued in roughly the middle of the 0 to 180 degree range. Using a potentiometer from the sparkfun kit, the degree value which became the middle of the range (0 rotational speed) was found and noted. Also, the IR sensor had to become functional through a few methods. The very first was obviously to download the IR library from Ken Shirriff's blog. Using some sample IR receiver code, and once the IR sensor had been plugged in correctly, the serial monitor which printed out what the IR sensor received from the TV remote revealed some combinations of numbers and letters. Through some help, we found out that the sensor was receiving numbers in hexadecimal. In order to incorporate the signals from the remote into the code, the numbers were converted to base 10 and used in the if statements which wrote to the servos. After this had been done, it was mostly trial and error and conversion. A forward, backward, and stop button on the remote was coded for each motor on the tank.

One motor did not have a clear center point in the range, so it didn't completely stop when the mid range servo.write function was used. This will require more testing. Overall, my focus was on the coding and motors, but I did help with the design of the tank's gears and treads.

-Kevin Cerritelli

Wednesday, December 11, 2013

Update from the past couple weeks:

-potentiometers inside servo motors have been glued
-both gears and the estimated 50 individual tank treads have been sent to be printed
-lego pieces have been ordered and will arrive soon
-approximate code for the servos and IR sensor has been created
The final implementation and testing will occur tomorrow.
The IR code and Servo code has been put into the same sketch, but the part missing from the code at this point is the frequency of the IR transmitter that is being used and the way to interpret a high or low signal from a button, i.e. channel up/down. The code could view these as two separate buttons.

The two servos have had their potentiometers glued roughly in the middle of each range, and the two approximate mid-values for each have been noted. This allows for the servo.write function to write a speed to the servo rather than an angle (position).

/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
//IR code:
#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

//Servo Code
#include <Servo.h>
Servo servoA;
Servo servoB;
const int servospeedA = 81 /*Check value */; //roughly mid value in 0-180 should be no motion
const int servospeedB = 86 /*Check value */; //roughly mid value in 0-180 should be no motion

void setup()
{
  Serial.begin(9600);
//Servo Code:
servoA.attach(9);
servoB.attach(10);
servoA.write(servospeedA);
servoB.write(servospeedB);

//IR Code:
  irrecv.enableIRIn(); // Start the receiver
}//end void setup

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
//Servo code:
if("(channel up) IR value is max"){
  servoA.write(180);
}//end if statement
if("(channel down) IR value is min"){
  servoA.write(0);
}//end if statement
 else(servoA.write(81));
 /* if statements controlling the motorspeeds need specifics on how to obtain high or low
 (up or down channel or volume signal) in order to write forward or backward speed to servo
 correctly. */

if("(volume up) IR value is max"){
  servoB.write(180);
}//end if statement
if("(volume down) IR value is min"){
  servoB.write(0);
}//end if statement
 else(servoB.write(86));
 
}//end void loop

Thursday, December 5, 2013

Tank tread design along with diameter which could vary depending on quality of print.

Designed by Brendan McGonagle