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

Commit 426a89c

Browse files
authored
Merge pull request #12 from jaenrig-ifx/master
Added drill trigger sketches
2 parents efcf559 + f1c4801 commit 426a89c

File tree

5 files changed

+155
-0
lines changed

5 files changed

+155
-0
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ env:
1919
- PLATFORMIO_CI_SRC=examples/Cartesian
2020
- PLATFORMIO_CI_SRC=examples/Cartesian_low_power
2121
- PLATFORMIO_CI_SRC=examples/DirIndicator
22+
- PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsGraph
23+
- PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsNumber
2224
- PLATFORMIO_CI_SRC=examples/ReadCaliper
2325
- PLATFORMIO_CI_SRC=examples/sine_generator
2426

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* For basic setup just create a Tle493d() object. If you want to use the wake up mode please use Tle493d_w2b6(). Also
3+
* the setUpdateRate() method is slightly different for different variants
4+
*/
5+
6+
7+
#include <Tle493d.h>
8+
9+
Tle493d Tle493dMagnetic3DSensor = Tle493d();
10+
11+
void setup() {
12+
Serial.begin(9600);
13+
while (!Serial);
14+
Tle493dMagnetic3DSensor.begin();
15+
Tle493dMagnetic3DSensor.enableTemp();
16+
}
17+
18+
void loop() {
19+
Tle493dMagnetic3DSensor.updateData();
20+
int spe =0; //Speed =0
21+
double z = Tle493dMagnetic3DSensor.getZ();
22+
// Serial.println("_________________________________");
23+
// Serial.println(" ");
24+
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
25+
z = z * zSign; //change sign of speed if needed
26+
double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */
27+
double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */
28+
double sp = -1;
29+
int sp_int=-1;
30+
int count=0;
31+
int number_char=-1;
32+
int counter=0;
33+
34+
//** readout & print sensor data
35+
//Serial.print("zsign = ");
36+
//Serial.print(zSign);
37+
//Serial.print(" ; (x= ");
38+
//Serial.print(x);
39+
//Serial.print(" ; (y= ");
40+
//Serial.print(y);
41+
//Serial.print(") ; z=");
42+
//Serial.println(z);
43+
44+
//** Speed calculation
45+
sp=(atan2(x*zSign,z)+1)*1250; // calculation of the speed sp; zsign used for independency of the magnetic orientation
46+
if (sp<0) sp=0; // cutting negative speed
47+
if (sp>2500) sp=2500; //cutting higher speed limit to 2500
48+
sp_int=2501-sp; //change
49+
//Serial.print("Speed= ");
50+
//Serial.println(sp_int);
51+
52+
//* convert speed into numbers of characters
53+
number_char=sp_int/25; //calculaion of the requiered number of characters representing the speed
54+
// Serial.print("Characters for speed = ");
55+
// Serial.println(number_char);
56+
57+
//** print out number of characters
58+
delay(5);
59+
Serial.println();
60+
// missing of automatic cal algorythm
61+
do { //giving out the required characters representing the speed.
62+
count=count+1;
63+
Serial.print("*");
64+
} while (count < number_char);
65+
66+
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
### Instruction Power Drill Trigger
4+
[![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")
5+
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.
6+
Two different codes are available:
7+
- For demonstration reasons use the "DrillTrigger_SpeedAsGraph". This indicates the speed/position by showing a dedicated number of charaters.
8+
- For deeper understanding please use the "DrillTrigger_SpeedAsNumber". This indicated the speed as number and some calculated parameters.
9+
10+
Note: The Magnet can be moved into it's holder by a small needle. A hole is on the opposite site.
11+
12+
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.
13+
Following magnet is [used](https://www.supermagnete.de/data_sheet_S-05-05-N.pdf "used") in this application.
14+
- 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").
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* For basic setup just create a Tle493d() object. If you want to use the wake up mode please use Tle493d_w2b6(). Also
3+
* the setUpdateRate() method is slightly different for different variants
4+
*/
5+
6+
7+
#include <Tle493d.h>
8+
9+
Tle493d Tle493dMagnetic3DSensor = Tle493d();
10+
11+
void setup() {
12+
Serial.begin(9600);
13+
while (!Serial);
14+
Tle493dMagnetic3DSensor.begin();
15+
Tle493dMagnetic3DSensor.enableTemp();
16+
17+
}
18+
19+
void loop() {
20+
double X_min=0;
21+
double X_max=0;
22+
double Z_min=0;
23+
double Z_max=0;
24+
Tle493dMagnetic3DSensor.updateData();
25+
int spe =0;
26+
double gain_default=1250;
27+
double z = Tle493dMagnetic3DSensor.getZ();
28+
double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */
29+
double y = Tle493dMagnetic3DSensor.getY();
30+
Serial.println("_________________________________");
31+
Serial.println(" ");
32+
int zSign = z < 0 ? -1 : 1;
33+
z = z * zSign;
34+
35+
36+
double sp = -1;
37+
int sp_int=-1;
38+
int number_char=-1;
39+
int counter=0;
40+
41+
Serial.print("zsign = ");
42+
Serial.print(zSign);
43+
Serial.print(" ; (x= ");
44+
Serial.print(x);
45+
Serial.print(" ; (y= ");
46+
Serial.print(y);
47+
Serial.print(") ; z=");
48+
Serial.println(z);
49+
sp=(atan2(x*zSign,z)+1)*gain_default;
50+
if (sp<0) sp=0;
51+
if (sp>2500) sp=2500;
52+
sp_int=2501-sp;
53+
Serial.print("Speed= "); //if at no pull at the trigger is bigger than zero some kind of correction or calibration needs to be implemented
54+
Serial.println(sp_int);
55+
delay(1500);
56+
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
### Instruction Power Drill Trigger
4+
[![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")
5+
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.
6+
Two different codes are available:
7+
- For demonstration reasons use the "DrillTrigger_SpeedAsGraph". This indicates the speed/position by showing a dedicated number of charaters.
8+
- For deeper understanding please use the "DrillTrigger_SpeedAsNumber". This indicated the speed as number and some calculated parameters.
9+
10+
Note: The Magnet can be moved into it's holder by a small needle. A hole is on the opposite site.
11+
12+
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.
13+
Following magnet is [used](https://www.supermagnete.de/data_sheet_S-05-05-N.pdf "used") in this application.
14+
- 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 commit comments

Comments
 (0)