Friday, 27 March 2015

FYP2 - Week 7

WHY USING SOLENOID?



Solenoids are basically electromagnets: they are made of a big coil of copper wire with an armature (a slug of metal) in the middle. When the coil is energized, the slug is pulled into the center of the coil. This makes the solenoid able to pull from one end.

This solenoid in particular is nice and strong, and has a slug with a slanted cut and a good mounting bracket. It's basically an electronic lock, designed for a basic cabinet or safe or door. Normally the lock is active so you can't open the door because the solenoid slug is in the way. It does not use any power in this state. When 9-12VDC is applied, the slug pulls in so it doesn't stick out anymore and the door can be opened.

The solenoids come with the slanted slug as shown above, but you can open it with the two Phillips-head screws and turn it around so its rotated 90, 180 or 270 degrees so that it matches the door you want to use it with.

You will need a fairly good power supply to drive a solenoid, as a lot of current will rush into the solenoid to charge up the electro-magnet, about 500mA, so don't try to power it with a 9V battery!


TECHNICAL DETAILS
  • 24 DC operation (you can use 9-24 DC volts, but lower voltage results in weaker/slower operation)
  • Push or pull type with 5.5 mm throw
  • DC coil resistance: 100 ohms
  • 5 Newton starting force (24VDC)
  • 1.4 oz / 39 grams




When an electrical current is passed through the coils windings, it behaves like an electromagnet and the plunger, which is located inside the coil, is attracted towards the centre of the coil by the magnetic flux setup within the coils body, which in turn compresses a small spring attached to one end of the plunger. The force and speed of the plungers movement is determined by the strength of the magnetic flux generated within the coil.

When the supply current is turned “OFF” (de-energised) the electromagnetic field generated previously by the coil collapses and the energy stored in the compressed spring forces the plunger back out to its original rest position. This back and forth movement of the plunger is known as the solenoids “Stroke”, in other words the maximum distance the plunger can travel in either an “IN” or an “OUT” direction, for example, 0 – 30mm.



Linear solenoids are useful in many applications that require an open or closed (in or out) type motion such as electronically activated door locks, pneumatic or hydraulic control valves, robotics, automotive engine management, irrigation valves to water the garden and even the “Ding-Dong” door bell has one. They are available as open frame, closed frame or sealed tubular types.

Thursday, 12 March 2015

FYP2 - Week 6

TESTING CONTROLED LED AS SOLENOID IN ARDUINO WEB SERVER 


I wanted to investigate controlling the digital outputs on a Arduino from a webpage so I decided to build a simple setup to Turn a LED on and off from a webpage. For this project I used the Arduino Uno R3 and Arduino Ethernet Shield.


First off we need to configure the web server  this is done by calling the Ethernet libraries, setting the Mac Address, IP Address and Server Port. then in the Void Setup you start the server and define the pin you want to plug the LED into.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0, 2);

EthernetServer server(80);

void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
Ethernet.begin(mac, ip);
server.begin();

}

In the Void Loop we define client then check that the web server is connected and available the get it to display some HTML. The first lot checks the status of pin 8 and prints HTML to tell us if the LED is currently turned on or off. Then we use a HTML form to make some radio buttons and a submit button to select the status on or off.

if (digitalRead(8)){
client.print(” LED is <font color=’green’>ON</font>”);
}else{
client.print(” LED is <font color=’red’>OFF</font>”);
}
client.println(“<br />”);

client.print(“<FORM action=\”http://192.168.1.177/\” >”);
client.print(“<P> <INPUT type=\”radio\” name=\”status\” value=\”1\”>ON”);
client.print(“<P> <INPUT type=\”radio\” name=\”status\” value=\”0\”>OFF”);
client.print(“<P> <INPUT type=\”submit\” value=\”Submit\”> </FORM>”);

break;

}

Now all that is left is to read the input from the HTML Form and turn the led on or off. When you select one of the radio buttons and click submit the form adds a status=1 or status=0 to the end of the URL. We can now use the GET function to read the value and run through am IF statement to set the digital write on pin 8 to either High or Low (On or Off).

if (c == ‘\n’) {

currentLineIsBlank = true;
buffer=”";
} else if (c == ‘\r’) {
if(buffer.indexOf(“GET /?status=1″)>=0)
digitalWrite(8,HIGH);

if(buffer.indexOf(“GET /?status=0″)>=0)
digitalWrite(8,LOW);
}

