Wednesday, May 9, 2012

Belated ColorPal Post

//Dr. Bogen, sorry about not having this on by the 5th, we were looking through and realized it wasn't on.  This was the version that I found, just wanted to make sure you knew we'd done it! Thanks, Jason and Theresa

/*====================================================
 / Connect ColorPAL SIG signal to Arduino pin 2 and 3
 / Add 2K pullup resistor from pins 2 & 3 to +5v
 / Baud Rate = 9600 kbps
 / Read signal on 9600 in HEX
 /====================================================*/
#include <OldSoftwareSerial.h>
OldSoftwareSerial Color90(2, 3);  // rx = 2, tx = 3

float red; 
float grn; 
float blu; 
float wr = 240;
float wg = 191;
float wb = 318;
float br = 22;
float bg = 21;
float bb = 33;

int gotcolor = 0;
int letter;

void setup()
{
  Serial.begin(9600); // Start communication with serial port read value
  Color90.begin(4800); // Send signal to led to read value

  pinMode(2,INPUT); // serial pin out from color pal
  pinMode(3,INPUT); // from same serial pin, signal pulls up, sends, pulls down, reads
  digitalWrite(2,HIGH); // Enable the pull-up resistor
  digitalWrite(3,HIGH); // Enable the pull-up resistor

  pinMode(2,OUTPUT); // send signal out
  pinMode(3,OUTPUT);
  digitalWrite(2,LOW); // turn pin off so pin 3 can go high
  digitalWrite(3,LOW);

  pinMode(2,INPUT); // Input signal to print
  pinMode(3,INPUT);
  

  Serial.println("Pass 1");
//  delay(20);

  while( digitalRead(2) != HIGH || digitalRead(3) != HIGH ) {
    Serial.println("In the loop");
    delay(50);
  }

  Serial.println("Pass 2");

  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  delay(100);     // spec is 80, but not all ColorPAL units work with 80

  pinMode(2,INPUT);
  pinMode(3,OUTPUT);
  delay(100); 

}

// This oscillates back and forth on one wire to turn off led, send signal,
// turn on led, read signal. very fast strobe read - arduino is not capable of
// one wire signal communication over digital ports, so this is a way around
// that over 2 wires communicating with 1 pin on the sensor.
//---------------------------------

