8 April 2012

week 11


8 APRIL 2012

This week, i start focusing on PCB layout for stand alone Arduino (for timer display and alarm). 
I choose to design my layout in DipTrace software. At first, it is hard to start, as i'm not familiar with this software. But, in few hours time, i know where to find the component, draw the connection and make my own component hole for the component those i can't find. It takes almost four hours for me to complete the layout; but i'm proud because i manage to do it myself. =)
Here, i attach the complete layout:


  
This layout consists of: 
- Atmega 328
- LED
- Resistors
- Crystal Oscillator
- Capacitor
- Voltage Regulator
- Push button switch
- Buzzer
- LCD


Besides doing this layout, this week, i'm also focusing on the Arduino timer program. I have tried few program, But it is hard to find like i want. Finally, i found this one program and after some modification, i manage to run a timer. =)
Below is the simple process:



Parts List :
1) 1x 16×2 parallel LCD display (compatible with Hitachi HD44780 driver)
2) 1x Arduino
3) 1x 10kΩ potentiometer
4) 1x 10kΩ resistor
5) 1x switch
6) Jumper wire

Instruction :
1) Connect all jumper wire as shown in diagram.







2) Connect digital input from switch to digital pin 2.

3) Upload this code to your Arduino



#include <LiquidCrystal.h> 

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 
int ledPin = 13;                    // LED connected to digital pin 13
int buttonPin = 2;                  // button on pin 2
 
int value = LOW;                    // previous value of the LED
int buttonState;                    // variable to store button state
int lastButtonState;                // variable to store last button state
int blinking;                       // condition for blinking - timer is timing
int frameRate = 100;                // the frame rate (frames per second) at which the stopwatch runs - Change to suit
long interval = (1000/frameRate);   // blink interval
long previousMillis = 0;            // variable to store last time LED was updated
long startTime ;                    // start time for stop watch
long elapsedTime ;                  // elapsed time for stop watch
int fractional;                     // variable used to store fractional part of Frames
int fractionalSecs;                 // variable used to store fractional part of Seconds
int fractionalMins;                 // variable used to store fractional part of Minutes
int elapsedFrames;                  // elapsed frames for stop watch
int elapsedSeconds;                 // elapsed seconds for stop watch
int elapsedMinutes;                 // elapsed Minutes for stop watch
char buf[10];                       // string buffer for itoa function
 
void setup()
{
  lcd.begin(16, 2);                // intialise the LCD.
  pinMode(ledPin, OUTPUT);         // sets the digital pin as output
  pinMode(buttonPin, INPUT);       // not really necessary, pins default to INPUT anyway
  digitalWrite(buttonPin, HIGH);   // turn on pullup resistors. Wire button so that press shorts pin to ground.
}
 