else {
After create HTML form, the web server will look like this

Before click the on LED

After click the ON the LED in red led




Wednesday, 4 March 2015

FYP2 - Week 5

Briefing #1 FYP2 Degree

The briefing is about to give some explanation for the students who are taking the Final Year Project for Diploma and Degree programmed. The briefing is about:
  •  Introduction
  • Objectives
  • Credits and duration
  • Scope of projects
  • Title selection
  • Project Assessment
  • Presentation day
  •  Submission date of project

Wednesday, 25 February 2015

FYP2 - Week 4(2)

Result form previous post of SD Card
  • Copy the coding sketch in previous post and paste it into the Arduino IDE. 
  • Change the IP address in the sketch to match the IP address range of your network.
  • Your hardware must be set up as described in previous of this tutorial.
  • Load the sketch to the Arduino and then open a web browser on a computer that is connected to the same network as the Arduino.
  • Surf to the Arduino by typing the IP address of the Arduino into the URL field of the browser, e.g. 192.168.0.2 

The Web Server should display a web page as shown below.





Important Note!
  • If an uninitialized SD card is left in the SD card socket of the shield, it can cause problems with code in the sketch that is accessing the Ethernet chip. This may cause symptoms such as the sketch running once or twice, then hanging up.
  • This is because both the Ethernet chip and the SD card are accessed by the Arduino using the same SPI bus.
  • If the SD card is not being used with an Ethernet application, either remove it from the socket or add the following code to disable the SD card


Tuesday, 24 February 2015

FYP2 - Week 4

Test the SD card in the Ethernet shield

The Arduino Uno board and official Arduino Ethernet shield are used. The Ethernet shield contains the WIZnet W5100 Ethernet chip. To set up the hardware, first plug the Arduino Ethernet shield into the Arduino board and then plug a micro SD card into the SD card socket of the Ethernet shield. Power the Arduino from a USB cable plugged into the host PC computer.

The Arduino, Arduino Ethernet shield and micro SD card are used to make a web server that hosts a web page on the SD card. When a browser requests a web page from the Arduino web server, the Arduino will fetch the web page from the SD card.

Creating the Web Page
Because the web page is to be stored on the SD card, it must first be created using a text editor and then copied to the SD card.

Web Page
Create the following web page in a text editor. When you save the text file, give it the name: index.htm


<!DOCTYPE html>
<html>
    <head>
        <title>Arduino SD Card Web Page</title>
    </head>
    <body>
        <h1>Hello from the Arduino SD Card!</h1>
        <p>A web page from the Arduino SD card server.</p>
    </body>
</html>


Nothing new here, it is the same as the web page from the first web server in this tutorial with just the text changed. Test this web page by opening it in a web browser
.
Copying the Web Page
You will need a micro SD card slot on your computer or a card reader that is capable of reading and writing a micro SD card.

Insert the micro SD card into the slot on the computer or card reader that is plugged into the computer and copy the index.htm file to the micro SD card.

Now plug the SD card into the micro SD card slot on the Ethernet shield.


SD Card Web Server

Hardware
You should now have the micro SD card with web page copied to it inserted into the card slot on the Arduino Ethernet shield. The Ethernet shield should be plugged into a compatible Arduino and into an Ethernet cable connected to your network. The Arduino / Ethernet shield should be powered from a USB cable.

Arduino Sketch
The Arduino sketch that fetches the web page from the SD card and sends it to the browser is shown below.


#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 2); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

File webFile;

void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for debugging
   
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    webFile = SD.open("index.htm");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                }
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}


Using the Sketch
Copy the above sketch and paste it into the Arduino IDE. Load the sketch to the Arduino and then surf to the IP address set in the sketch with your web browser. The web page that you created should be displayed in the browser as it is served up by the Arduino SD card web server.


Friday, 20 February 2015

FYP2 - Week 3

WEB SERVER EXAMPLE

The WebServer example sketch found in the Arduino software (found under File → Examples → Ethernet → WebServer – already covered in the article Plugging In and Testing the Arduino Ethernet Shield) actually does not conform to the full HTML page structure, but instead places text directly between the opening and closing <html> tags.


In the WebServer example, each line is ended with a line break so that the next line is shown below the previous line in the browser. The following image shows the output of the WebServer sketch in the browser and the HTML code used to produce the output text.


Arduino uno attach with DFRduino Ethernet Shiled

The Web Server and the coding 

Router as a wireless


Friday, 13 February 2015

FYP2 - Week 2 (2)

This function is to plug the Arduino Ethernet shield into an Arduino Uno, then connect it to an Ethernet cable and finally test whether the Ethernet shield is working or not. These are the first things that people need to do after buying an Arduino Ethernet shield for the first time.






But, in this case, I use DFRduino Ethernet Shield. This new version Arduino Ethernet shield which is DFRduino Ethernet Shield V2 supports Mega both 1280 and 2560 and also supports SD card read/write as well.  The V2 Ethernet Shield is fully compatible with Ardunio Ethernet Shield. People can do exactly the same thing as the original one and more affordable price.