Engineering

Infineon DC Motor Shield with TLE94112EL

Introduction

This DC motor shield can be assembled on Arduino Uno compatible development kit.

Block Diagram

Capture_dcmotor_pinout

Lab setup

 

Platform IO Coding

wire.h is not recognized at first, so, inside “platformio.ini,” lib_deps = Wire needs to be included to avoid an error when main.cpp was complied.

  • lib_deps = Wire, TLE94122
Capture_PlatformIO_wire_tle94112 Capture_PlatformIO_Lib_DC_Motor.PNG

Arduino Coding Explanation

  • Header Files

    • #include <TLE94112.h>
    • #include <Tle94123Motor.h>
    • #include <tle94112_conf.h>
  • TLE Object

    • Tle94112 controller = Tle94112();
  • Tle94112 Motor Objects

    • Tle94112 Motor motor1(controller);
    • Tle94112Motor motor2(controller);
  • void setup()

      // Enable MotorController Tle94112
      // Note: Required to be done before starting to configure the motor
      controller.begin();
      // Connect motor1 to HB1 and HB2
      motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
      motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);
      // Drive HB1 with signal from PWM1
      // Note: This allows to control the speed of the motor
      motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM1);
      // Set PWM Frequency, default is 80 Hz
      motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ100HZ);
      //when configuration is done, call begin to start operating the motors
      motor1.begin();
  • void loop()

  // start the motor1 forwards on half speed
  motor1.start(127);
  // accelerate motor1 to full speed
  motor1.setSpeed(255);
           // Stop motor1
  motor1.stop(255);

References

ABOUT ME
green scientist
Love travel, running, engineering, and gardening. Exploring new parks.

Leave a Reply

%d bloggers like this: