Tuesday, December 17, 2013

RGHG808

RGHG808





Photo Credit: Professor Daniel Sullivan

Finished Project

Our Finished Project


After countless hours of compiling code and trying to make this mechanism work, we finally were able to make our ideas a reality! Although at times it was very frustrating to say the least, overall it was a great experience and as a group we learned so much that will be carried with us throughout our successful futures.

Thursday, December 12, 2013

Wheel Code

This new updated code (posted through Github finally whoooohoooo!!) has put the wheel activation within the alarm loop so that the alarm clock can move away from the user.

Wednesday, December 11, 2013

H-Bridge Difficulties

That Pesky H- Bridge!!


So far our pursuit in successfully operating our arduino with the H-Bridge has not been achieved. With some serious perseverance and some help from Prof. Sullivan we are looking to get it working by the end of today's group meeting. (Fingers crossed)

Our goal is to have the wheel turning beneath the alarm when the alarm sounds and have everything terminate when the button is clicked. So far getting the wheel to sync with the button has been a bit difficult.

More updates with pictures and videos of our almost finished project are soon to come!

Tuesday, December 10, 2013

We're Almost There

We're Almost There!!!
 
 
 
Today's Challenges
Today we have hit that monumental moment of trying to cram all of our arduino components into the 3D part. We've quickly realized that since the initial design of our 3D part our arduino arrangements have changed slightly therefore making it hard to fit everything inside. A video is shown that displays our current setup. It was challenging getting our breadboards and our redboards to sit still during the process of trying to put every part into its designated place.
 
Future Challenges
The next challenge is placing the wires so that they are tucked away and not visible. We also need to add extensions that make the buttons and potentiometer more accessible (because as of now they are awkwardly tucked away). When we get together next, we will have super glue, tape, cardboard as well as other helpful adhesives and structures to secure all of our components into the case. Once all of the components are secured, we need to add a back and a bottom to the case. These parts were unable to be 3D printed due to our constriction to 4 cubic inches so we will need to improvise.
Today we had our part soaked in a basic solution to remove the residual support layer that was utilized during printing. This layer was inhibiting us from sliding our arduino boards into our part. With this layer removed we will hopefully be able to cram all our electronics into our little case


Monday, December 9, 2013

3D Part

Today we retrieved our 3D part. It was very interesting to see that all the measurements were exactly the same and that it was completely constructed over the course of one weekend. The next challenge is to have all arduino and breadboards to fit within the part.

Wednesday, December 4, 2013

Waking up to Arduino

