Project tutorial
IEncode - Intelligent Encoder for Industrial Motors

IEncode - Intelligent Encoder for Industrial Motors © CC BY-SA

Predictive maintenance of industrial motors using high precision 3D magnetic sensor TLV493D-A1B6.

  • 914 views
  • 0 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

IEncode stands for Intelligent Encoder. First, let me explain what is an encoder. Encoders are nothing but sensors which can convert mechanical movements such as linear or rotational motion to electric signal. This signal is used as feedback for closed loop motor control system.

What motivated me to do this project?

When I applied my idea to the Infineon contest it was about a smart remote but it failed to get free sensor kit which had built-in microcontroller. But I never give up, I bought only the sensor TLV493D AB16 through element14.com to continue my expedition with 3D magnetic sensor. Recently I started working on a 6 DoF robotic arm which was driven by servo motors. In order to control this arm with ROS (Robot OS) I should use URDF model of it and should feed joint angles as input. But since I'm using servo motors to control the arm I need to get proper joint angle values as feedback. 3D magnetic sensor helped me to calculate joint angles from each joint. Then I used the same method to calculate angles in DC motors and used Z axis movements for predictive maintenance of motors.

What's the use of an encoder? Is it necessary to have one?

Yes. Encoder provides feedback signal which is vital for controlling the motor or generator to very high precision. This precision is very much needed in industrial controlling and measuring instruments where there is no room for error. Almost all industrial robotic arms operate by taking joint angles as input. Encoders helps us to provide necessary joint angles at each joint in the robotic arm. If we look at the data sheet of Infineon TLV493D 3D magnetic sensor, we see that the maximum data rate possible is 1Mbps which is more than sufficient to act as encoder even for BLDC motors.

These encoders data can be used to drive BLDC motors more efficiently thereby saving energy. Infineon's 3D magnetic sensor TLV493D A1B6 provides high precision angle data which can be directly used to determine position, speed and direction of rotation.

IEncode is smarter when compared to conventional magnetic encoders because it can provides Z axis motion feedback of motor shaft. After years of operations, industrial motor bearings fail and can cause motor shaft movements in Z direction also. These minute motions can be detected by 3D magnetic sensor with the help of its Z axis movement detection.

In an industry where day to day operations are critical in reaching necessary production rates, failure of an instrument is not affordable. There should be no room for error.

IEncode helps to detect these faulty motor movements and thereby informing us to repair the motor or arrange for a backup. This can also alert the repairman by sending an SMS.

Step 1: Get All the Parts

Get all the required parts such as 3D magnetic sensor, an arduino microcontroller to read the data, SIM800 module for alert system motors for testing.

Step 2: Connect the Components

Connect all the components by referring following circuit diagram.

Step 3: Coding

Let's code arduino board which will provide us rotation angle and Z axis movements. The code involves basic functions to get data from the magnetic sensor using I2C protocol and display it or send it via necessary communication means.

Step 4: Let's Test It

Video showing how 2 tests are performed to confirm its use as an encoder and predictive maintenance sensor

Test 1: Encoder to a servo motor : I have this setup on my breadboard where I analyse magnetometer data on Arduino IDE and Microsoft Excel. The error in data seems to be very less.

Here we are getting very good result without any filtering. I have interfaced the sensor directly to the arduino microcontroller without any hardware or software filter. If we implement a filter definitely the data will be clean and accurate.

Test 2: Involves encoder as a sensor to detect faulty linear movements of motor. After heavy usage motor bearings worn out due to friction and heat. This causes movement of motor shaft on its axis of rotation. i.e Z direction. These minute movements in-terms of millimeters can be detected by Infineon's 3D magnetic sensor TLV493D-A1B6. Now I'm using certain number of linear Z axis motions as input to send a maintenance signal to concerned authorities. Now it sends SMS along with machine number which needs maintenance or replacement. This prior alert helps to arrange for backups while saving a lot of money to the firm. This can be improvised by bringing in machine learning based data analytics.

This is very useful in industries with high production rates and to detect failure of diesel generators in cell phone towers where the power is critical. few hours of downtime in mobile networks may cause huge losses to tower maintenance companies.

Further enhancements:

1. Applying good filter.

2. Using encoder for BLDC controller.

3. Applying machine learning techniques to accurately predict failures.

4. GUI based dashboard to handle multiple motors.

5. MODBUS implementation to attain industrial communication standards.

Code

IEncodeC/C++
#include <SoftwareSerial.h>
#include "TLV493D.h"
#include "Wire.h"


