Project tutorial
RF Remote Control With Infineon 3D Magnetic Sensor 2Go

RF Remote Control With Infineon 3D Magnetic Sensor 2Go © CC BY-SA

This project shows us how we control a "Micro Robot Car" and using a RF Remote Control with "Infineon 3D Magnetic Sensor 2Go".

  • 699 views
  • 0 comments
  • 2 respects

Components and supplies

3d 2go neu.jpg 1780796916
Infineon 3D Magnetic Sensor 2Go
×1
Ph a000066 iso (1) ztbmubhmho
Arduino UNO
×1
Ph a000067 iso (1) wzec989qrf
Arduino Mega 2560
×1
RLP 434 RF Receiver
×1
TLP 434A RF Transmitter
×1
L293B driver
×1

Apps and online services

About this project

Introduction

To achieve my goals, we divide the project into two parts: the transmitting part and the receiving part. In the transmitting part I use the "Infineon 3D Magnetic Sensor 2Go" board to capture and process the data that this sensor gave me and I use the "Mega 2560" board to send this data by “Radio Frequency”. In the receiving part I use the "Arduino UNO" board to execute the received orders. To make this prototype, I was inspired by my project:

We have to review the technical sheet of our magnetic sensor. In the following image we can see the components of this board.

In the following image we can see the configuration of the pins of our board.

To program our board, we have to download and install the following software:

  • Arduino IDE.
  • 3D Magnetic Sensor 2 Go.
  • USB Driver from SEGGER.
  • Library: TLE493D-W2B6-3DMagnetic-Sensor
  • Board: XMC Microcontroller by Infineon

The latest version of Arduino IDE is downloaded from: https://www.arduino.cc/en/Main/Software

3D Magnetic Sensor 2 Go, serves us to test with our device and download it from the official site of Infineon. This program only runs under Windows and has an old USB version of SEGGER. We have to download and install the latest version of SEGGER USB Driver so that our device works correctly.

The library TLE493D-W2B6-3DMagnetic-Sensor is downloaded from: https://github.com/Infineon/TLE493D-W2B6-3DMagnetic-Sensor

The Microcontroller board is downloaded from the official Infineon site on github. There we will find the instructions for a correct installation.

https://github.com/Infineon/XMC-for-Arduino

In my case, I installed version 1.1.0 since version 1.1.1 indicated an error. Later we added the url of the card and installed it: https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json

RF Transmitter

Theelectrical diagram of the “RF Transmitter” is as follows:

The operation of the RF Transmitter is as follows:

We rotate the "Rotation Knob" of our magnetic sensor and we can execute four orders that are programmed by software and using the GPIO4 and GPIO5 pins as outputs:

  • Stop: order to stop the car and send the code "00".
  • Right: order to turn the car to the right and send the code "01".
  • Forward: order to go forward and send the code "10".
  • Left: order to turn the car to the left and send the code "11".


Infineon.ino

#include <Tle493d_w2b6.h>
Tle493d_w2b6 Tle493dMagnetic3DSensor = Tle493d_w2b6();
void setup() {
Serial.begin(9600);
pinMode (4,OUTPUT);
pinMode (5,OUTPUT);
while (!Serial);
Tle493dMagnetic3DSensor.begin();
Tle493dMagnetic3DSensor.enableTemp();
}

The board receives these four orders from the magnetic sensor, encodes them and sends them through the transmitter "TLP434A", which works at 433 MHz. These encodings are the following:

  • Stop: we send the character "S".
  • Right: we send the character "R".
  • Forward: we send the character "F".
  • Left: we send the character "L".

We can use several libraries to validate the data sent by Radio Frequency, in my case I have used the library "VirtualWire.h" and this library works very well. The codes of the boards "Infineon 3D Magnetic Sensor 2Go" and "Mega 2560" can be downloaded at the end of this tutorial.

TX_mega.ino

#include <VirtualWire.h>
#define SWITCH1 8 //input for SWITCH1
#define SWITCH2 9 //input for SWITCH2
void setup()
{
Serial.begin(9600);
Serial.println("Tx RF");
pinMode (SWITCH1,INPUT);
pinMode (SWITCH2,INPUT);
// Se inicializa el RF
vw_setup(2000); // bps
vw_set_tx_pin(2); //output RF
}

