การทำงานของ PLC ทำงานโดยการสแกน (SCAN) โปรแกรมอย่างต่อเนื่อง การ SCAN 1 รอบจะประกอบด้วยขั้นตอนที่สำคัญ 3 ขั้นตอน (อาจจะมีมากว่า 3 ข้ันตอนก็ได้) ดังภาพ
ขั้นตอนที่ 1 ตรวจสอบสถานะของอินพุท
ขั้นแรก PLC จะตรวจสอบอินพุตแต่ละอินพุตว่ามีสถานะ ON หรือ OFF โดยจะทำการตรวจสอบดูว่า Sensor ที่ต่ออยู่กับอินพุตตัวแรกว่ามีสถานะเป็นอย่างไรแล้วจึงตรวสอบที่อินพุตตัวที่ 2 และ 3 ไปเรื่อยๆ จากนั้นจะทำการบันทึกข้อมูลที่ได้ลงในหน่วยความจำเพื่อจะใช้ในขั้นตอนต่อไป
ขั้นตอนที่ 2 การประมวลผลของโปรแกรม
ขั้นตอนนี้ PLC จะทำการประมวลผลตามโปรแกรมที่ได้เขียนขึ้นโดยจะทำเพียงคำสั่งละครั้ง ตัวอย่างเช่น ตัวโปรแกรมอาจจะบอกว่า "ถ้าอินพุตแรกมีสถานะเป็น ON จากนั้นจะ ทำให้เอาต์พุตแรกมีสถานะ ON" เนื่องจากเรารู้มาแล้วว่าอินพุตมีสถานะ ON หรือ OFF จากขั้นตอนที่แล้ว ดังนั้นจึงทำให้ PLC สามารถตัดสินใจได้ว่าเอาต์พุตแรกควรจะมีสถานะ เป็นอย่างไร จากนั้นก็จะเก็บผลที่ได้จากการประมวลผลไว้ในหน่วยความจำเพื่อใช้ในขั้นตอนต่อไป
ขั้นตอนที่ 3 ปรับปรุงสถานะของเอาต์พุต
ขั้นตอนสุดท้ายคือ PLC จะทำการปรับปรุงสถานะของเอาต์พุด โดยในการปรับปรุงค่าสถานะของเอาต์พุตนี้จะขึ้นอยู่สถานะ ของอินพุตที่ได้มาจากขั้นตอนแรกและผลจากการประมวลผลตามโปรแกรมในช่วงขั้นตอนที่สอง
หลังจากเสร็จขั้นตอนที่สามแล้ว PLC จะกลับไปที่ขั้นตอนที่ 1 และทำซ้ำไปเรื่อยๆอย่างต่อเนื่อง ซึ่งนอกจากเหนือจากขั้นตอนทั้งสามนี้แล้ว PLC อาจจะใช้เวลาในการติดต่อสื่อสารกับอุปกรณ์อื่นๆ หรือตรวจสอบสถานการณ์ทำงานต่างๆ ซึ่งไม่มีนัยยะสำคัญมากนัก
ดังนั้น 1 scan time จะหมายถึงเวลาที่ใช้ไปในการทำงานตามขั้นตอนหลักทั้ง 3 ที่ได้กล่าวมา
รับทำ project เขียนโปรแกรม Microcontroller PLC Crack Omron Mitsubishi Siemens ทุกชนิด WinCC SCADA ทัชกรีน HMI WinCC Flexible automation control system ทำระบอิเล็กทรอนิกส์ โปรเจคจบของนักศึกษา โดยทีมงานวิศวกรคุณภาพ id line: @vrautomation Email:sales.vrautomations@gmail.com Tel. 083-848-8314
วันพุธที่ 14 พฤษภาคม พ.ศ. 2557
วันอังคารที่ 13 พฤษภาคม พ.ศ. 2557
Project Arduino Bluetooth Servo Motor Control
หลักการทำงาน

Wiring Digaram

Arduino Code

Wiring Digaram

Arduino Code
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
int motor = 0;
void setup()
{
Serial.begin(9600); // initialize serial:
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.print("Arduino control Servo Motor Connected OK");
Serial.print('\n');
}
void loop()
{
// if there's any serial available, read it:
while (Serial.available() > 0) {
// look for the next valid integer in the incoming serial stream:
motor = Serial.parseInt();
// do it again:
pos = Serial.parseInt();
// look for the newline. That's the end of your sentence:
if (Serial.read() == '\n') {
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
// print the three numbers in one string as hexadecimal:
Serial.print("Data Response : ");
Serial.print(motor, DEC);
Serial.print(pos, DEC);
}
}
}
//for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
//{ // in steps of 1 degree
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
//}
//for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
//{
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
//}
//val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
//val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
//myservo.write(val); // sets the servo position according to the scaled value
//delay(15);
App Andorid
ขอบคุณ http://microcontrollerkits.blogspot.com/2014/01/arduino-usb-control-servo-motor.html