void loop(){
  digitalWrite(ledPin, LOW);            // Initiate LED and Step Pin States
 
  buttonState = digitalRead(buttonPin); // Check for button press, read the button state and store
 
// check for a high to low transition if true then found a new button press while clock is not running - start the clock    
   if (buttonState == LOW && lastButtonState == HIGH  &&  blinking == false){
    startTime = millis();                               // store the start time
      blinking = true;                                  // turn on blinking while timing
      delay(10);                                         // short delay to debounce switch
      lastButtonState = buttonState;                    // store buttonState in lastButtonState, to compare next time 
   }
 
// check for a high to low transition if true then found a new button press while clock is running - stop the clock and report
   else if (buttonState == LOW && lastButtonState == HIGH && blinking == true){
   blinking = false;                                    // turn off blinking, all done timing
   lastButtonState = buttonState;                       // store buttonState in lastButtonState, to compare next time
 
// Routine to report elapsed time            
   elapsedTime =   millis() - startTime;                // store elapsed time
   elapsedMinutes = (elapsedTime / 60000L);
   elapsedSeconds = (elapsedTime / 1000L);              // divide by 1000 to convert to seconds - then cast to an int to print
   elapsedFrames = (elapsedTime / interval);            // divide by 100 to convert to 1/100 of a second - then cast to an int to print
   fractional = (int)(elapsedFrames % frameRate);       // use modulo operator to get fractional part of 100 Seconds
   fractionalSecs = (int)(elapsedSeconds % 60L);        // use modulo operator to get fractional part of 60 Seconds
   fractionalMins = (int)(elapsedMinutes % 60L);        // use modulo operator to get fractional part of 60 Minutes
   lcd.clear();                                         // clear the LDC
 
 if (fractionalMins < 10){                            // pad in leading zeros
      lcd.print("0");                                 // add a zero
      }
 
    lcd.print(itoa(fractionalMins, buf, 10));       // convert the int to a string and print a fractional part of 60 Minutes to the LCD
      lcd.print(":");                                 //print a colan. 
 
 if (fractionalSecs < 10){                            // pad in leading zeros
      lcd.print("0");                                 // add a zero
      }
 
 lcd.print(itoa(fractionalSecs, buf, 10));          // convert the int to a string and print a fractional part of 60 Seconds to the LCD
   lcd.print(":");                                    //print a colan. 
 
 if (fractional < 10){                                // pad in leading zeros 
      lcd.print("0");                                 // add a zero
      }     
 
 lcd.print(itoa(fractional, buf, 10));              // convert the int to a string and print a fractional part of 25 Frames to the LCD
   }
 
 else{
      lastButtonState = buttonState;                  // store buttonState in lastButtonState, to compare next time
   }
 
// run commands at the specified time interval
// blink routine - blink the LED while timing
// check to see if it's time to blink the LED; that is, the difference
// between the current time and last time we blinked the LED is larger than
// the interval at which we want to blink the LED.
 
 if ( (millis() - previousMillis > interval) ) {
 
    if (blinking == true){
       previousMillis = millis();                    // remember the last time we blinked the LED
 
       digitalWrite(ledPin, HIGH);                   // Pulse the LED for Visual Feedback
 
       elapsedTime =   millis() - startTime;         // store elapsed time
         elapsedMinutes = (elapsedTime / 60000L);      // divide by 60000 to convert to minutes - then cast to an int to print
         elapsedSeconds = (elapsedTime / 1000L);       // divide by 1000 to convert to seconds - then cast to an int to print
         elapsedFrames = (elapsedTime / interval);     // divide by 40 to convert to 1/25 of a second - then cast to an int to print
         fractional = (int)(elapsedFrames % frameRate);// use modulo operator to get fractional part of 25 Frames
         fractionalSecs = (int)(elapsedSeconds % 60L); // use modulo operator to get fractional part of 60 Seconds
         fractionalMins = (int)(elapsedMinutes % 60L); // use modulo operator to get fractional part of 60 Minutes
         lcd.clear();                                  // clear the LDC
 
       if (fractionalMins < 10){                     // pad in leading zeros
         lcd.print("0");                             // add a zero
         }
 
       lcd.print(itoa(fractionalMins, buf, 10));   // convert the int to a string and print a fractional part of 60 Minutes to the LCD
         lcd.print(":");                             //print a colan. 
 
       if (fractionalSecs < 10){                     // pad in leading zeros 
         lcd.print("0");                             // add a zero
         }
 
       lcd.print(itoa(fractionalSecs, buf, 10));   // convert the int to a string and print a fractional part of 60 Seconds to the LCD
         lcd.print(":");                             //print a colan. 
 
       if (fractional < 10){                         // pad in leading zeros 
         lcd.print("0");                             // add a zero
         }
          lcd.print(itoa((fractional), buf, 10));  // convert the int to a string and print a fractional part of 25 Frames to the LCD
         }
 
    else{
          digitalWrite(ledPin, LOW);            // turn off LED when not blinking 
          }
 }
 
}

:: Its works, and this is the result:



3 April 2012

Synchronous motor


A synchronous electric motor is an AC motor in which the rotation rate of the shaft is synchronized with the frequency of the AC supply current; the rotation period is exactly equal to an integral number of AC cycles. Synchronous motors contain electromagnets on the stator of the motor that create a magnetic field which rotates in time with the oscillations of the line current. The rotor turns in step with this field, at the same rate.

The speed of the synchronous motor is determined by the number of magnetic poles and the line frequency. Synchronous motors are available in sub-fractional self-excited sizes to high-horsepower direct-current excited industrial sizes.

Advantage of synchronous motor:

  • Speed is independent of the load, provided an adequate field current is applied.
  • Accurate control in speed and position using open loop controls, e.g. stepper motors.
  • They will hold their position when a DC current is applied to both the stator and the rotor winding.
  • Their power factor can be adjusted to unity by using a proper field current relative to the load. Also, a "capacitance" power factor, (current phase leads voltage phase), can be obtained by increasing this current slightly, which can help achieve a better power factor correction for the whole installation.
  • Their construction allows for increased electrical efficiency when a low speed is required (as in ball mills and similar apparatus).
  • They run either at the synchronous speed or they do not run at all.



Outline drawing