void loop()
{
  readcolor();
  float R = (red-br)/(wr-br);
  float G = (grn-bg)/(wg-bg);
  float B = (blu-bb)/(wb-bb);
  Serial.print("R");
  Serial.print(R);
  Serial.print("   G");
  Serial.print(G);
  Serial.print("   B");
  Serial.println(B);
  
  if (R < .15 && G < .15 && B < .15){
    Serial.print("Black");
    delay(50);
  }
  if((R > .85 && G > .85 && B > .85){
    Serial.print("White");
    delay(50);
  }
  if((R>.15 && R <.85) && G<.15 && B <.15){
  Serial.print("Red");
  delay(50);
  }
  if((B>.15 && B <.85) && R<.15 && B <.15){
  Serial.print("Blue");
  delay(50);
  }
  if((G>.15 && G <.85) && R<.15 && B <.15){
  Serial.print("Green");
  delay(50);
  }
  if((G>.15 && G <.85) &&(R>.15 && R <.85) && B <.15){
  Serial.print("Yellow");
  delay(50);
  }
  if((G>.15 && G <.85) &&(B>.15 && B <.85) && R <.15){
  Serial.print("Cyan");
  delay(50);
  }
  if((R>.15 && R <.85) &&(B>.15 && B <.85) && G <.15){
  Serial.print("Magenta");
  delay(50);
  }
  gotcolor = 0;
  delay(50);
}

void readcolor() {  // Reads ColorPAL, putting results in the red,grn,blu variables

  char rByte[9];
  char dummy[4];

  delay(20);
  Color90.begin(4800);
 Color90.print("= (00 $ m) !");  // set up loop to continuously send color data
  pinMode(3,INPUT);
  gotcolor = 0;
  while (gotcolor == 0) {
    rByte[0] = Color90.read();
    if( rByte[0] == '$' ) {
      gotcolor = 1;
      for(int i=0; i<9; i++) {
        rByte[i] = Color90.read();
//        Serial.print(rByte[i]);
      }
      Serial.println("");
      dummy[0] = rByte[0];
      dummy[1] = rByte[1];
      dummy[2] = rByte[2];
      dummy[3] = 0;

      red = strtol(dummy,NULL,16);

      dummy[0] = rByte[3];
      dummy[1] = rByte[4];
      dummy[2] = rByte[5];

      grn = strtol(dummy,NULL,16);

      dummy[0] = rByte[6];
      dummy[1] = rByte[7];
      dummy[2] = rByte[8];

      blu = strtol(dummy,NULL,16); 
    }
  }
}


  

Friday, May 4, 2012

Assistive IR Remote - Functional Block Diagram

The inputs to the device are two ability switches, which have only an on/off setting.  These are used to navigate the functions of the device.  Also, if the device is powered off, either button will power it on.  The Arduino board reads the state of the ability switches and uses it to generate the current state of the device based on a number sequence.  These sequences are one-way, pressing a switch will allow the user to cycle through functions.  There are essentially two levels of device states: the higher level allows cycling through each function type (Power, Channel Surf, Channel Input, and Volume) and the second level is for performing different actions within that scope.  For example, within Channel Surf, the user may select "Channel Up", "Channel Down", and "Back to Main Menu".  One of the ability switches is used for cycling, and one is used as the "action" button.  Depending on which function is selected, the IR Remote will output a brand-specific IR sequence using the IR functionality of the Arduino.  The LCD also outputs based on the number-state combination.  Using a combination of two numbers, it will know whether the menu is in the high level or within a function, and it will know the specific action selected.   The LCD will display the appropriate information.



Assistive IR Remote - Specifications


            Our Assistive IR Remote targeted for people with motor abilities consists of two ability switches, an LCD screen, and an Arduino board with circuits built in.  The remote has four main functions that will allow the user to control a given electronic device – power on/off, volume, channel surf, and channel input.  In general, one of the buttons allows the user to flip through the options in a given menu, while the other one serves as a confirmation button that transmit the IR code to the electronic device.  Listed below are the specifications for the device. 
Specification
Values
Comments
 Power
On/off
The function allows the user to turn the power on with either button. To turn the power off, the user has to scroll through the main menu to “Power” option.
Volume
Up/Down
The function allows the user to turn the volume up and down.
Channel Surf
Up/Down
The function allows the user to switch the channel up and down.
Channel Input
Three-digit Input (Hundreds, Tens, and Ones)
On top of the channel surf function, channel input is useful due to the large selection of available channels in television networks. This function allows the user to input a single digit for hundreds, tens, and ones sequentially. After all three digits are inputted, the device will transmit all three digits to the electronic device at once.
LCD Screen
Two-line display – selected menu and options within the menu
The first line in the LCD screen will display the selected function within the menu – power on/off, volume, channel surf, or channel input. The second line will display the options within the menu. For example, if the user chooses the volume menu, the second line will display either “volume up” or “volume down.” The two-lined LCD screen will therefore display the selected option in large fonts before the user chooses to transmit the code to the electronic device.

Assistive IR Remote - Analysis and Reverse Engineering of Current Competitions

There are many remotes designed for people with limited hand functionality.  The most prominent types are "large-button" remotes, which are simply programmable remotes with large buttons.  These still require a reasonable level of dexterity to use, and thus would not be useful for a cerebral palsy patient.  A search for a "one-button" remote also yielded no true results; the only product coming close was a remote with a button and a small switch to change functionality.  The product type most similar to our design is a large, ability switch-based remote, such as the one from BroadendHorizons.com (see figure below). This remote control has five buttons: power, volume up/down, and channel up/down.  Although we are not able to physically take apart the product to examine the circuits, it is fairly straightforward to understand how the product works. It is likely that the product works by transmitting the programmed function via IR when the button is pressed.  The main advantage of this type of design is its simplicity.  It is simply one button = one function, so no coding is required to navigate menus and no display is required to show the device's state.  The disadvantages of this device are its limited functionality, its cost, and its size.  Having five one-function buttons limits the device to five functions.  There is no way to input a channel number or perform any other function on the TV.  In addition, the blocky size would preclude its installation on a wheelchair and makes it more difficult to carry.  It is also $250.  We feel that there is room for significant improvement in all of these areas over this design. 



Although our device is only pre-programmed to work on a SONY television, it can be easily re-programmed to be a universal remote that is adaptable to different brands.  Therefore, we also decided to examine the current universal remotes to understand how they work.  Universal remotes have two main categories - the pre-programmed remotes and the learning remotes. A pre-programmed remote allows the user to set up the remote using a list of options based on the brand of the device. As inferred from the name, the transmission codes of each matching device for all the functions are pre-programmed into the remote control so the user does not have to "teach" the device. Frankly, this type of universal remote is not any more complicated than the IR remote we developed - it just has another layer of menu that chooses the brand of the device and a larger library of codes for each function.  The other type of universal remotes, the learning remotes, allow the user to "teach" the remote upon set up.  Although learning remotes enable the user to control any electronic device, it takes more effort to set up the codes. Instead of having a set of codes pre-programmed into the remote, the learning remote requires the user to transmit codes from the teaching remote to the learning remote button by button so the learning remote can input the transmission code into its library. This process is very similar to how we programmed our remote - we used an IR receiver to obtain the transmission codes from a teaching remote, and input the code into the algorithm correspondingly. 


Overall, we believe that the current market for remote controls does not offer an assistive remote that is programmable, easy to use, and affordable. Therefore, we feel that our product will be beneficial to the target population.