From 46bbb36b6f1c1595a75689aa448e302123044398 Mon Sep 17 00:00:00 2001 From: sigizaruba <56256755+sigizaruba@users.noreply.github.com> Date: Thu, 27 Feb 2020 14:35:32 +0100 Subject: [PATCH 01/10] Add files via upload --- .../DrillTrigger_SpeedAsGraph.ino | 67 ++++++++++++++++ .../DrillTrigger_SpeedAsNumber.ino | 77 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino create mode 100644 examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino diff --git a/examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino b/examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino new file mode 100644 index 0000000..141cab1 --- /dev/null +++ b/examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino @@ -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 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); + + +} diff --git a/examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino b/examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino new file mode 100644 index 0000000..668df3a --- /dev/null +++ b/examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino @@ -0,0 +1,77 @@ +/** +* 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 Tle493dMagnetic3DSensor = Tle493d(); + +void setup() { + Serial.begin(9600); + while (!Serial); + Tle493dMagnetic3DSensor.begin(); + Tle493dMagnetic3DSensor.enableTemp(); + double X_min=0; + double X_max=0; + double Z_min=0; + double Z_max=0; +} + +void loop() { + Tle493dMagnetic3DSensor.updateData(); + int spe =0; + double gain_default=1250; + double z = Tle493dMagnetic3DSensor.getZ(); + Serial.println("_________________________________"); + Serial.println(" "); + int zSign = z < 0 ? -1 : 1; + z = z * zSign; + + double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */ + //cal for gain. check for new x extrema + if (xX_max) { + X_max=x) + } + // ---- + + double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */ + //calibration for gain. check for new y extrema + if (yY_max) { + Y_max=y) + } + + + 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; + if (sp<0) sp=0; + if (sp>2500) sp=2500; + sp_int=2501-sp; + Serial.print("Speed= "); + Serial.println(sp_int); + number_char=sp_int/50; + Serial.print("Characters for speed = "); + Serial.println(number_char); + delay(500); + + +} From 99f9b7f590dc306dd4f706a5b9d254b2fd662745 Mon Sep 17 00:00:00 2001 From: sigizaruba <56256755+sigizaruba@users.noreply.github.com> Date: Thu, 27 Feb 2020 15:05:00 +0100 Subject: [PATCH 02/10] Update Readme.md --- examples/DrillTrigger/Readme.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/DrillTrigger/Readme.md b/examples/DrillTrigger/Readme.md index 838023b..594f0c6 100644 --- a/examples/DrillTrigger/Readme.md +++ b/examples/DrillTrigger/Readme.md @@ -3,11 +3,12 @@ ### 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. -1. Mount the AddOn Power Drill Trigger onto the 3D shield (incl. XMC) or 3D2Go kit. -1. Download and run the [.exe file.](https://github.com/sigizaruba/TLE493D-3DMagnetic-Sensor/blob/master/examples/DrillTrigger/TriggerExtension.exe ".exe file.") located at this site. +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. (coming soon) +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"). From a169ec15796ccbafab1723a518c327357c102102 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:18:35 +0100 Subject: [PATCH 03/10] Updated lib manifest metadata --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 74d52a7..544450c 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/Infineon/TLE493D-3DMagnetic-Sensor.git" }, - "version": "1.1.1", + "version": "1.1.2", "frameworks": "arduino", "platforms": "infineonxmc" } diff --git a/library.properties b/library.properties index d00ced7..7988ed8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TLE493D -version=1.1.1 +version=1.1.2 author=Infineon Technologies maintainer=Infineon Technologies sentence=This library provides an Interface for Infineon's TLE493D From 9f1394d37a38d510c722b317b0473232aff2c536 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:22:13 +0100 Subject: [PATCH 04/10] Updated lib manifest metadata --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 544450c..74d52a7 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/Infineon/TLE493D-3DMagnetic-Sensor.git" }, - "version": "1.1.2", + "version": "1.1.1", "frameworks": "arduino", "platforms": "infineonxmc" } diff --git a/library.properties b/library.properties index 7988ed8..d00ced7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TLE493D -version=1.1.2 +version=1.1.1 author=Infineon Technologies maintainer=Infineon Technologies sentence=This library provides an Interface for Infineon's TLE493D From a1391e0ff3f62ef77bcf9d1849c7c6c182a4c679 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:24:40 +0100 Subject: [PATCH 05/10] Updated travis with new example --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4eda467..595e3f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ env: - PLATFORMIO_CI_SRC=examples/Cartesian - PLATFORMIO_CI_SRC=examples/Cartesian_low_power - PLATFORMIO_CI_SRC=examples/DirIndicator + - PLATFORMIO_CI_SRC=examples/DrillTrigger - PLATFORMIO_CI_SRC=examples/ReadCaliper - PLATFORMIO_CI_SRC=examples/sine_generator From 2bcc2d24b935c8c525d3d8682344ea1f57b2dc37 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:43:25 +0100 Subject: [PATCH 06/10] Moved drill trigger examples to different folders --- .../DrillTrigger_SpeedAsGraph.ino | 134 +++++++-------- .../Readme.md | 28 ++-- .../DrillTrigger_SpeedAsNumber.ino | 154 +++++++++--------- examples/DrillTrigger_SpeedAsNumber/Readme.md | 14 ++ 4 files changed, 172 insertions(+), 158 deletions(-) rename examples/{DrillTrigger => DrillTrigger_SpeedAsGraph}/DrillTrigger_SpeedAsGraph.ino (96%) rename examples/{DrillTrigger => DrillTrigger_SpeedAsGraph}/Readme.md (99%) mode change 100644 => 100755 rename examples/{DrillTrigger => DrillTrigger_SpeedAsNumber}/DrillTrigger_SpeedAsNumber.ino (95%) create mode 100644 examples/DrillTrigger_SpeedAsNumber/Readme.md diff --git a/examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino b/examples/DrillTrigger_SpeedAsGraph/DrillTrigger_SpeedAsGraph.ino similarity index 96% rename from examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino rename to examples/DrillTrigger_SpeedAsGraph/DrillTrigger_SpeedAsGraph.ino index 141cab1..c062122 100644 --- a/examples/DrillTrigger/DrillTrigger_SpeedAsGraph.ino +++ b/examples/DrillTrigger_SpeedAsGraph/DrillTrigger_SpeedAsGraph.ino @@ -1,67 +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 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); - - -} +/** +* 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 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); + + +} diff --git a/examples/DrillTrigger/Readme.md b/examples/DrillTrigger_SpeedAsGraph/Readme.md old mode 100644 new mode 100755 similarity index 99% rename from examples/DrillTrigger/Readme.md rename to examples/DrillTrigger_SpeedAsGraph/Readme.md index 594f0c6..90ee84a --- a/examples/DrillTrigger/Readme.md +++ b/examples/DrillTrigger_SpeedAsGraph/Readme.md @@ -1,14 +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"). + + +### 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"). diff --git a/examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino similarity index 95% rename from examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino rename to examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino index 668df3a..2651da1 100644 --- a/examples/DrillTrigger/DrillTrigger_SpeedAsNumber.ino +++ b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino @@ -1,77 +1,77 @@ -/** -* 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 Tle493dMagnetic3DSensor = Tle493d(); - -void setup() { - Serial.begin(9600); - while (!Serial); - Tle493dMagnetic3DSensor.begin(); - Tle493dMagnetic3DSensor.enableTemp(); - double X_min=0; - double X_max=0; - double Z_min=0; - double Z_max=0; -} - -void loop() { - Tle493dMagnetic3DSensor.updateData(); - int spe =0; - double gain_default=1250; - double z = Tle493dMagnetic3DSensor.getZ(); - Serial.println("_________________________________"); - Serial.println(" "); - int zSign = z < 0 ? -1 : 1; - z = z * zSign; - - double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */ - //cal for gain. check for new x extrema - if (xX_max) { - X_max=x) - } - // ---- - - double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */ - //calibration for gain. check for new y extrema - if (yY_max) { - Y_max=y) - } - - - 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; - if (sp<0) sp=0; - if (sp>2500) sp=2500; - sp_int=2501-sp; - Serial.print("Speed= "); - Serial.println(sp_int); - number_char=sp_int/50; - Serial.print("Characters for speed = "); - Serial.println(number_char); - delay(500); - - -} +/** +* 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 Tle493dMagnetic3DSensor = Tle493d(); + +void setup() { + Serial.begin(9600); + while (!Serial); + Tle493dMagnetic3DSensor.begin(); + Tle493dMagnetic3DSensor.enableTemp(); + double X_min=0; + double X_max=0; + double Z_min=0; + double Z_max=0; +} + +void loop() { + Tle493dMagnetic3DSensor.updateData(); + int spe =0; + double gain_default=1250; + double z = Tle493dMagnetic3DSensor.getZ(); + Serial.println("_________________________________"); + Serial.println(" "); + int zSign = z < 0 ? -1 : 1; + z = z * zSign; + + double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */ + //cal for gain. check for new x extrema + if (xX_max) { + X_max=x) + } + // ---- + + double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */ + //calibration for gain. check for new y extrema + if (yY_max) { + Y_max=y) + } + + + 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; + if (sp<0) sp=0; + if (sp>2500) sp=2500; + sp_int=2501-sp; + Serial.print("Speed= "); + Serial.println(sp_int); + number_char=sp_int/50; + Serial.print("Characters for speed = "); + Serial.println(number_char); + delay(500); + + +} diff --git a/examples/DrillTrigger_SpeedAsNumber/Readme.md b/examples/DrillTrigger_SpeedAsNumber/Readme.md new file mode 100644 index 0000000..90ee84a --- /dev/null +++ b/examples/DrillTrigger_SpeedAsNumber/Readme.md @@ -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"). From 2c3f4857712582b9fd1556d47eaf4b344a43b622 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:46:26 +0100 Subject: [PATCH 07/10] updated travis ci --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 595e3f6..08f6af0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +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 + - PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsGraph + - PLATFORMIO_CI_SRC=examples/DrillTrigger_SpeedAsNumber - PLATFORMIO_CI_SRC=examples/ReadCaliper - PLATFORMIO_CI_SRC=examples/sine_generator From 204eaa8f80048942ba1adc7a4a0c0d99dafdebf3 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 11:50:14 +0100 Subject: [PATCH 08/10] Moved global var out of setup() --- .../DrillTrigger_SpeedAsNumber.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino index 2651da1..423048c 100644 --- a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino +++ b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino @@ -8,15 +8,17 @@ Tle493d Tle493dMagnetic3DSensor = Tle493d(); +double X_min=0; +double X_max=0; +double Z_min=0; +double Z_max=0; + void setup() { Serial.begin(9600); while (!Serial); Tle493dMagnetic3DSensor.begin(); Tle493dMagnetic3DSensor.enableTemp(); - double X_min=0; - double X_max=0; - double Z_min=0; - double Z_max=0; + } void loop() { From de20131b08a95b43bff9dec91e809f1a9cf27c57 Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Fri, 28 Feb 2020 12:53:17 +0100 Subject: [PATCH 09/10] Fixed sketches syntactically. No functional verification --- .../DrillTrigger_SpeedAsNumber.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino index 423048c..6649f6d 100644 --- a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino +++ b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino @@ -2,14 +2,14 @@ * 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 Tle493dMagnetic3DSensor = Tle493d(); double X_min=0; double X_max=0; +double Y_min=0; +double Y_max=0; double Z_min=0; double Z_max=0; @@ -18,7 +18,6 @@ void setup() { while (!Serial); Tle493dMagnetic3DSensor.begin(); Tle493dMagnetic3DSensor.enableTemp(); - } void loop() { @@ -34,20 +33,20 @@ void loop() { double x = Tle493dMagnetic3DSensor.getX(); /* *zSign */ //cal for gain. check for new x extrema if (xX_max) { - X_max=x) + X_max=x; } // ---- double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */ //calibration for gain. check for new y extrema if (yY_max) { - Y_max=y) + Y_max=y; } @@ -55,6 +54,7 @@ void loop() { int sp_int=-1; int number_char=-1; int counter=0; + int gain = 1; Serial.print("zsign = "); Serial.print(zSign); From f1c48011f38af359de538c1e8733485270a0fded Mon Sep 17 00:00:00 2001 From: "Enriquez Garcia Juan Antonio (IFAG DES TCP EDS)" Date: Thu, 5 Mar 2020 16:53:12 +0100 Subject: [PATCH 10/10] Updated uncompleted example --- .../DrillTrigger_SpeedAsNumber.ino | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino index 6649f6d..7361172 100644 --- a/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino +++ b/examples/DrillTrigger_SpeedAsNumber/DrillTrigger_SpeedAsNumber.ino @@ -2,59 +2,41 @@ * 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 Tle493dMagnetic3DSensor = Tle493d(); -double X_min=0; -double X_max=0; -double Y_min=0; -double Y_max=0; -double Z_min=0; -double Z_max=0; - 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 x = Tle493dMagnetic3DSensor.getX(); /* *zSign */ - //cal for gain. check for new x extrema - if (xX_max) { - X_max=x; - } - // ---- - - double y = Tle493dMagnetic3DSensor.getY(); /* *zSign */ - //calibration for gain. check for new y extrema - if (yY_max) { - Y_max=y; - } - double sp = -1; int sp_int=-1; int number_char=-1; int counter=0; - int gain = 1; Serial.print("zsign = "); Serial.print(zSign); @@ -64,16 +46,13 @@ void loop() { Serial.print(y); Serial.print(") ; z="); Serial.println(z); - sp=(atan2(x*zSign,z)+1)*gain; + 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= "); + 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); - number_char=sp_int/50; - Serial.print("Characters for speed = "); - Serial.println(number_char); - delay(500); + delay(1500); }