Specification:


Features:


1. Miniature in size but delivers high torque. 
2. Low noise and smooth revolution.
3. Motor rotation: freely. It can be CW or CCW. If need it to turn just in one direction, can add a
directional plate. In this case, the motor rotation would be irreversible.
4) Long life (more than 8,000 hours), low noise [less than 40dB (A)], low temperature rising (less than 60K), and high torque.










2 April 2012

week 10


2 APRIL 2012



It’s time for me to focus on the motor and pump. For the guideline, first of all, I plan again my block diagram. Here is my block diagram:



This project requires motor and pump for the main operation.  So, from the block diagram, when power supply is switch on, it will activate air pump which will suck air from environment and delivered it to the valve. Air pump is controlled by pressure controller. I’m using variable resistor 50K to control the pressure of air pump. When variable resistor is turn to the maximum, it will give high pressure of air through the valve, to the mattress and vice verse.

Valve; which the rotation is controlled by motor will delivered the air through two tubes to the mattress. Here come the difficulties for me to choose the best motor to rotate the valve. These valves have three chambers; which one of it is from the air pump, and another two I connect to the mattress by tube.  When the motor rotate, it wills also rotating the valve. So, each time only one chamber to the mattress will open to deliver air to the mattress. The other chamber will not delivered air. After half cycle, the other chamber opens to delivered air, and vice versa. This will generate alternating flow to the mattress.

Valve: after half cycle each valve will open to delivered air

Three chamber valve. 1 from air pump; the other 2 to the mattress

Finally, I decided not to use Stepper motor, and choose synchronous brush less DC motor to rotate the valve. It is because, the operation of both motor is similar; but stepper requires programming for it to operate; which requires more time to explore and troubleshoot. Later I’ll explain the specification of the synchronous motor. =)

27 March 2012

week 9


27 MARCH 2012

After attending Arduino workshop last week, I tried to do simple buzzer program. This buzzer is planned to be insert in my timer. The purpose is, after certain time, for example, 2 minutes, the buzzer will sound. I set it 2 minutes time is just for demo on the presentation day. For real application, I will set the buzzer to sound after 8 hours. It is to alert user to switch off the supply and rest the motor for few hours before start use it again. The existing ripple mattress doesn’t have this function. What makes it cross my mind to add these features is, in real world, nurses at hospitals or users often forget to switch off the supply. This could damage the motor; and reduce its lifetime if use in 24 hours continuously.

First of all, I construct simple buzzer circuit
    - Connect a wire (blue wire in photo below) from pin 4 to the breadboard.
         - Connect the other side of the wire to the 100R resistor.
        - Connect the 100R resistor to the buzzer.
        - Connect the buzzer to the other (yellow in photo) wire.
       - Connect the wire to the GND pin on the Arduino. 

     so, in order to start programming using Arduino software, we have to install the software in our laptop. Just follow the installation instruction by clicking “Next” until “Finish”.  Then, follow this simple instruction: 

     1)  Check Arduino ports at our Control Panel. Click System.


     2)  In System Properties, click Hardware, then Device Manager
  

    3)  In Device Manager, see under Ports (COM & LPT). Make sure the ports to      be set in the Arduino are the same as appear in Device Manager. for example, in the device manager shows COM19,same as in Arduino.



    
    Don't forget to set Arduino Uno board (refer to the board that you use) in Tools. 





    Here, i provide the example of 2 minutes program. To test the program, we have to compile it by click upload symbol à

  
     Here is the result:













19 March 2012

ARDUINO WORKSHOP BY SIR ZUL


18 MARCH 2012


This weekend, Medical Section committee conducted Arduino workshop. It is open for any course, but targeted especially for FYP student. There is lots of things that we get from this workshop as it is conducted for the beginners ; from Introduction to Arduio, how to install the software, run simple program such as running LED and switches, be guided line-by-line and the important command that should have in the programming and many more.  
we also being provided with CD that consists of Arduino e-book, example of program, power point notes, support program such as Fritzing and Toolduino software.  


Here is some interesting point that can be highlighted through out these workshop:

ABOUT ARDUINO:

Arduino is great because it can give you results right away, and quickly build your confidence and understanding. Confidence is the only real currency of innovation after all. Once you have that, you can move on to more sophisticated projects. But without an easy-to-understand entry point, you’ll never get there at all.


  •       It's an open-source physical computing platform based on a simple micro-controller board, and a development environment for writing software for the board.
  •       Arduino projects can be stand-alone, or they can be communicate with software running on your computer (e.g. Flash, Processing, Max MSP.)

  •       The boards can be assembled by hand or purchased pre-assembled; the open-source IDE can be downloaded for free. 
