WELLCOME -----FYP S2 2011 PROJECT BLOG-----SUPERVISED BY: SIR KAMALUL FAIZIN B. MOHD SUHUT

Tuesday, April 19, 2011

PRESENTATION DAY!!!!

Firstly thanks to ALLAH, for He always there for us giving me strength to this very day to write about my viva day. Okay it was not that good, since I was preparing the for only the technical stuff, electronics, and the hardware parts. Our project assessor, Sir Samsul was giving us a hard time, testing our medical knowledge. Well it goes without saying that OBVIOUSLY I can't confidently answer his questions. Some of it I got it right, but all and all he was confident that we are the one that have lose our sharpness. He told us to go back to study  medical.Wait. Study it from the SPM level. OUCH. 
Em.. Enough about my viva, let;s get uploading! :)
Okay I am about to upload my precious sketch. So Here you go guys, hope it'll help u as it helped me. :)

SENDER (XBEE TRANSMITTER)

/*Sketch ini dibuat utk menghanatar signal dr analog pin Uno 1 
ke UNO 2 utk mendisplay bubble detected ke LCD display sambil 
membunyikkan buzzer. Insyallah. */

int sensorPin = A0; 
int sensorValue = 0;
const int ledPin = 13;   //PIN 13 DA MMG ADE LAMPU LED
#include <Stepper.h>
#define STEPS 100
Stepper motor1(STEPS, 8, 9, 10, 11);
void setup()
{
  Serial.begin(19200);
  motor1.setSpeed(20);
}

void loop()
{
  //motor1.step(1*STEPS);
  //delay(2000);
  motor1.step(-1*STEPS);
  delay(2000);
  //baca analog inout dr bubble detector
  sensorValue = analogRead(sensorPin);
  //remap value utk mencantikkan signal bubble yg dikesan
  sensorValue = map(sensorPin, 0, 1023, 253, 0);
  

if ((int(incomingByte) <80)) //ni utk keadaan biasa, iaitu bila ade fluid
  {
  Serial.print(255,BYTE); //

  Serial.print(sensorValue,BYTE);
  digitalWrite(ledPin, HIGH);
  }

  if ( sensorValue > 150) //150 adalah bersamaan dgn 3Volt.
  {
  Serial.print(254,BYTE); //
  Serial.print(sensorValue,BYTE);
  digitalWrite(ledPin, LOW);
  }
  else 
  {
    digitalWrite(ledPin, HIGH); //YG NI utk aku tunjuk bahawa xde ape2 
  }
  delay(150);
}

RECEIVER (XBEE RECEIVER)

/* Skecth ini pula dibuat utk menerima data dr UNO 1 yg ada bubble 
detector, dan menyuruh LCD, BUZZER asalarm indicators. Insyallah.. 
TP FIRST NAK TEST PAKAI LCD LA DULU  */

#include <LiquidCrystal.h>
int speakerPin = 5;
byte incomingByte, sensor1;

//LCD saya memakai pin Uno 2 yg berikut:
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() 
  {
  Serial.begin(19200);
  pinMode (13, OUTPUT);
  pinMode(speakerPin, OUTPUT);
  (" Ready! ");
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Monitoring: OK");
  lcd.setCursor(0, 1);
  lcd.print("BED 2");
  delay(1000);
  }

void loop() {
if (Serial.available()) 
{
incomingByte = Serial.read();

Serial.print(int(incomingByte));

if ((int(incomingByte) <80)) //ni utk keadaan biasa, iaitu bila ade fluid
  {
    sensor1 = Serial.read();
    lcd.clear();
    lcd.print("LINE CLEAR");
    Serial.print(int(sensor1));
    digitalWrite(13, LOW);
  }

if ((int(incomingByte) > 150)) //150 utk detect 3V, sbb kalo de bubble voltan akan naik smpai ke 3V.
  { 
  sensor1 = Serial.read(); //x de pon x pe kot??ntah
  digitalWrite(speakerPin, HIGH);
  delay(500);
  digitalWrite(speakerPin, LOW);
  delay(500);
  lcd.clear();
  lcd.print("BUBBLE DETECTED!!"); 
  Serial.print(int(sensor1));
  digitalWrite(13, HIGH);
  }
}

   for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
   // scroll one position left:
   lcd.scrollDisplayLeft(); 
   // wait a bit:
   delay(250);
  }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight(); 
    // wait a bit:
    delay(250);
  }
  
    // scroll 16 positions (display length + string length) to the left
    // to move it back to center:
    for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft(); 
    // wait a bit:
    delay(250);
  }
  
    // delay at the end of the full loop:
    delay(1000);
    digitalWrite (13, sensor1);
}

Both above sketches are done using XBEE Shield, so note that other XBEE may not work with this program. Also, the sketches is actually made to detect bubble from the infra red, (A0) and convert it into digital input. The ADC function has been done by MAPPING FUNCTION BY THE ARDUINO. So no need for ADC IC. (Cool eh?)

GOOD LUCK FOR THURSDAY PEEPS!!! :)



Monday, April 18, 2011

FINAL TOUCH

Okay right now I really shouldn't be writing to the blog, but I think I'll regret it if I didn't. Last touch for the project, we are working on the hardware for the prototype. Hilwani is mounting the motor to the proto board, and I am working on the ARDUINO WHOLE SYSTEM SKETCHES. I'll update the pictures tomorrow. 

Still, we are not done. There are some missing points that we haven't touch but at least there are some things that are succeed thanks to ALLAH.

Lastly, pray for us. Good luck to our friends also, La Tahzan, for Allah is always with you. :)

Wednesday, March 30, 2011

DATELINE:19th APRIL 2011

