This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jaenrig-ifx/master
Added drill trigger sketches
- Loading branch information
Showing
5 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
examples/DrillTrigger_SpeedAsGraph/DrillTrigger_SpeedAsGraph.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
58
examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"). |