Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from jaenrig-ifx/master
Browse files Browse the repository at this point in the history
Added drill trigger sketches
  • Loading branch information
jaenrig-ifx authored Mar 5, 2020
2 parents efcf559 + f1c4801 commit 426a89c
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ env:
- PLATFORMIO_CI_SRC=examples/Cartesian
- PLATFORMIO_CI_SRC=examples/Cartesian_low_power
- PLATFORMIO_CI_SRC=examples/DirIndicator
- PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsGraph
- PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsNumber
- PLATFORMIO_CI_SRC=examples/ReadCaliper
- PLATFORMIO_CI_SRC=examples/sine_generator

Expand Down
67 changes: 67 additions & 0 deletions examples/DrillTrigger_SpeedAsGraph/DrillTrigger_SpeedAsGraph.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* For basic setup just create a Tle493d() object. If you want to use the wake up mode please use Tle493d_w2b6(). Also
* the setUpdateRate() method is slightly different for different variants
*/


#include <Tle493d.h>

Tle493d Tle493dMagnetic3DSensor = Tle493d();

void setup() {
Serial.begin(9600);
while (!Serial);
Tle493dMagnetic3DSensor.begin();
Tle493dMagnetic3DSensor.enableTemp();
}

void loop() {
Tle493dMagnetic3DSensor.updateData();
int spe =0; //Speed =0
double z = Tle493dMagnetic3DSensor.getZ();
// Serial.println("_________________________________");
// Serial.println(" ");
int zSign = z < 0 ? -1 : 1; //zSign: sign of the perpendicular z- component of the magnet. is used to make the magnet orientation regardless/no meaning
z = z * zSign; //change sign of speed if needed
double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */
double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */
double sp = -1;
int sp_int=-1;
int count=0;
int number_char=-1;
int counter=0;

//** readout & print sensor data
//Serial.print("zsign = ");
//Serial.print(zSign);
//Serial.print(" ; (x= ");
//Serial.print(x);
//Serial.print(" ; (y= ");
//Serial.print(y);
//Serial.print(") ; z=");
//Serial.println(z);

//** Speed calculation
sp=(atan2(x*zSign,z)+1)*1250; // calculation of the speed sp; zsign used for independency of the magnetic orientation
if (sp<0) sp=0; // cutting negative speed
if (sp>2500) sp=2500; //cutting higher speed limit to 2500
sp_int=2501-sp; //change
//Serial.print("Speed= ");
//Serial.println(sp_int);

//* convert speed into numbers of characters
number_char=sp_int/25; //calculaion of the requiered number of characters representing the speed
// Serial.print("Characters for speed = ");
// Serial.println(number_char);

//** print out number of characters
delay(5);
Serial.println();
// missing of automatic cal algorythm
do { //giving out the required characters representing the speed.
count=count+1;
Serial.print("*");
} while (count < number_char);


}
14 changes: 14 additions & 0 deletions examples/DrillTrigger_SpeedAsGraph/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