SPECIFICATIONS OF ARDUINO:
  •        Microcontroller: ATmega328
  •        Operating Voltage: 5V
  •        Input Voltage (recommended): 7-12V
  •        Input Voltage (limits): 6-20V
  •        Digital I/O Pins: 14 (of which 6 provide PWM output)
  •        Analog Input Pins: 6
  •        DC Current per I/O Pin: 40 mA
  •        DC Current for 3.3V Pin: 50 mA
  •        Flash Memory: 32 KB (ATmega328) of which 0.5 KB used by bootloader
  •        SRAM: 2 KB (ATmega328)
  •        EEPROM: 1 KB (ATmega328)
  •        Clock Speed: 16 MHz
Runs on: Windows, Mac OS X, Linux
Languages: Wiring/Arduino, C/C++
Getting Started guides: Clear step-by-step instructions, from download to blinking LED.
Knowledge base:
• Many simple examples included with download
• Good reference guide to the commands
• Large knowledge base on Arduino site and elsewhere
Advantage:
• Can be run as I/O board, using Firmata firmware
• Very large knowledge base
• Simple language, but expandable using C/C++
• Multiple models, for shields, breadboards, wearable, extra I/O pins
• Many shield modules
• Large number of open source derivative boards
Disadvantage:
• C language constructs (semicolons, brackets, case sensitivity) are confusing

:: Arduino also can be stand alone. it is impossible for FYP student to attach Arduino board in their project. so, to make it stand alone, it just requires two capacitors, and oscillator; connected Atmega 328P and 5V supply. 



NOTE: I can try applying Aduino in my project to add function such as alarm if the tube disconnect from the mattress, or add LCD display; for example, to display amount of pressure delivered into or sucked out of the mattress.    

12 March 2012

week 8


 12 march 2012



As i have mention before, i think stepper has the best characteristic to be use in my project. so, i learn more about stepper this week. Stepper has many types. we have to choose it based on number of step that it produce. 








First of all, I simply choose a stepper with 50 number of step. There are six wires emerging from the stepper motor: two red, two yellow, and two grey. We will call the wires R1, Y1, G1, R2, Y2, and G2 where the letter is the first letter of the wire's color and the number is to differentiate them. The next step is, measuring the resistance to determine the connection. Systematically we connected the testing leads of the multimeter to pairs of wires coming out from the stepper motors and put the measured results into the following simple table:



R1
R2
G1
G2
Y1
Y2
R1

-
117
-
117
-
R2
-

-
117
-
117
G1
117
-

-
234
-
G2
-
117
-

-
236
Y1
117
-
234
-

-
Y2
-
117
-
234
-

    All of the above results are measurements taken in Ohms. Infinite resistance is represented by a '-'. 

Where the resistance between two wires is infinite we know there is no connection between those two wires within the stepper motor. For example, between R1 and R2 or G1 and G2. We have two different values of resistance between the other wires - 117 Ohms and 234 Ohms with one being half of the other. This is because this stepper motor has four phases and therefore four identical coils. When the resistance measured between two wires is 117 Ohms, the wires are connected across one coil, and when the resistance is 234 Ohms the wires are connected across two coils.

R1 is connected to G1 and Y1 across one coil. R2 is connected to G2 and Y2 across one coil. G1 and Y1 are connected across two coils, and G2 and Y2 are connected across two coils. None of the 2's are connected to any of the 1's. Therefore we can draw the following simple diagram of the wiring of this stepper motor:
Stepper Motor Wiring Diagram

The four live wires are G1, G2, Y1, and Y2, and there are two common wires R1 and R2


Here i attached some picture as for reference:
.




Now, I know how to connect stepper motor and do simple programming to test it. =) 



2 March 2012

week 7


1st of March


Nothing much i can do this week as it is a phase tests week. 


I didn't have much time to have a discussion with Mdm. Naza as the time is quite limited. But i do meet her in a short period to discuss about using two motor; based on Sir Zubir suggestion. So, one is for pumping air and the other for sucking. 


Mdm Naza advise me to do more research regarding the motor.Yes, it is not efficient to use two motor just for pumping and sucking the air. I need to research more about this. 


Next week will be mid-term break.. I plan to come back earlier to complete my project. but then, all Medical Section staff are not around for the entire week. =(
So, i'll proceed with my research regarding selection of pump and motor.