Giỏ hàng
Danh mục sản phẩm

Lập Trình Mobus Biến tần Omron 3G3JZ Arduino PLC Công nghiệp

Đăng bởi Trần Văn Bùi ngày bình luận

Lập Trình Mobus Biến tần Omron 3G3JZ  Arduino PLC  Công nghiệp
Hôm nay mình giới thiệu cơ bản modbus Biến tần Omron
Đầu tiên các bạn cài đặt biến tần chế độ modbus 

Các bạn vào mục N2.01 Cài Chế độ 3 hoặc 4 

Tiếp tục các bạn vào chế độ N9.00-N9.05 để cài đặt địa chỉ và baud

Sơ đồ kết nối Biến tần 

Chân RJ45 chân 4P A- ,5P -B

Tiếp tục các bạn dùng USB TO COM dùng phần mền modbus POlll để kết nối biến tần 

Modbus gồm 2 hàm 03H và 10H 

Với hàm 10H đổi mã DEC chính 16

Mã Modbus giá trị thanh ghi

giá trị Thanh ghi 16 chính 40001-50000

Trên biến tần các bạn quan tâm 2 biến Thanh ghi 2101H và 2102H

Trong đó giá trị 00=0 STOP,01=01 quau thuận ,10=2;Quan ngược,11=3 stop;

Về chương trình các bạn cài thư viện sau 

https://www.arduinolibraries.info/libraries/modbus-master

#include <ModbusMaster.h>

/*!
  We're using a MAX485-compatible RS485 Transceiver.
  Rx/Tx is hooked up to the hardware serial port at 'Serial'.
  The Data Enable and Receiver Enable pins are hooked up as follows:
*/


// instantiate ModbusMaster object
ModbusMaster node;
//ModbusMaster node1;

#define CW A13
#define CCW A12
#define STOP A11 
#define LED_CW 34
#define LED_CCW 33 
#define LED_STOP 32 
#define LED_PWM 45
void setup()
{
 node.begin(1, Serial2);//SALVE 1 
   pinMode(CW, INPUT);
     pinMode(CCW, INPUT);
       pinMode(STOP, INPUT);
        pinMode(LED_CW, OUTPUT);
         pinMode(LED_CCW, OUTPUT);
          pinMode(LED_STOP, OUTPUT);
          pinMode(LED_PWM, OUTPUT);
Serial.begin(9600);
  // Modbus communication runs at 115200 baud
  Serial2.begin(9600,SERIAL_8E1);

  // Modbus slave ID 1
  
  //node1.begin(2, Serial1);
  // Callbacks allow us to configure the RS485 transceiver correctly
  
}

bool state = true;
  int sensorValue=0;
int  i=0;//CHIỀU QUAY 2 10 ,1 01 0 00
int  i1=0;//TẦN SỐ
void loop()
{
  
  uint8_t j, result;
  uint16_t data[6];
   
   if(digitalRead(CW)==0){  i=1; Serial.println(i);digitalWrite(LED_CW, HIGH);digitalWrite(LED_CCW,LOW);digitalWrite(LED_STOP ,LOW);  }//Chiều quay thuận tần biến tần
    if(digitalRead(CCW)==0 ) {i=2;Serial.println(i);digitalWrite(LED_CW, LOW);digitalWrite(LED_CCW,HIGH);digitalWrite(LED_STOP ,LOW);}//Chiều quay Ngược tần biến tần
      if(digitalRead(STOP)==0){ i=0;Serial.println(i);digitalWrite(LED_CW, LOW);digitalWrite(LED_CCW,LOW);digitalWrite(LED_STOP ,HIGH);}//Dừng Motor 
  // set word 0 of TX buffer to least-significant word of counter (bits 15..0)
  node.setTransmitBuffer(0, i);//SEND 8449 
  sensorValue = analogRead(A0);
   analogWrite(LED_PWM, sensorValue/4);

 //  Serial.println(sensorValue);
  // set word 1 of TX buffer to most-significant word of counter (bits 31..16)
  node.setTransmitBuffer(1,sensorValue*3);//SEND 8450 
 //  node.setTransmitBuffer(2,i1);


  // slave: write TX buffer to (2) 16-bit registers starting at register 0
   result = node.writeMultipleRegisters(8449, 2);//SEND 8449 LEN 2
 //   result = node.writeMultipleRegisters(10, 20);
   // result = node.writeMultipleRegisters(20, 30);
  // slave: read (6) 16-bit registers starting at register 2 to RX buffer
//  result = node.readHoldingRegisters(2, 6);

  // do something with data if read is successful

}

ở đây Chúng ta quan tâm đến 2 thanh 2101H=8449 Chạy và chiều quay ;và 2102H=8450 tần số 

Cảm ơn các bạn đã ghé  thăm shop .

 

 

 


Cũ hơn Mới hơn