Okay there is a motherlode of shock wave shocked me after I am hearing about my FYP presentation dateline. 2 weeks to go prepare for my report, presentation, logbook, posters, and yet my software is STILL NOT WORKING!!!!!!!!

I am a little bit crazy and hazy and I am sure I am not the only one. Just have to try my best...

Ugh.... :(

Saturday, March 26, 2011

Wire Identification

Motor Identification.

 One winding is on each stator pole.Unipolar motors may have 5 leads but generally have 6 or 8 wires. In all the motors we have seen, the wires for the 6 & 8 types come out in two bundles of 3 or 4 wires resp. Unipole steppers have two coils per stator pole. In the 8 lead motors the 2 leads from the 2 coils from both stators emerge from the motor. In the 6 lead motors the two coils on each stator pole are joined (opposite sense) together before they emerge from the motor. In the 5 lead  motors each of the two joined wires are themselves joined  before they leave the motor. In the 6 wire version a multimeter (set it to 200ohm resistance range) will show which is the centre lead within each group of 3 leads. 


5 wire version

6 wire version
 Typically the resistance between the centre lead to the other two will be about 40 ohms while the resistance between the outer two leads will be twice that. Call the outer two leads in each of the two bunches of wires A & B, C & D.  The centre lead in each bunch is the power lead & goes into the pad marked +.  Note that it does not matter which way around the A/B, C/D leads go onto the pads. 

 In the 5 wire motor these centre leads  are  connected internally. Note that both + pads on the PCB are connected together.So to power a 5 lead stepper just connect the common centre tap lead from both phases to one of  the + pads. The A/B, C/D leads are connected just as  in the 6 lead motors. 

STILL NOT WORKING

Okay just an update about my Xbee..Still not working... Em... I dunno wut to do so I think I'll just go writes about my report and the other 2 assignments. I dunno how to get the receiver talking to each other. Maybe it's because of I didn't use 2 UNO's. Hm.... Yeah! I think so, but if we configures it separately, it would still works just fine. 
Em, Yes, now I just rambling on and on to make the posts seems a lot more than it actually is. 

AH, now I remember. Yesterday, we went to see Sir Kamal and bring along our so called 'back up plan' for the infusion pump. And yes it works just fine (credit to my best freind Syed Akil), and we disassembled the pump and adjust it to our own stepper motor. I do not have any pictures of it yet but I'll update it just for the sake of rubbing it to your face Hahahahaha. kidding... :)

Sir Kamal also mentioned about this awesome IC for driving a stepper motor. It is 5804 and it is considered awesome because it will only USE 2 PINS TO YOUR UNO!!!! Isn't that fantastic?? XD 




Now I am at Kuala Pilah hotel, Melang Inn rambling on what to do.. Sir Kamal and my partner Hilwani are both busy with their program at Tasik Puteri, Rawang. May Allah bless them with their good doings there. I heard they going to cook as well! I hope I can go there when I get back. Insyaallah when I have done my report. :)

Thursday, March 24, 2011

EYE SORE SORRY :P

Okay... Table below is created to make my viewer's life easier. I know that it is an eye sore when everything is written in essay form.. But please remember that the other 2 red wires from the stepper motor (unipolar) is connected to 5V. Then your stepper motor is ready to go! :)
                                                                             

Wednesday, March 23, 2011

AWESOME STEPPER MOTOR!!! :D

Alhamdulillah, our prayers and hard confusing moments of stepper motor have passed! Thanx to our lecturer of medical subject, sir Zul, who has giving us hard 2 hours of agonizing torture, brainstorms and much more to use stepper motor with our UNO. Okay, I am so excited to write about this post, I don't even know where to start. XD 

Okay firstly, we have to know what is the stepper motor that we're about to use. For our project, we use unipolar stepper motor, with 6 wires, colored with 2 reds, orange, yellow, brown and black. The 2 reds is actually the power wire, so it'll be connected to Vin at Arduino. We also have to bear in mind that these color coding are different according to it's manufacturer or country where it's made. (ahah!!! I bet you're just as shocked as I am when I found out about this!) 


Figure 1: Unipolar stepper motor, schematic diagram 

Then, the other 4 wires are determined by the stepper constructions at this one blog sir Zul has given us, found by him in the internet, and can be connected to the H bridge, used to control the motions of it's sequences. I cannot find the links that my lecturer gave me, but I am sure I remember how those wire are connected to the H bridge.

The H bridge is actually transistors to control the movements of the stepper motor, forward or backwards. the H-bridge is so named because it has four switching elements at the "corners" of the H and the motor forms the cross bar. The H bridge that we used to control our stepper motor is L293. The schematic diagram is shown as the figure below. 

Image: Courtesy of Texas Instrument Datasheet. 
Figure 2: L293 (H-bridge circuit diagram). 

So, pin 3 and 6 and connected to: black and yellow and pin 11 and 14 are connected to orange and brown respectively. Then, pin 4,5,12 and 13 are joined together and connected to pin GND at UNO. Pin 16 and 2 red wires are joined and connected to 5V at UNO, and pin 8, 9 and 1 are connected to 5V. Then, lastly connect pin 7 to 11, pin 2 to 10, pin 15 to 9, and pin 10 to  at the UNO. 

After all these wires are connected, upload these sketches to your ARDUINO. 




#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 100
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
void setup(){  // set the speed of the motor to 30 RPMs  
stepper.setSpeed(20);
}
void loop()
{
  stepper.step(1*STEPS);
  delay(2000);
  stepper.step(-1*STEPS);
  delay(2000);
}


The above sketches is from sir zul also... Check out the video below, You'll understand what it's doing.




So, there you go, our stepper motor for infusion pump configures... Only next we have to determine what is the flow rate and connects the motor to a gear to push the tube. I hope we can get this all done by the end of the month. Wish us all the luck in the world!!! Insyaallah!!! :)