Skip to content

Commit

Permalink
Fix right orign repo
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafFilies committed Oct 28, 2019
1 parent 1f402c8 commit 013be27
Show file tree
Hide file tree
Showing 11 changed files with 459 additions and 250 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sudo: required

branches:
- master
only:
- tle94112

env:
Expand Down
30 changes: 28 additions & 2 deletions examples/Control2Motors/Control2Motors.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
#include <Tle94112.h>
/*!
* \name Control2Motors
* \author Infineon Technologies AG
* \copyright 2019 Infineon Technologies AG
* \version 1.4.1
* \brief
* This example demonstrates how to control two motors, their speed and direction
* with the TLE94112 shield
* \detail
* By attaching a Tle94112 controller object to two Tle94112Motor objects, we can generate
* an easy to handle motor object for each motor. We can easily attach this motor object
* two any of the halfbridges and to any of the PWM units. This is done in the setup part.
* Keep in mind that you have to initialize the Tle94112 controller and each motor object,
* which is done in the setup function.
* After that we can take the motor start, stop and setSpeed function to easily control
* each motor.
*
* \attention Motors have depending on there size a very big latency until a motor has
* fully started or is stoped to 0. Specially the time between a start and stop and vice versa
* is much higher than higher than the processing speed of any microcontroller. This
* is solved in this example with the delay command, but there are better solutions than that.
* This delays are needed because a direct switch between start and stop will lead to high currents
* and the TLE94112 will signal an overcurrent.
*
*/

#include <TLE94112.h>
#include <Tle94112Motor.h>

// Tle94112 Object
Expand Down Expand Up @@ -78,4 +104,4 @@ void loop()
motor1.stop(255);

delay(5000);
}
}
24 changes: 21 additions & 3 deletions examples/rampSpeedTest/rampSpeedTest.ino
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
#include <Tle94112.h>
/*!
* \name rampSpeedTest
* \author Infineon Technologies AG
* \copyright 2019 Infineon Technologies AG
* \version 1.4.1
* \brief
* This example measure the rampspeed of an attached motor with the TLE94112 shield
* \detail
* By attaching a motor to the TLE94112 and running a testcase scenario, we can measure the
* optimal values for the rampSpeed function. This function allows us to smoothly start, stop,
* raise or break the motor.
*
* \attention A free running motor ramps very different that the same motor with load attached.
* So you have to measure different scenarios.
*
*/

#include <TLE94112.h>
#include <Tle94112Motor.h>


// Tle94112 Object on Shiled 1
// Tle94112 Object on Shield 1
Tle94112 controller1 = Tle94112();

// Tle94112Motor Objects on controller1
Expand All @@ -15,6 +32,7 @@ typedef struct {
uint16_t slope;
} RampMeasurement_t, *RampMeasurement_p;

// lets define an array with different
#define NUM_TESTS 6
RampMeasurement_t testcases[NUM_TESTS] = {
{ 0, 255, 5000 },
Expand Down Expand Up @@ -78,4 +96,4 @@ void loop() {
{
measureRampTime(i);
}
}
}
233 changes: 122 additions & 111 deletions examples/rampTest/rampTest.ino
Original file line number Diff line number Diff line change
@@ -1,111 +1,122 @@
#include <Tle94112.h>
#include <Tle94112Motor.h>
/*
============================================================================
Name : Lego Robot III
Author : Dr. Olaf Filies, Marcus Gordon Filies
Version : 0.9
Description : ramping the motor speed of a high current motor
============================================================================
*/

// Tle94112 Object on Shiled 1
Tle94112 controller1 = Tle94112();

// Tle94112Motor Objects on controller1
Tle94112Motor motor1(controller1);


void setup() {
Serial.begin(115200); // Switch on comunication
Serial.println("Init ready");

// Enable MotorController on all Shields and Motors
// Note: Required to be done before starting to configure the motor
// controller1 is set to default CS1 pin
controller1.begin();

//-Motor1-high current motor between out1/out2 = HB1/HB2 and out3/out4 = HB3/HB4-------------------

// Connect motor1 to HB1/HB2 highside and HB3/HB4 lowside
// IMPORTANT connect PWM to Lowside as higside is active Free wheeling
motor1.initConnector(motor1.HIGHSIDE, controller1.TLE_NOPWM, controller1.TLE_HB1, controller1.TLE_HB2, controller1.TLE_NOHB, controller1.TLE_NOHB);
motor1.initConnector(motor1.LOWSIDE, controller1.TLE_PWM1, controller1.TLE_HB3, controller1.TLE_HB4, controller1.TLE_NOHB, controller1.TLE_NOHB);

// start motor1
motor1.begin();
}