Today I officially tested the functionality of our Arduino Alarm system. I uploaded the code to sync with the real time from my computer (You'll see that the time on my iTouch is one minute fast) and go off at 9:15am. As you can tell by my very groggy morning voice, it worked, and I successfully reset the alarm with the push button.



After resetting the alarm, I  let the timer run all day (without any resets) to test if the clock would successfully maintain a 24 hour cycle. As you can see in the picture below, the clock has cycled from 9:15am to 1:36:33am the next day.

Tuesday, December 3, 2013

Below shows the new and improved Alarm code as described in the previous post. A new variable TRAP =0 is set at the beginning of the code. The alarm loop is now activivated when it receives a HIGH signal or variable TRAP = 1. As a result, when the board receives a single HIGH signal, it sets TRAP =1, indefinitely trapping the arduino in the alarm loop. Pressing the reset button sets TRAP =0, ending the loop and stopping the alarm


const byte POTENTIOMETER = 0;  // Plugged into A0
const byte CONTROL = 13;  // pin #
int reading;
int value;
int MakeSound=0;
int Trap = 0;
int ledArray[] = {1,2,3,4,5};  //LED Array
int rate = 50;
int pause = 1;
void setup() {
  pinMode(CONTROL, OUTPUT);
  pinMode(11,OUTPUT);
 
  beep(50);
  beep(50);
  beep(50);
  delay(1000);
 
  pinMode(8,INPUT);
 
 
  for (int i=0; i<5; i++){  //LED Array
    pinMode(ledArray[i], OUTPUT);
 
}
}
void loop() {
  MakeSound=digitalRead(8);
   if (MakeSound==HIGH || Trap==HIGH)
   {
     Trap=1;
     {
       beep(200);
     }
  for (int i=0; i<5; i++){
    digitalWrite(ledArray[i], HIGH);
    delay(rate);
    digitalWrite(ledArray[i], LOW);
    if (i == 4) delay(pause*rate);
    else delay(rate);
  }
   for (int j=1; j<4; j++){
    int k = 4-j;
    digitalWrite(ledArray[k], HIGH);
    delay(rate);
    digitalWrite(ledArray[k], LOW);
    delay(rate);
  }
}
  reading = analogRead(POTENTIOMETER);
  value = map(reading, 0, 1024, 0, 255);  
  analogWrite(CONTROL, value);
} // end loop

void beep(unsigned char delayms){
  analogWrite(11, 20);      // Almost any value can be used except 0 and 255
                           // experiment to get the best tone
  delay(delayms);          // wait for a delayms ms
  analogWrite(11, 0);       // 0 turns it off
  delay(delayms);          // wait for a delayms ms  
}
Today, a relay was added to isolate the power sources of each Arduino board. We also installed a reset push button for the secondary Arduino board so that it can be easily accessed.

In the beginning of the alarm code we added a variable flag "trap" which was equal to zero.
We changed the alarm code so that the alarm is initiated when it either receives a high signal from the primary board or when the flag "trap" is equal to one. When the secondary board receives a high signal, it initiates the alarm and sets "trap" equal to one so that the Arduino continues in the alarm loop even without the high signal. Pressing the reset button on the sound board sets the variable "trap" back to zero therefore ending the alarm loop.

In simpler terms, the alarm goes off at the designated alarm time and keeps sounding and flashing until the reset button is pressed. This is helpful so that the alarm doesn't keep sounding obnoxiously for a minute straight. When the person wakes up, they can shut it off and start their day!

A video is shown below to show the alarm clocks current functionality.

Monday, December 2, 2013

The Final Part for 3D Printing!


This is the final Part that was sent today for 3D printing. Getting the dimensions right was a bit challenging but I think we pulled it off!

Sunday, December 1, 2013

Code Catchup (LED Array, Sound and Fan)

Below is the code uploaded to our secondary board, which activates the sound and lights upon receiving a signal from the primary board. The potentiometer controlled fan code is integrated as well.

The current issue with this code is that we cannot get the alarm loop to continue after the primary board sends the initial signal. The goal is that the secondary board does nothing but spend its time constantly checking for a signal from the primary board. At 8:00:00, the primary board sends a single signal to the secondary board, activating an alarm loop that continues even after the signal ceases to be sent. That way, the alarm will continue until the secondary board is reset and begins waiting for 8:00:00 again. This way, the timer is never interrupted and can continue keeping time.


const byte POTENTIOMETER = 0;  // Plugged into A0
const byte CONTROL = 13;  // pin #
int reading;
int value;
int MakeSound=0;

int ledArray[] = {1,2,3,4,5};  //LED Array
int rate = 50;
int pause = 1;

void setup() {
  pinMode(CONTROL, OUTPUT);
  pinMode(11,OUTPUT);
 
  beep(50);
  beep(50);
  beep(50);
  delay(1000);
 
  pinMode(8,INPUT);
 
 
  for (int i=0; i<5; i++){  //LED Array
    pinMode(ledArray[i], OUTPUT);
 
}
}
void loop() {
  MakeSound=digitalRead(8);
   if (MakeSound==HIGH)
   {
     {
       beep(200);
     }
  for (int i=0; i<5; i++){
    digitalWrite(ledArray[i], HIGH);
    delay(rate);
    digitalWrite(ledArray[i], LOW);
    if (i == 4) delay(pause*rate);
    else delay(rate);
  }
   for (int j=1; j<4; j++){
    int k = 4-j;
    digitalWrite(ledArray[k], HIGH);
    delay(rate);
    digitalWrite(ledArray[k], LOW);
    delay(rate);
  }
}

  reading = analogRead(POTENTIOMETER);
  value = map(reading, 0, 1024, 0, 255);  
  analogWrite(CONTROL, value);
} // end loop


void beep(unsigned char delayms){
  analogWrite(11, 20);      // Almost any value can be used except 0 and 255
                           // experiment to get the best tone
  delay(delayms);          // wait for a delayms ms
  analogWrite(11, 0);       // 0 turns it off
  delay(delayms);          // wait for a delayms ms  
}

Code Catchup (Timer and Alarm Signal)

Below is the code uploaded to our primary board that controls our Timer and sends a signal to the secondary board at 8:00:00


#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int s=55; // Adjust the starting seconds
int m=59; // Adjust the starting minutes
int h=7; // Adjust the starting hours
int Alarm_s=0; // Adjust the alarm seconds
int Alarm_m=0; // Adjust the alarm minutes
int Alarm_h=8; // Adjust the alarm hours

boolean x=false;

ISR(TIMER1_OVF_vect) {
 s++;
 if(s==60){
   s=0;
   m++;
 }

 if(m==60){
   m=0;
   h++;
 }

 if(h>23){
   h=0;
 }

 x=!x;

 TCNT1=0x0BDC;

}// end of ISR Function



void setup() {
digitalWrite(9,LOW);
 pinMode(9,OUTPUT);

 lcd.begin(16, 2);
 lcd.setCursor(2,0);
 lcd.print(":");

TIMSK1=0x01; // enabled global and timer overflow interrupt;
TCCR1A = 0x00; // normal operation page 148 (mode0);
TCNT1=0x0BDC; // set initial value to remove time error (16bit counter register)
TCCR1B = 0x04; // start timer/ set clock

}



void loop () {

 if(x==true){

   lcd.setCursor(5,0);

   lcd.print(":");

 }

 else{

   lcd.setCursor(5,0);

 lcd.print(":");}
 seconds();
 minutes();
 hours();


if (h == Alarm_h & m == Alarm_m & s == Alarm_s)
{digitalWrite(9,HIGH);
}
else
{
 digitalWrite(9,LOW);
 } // End of loop function
}
 

 int seconds()
 {

   lcd.setCursor(6,0);

   if(s<10){

     lcd.print("0");}

     lcd.print(s);
     lcd.print(" ");
 }

 int minutes(){

   lcd.setCursor(3,0);

   if(m<10){

     lcd.print("0");}

     lcd.print(m);

 }

 int hours(){

   lcd.setCursor(0,0);

   if(h<10){

     lcd.print("0");}

     lcd.print(h);

 }

Today some good progress was made on the alarm clock. 

1) Issues with the sound device were solved. Before, the sound kept going off even when an initiating signal stopped being sent. We realized that we needed to add a 10K resistor to the sound system as a ground because it eliminated the lingering initiation signal that kept setting the alarm off. With this fixed, the pin signal sent from the timer on one board could initiate the beeping on the other board. 

2) We then moved all of our LED Array components onto the secondary board to reduce clutter on the primary LCD board. Now, both the LED Array and sound are initiated by a single signal from the primary board that is sent when the timer hits 8:00:00. 

Issues moving forward
- Need to finalize physical arrangement for casing design on solidworks
- Currently, at 8:00:00 the alarm mechanisms are triggered but then cease after one second. We're having difficultly programming the board to continue the alarm even after 8:00:00 has passed

Below is a video showing our potentiometer controlled fan and alarm system going off at 8:00:00. 



We have had significant issues dealing with Github up until this point and as a result we have been unable to post our code and the progress we've made. We were just recently informed that simply posting the code in a post is acceptable, so the next two posts will contain our code. We apologize for this delay