### Instruction Power Drill Trigger
[![Power Drill Trigger](https://www.infineon.com/export/sites/default/media/products/Sensors/powerdrill.png_1066915183.png "Power Drill Trigger")](https://www.infineon.com/export/sites/default/media/products/Sensors/powerdrill.png_1066915183.png "Power Drill Trigger")
1. In order to use the PowerDrill2Go AddOn, first install and run the Graphical User Interface located [here](https://www.infineon.com/dgdl/Infineon-Software-for-3D-Magnetic-Sensor-2Go+incl.+out-of-shaft_05_06-SW-v05_06-EN.zip?fileId=5546d4626102d35a01614626f9644e4e "here") one time.
Two different codes are available:
- For demonstration reasons use the "DrillTrigger_SpeedAsGraph". This indicates the speed/position by showing a dedicated number of charaters.
- For deeper understanding please use the "DrillTrigger_SpeedAsNumber". This indicated the speed as number and some calculated parameters.

Note: The Magnet can be moved into it's holder by a small needle. A hole is on the opposite site.

The 3D print files can be found [here](https://www.infineon.com/cms/en/tools/landing/infineon-for-makers/kits-2go/ "here") in the ***Do-it-yourself*** section.
Following magnet is [used](https://www.supermagnete.de/data_sheet_S-05-05-N.pdf "used") in this application.
- For further information about the 3D sensor please click [here](https://www.infineon.com/cms/en/product/promopages/sensors-2go/#3d-magnetic-sensor-2go "here").
58 changes: 58 additions & 0 deletions examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* For basic setup just create a Tle493d() object. If you want to use the wake up mode please use Tle493d_w2b6(). Also
* the setUpdateRate() method is slightly different for different variants
*/


#include <Tle493d.h>

Tle493d Tle493dMagnetic3DSensor = Tle493d();

void setup() {
Serial.begin(9600);
while (!Serial);
Tle493dMagnetic3DSensor.begin();
Tle493dMagnetic3DSensor.enableTemp();

}

void loop() {
double X_min=0;
double X_max=0;
double Z_min=0;
double Z_max=0;
Tle493dMagnetic3DSensor.updateData();
int spe =0;
double gain_default=1250;
double z = Tle493dMagnetic3DSensor.getZ();
double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */
double y = Tle493dMagnetic3DSensor.getY();
Serial.println("_________________________________");
Serial.println(" ");
int zSign = z < 0 ? -1 : 1;
z = z * zSign;


double sp = -1;
int sp_int=-1;
int number_char=-1;
int counter=0;

Serial.print("zsign = ");
Serial.print(zSign);
Serial.print(" ; (x= ");
Serial.print(x);
Serial.print(" ; (y= ");
Serial.print(y);
Serial.print(") ; z=");
Serial.println(z);
sp=(atan2(x*zSign,z)+1)*gain_default;
if (sp<0) sp=0;
if (sp>2500) sp=2500;
sp_int=2501-sp;
Serial.print("Speed= "); //if at no pull at the trigger is bigger than zero some kind of correction or calibration needs to be implemented
Serial.println(sp_int);
delay(1500);


}
14 changes: 14 additions & 0 deletions examples/DrillTrigger_SpeedAsNumber/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


### Instruction Power Drill Trigger
[![Power Drill Trigger](https://www.infineon.com/export/sites/default/media/products/Sensors/powerdrill.png_1066915183.png "Power Drill Trigger")](https://www.infineon.com/export/sites/default/media/products/Sensors/powerdrill.png_1066915183.png "Power Drill Trigger")
1. In order to use the PowerDrill2Go AddOn, first install and run the Graphical User Interface located [here](https://www.infineon.com/dgdl/Infineon-Software-for-3D-Magnetic-Sensor-2Go+incl.+out-of-shaft_05_06-SW-v05_06-EN.zip?fileId=5546d4626102d35a01614626f9644e4e "here") one time.
Two different codes are available:
- For demonstration reasons use the "DrillTrigger_SpeedAsGraph". This indicates the speed/position by showing a dedicated number of charaters.
- For deeper understanding please use the "DrillTrigger_SpeedAsNumber". This indicated the speed as number and some calculated parameters.

Note: The Magnet can be moved into it's holder by a small needle. A hole is on the opposite site.

The 3D print files can be found [here](https://www.infineon.com/cms/en/tools/landing/infineon-for-makers/kits-2go/ "here") in the ***Do-it-yourself*** section.
Following magnet is [used](https://www.supermagnete.de/data_sheet_S-05-05-N.pdf "used") in this application.
- For further information about the 3D sensor please click [here](https://www.infineon.com/cms/en/product/promopages/sensors-2go/#3d-magnetic-sensor-2go "here").

0 comments on commit 426a89c

Please sign in to comment.