Thursday, 15 November 2012

WEEK 11

Week 11....Final Year Project working progress....

In this week....What I've done is testing the circuit whether it is working properly or not....
These are the pictures that I've captured during the testing.....

This is how the electrodes being attached to the human body.

Muscle voltage at rest : 3.36V.


Muscle voltage when some force given to muscle : 3.60V.

Muscle voltage when high force given to muscle : 3.64V.

When we straighten our arm, a lot of force will be given to the muscle.

Muscle voltage for straight arm : 6.84V.

WEEK 10

Week 10...Final Year Project working progress...

Processing program code

AnalogVisualizationProcessing


import processing.serial.*;

// definition of window size
// you can change the size of the window as you like
// the thresholdGraph will be scaled to fit
// the optimal size for the thresholdGraph is 1000 x 400
int xWidth = 1350;
int yHeight = 700;

// xPos input array, using prefix
int[] xPosArr= {0,0,0,0,0,0};

//
int[] messageArr= {0,0,0,0,0,0};
 
// Arrays for threshholding
int[] threshMax= {0,0,0,0,0,0};
int[] threshMin= {0,0,0,0,0,0};
 
// variables for serial connection. portname and baudrate are user specific
Serial port1;

//Set your serial port here (look at list printed when you run the application once)
String V3 = Serial.list()[1];
String portname1 = V3;
int baudrate = 9600;
 
int prefix = 10001;
boolean myCatch = false;
String serialIN = "";
String serialINPUT = "";
String buffer = "";
int value = 0;

// ThresholdGraph draws grid and poti states
ThresholdGraph in;

void setup(){
  // set size and framerate
  size(xWidth, yHeight);
  frameRate(25);
  background(255);
  strokeWeight(5);
  stroke(0);
  smooth();
  strokeCap(ROUND);

  // establish serial port connection     
  port1 = new Serial(this, portname1, baudrate);
  port1.bufferUntil('\n') ;
  println(Serial.list());  // print serial list

  // create DisplayItems object
  in = new ThresholdGraph();
 
  // THRESHOLD VALUES:
  // using the thresholdGraph you can determine the MIN and MAX values
  // of your sensors. Enter these here. They must lie between 0 and 1000.
 
    //MIN trashhold
    threshMin[0] = 20;   // one
    threshMin[1] = 20;   // two
    threshMin[2] = 20;   // three
    threshMin[3] = 20;   // four
    threshMin[4] = 20;   // five
    threshMin[5] = 20;   // six
   
    //MAX trashhold
    threshMax[0] = 600;   // one
    threshMax[1] = 600;   // two
    threshMax[2] = 600;   // three
    threshMax[3] = 600;   // four
    threshMax[4] = 600;   // five
    threshMax[5] = 600;   // six
}//end setup

// draw listens to serial port, draw
void draw(){
 
  // listen to serial port and trigger serial event 
  while(port1.available() > 0){
        serialIN = port1.readStringUntil('\n');
        //println((int)float(serialIN));
        if(serialIN != "")
          serialEvent(serialIN); 
        else
          println("found empty");
        }
       
  // threshold serial input 
  threshHolding(); 

  // draw serial input
  in.update();
}//end draw()




WEEK 9

Week 9....Final Year Project working progress...

Processing program code


Thresholding

void threshHolding(){
  for (int i=0; i<threshMin.length; i++) {
    float maxi=threshMax[i];
    float mini=threshMin[i];
    float dif = (maxi-mini)/255;
    messageArr[i]= xPosArr[i]-threshMin[i];
    if (messageArr[i] <0) messageArr[i]=0;
    float temp = messageArr[i];  
    temp = temp/dif;
    messageArr[i] = int(temp);
    if (messageArr[i] <0) messageArr[i]=0;
    if (messageArr[i] >255) messageArr[i]=255;
    }
}

SerialEvent

void serialEvent(String serialINPUT) {
  try
  {
    int inByte = Integer.parseInt(serialINPUT.replaceAll("(\\r|\\n)", ""));

    if (myCatch == true) {
      if (inByte != 10010) {       
        // add event to buffer
        value = inByte;
        xPosArr[(prefix-10001)] = value;
        //println("found data");
        println(value);
      }
      else {
        // if serial is line break set value to buffer value and clear buffer
        myCatch = false;    
        //println("found footer");
      }
    }
    //myCatch is the beginging of the each sended number used to define the port
    // myCatch gets true if serial is less than 10010 since header is 10001-10009
    if (!myCatch && inByte < 10010 && inByte > 10000) {
      myCatch = true;
      prefix = inByte; 
      //println("found header"); 
      //println(prefix);
    }
  }
  catch(NumberFormatException e)
  {
    //println(e.getMessage());
  }
  catch(NullPointerException e)
  {
    //println(e.getMessage());
  }
}