void loop() {

motor1.coast();
delay(1000);

// max forward/backward
Serial.println("max forward/backward");
motor1.start(255);
delay(1000);
motor1.coast();
delay(1000);
motor1.start(-255);
delay(1000);
motor1.coast();
delay(1000);

// ramp rippel forward/backward
Serial.println("ramp rippel forward/backward");
motor1.start(255);
delay(1000);
motor1.rampSpeed(0,5000);
delay(1000);
motor1.start(-255);
delay(1000);
motor1.rampSpeed(0,5000);
delay(1000);

// ramp up/down forward
Serial.println("ramp up/down forward");
motor1.start(50); // start above 0 to allow motor to start
motor1.rampSpeed(255,5000);
delay(1000);
motor1.rampSpeed(100,5000);
delay(1000);
motor1.rampSpeed(255,5000);
delay(1000);
motor1.rampSpeed(0,5000);

// ramp up/down backward
Serial.println("ramp up/down backward");
motor1.start(50);
motor1.rampSpeed(-255,5000);
delay(1000);
motor1.rampSpeed(-100,5000);
delay(1000);
motor1.rampSpeed(-255,5000);
delay(1000);
motor1.rampSpeed(0,5000);

// ramp transient
Serial.println("ramp transient");
motor1.rampSpeed(-255,1000);
delay(1000);
motor1.rampSpeed(255,1000);
delay(1000);
motor1.rampSpeed(-255,1000);
delay(1000);
motor1.rampSpeed(0,1000);
delay(1000);

// stop and coast
Serial.println("stop and coast");
motor1.stop(255);
delay(1000);
motor1.coast();
delay(1000);


}




/*!
* \name rampTest
* \author Infineon Technologies AG
* \copyright 2019 Infineon Technologies AG
* \version 1.4.1
* \brief
* This example to run a motor with the rampSpeed function
* \detail
* This example also demonstrats how to attach a bigger motor on 4 halfbridges with a total
* current of 1.8 A. Originally designed to test Lego (R) Powerfunktions or Mindstorm motors,
* this sketch can be used to simply run a motor smoothly with different speeds
* in different directions.
*
*/

#include <TLE94112.h>
#include <Tle94112Motor.h>
/*
============================================================================
Name : Lego Robot III
Author : Dr. Olaf Filies, Marcus Gordon Filies
Version : 0.9
Description : ramping the motor speed of a high current motor
============================================================================
*/

// Tle94112 Object on Shield 1
Tle94112 controller1 = Tle94112();

// Tle94112Motor Objects on controller1
Tle94112Motor motor1(controller1);


void setup() {
Serial.begin(115200); // Switch on communications
Serial.println("Init ready");

// Enable MotorController on all Shields and Motors
// Note: Required to be done before starting to configure the motor
// controller1 is set to default CS1 pin
controller1.begin();

//-Motor1-high current motor between out1/out2 = HB1/HB2 and out3/out4 = HB3/HB4-------------------

// Connect motor1 to HB1/HB2 highside and HB3/HB4 lowside
// IMPORTANT connect PWM to Lowside as higside is active Free wheeling
motor1.initConnector(motor1.HIGHSIDE, controller1.TLE_NOPWM, controller1.TLE_HB1, controller1.TLE_HB2, controller1.TLE_NOHB, controller1.TLE_NOHB);
motor1.initConnector(motor1.LOWSIDE, controller1.TLE_PWM1, controller1.TLE_HB3, controller1.TLE_HB4, controller1.TLE_NOHB, controller1.TLE_NOHB);

// start motor1
motor1.begin();
}

void loop() {

motor1.coast();
delay(1000);

// max forward/backward
Serial.println("max forward/backward");
motor1.start(255);
delay(1000);
motor1.coast();
delay(1000);
motor1.start(-255);
delay(1000);
motor1.coast();
delay(1000);

// ramp ripple forward/backward
Serial.println("ramp ripple forward/backward");
motor1.start(255);
delay(1000);
motor1.rampSpeed(0,5000);
delay(1000);
motor1.start(-255);
delay(1000);
motor1.rampSpeed(0,5000);
delay(1000);

// ramp up/down forward
Serial.println("ramp up/down forward");
motor1.start(50); // start above 0 to allow motor to start
motor1.rampSpeed(255,5000);
delay(1000);
motor1.rampSpeed(100,5000);
delay(1000);
motor1.rampSpeed(255,5000);
delay(1000);
motor1.rampSpeed(0,5000);

// ramp up/down backward
Serial.println("ramp up/down backward");
motor1.start(50);
motor1.rampSpeed(-255,5000);
delay(1000);
motor1.rampSpeed(-100,5000);
delay(1000);
motor1.rampSpeed(-255,5000);
delay(1000);
motor1.rampSpeed(0,5000);

// ramp transient
Serial.println("ramp transient");
motor1.rampSpeed(-255,1000);
delay(1000);
motor1.rampSpeed(255,1000);
delay(1000);
motor1.rampSpeed(-255,1000);
delay(1000);
motor1.rampSpeed(0,1000);
delay(1000);

// stop and coast
Serial.println("stop and coast");
motor1.stop(255);
delay(1000);
motor1.coast();
delay(1000);


}
Loading

0 comments on commit 013be27

Please sign in to comment.