TLV493D sensor2;
int i = 0;
int threshold = 50;
int val = 0;
int xyang = 0;
int yzang = 0;
int zxang = 0;
float v1, v2 = 0;
const int sensor2_pwr_pin = A3;
const int i2c_sda = A4;
SoftwareSerial sim(10, 11);
int _timeout;
String _buffer;
String number = "+919482005201";
void setup() {
  pinMode(sensor2_pwr_pin, OUTPUT);
  pinMode(i2c_sda, OUTPUT);
   pinMode(5, OUTPUT);
  digitalWrite(sensor2_pwr_pin, LOW);
  digitalWrite(i2c_sda, LOW);
  //init sensor2
  digitalWrite(sensor2_pwr_pin, HIGH);
  digitalWrite(i2c_sda, HIGH); //0x5E
  Serial.println("Starting sensor 2");
  delay(500);

  Wire.begin(); // Begin I2C wire communication


  //initialize sensor 2
  //  Serial.print("Initializing sensor 2: 0x");
  Serial.println(sensor2.init(HIGH), HEX);
  delay(7000); //delay for 7 seconds to make sure the modules get the signal
  Serial.begin(9600);
  _buffer.reserve(50);
  // Serial.println("Sistem Started...");
  sim.begin(9600);
  delay(1000);
}
void loop()
{
  sensor2.update(); // updates sensor value
  xyang = ( sensor2.m_dPhi_xy * 57.2958); // Measures angle between X and Y i.e encoder angle or shaft angle
  Serial.print("X angle == ");
  Serial.print(xyang);
  v1 = sensor2.m_dBz;
  if (v1 > threshold)
  {
    i++;
  }
  if (i > 5)
  {
    digitalWrite(5,HIGH);
    SendMessage();// Sends an SMS to the concerned person or a soft number that machine needs a service
    i = 0;
  }

}
void SendMessage()
{
  //Serial.println ("Sending Message");
  sim.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);
  //Serial.println ("Set SMS Number");
  sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message
  delay(1000);
  String SMS = "Service is required for machine number 5";
  sim.println(SMS);
  delay(100);
  sim.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  _buffer = _readSerial();
}
String _readSerial() {
  _timeout = 0;
  while  (!sim.available() && _timeout < 12000  )
  {
    delay(13);
    _timeout++;
  }
  if (sim.available()) {
    return sim.readString();
  }
}
Servo EncoderC/C++
Testing Encoder with Servo
#include "TLV493D.h"
#include "Wire.h"
#include <Servo.h>
TLV493D sensor1;
TLV493D sensor2;

int val =0;
int xyang =0;
int yzang =0;
int zxang =0;
float v1,v2=0;
const int sensor2_pwr_pin = A3;
const int i2c_sda = A4;


Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; 

void setup()
{
  Serial.begin(115200);

  pinMode(sensor2_pwr_pin, OUTPUT);
  pinMode(i2c_sda, OUTPUT);

  digitalWrite(sensor2_pwr_pin, LOW);
  digitalWrite(i2c_sda, LOW);

  delay(500);




  digitalWrite(sensor2_pwr_pin, HIGH);
  digitalWrite(i2c_sda, HIGH); //0x5E
 // Serial.println("Starting sensor 2");
  delay(500);

  Wire.begin(); // Begin I2C wire communication
  myservo.attach(9); // Servo initilisation

  //initialize sensor 2
//  Serial.print("Initializing sensor 2: 0x");
  Serial.println(sensor2.init(HIGH), HEX);
}

void loop()
{
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
   //Serial.print("Servo angle=");// Servo angle printing for comparision
  // Serial.println(pos);
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
    sensor2.update();
 
 // Serial.print(sensor2.m_dBz);

  xyang=( sensor2.m_dPhi_xy*57.2958);//Converts radian value to degree
 // Serial.print("X angle == ");
  Serial.println(xyang);// Calculated angle between X and Y plane
 // Serial.println(";");//\t");
  /*yzang=( sensor2.m_dPhi_yz*57.2958);//
   Serial.print("Y angle ==");
  Serial.print(yzang);
  Serial.println(";");//\t");
  zxang=( sensor2.m_dPhi_xz*57.2958);
  Serial.print("Z angle ==");
  Serial.print(zxang);
  Serial.println(";");//\t");
//  Serial.println(";");
 // Serial.println(sensor2.m_dMag_2);
  delay(20);*/
  delay(200);
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);   
 //      Serial.print("Servo angle=");
  // Serial.println(pos);
    delay(15);   
    sensor2.update();
 
//  Serial.print(sensor2.m_dBz);

  xyang=( sensor2.m_dPhi_xy*57.2958);
//  Serial.print("X angle == ");
  Serial.println(xyang);
//  Serial.println(";");//\t");
 /* yzang=( sensor2.m_dPhi_yz*57.2958);
   Serial.print("Y angle ==");
  Serial.print(yzang);
  Serial.println(";");//\t");
  zxang=( sensor2.m_dPhi_xz*57.2958);
  Serial.print("Z angle ==");
  Serial.print(zxang);
  Serial.println(";");//\t");
//  Serial.println(";");
 // Serial.println(sensor2.m_dMag_2);
  delay(500);
  // waits 15ms for the servo to reach the position*/
  delay(200);
  }
}


  


  

Custom parts and enclosures

Log data
Log data in xlsx format
encoder_test_data_XlLsBxExaL.xlsx

Schematics

Schematic
Schematic Diagram
Iencode schematic zalzad01eh

Comments

Similar projects you might like

Exploring Encoders - Step Trackers for Motors

Project tutorial by SciJoy

  • 3,223 views
  • 3 comments
  • 9 respects

Autobot Using Lego NXT Motors and Sensor

Project tutorial by Mark Tashiro

  • 14,928 views
  • 5 comments
  • 25 respects

Arduino Menu on a Nokia 5110 Lcd Using a Rotary Encoder

Project tutorial by Nick Koumaris

  • 14,630 views
  • 10 comments
  • 40 respects

PIR Automated Intelligent Zebra Crossing

Project showcase by Adersh B

  • 2,832 views
  • 1 comment
  • 8 respects
Add projectSign up / Login