RF Receiver

The diagram of the “RF Receiver” is as follows:

The operation of the RF Receiver is as follows:

The "Arduino UNO" board receives four orders from the RF Transmitter through the receiver "RLP434", which works at 433 MHz. These commands are decoded and executed in the following way:

  • Stop: we receive the character "S" and the car stops.
  • Right: we receive the character "R" and the car turns to the right.
  • Forward: we receive the character "F" and the car moves forward.
  • Left: we receive the character "L" and the car moves to the left.

Each time the car moves, we use the "L293B" driver and two reduction motors.

We can use several libraries to validate the data sent by Radio Frequency; in my case I have used the library "VirtualWire.h" and this library works very well. The code of the "Arduino UNO" board can be downloaded at the end of this tutorial.

Rx_arduino.ino

#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Se inicializa el RF
vw_setup(2000); // bps
vw_set_rx_pin(2); //Pin 2 as input RF
vw_rx_start(); // start
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}

Test

Conclusions

I first tested the prototype with the devices connected to my PC to verify that the communication was being made and that the "RF Receiver" received the data that the "RF Transmitter" was sending. The serial port of the Arduino UNO board shows us this data that I was waiting for. In the second test I used a prototype of a "Microrobot Car" to demonstrate an application of this prototype.

Using the "Infineon 3D Magnetic Sensor 2Go" board in a remote control is a good option to control a "Micro Robot Car", since it gives you the opportunity to maneuver your cart in a practical and efficient way.

Code

Infineon.inoArduino
#include <Tle493d_w2b6.h>

Tle493d_w2b6 Tle493dMagnetic3DSensor = Tle493d_w2b6();
void setup() {
  Serial.begin(9600);
  pinMode (4,OUTPUT);
  pinMode (5,OUTPUT);
  while (!Serial);
  Tle493dMagnetic3DSensor.begin();
  Tle493dMagnetic3DSensor.enableTemp();
}

void loop() {
  Tle493dMagnetic3DSensor.updateData();
  float angle = Tle493dMagnetic3DSensor.getAzimuth() * 57.3;
  int angle1 = angle;
  float Norm = Tle493dMagnetic3DSensor.getNorm();

  if ((angle1>=165 && angle1<=180 && Norm>=90)||(angle1>=-180 && angle1<=-165 && Norm>=90)){    // STOP
        Serial.print(angle1);
        Serial.println(" = STOP");
        digitalWrite (4,LOW);
        digitalWrite (5,LOW);
        delay (10);
    }  

  else if (angle1>=-105 && angle1<=-75 && Norm>=90){    // RIGHT
        Serial.print(angle1);
        Serial.println(" = RIGHT");
        digitalWrite (4,LOW);
        digitalWrite (5,HIGH);
        delay (10);
    }  

  if (angle1>=-15 && angle1<=15 && Norm>=90){    // FORWARD
        Serial.print(angle1);
        Serial.println(" = FORWARD");
        digitalWrite (4,HIGH);
        digitalWrite (5,LOW);
        delay(10);
    }

  else if (angle1>=75 && angle1<=105 && Norm>=90){    // LEFT
        Serial.print(angle1);
        Serial.println(" = LEFT");
        digitalWrite (4,HIGH);
        digitalWrite (5,HIGH);
        delay (10);
    }  
}

Schematics

RF Transmitter
02 transmitter c8ws9yyzhy ok6eu6p8hb
RF Receiver
02 receiver mb5vlgfnj0 pdkm0mhozt

Comments

Similar projects you might like

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 18,761 views
  • 11 comments
  • 23 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 13,055 views
  • 6 comments
  • 35 respects

Turn LEDs On/Off via Remote Control

Project tutorial by ismystore

  • 9,818 views
  • 1 comment
  • 8 respects

RGB Infinity Mirror with 3D Magnetic Sensor

Project tutorial by Abdullah Sadiq

  • 3,771 views
  • 2 comments
  • 14 respects

Wireless Magnetic Data Transfer

Project tutorial by Tomi Chen

  • 6,923 views
  • 4 comments
  • 22 respects
Add projectSign up / Login