From 1fb85fcf2582320cc41621b90adbb0a1aef551e0 Mon Sep 17 00:00:00 2001 From: Abel Tim Date: Sun, 11 May 2025 22:01:13 +0200 Subject: added encoder again Multi-line description of commit, feel free to be detailed. Signed-off-by: Abel Tim --- code/debug/IR/cheapRCJ05sensors-RobotDemos09.pdf | Bin 480338 -> 0 bytes .../rx/rx_decode_teensy/include/README | 37 +++ .../rx/rx_decode_teensy/lib/README | 46 ++++ .../rx/rx_decode_teensy/platformio.ini | 14 + .../rx/rx_decode_teensy/src/main.cpp | 48 ++++ .../rx/rx_decode_teensy/test/README | 11 + .../communication&IR/rx/rx_teensy/include/README | 37 +++ .../debug/communication&IR/rx/rx_teensy/lib/README | 46 ++++ .../communication&IR/rx/rx_teensy/platformio.ini | 14 + .../communication&IR/rx/rx_teensy/src/main.cpp | 20 ++ .../communication&IR/rx/rx_teensy/test/README | 11 + .../tx/tx-IR/cheapRCJ05sensors-RobotDemos09.pdf | Bin 0 -> 480338 bytes .../debug/communication&IR/tx/tx-IR/include/README | 37 +++ code/debug/communication&IR/tx/tx-IR/lib/README | 46 ++++ .../debug/communication&IR/tx/tx-IR/platformio.ini | 14 + code/debug/communication&IR/tx/tx-IR/src/main.cpp | 86 +++++++ code/debug/communication&IR/tx/tx-IR/test/README | 11 + .../tx/tx_rand_XIAO/include/README | 37 +++ .../communication&IR/tx/tx_rand_XIAO/lib/README | 46 ++++ .../tx/tx_rand_XIAO/platformio.ini | 14 + .../communication&IR/tx/tx_rand_XIAO/src/main.cpp | 75 ++++++ .../communication&IR/tx/tx_rand_XIAO/test/README | 11 + .../rx/rx_decode_teensy/.vscode/extensions.json | 10 - .../rx/rx_decode_teensy/include/README | 37 --- .../communication/rx/rx_decode_teensy/lib/README | 46 ---- .../rx/rx_decode_teensy/platformio.ini | 14 - .../communication/rx/rx_decode_teensy/src/main.cpp | 48 ---- .../communication/rx/rx_decode_teensy/test/README | 11 - .../rx/rx_teensy/.vscode/extensions.json | 10 - .../communication/rx/rx_teensy/include/README | 37 --- code/debug/communication/rx/rx_teensy/lib/README | 46 ---- .../communication/rx/rx_teensy/platformio.ini | 14 - code/debug/communication/rx/rx_teensy/src/main.cpp | 20 -- code/debug/communication/rx/rx_teensy/test/README | 11 - code/debug/communication/tx/tx-IR/include/README | 37 --- code/debug/communication/tx/tx-IR/lib/README | 46 ---- code/debug/communication/tx/tx-IR/platformio.ini | 14 - code/debug/communication/tx/tx-IR/src/main.cpp | 86 ------- code/debug/communication/tx/tx-IR/test/README | 11 - .../tx/tx_rand_XIAO/.vscode/extensions.json | 10 - .../communication/tx/tx_rand_XIAO/include/README | 37 --- .../debug/communication/tx/tx_rand_XIAO/lib/README | 46 ---- .../communication/tx/tx_rand_XIAO/platformio.ini | 14 - .../communication/tx/tx_rand_XIAO/src/main.cpp | 75 ------ .../communication/tx/tx_rand_XIAO/test/README | 11 - code/debug/motors/3motor_PWM/src/main.cpp | 53 ++-- code/debug/motors/PWM/src/main.cpp | 2 + code/debug/motors/enc-pwm-3-motor/.gitignore | 1 + code/debug/motors/enc-pwm-3-motor/include/README | 37 +++ code/debug/motors/enc-pwm-3-motor/lib/README | 46 ++++ code/debug/motors/enc-pwm-3-motor/platformio.ini | 14 + code/debug/motors/enc-pwm-3-motor/src/main.cpp | 284 +++++++++++++++++++++ code/debug/motors/enc-pwm-3-motor/test/README | 11 + code/main/teensy_player/src/main.cpp | 17 -- 54 files changed, 1090 insertions(+), 727 deletions(-) delete mode 100644 code/debug/IR/cheapRCJ05sensors-RobotDemos09.pdf create mode 100644 code/debug/communication&IR/rx/rx_decode_teensy/include/README create mode 100644 code/debug/communication&IR/rx/rx_decode_teensy/lib/README create mode 100644 code/debug/communication&IR/rx/rx_decode_teensy/platformio.ini create mode 100644 code/debug/communication&IR/rx/rx_decode_teensy/src/main.cpp create mode 100644 code/debug/communication&IR/rx/rx_decode_teensy/test/README create mode 100644 code/debug/communication&IR/rx/rx_teensy/include/README create mode 100644 code/debug/communication&IR/rx/rx_teensy/lib/README create mode 100644 code/debug/communication&IR/rx/rx_teensy/platformio.ini create mode 100644 code/debug/communication&IR/rx/rx_teensy/src/main.cpp create mode 100644 code/debug/communication&IR/rx/rx_teensy/test/README create mode 100644 code/debug/communication&IR/tx/tx-IR/cheapRCJ05sensors-RobotDemos09.pdf create mode 100644 code/debug/communication&IR/tx/tx-IR/include/README create mode 100644 code/debug/communication&IR/tx/tx-IR/lib/README create mode 100644 code/debug/communication&IR/tx/tx-IR/platformio.ini create mode 100644 code/debug/communication&IR/tx/tx-IR/src/main.cpp create mode 100644 code/debug/communication&IR/tx/tx-IR/test/README create mode 100644 code/debug/communication&IR/tx/tx_rand_XIAO/include/README create mode 100644 code/debug/communication&IR/tx/tx_rand_XIAO/lib/README create mode 100644 code/debug/communication&IR/tx/tx_rand_XIAO/platformio.ini create mode 100644 code/debug/communication&IR/tx/tx_rand_XIAO/src/main.cpp create mode 100644 code/debug/communication&IR/tx/tx_rand_XIAO/test/README delete mode 100644 code/debug/communication/rx/rx_decode_teensy/.vscode/extensions.json delete mode 100644 code/debug/communication/rx/rx_decode_teensy/include/README delete mode 100644 code/debug/communication/rx/rx_decode_teensy/lib/README delete mode 100644 code/debug/communication/rx/rx_decode_teensy/platformio.ini delete mode 100644 code/debug/communication/rx/rx_decode_teensy/src/main.cpp delete mode 100644 code/debug/communication/rx/rx_decode_teensy/test/README delete mode 100644 code/debug/communication/rx/rx_teensy/.vscode/extensions.json delete mode 100644 code/debug/communication/rx/rx_teensy/include/README delete mode 100644 code/debug/communication/rx/rx_teensy/lib/README delete mode 100644 code/debug/communication/rx/rx_teensy/platformio.ini delete mode 100644 code/debug/communication/rx/rx_teensy/src/main.cpp delete mode 100644 code/debug/communication/rx/rx_teensy/test/README delete mode 100644 code/debug/communication/tx/tx-IR/include/README delete mode 100644 code/debug/communication/tx/tx-IR/lib/README delete mode 100644 code/debug/communication/tx/tx-IR/platformio.ini delete mode 100644 code/debug/communication/tx/tx-IR/src/main.cpp delete mode 100644 code/debug/communication/tx/tx-IR/test/README delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/.vscode/extensions.json delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/include/README delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/lib/README delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/platformio.ini delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/src/main.cpp delete mode 100644 code/debug/communication/tx/tx_rand_XIAO/test/README create mode 100644 code/debug/motors/enc-pwm-3-motor/.gitignore create mode 100644 code/debug/motors/enc-pwm-3-motor/include/README create mode 100644 code/debug/motors/enc-pwm-3-motor/lib/README create mode 100644 code/debug/motors/enc-pwm-3-motor/platformio.ini create mode 100644 code/debug/motors/enc-pwm-3-motor/src/main.cpp create mode 100644 code/debug/motors/enc-pwm-3-motor/test/README diff --git a/code/debug/IR/cheapRCJ05sensors-RobotDemos09.pdf b/code/debug/IR/cheapRCJ05sensors-RobotDemos09.pdf deleted file mode 100644 index 3eed27d..0000000 Binary files a/code/debug/IR/cheapRCJ05sensors-RobotDemos09.pdf and /dev/null differ diff --git a/code/debug/communication&IR/rx/rx_decode_teensy/include/README b/code/debug/communication&IR/rx/rx_decode_teensy/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_decode_teensy/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication&IR/rx/rx_decode_teensy/lib/README b/code/debug/communication&IR/rx/rx_decode_teensy/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_decode_teensy/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication&IR/rx/rx_decode_teensy/platformio.ini b/code/debug/communication&IR/rx/rx_decode_teensy/platformio.ini new file mode 100644 index 0000000..a13d034 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_decode_teensy/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:teensy41] +platform = teensy +board = teensy41 +framework = arduino diff --git a/code/debug/communication&IR/rx/rx_decode_teensy/src/main.cpp b/code/debug/communication&IR/rx/rx_decode_teensy/src/main.cpp new file mode 100644 index 0000000..f91d6d3 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_decode_teensy/src/main.cpp @@ -0,0 +1,48 @@ +#include + +int incomingbyte = 0; +bool iswriting = false; +String tlocdat = ""; //temporary location data +String locdat = ""; //location data +int ir1 = -99; +int ir2 = -99; +int ir3 = -99; +int ir4 = -99; +int ir5 = -99; +int ir6 = -99; +int ir7 = -99; +int ir8 = -99; + + +void setup() { + Serial.begin(9600); + Serial3.begin(9600); //19200 +} + +void loop() { + if (Serial3.available() > 0) { + incomingbyte = Serial3.read(); + //Serial.print(char(incomingbyte)); + if (incomingbyte == 's'){ + iswriting = true; + tlocdat = ""; + }else if(incomingbyte == 'e'){ + iswriting = false; + locdat = tlocdat; + }else if(iswriting == true){ + //Serial.print(char(incomingbyte)); + tlocdat += (char)incomingbyte; + } + } + //Serial.println(locdat); + sscanf(locdat.c_str(), "%d, %d, %d, %d, %d, %d, %d, %d", &ir1, &ir2, &ir3, &ir4, &ir5, &ir6, &ir7, &ir8); //split recieved data into seperate variables + Serial.print("IR sensor N: "); + Serial.print(ir1); + Serial.print(ir2); + Serial.print(ir3); + Serial.print(ir4); + Serial.print(ir5); + Serial.print(ir6); + + delayMicroseconds(1); +} diff --git a/code/debug/communication&IR/rx/rx_decode_teensy/test/README b/code/debug/communication&IR/rx/rx_decode_teensy/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/code/debug/communication&IR/rx/rx_decode_teensy/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication&IR/rx/rx_teensy/include/README b/code/debug/communication&IR/rx/rx_teensy/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_teensy/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication&IR/rx/rx_teensy/lib/README b/code/debug/communication&IR/rx/rx_teensy/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_teensy/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication&IR/rx/rx_teensy/platformio.ini b/code/debug/communication&IR/rx/rx_teensy/platformio.ini new file mode 100644 index 0000000..a13d034 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_teensy/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:teensy41] +platform = teensy +board = teensy41 +framework = arduino diff --git a/code/debug/communication&IR/rx/rx_teensy/src/main.cpp b/code/debug/communication&IR/rx/rx_teensy/src/main.cpp new file mode 100644 index 0000000..f3e9e79 --- /dev/null +++ b/code/debug/communication&IR/rx/rx_teensy/src/main.cpp @@ -0,0 +1,20 @@ +// this code is for Teensy 4.1 to read serial data and relay it to serial 1(computer) + +#include + +int incomingbyte = 0; +void setup() { + Serial.begin(9600); + Serial2.begin(9600); //19200 + Serial3.begin(9600); //19200 + Serial.print("Starting ...."); +} + +void loop() { + if (Serial3.available() > 0) { + incomingbyte = Serial3.read(); + Serial.print(char(incomingbyte)); + } + milis(1); + +} \ No newline at end of file diff --git a/code/debug/communication&IR/rx/rx_teensy/test/README b/code/debug/communication&IR/rx/rx_teensy/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/code/debug/communication&IR/rx/rx_teensy/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication&IR/tx/tx-IR/cheapRCJ05sensors-RobotDemos09.pdf b/code/debug/communication&IR/tx/tx-IR/cheapRCJ05sensors-RobotDemos09.pdf new file mode 100644 index 0000000..3eed27d Binary files /dev/null and b/code/debug/communication&IR/tx/tx-IR/cheapRCJ05sensors-RobotDemos09.pdf differ diff --git a/code/debug/communication&IR/tx/tx-IR/include/README b/code/debug/communication&IR/tx/tx-IR/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/code/debug/communication&IR/tx/tx-IR/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication&IR/tx/tx-IR/lib/README b/code/debug/communication&IR/tx/tx-IR/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/code/debug/communication&IR/tx/tx-IR/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication&IR/tx/tx-IR/platformio.ini b/code/debug/communication&IR/tx/tx-IR/platformio.ini new file mode 100644 index 0000000..87a4592 --- /dev/null +++ b/code/debug/communication&IR/tx/tx-IR/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:seeed_xiao] +platform = atmelsam +board = seeed_xiao +framework = arduino diff --git a/code/debug/communication&IR/tx/tx-IR/src/main.cpp b/code/debug/communication&IR/tx/tx-IR/src/main.cpp new file mode 100644 index 0000000..43d396f --- /dev/null +++ b/code/debug/communication&IR/tx/tx-IR/src/main.cpp @@ -0,0 +1,86 @@ +#include + +int ir1 = 0; +int ir2 = 1; +int ir3 = 9; +int ir4 = 2; +int ir5 = 3; +int ir6 = 4; +int ir7 = 5; +int ir8 = 8; + +int dir1 = 1; // data IR1 +int dir2 = 1; // data IR2 +int dir3 = 1; // etc +int dir4 = 1; +int dir5 = 1; +int dir6 = 1; +int dir7 = 1; +int dir8 = 1; + +volatile long IRcount1 = 0; +volatile long IRcount2 = 0; +volatile long IRcount3 = 0; +volatile long IRcount4 = 0; +volatile long IRcount5 = 0; +volatile long IRcount6 = 0; +volatile long IRcount7 = 0; +volatile long IRcount8 = 0; + +void setup() { + pinMode(ir1, INPUT); + pinMode(ir2, INPUT); + pinMode(ir3, INPUT); + pinMode(ir4, INPUT); + pinMode(ir5, INPUT); + pinMode(ir6, INPUT); + pinMode(ir7, INPUT); + pinMode(ir8, INPUT); + + Serial.begin(9600); + Serial1.begin(9600); + Serial.println("start"); + Serial1.println("start"); + + Serial.println("Starting loop"); + Serial1.println("Starting loop"); +} + +void loop() { + unsigned long p1 = pulseIn(ir1, HIGH); //pulse width in microseconds + unsigned long p2 = pulseIn(ir2, HIGH); //pulse width in microseconds + unsigned long p3 = pulseIn(ir3, HIGH); //pulse width in microseconds + unsigned long p4 = pulseIn(ir4, HIGH); //pulse width in microseconds + unsigned long p5 = pulseIn(ir5, HIGH); //pulse width in microseconds + unsigned long p6 = pulseIn(ir6, HIGH); //pulse width in microseconds + unsigned long p7 = pulseIn(ir7, HIGH); //pulse width in microseconds + unsigned long p8 = pulseIn(ir8, HIGH); //pulse width in microseconds + + //one seeed xiao uses S-R the other uses B-E as start and end + // it returns data like this: + // S0, 0, 0, 0, 0, 0, 0, 0R + //or + // B0, 0, 0, 0, 0, 0, 0, 0E + + //Serial1print("B"); //uncomment this line to use B-E + Serial1.print("S"); //uncomment this line to use S-R + Serial1.print(p1); + Serial1.print(", "); + Serial1.print(p2); + Serial1.print(", "); + Serial1.print(p3); + Serial1.print(", "); + Serial1.print(p4); + Serial1.print(", "); + Serial1.print(p5); + Serial1.print(", "); + Serial1.print(p6); + Serial1.print(", "); + Serial1.print(p7); + Serial1.print(", "); + Serial1.println(p8); + //Serial1.println("E"); //uncomment this line to use B-E + Serialq.println("R"); //uncomment this line to use S-R + + delay(100); // delay to avoid flooding the serial port +} \ No newline at end of file diff --git a/code/debug/communication&IR/tx/tx-IR/test/README b/code/debug/communication&IR/tx/tx-IR/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/code/debug/communication&IR/tx/tx-IR/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication&IR/tx/tx_rand_XIAO/include/README b/code/debug/communication&IR/tx/tx_rand_XIAO/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/code/debug/communication&IR/tx/tx_rand_XIAO/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication&IR/tx/tx_rand_XIAO/lib/README b/code/debug/communication&IR/tx/tx_rand_XIAO/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/code/debug/communication&IR/tx/tx_rand_XIAO/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication&IR/tx/tx_rand_XIAO/platformio.ini b/code/debug/communication&IR/tx/tx_rand_XIAO/platformio.ini new file mode 100644 index 0000000..87a4592 --- /dev/null +++ b/code/debug/communication&IR/tx/tx_rand_XIAO/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:seeed_xiao] +platform = atmelsam +board = seeed_xiao +framework = arduino diff --git a/code/debug/communication&IR/tx/tx_rand_XIAO/src/main.cpp b/code/debug/communication&IR/tx/tx_rand_XIAO/src/main.cpp new file mode 100644 index 0000000..d164e3d --- /dev/null +++ b/code/debug/communication&IR/tx/tx_rand_XIAO/src/main.cpp @@ -0,0 +1,75 @@ +// code to send random numbers via the seeed XIAO's Serial1 port +#include + +long rn1; +long rn2; +long rn3; +long rn4; +long rn5; +long rn6; +long rn7; +long rn8; + + +void setup() { + Serial.begin(9600); + Serial1.begin(9600); + Serial.println("Starting loop"); + + randomSeed(analogRead(0)); +} + +void loop() { + rn1 = random(1500); + rn2 = random(1500); + rn3 = random(1500); + rn4 = random(1500); + rn5 = random(1500); + rn6 = random(1500); + rn7 = random(1500); + rn8 = random(1500); + + Serial.print("S"); + //Serial.print("B"); + Serial.print(rn1); + Serial.print(", "); + Serial.print(rn2); + Serial.print(", "); + Serial.print(rn3); + Serial.print(", "); + Serial.print(rn4); + Serial.print(", "); + Serial.print(rn5); + Serial.print(", "); + Serial.print(rn6); + Serial.print(", "); + Serial.print(rn7); + Serial.print(", "); + Serial.println(rn8); + Serial.println("R"); + //Serial.print("E"); + + Serial1.print("S"); + //Serial1.print("B"); + Serial1.print(rn1); + Serial1.print(", "); + Serial1.print(rn2); + Serial1.print(", "); + Serial1.print(rn3); + Serial1.print(", "); + Serial1.print(rn4); + Serial1.print(", "); + Serial1.print(rn5); + Serial1.print(", "); + Serial1.print(rn6); + Serial1.print(", "); + Serial1.print(rn7); + Serial1.print(", "); + Serial1.println(rn8); + Serial.println("R"); + //Serial1.print("E"); + + + delay(250); + +} \ No newline at end of file diff --git a/code/debug/communication&IR/tx/tx_rand_XIAO/test/README b/code/debug/communication&IR/tx/tx_rand_XIAO/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/code/debug/communication&IR/tx/tx_rand_XIAO/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication/rx/rx_decode_teensy/.vscode/extensions.json b/code/debug/communication/rx/rx_decode_teensy/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/code/debug/communication/rx/rx_decode_teensy/include/README b/code/debug/communication/rx/rx_decode_teensy/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/include/README +++ /dev/null @@ -1,37 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the convention is to give header files names that end with `.h'. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication/rx/rx_decode_teensy/lib/README b/code/debug/communication/rx/rx_decode_teensy/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into the executable file. - -The source code of each library should be placed in a separate directory -("lib/your_library_name/[Code]"). - -For example, see the structure of the following example libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -Example contents of `src/main.c` using Foo and Bar: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -The PlatformIO Library Dependency Finder will find automatically dependent -libraries by scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication/rx/rx_decode_teensy/platformio.ini b/code/debug/communication/rx/rx_decode_teensy/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:teensy41] -platform = teensy -board = teensy41 -framework = arduino diff --git a/code/debug/communication/rx/rx_decode_teensy/src/main.cpp b/code/debug/communication/rx/rx_decode_teensy/src/main.cpp deleted file mode 100644 index 07639ce..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/src/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -int incomingbyte = 0; -bool iswriting = false; -String tlocdat = ""; //temporary location data -String locdat = ""; //location data -int ir1 = -99; -int ir2 = -99; -int ir3 = -99; -int ir4 = -99; -int ir5 = -99; -int ir6 = -99; -int ir7 = -99; -int ir8 = -99; - - -void setup() { - Serial.begin(9600); - Serial3.begin(9600); //19200 -} - -void loop() { - if (Serial3.available() > 0) { - incomingbyte = Serial3.read(); - //Serial.print(char(incomingbyte)); - if (incomingbyte == 's'){ - iswriting = true; - tlocdat = ""; - }else if(incomingbyte == 'e'){ - iswriting = false; - locdat = tlocdat; - }else if(iswriting == true){ - //Serial.print(char(incomingbyte)); - tlocdat += (char)incomingbyte; - } - } - //Serial.println(locdat); - sscanf(locdat.c_str(), "%d, %d, %d, %d, %d, %d, %d, %d", &ir1, &ir2, &ir3, &ir4, &ir5, &ir6, &ir7, &ir8); - Serial.print("IR sensor N: "); - Serial.print(ir1); - Serial.print(ir2); - Serial.print(ir3); - Serial.print(ir4); - Serial.print(ir5); - Serial.print(ir6); - - delayMicroseconds(1); -} diff --git a/code/debug/communication/rx/rx_decode_teensy/test/README b/code/debug/communication/rx/rx_decode_teensy/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/communication/rx/rx_decode_teensy/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication/rx/rx_teensy/.vscode/extensions.json b/code/debug/communication/rx/rx_teensy/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/code/debug/communication/rx/rx_teensy/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/code/debug/communication/rx/rx_teensy/include/README b/code/debug/communication/rx/rx_teensy/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/communication/rx/rx_teensy/include/README +++ /dev/null @@ -1,37 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the convention is to give header files names that end with `.h'. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication/rx/rx_teensy/lib/README b/code/debug/communication/rx/rx_teensy/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/communication/rx/rx_teensy/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into the executable file. - -The source code of each library should be placed in a separate directory -("lib/your_library_name/[Code]"). - -For example, see the structure of the following example libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -Example contents of `src/main.c` using Foo and Bar: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -The PlatformIO Library Dependency Finder will find automatically dependent -libraries by scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication/rx/rx_teensy/platformio.ini b/code/debug/communication/rx/rx_teensy/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/communication/rx/rx_teensy/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:teensy41] -platform = teensy -board = teensy41 -framework = arduino diff --git a/code/debug/communication/rx/rx_teensy/src/main.cpp b/code/debug/communication/rx/rx_teensy/src/main.cpp deleted file mode 100644 index 768b70b..0000000 --- a/code/debug/communication/rx/rx_teensy/src/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// this code is for Teensy 4.1 to read serial data - -#include - -int incomingbyte = 0; -void setup() { - Serial.begin(9600); - Serial2.begin(9600); //19200 - Serial3.begin(9600); //19200 - Serial.print("Starting ...."); -} - -void loop() { - if (Serial3.available() > 0) { - incomingbyte = Serial3.read(); - Serial.print(char(incomingbyte)); - } - milis(1); - -} \ No newline at end of file diff --git a/code/debug/communication/rx/rx_teensy/test/README b/code/debug/communication/rx/rx_teensy/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/communication/rx/rx_teensy/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication/tx/tx-IR/include/README b/code/debug/communication/tx/tx-IR/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/communication/tx/tx-IR/include/README +++ /dev/null @@ -1,37 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the convention is to give header files names that end with `.h'. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication/tx/tx-IR/lib/README b/code/debug/communication/tx/tx-IR/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/communication/tx/tx-IR/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into the executable file. - -The source code of each library should be placed in a separate directory -("lib/your_library_name/[Code]"). - -For example, see the structure of the following example libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -Example contents of `src/main.c` using Foo and Bar: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -The PlatformIO Library Dependency Finder will find automatically dependent -libraries by scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication/tx/tx-IR/platformio.ini b/code/debug/communication/tx/tx-IR/platformio.ini deleted file mode 100644 index 87a4592..0000000 --- a/code/debug/communication/tx/tx-IR/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:seeed_xiao] -platform = atmelsam -board = seeed_xiao -framework = arduino diff --git a/code/debug/communication/tx/tx-IR/src/main.cpp b/code/debug/communication/tx/tx-IR/src/main.cpp deleted file mode 100644 index 43d396f..0000000 --- a/code/debug/communication/tx/tx-IR/src/main.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include - -int ir1 = 0; -int ir2 = 1; -int ir3 = 9; -int ir4 = 2; -int ir5 = 3; -int ir6 = 4; -int ir7 = 5; -int ir8 = 8; - -int dir1 = 1; // data IR1 -int dir2 = 1; // data IR2 -int dir3 = 1; // etc -int dir4 = 1; -int dir5 = 1; -int dir6 = 1; -int dir7 = 1; -int dir8 = 1; - -volatile long IRcount1 = 0; -volatile long IRcount2 = 0; -volatile long IRcount3 = 0; -volatile long IRcount4 = 0; -volatile long IRcount5 = 0; -volatile long IRcount6 = 0; -volatile long IRcount7 = 0; -volatile long IRcount8 = 0; - -void setup() { - pinMode(ir1, INPUT); - pinMode(ir2, INPUT); - pinMode(ir3, INPUT); - pinMode(ir4, INPUT); - pinMode(ir5, INPUT); - pinMode(ir6, INPUT); - pinMode(ir7, INPUT); - pinMode(ir8, INPUT); - - Serial.begin(9600); - Serial1.begin(9600); - Serial.println("start"); - Serial1.println("start"); - - Serial.println("Starting loop"); - Serial1.println("Starting loop"); -} - -void loop() { - unsigned long p1 = pulseIn(ir1, HIGH); //pulse width in microseconds - unsigned long p2 = pulseIn(ir2, HIGH); //pulse width in microseconds - unsigned long p3 = pulseIn(ir3, HIGH); //pulse width in microseconds - unsigned long p4 = pulseIn(ir4, HIGH); //pulse width in microseconds - unsigned long p5 = pulseIn(ir5, HIGH); //pulse width in microseconds - unsigned long p6 = pulseIn(ir6, HIGH); //pulse width in microseconds - unsigned long p7 = pulseIn(ir7, HIGH); //pulse width in microseconds - unsigned long p8 = pulseIn(ir8, HIGH); //pulse width in microseconds - - //one seeed xiao uses S-R the other uses B-E as start and end - // it returns data like this: - // S0, 0, 0, 0, 0, 0, 0, 0R - //or - // B0, 0, 0, 0, 0, 0, 0, 0E - - //Serial1print("B"); //uncomment this line to use B-E - Serial1.print("S"); //uncomment this line to use S-R - Serial1.print(p1); - Serial1.print(", "); - Serial1.print(p2); - Serial1.print(", "); - Serial1.print(p3); - Serial1.print(", "); - Serial1.print(p4); - Serial1.print(", "); - Serial1.print(p5); - Serial1.print(", "); - Serial1.print(p6); - Serial1.print(", "); - Serial1.print(p7); - Serial1.print(", "); - Serial1.println(p8); - //Serial1.println("E"); //uncomment this line to use B-E - Serialq.println("R"); //uncomment this line to use S-R - - delay(100); // delay to avoid flooding the serial port -} \ No newline at end of file diff --git a/code/debug/communication/tx/tx-IR/test/README b/code/debug/communication/tx/tx-IR/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/communication/tx/tx-IR/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/communication/tx/tx_rand_XIAO/.vscode/extensions.json b/code/debug/communication/tx/tx_rand_XIAO/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/.vscode/extensions.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] -} diff --git a/code/debug/communication/tx/tx_rand_XIAO/include/README b/code/debug/communication/tx/tx_rand_XIAO/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/include/README +++ /dev/null @@ -1,37 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the convention is to give header files names that end with `.h'. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/communication/tx/tx_rand_XIAO/lib/README b/code/debug/communication/tx/tx_rand_XIAO/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into the executable file. - -The source code of each library should be placed in a separate directory -("lib/your_library_name/[Code]"). - -For example, see the structure of the following example libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -Example contents of `src/main.c` using Foo and Bar: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -The PlatformIO Library Dependency Finder will find automatically dependent -libraries by scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/communication/tx/tx_rand_XIAO/platformio.ini b/code/debug/communication/tx/tx_rand_XIAO/platformio.ini deleted file mode 100644 index 87a4592..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/platformio.ini +++ /dev/null @@ -1,14 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:seeed_xiao] -platform = atmelsam -board = seeed_xiao -framework = arduino diff --git a/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp b/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp deleted file mode 100644 index d164e3d..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/src/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// code to send random numbers via the seeed XIAO's Serial1 port -#include - -long rn1; -long rn2; -long rn3; -long rn4; -long rn5; -long rn6; -long rn7; -long rn8; - - -void setup() { - Serial.begin(9600); - Serial1.begin(9600); - Serial.println("Starting loop"); - - randomSeed(analogRead(0)); -} - -void loop() { - rn1 = random(1500); - rn2 = random(1500); - rn3 = random(1500); - rn4 = random(1500); - rn5 = random(1500); - rn6 = random(1500); - rn7 = random(1500); - rn8 = random(1500); - - Serial.print("S"); - //Serial.print("B"); - Serial.print(rn1); - Serial.print(", "); - Serial.print(rn2); - Serial.print(", "); - Serial.print(rn3); - Serial.print(", "); - Serial.print(rn4); - Serial.print(", "); - Serial.print(rn5); - Serial.print(", "); - Serial.print(rn6); - Serial.print(", "); - Serial.print(rn7); - Serial.print(", "); - Serial.println(rn8); - Serial.println("R"); - //Serial.print("E"); - - Serial1.print("S"); - //Serial1.print("B"); - Serial1.print(rn1); - Serial1.print(", "); - Serial1.print(rn2); - Serial1.print(", "); - Serial1.print(rn3); - Serial1.print(", "); - Serial1.print(rn4); - Serial1.print(", "); - Serial1.print(rn5); - Serial1.print(", "); - Serial1.print(rn6); - Serial1.print(", "); - Serial1.print(rn7); - Serial1.print(", "); - Serial1.println(rn8); - Serial.println("R"); - //Serial1.print("E"); - - - delay(250); - -} \ No newline at end of file diff --git a/code/debug/communication/tx/tx_rand_XIAO/test/README b/code/debug/communication/tx/tx_rand_XIAO/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/communication/tx/tx_rand_XIAO/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PlatformIO Test Runner and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PlatformIO Unit Testing: -- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/debug/motors/3motor_PWM/src/main.cpp b/code/debug/motors/3motor_PWM/src/main.cpp index c9753d5..1a0fa98 100644 --- a/code/debug/motors/3motor_PWM/src/main.cpp +++ b/code/debug/motors/3motor_PWM/src/main.cpp @@ -119,14 +119,26 @@ void updatePWM() { void drive(int speed, int direction){ + // + //!!! + // If the motors are spinning incorectly, change pins not the drive function. + //!!! + // + // 0 = motor off + // + = motor spinning forwards + // - = motor spinning backwards + // + // Motor 1 is the left one. + // Motor 2 is the one in the back. + // Motor 3 is the right one. // // Direction............|.Motor 1.|.Motor 2.|.Motor 3. - // 0deg(forward)........|....0....|....-....|....+.... - // 60deg................|....+....|....-....|....0.... - // 120deg...............|....+....|....0....|....-.... - // 180 deg (backward)...|....0....|....+....|....-.... - // 240 deg..............|....-....|....+....|....0.... - // 300 deg..............|....-....|....0....|....+.... + // 0deg(forward)........|....-....|....0....|....+.... + // 60deg................|....0....|....-....|....+.... + // 120deg...............|....+....|....-....|....0.... + // 180 deg (backward)...|....+....|....0....|....-.... + // 240 deg..............|....0....|....+....|....-.... + // 300 deg..............|....-....|....+....|....0.... // PWMval1 = speed; @@ -139,15 +151,15 @@ void drive(int speed, int direction){ Serial.println(direction); if(direction>330 || direction<=30){ //0 deg - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); + Serial.println("0 deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); digitalWrite(m2pwm1, LOW); digitalWrite(m2pwm2, LOW); digitalWrite(m3pwm1, HIGH); - digitalWrite(m3pwm2, LOW); - Serial.println("0 deg"); + digitalWrite(m3pwm2, LOW); }else if (direction>30 && direction <= 90){ //60 deg Serial.println("60deg"); @@ -157,22 +169,24 @@ void drive(int speed, int direction){ digitalWrite(m2pwm1, LOW); digitalWrite(m2pwm2, HIGH); - digitalWrite(m3pwm1, LOW); - digitalWrite(m3pwm2, HIGH); + digitalWrite(m3pwm1, HIGH); + digitalWrite(m3pwm2, LOW); }else if (direction>90 && direction <= 150){ //120 deg Serial.println("120 deg"); digitalWrite(m1pwm1, HIGH); digitalWrite(m1pwm2, LOW); - digitalWrite(m2pwm1, HIGH); - digitalWrite(m2pwm2, LOW); + + digitalWrite(m2pwm1, LOW); + digitalWrite(m2pwm2, HIGH); + digitalWrite(m3pwm1, LOW); digitalWrite(m3pwm2, LOW); }else if (direction > 150 && direction <= 210) { //180 degrees Serial.println("on 180"); - digitalWrite(m1pwm1, LOW); - digitalWrite(m1pwm2, HIGH); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); digitalWrite(m2pwm1, LOW); digitalWrite(m2pwm2, LOW); @@ -181,6 +195,7 @@ void drive(int speed, int direction){ digitalWrite(m3pwm2, HIGH); }else if (direction > 210 && direction <= 270) { //240 degrees + Serial.println("240deg"); digitalWrite(m1pwm1, LOW); digitalWrite(m1pwm2, LOW); @@ -191,13 +206,13 @@ void drive(int speed, int direction){ digitalWrite(m3pwm2, HIGH); }else if (direction > 270 && direction <= 330) { //300 degrees - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); + Serial.println("300deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); digitalWrite(m2pwm1, HIGH); digitalWrite(m2pwm2, LOW); - Serial.println("300deg"); digitalWrite(m3pwm1, LOW); digitalWrite(m3pwm2, LOW); }else{ diff --git a/code/debug/motors/PWM/src/main.cpp b/code/debug/motors/PWM/src/main.cpp index 53369e4..c7d8fe0 100644 --- a/code/debug/motors/PWM/src/main.cpp +++ b/code/debug/motors/PWM/src/main.cpp @@ -1,5 +1,7 @@ #include +IntervalTimer myTimer; + int pwmPin = 3; //pin for PWM output int pwmacc = 1000; //how accurate the PWM is, means you can enter value from 0 to the value of pwmacc int PWMval = 0; //value of the PWM, means you can enter value from 0 to the value of pwmacc diff --git a/code/debug/motors/enc-pwm-3-motor/.gitignore b/code/debug/motors/enc-pwm-3-motor/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/code/debug/motors/enc-pwm-3-motor/include/README b/code/debug/motors/enc-pwm-3-motor/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/code/debug/motors/enc-pwm-3-motor/lib/README b/code/debug/motors/enc-pwm-3-motor/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/code/debug/motors/enc-pwm-3-motor/platformio.ini b/code/debug/motors/enc-pwm-3-motor/platformio.ini new file mode 100644 index 0000000..a13d034 --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:teensy41] +platform = teensy +board = teensy41 +framework = arduino diff --git a/code/debug/motors/enc-pwm-3-motor/src/main.cpp b/code/debug/motors/enc-pwm-3-motor/src/main.cpp new file mode 100644 index 0000000..4e3cf37 --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/src/main.cpp @@ -0,0 +1,284 @@ +//motor: https://www.pololu.com/product/4861 +//motor driver: https://www.pololu.com/product/2997 + +//Create the timers +IntervalTimer pwm_timer; +IntervalTimer enc_timer; + +//define the pins +//If the motors are spinning incorectly, change pins not the drive function. +int led = 13; + +int m1enA = 6; +int m1enB = 5; +int m1pwm1 = 4; +int m1pwm2 = 3; +int m1encoA = 32; +int m1encoB = 31; + +int m2enA = 12; +int m2enB = 11; +int m2pwm1 = 9; +int m2pwm2 = 10; +int m2encoA = 30; +int m2encoB = 29; + +int m3enA = 27; +int m3enB = 26; +int m3pwm1 = 24; +int m3pwm2 = 25; +int m3encoA = 28; +int m3encoB = 23; + +//PWM variables +int pwmacc = 100; //how accurate the PWM is, means you can enter value from 0 to the value of pwmacc +int PWMval1 = 0; //value of the PWM1, means you can enter value from 0 to the value of pwmacc +int PWMval2 = 0; //same but for the second one +int PWMval3 = 0; //same but for the thirth one + +//encoder variables +const int refreshrate = 50; //refresh rate of the encoder +volatile long oneENCcount = 0; //the amount of pulses from motor one encoder +volatile long twoENCcount = 0; //idem, but motor two +volatile long threeENCcount = 0; //kɛlɔ + +double ONErpm = 0.00; //the amount of revolutions motor one makes per minute +double TWOrpm = 0.00; //mismo +double THREErpm = 0.00; //адилхан + + + +void setup() { + pinMode(m1enA, OUTPUT); + pinMode(m1enB, OUTPUT); + pinMode(m1pwm1, OUTPUT); + pinMode(m1pwm2, OUTPUT); + + pinMode(m2enA, OUTPUT); + pinMode(m2enB, OUTPUT); + pinMode(m2pwm1, OUTPUT); + pinMode(m2pwm2, OUTPUT); + + pinMode(m3enA, OUTPUT); + pinMode(m3enB, OUTPUT); + pinMode(m3pwm1, OUTPUT); + pinMode(m3pwm2, OUTPUT); + + pwm_timer.begin(updatePWM, refreshrate); //speed at wich PWM is updated PWM + enc_timer.begin(enc_refr, 50); //refresh rate of the encoder + + attachInterrupt(digitalPinToInterrupt(m1encoA), AoneIRS, CHANGE); //calls void AoneIRS if there is a change of the stare of m1encoA + attachInterrupt(digitalPinToInterrupt(m1encoB), BoneIRS, CHANGE); //ditto + attachInterrupt(digitalPinToInterrupt(m2encoA), AtwoIRS, CHANGE); //hali + attachInterrupt(digitalPinToInterrupt(m2encoB), BtwoIRS, CHANGE); //একই + attachInterrupt(digitalPinToInterrupt(m3encoA), AthreeIRS, CHANGE); //ߊ߬ ߓߍ߮ ߓߋ߫ ߞߟߋ߫ + attachInterrupt(digitalPinToInterrupt(m3encoB), AthreeIRS, CHANGE); //To samo + + Serial.begin(9600); + Serial.print("start"); + +} + +void updatePWM() { + //PWM one + //if the entered valvue is less the zero set it to zero, because lower that zero is not posible + if (PWMval1 < 0) { + PWMval1 = 0; + } + //if the enterd value is higher than the maximum posible value, set it to max. + if (PWMval1 > pwmacc) { + PWMval1 = pwmacc; + } + //check if the counter has passed the PWM value, and turn of the motor based on that. + if (counter1 < PWMval1) { + digitalWrite(m1enA, HIGH); + } else { + digitalWrite(m1enA, LOW); + } + counter1++; + + if (counter1 >= pwmacc) { + counter1 = 0; + } + + //PWM two + static int counter2 = 0; + if (PWMval2 < 0) { + PWMval2 = 0; + } + if (PWMval2 > pwmacc) { + PWMval2 = pwmacc; + } + + if (counter2 < PWMval2) { + digitalWrite(m2enA, HIGH); + } else { + digitalWrite(m2enA, LOW); + } + + counter2++; + if (counter2 >= pwmacc) { + counter2 = 0; + } + + //PWM three + int static counter3 = 0; + if (PWMval3 < 0) { + PWMval3 = 0; + } + if (PWMval3 > pwmacc) { + PWMval3 = pwmacc; + } + + if (counter3 < PWMval3) { + digitalWrite(m3enA, HIGH); + } else { + digitalWrite(m3enA, LOW); + } + + counter3++; + if (counter3 >= pwmacc) { + counter3 = 0; + } +} + +void AoneIRS(){ + oneENCcount++ //adds one to the count +} +void BoneIRS(){ + oneENCcount++ //dieselbe +} +void AtwoIRS(){ + twoENCcount++ //même +} +void BtwoIRS(){ + twoENCcount++ //samme +} +void AthreeIRS(){ + threeENCcount++ //aynı +} +void BthreeIRS(){ + threeENCcount++ //такой же +} + +void enc_refr(){ + //calculate RPM. It gets updated 48 times per rotation. + ONErpm = (oneENCcount/48.00) * (60000000.00 / refreshrate) + TWOrpm = (twoENCcount/48.00) * (60000000.00 / refreshrate) + THREErpm = (threeENCcount/48.00) * (60000000.00 / refreshrate) + //reset the counting to zero for next cycle. + oneENCcount = 0; + twoENCcount = 0; + threeENCcount = 0; + +} +void drive(int speed, int direction){ + // + //!!! + // If the motors are spinning incorectly, change pins not the drive function. + //!!! + // + // 0 = motor off + // + = motor spinning forwards + // - = motor spinning backwards + // + // Motor 1 is the left one. + // Motor 2 is the one in the back. + // Motor 3 is the right one. + // + // Direction............|.Motor 1.|.Motor 2.|.Motor 3. + // 0deg(forward)........|....-....|....0....|....+.... + // 60deg................|....0....|....-....|....+.... + // 120deg...............|....+....|....-....|....0.... + // 180 deg (backward)...|....+....|....0....|....-.... + // 240 deg..............|....0....|....+....|....-.... + // 300 deg..............|....-....|....+....|....0.... + // + + PWMval1 = speed; + PWMval2 = speed; + PWMval3 = speed; + digitalWrite(m1enB, LOW); + digitalWrite(m2enB, LOW); + digitalWrite(m3enB, LOW); + Serial.println("debug2"); + Serial.println(direction); + if(direction>330 || direction<=30){ + //0 deg + Serial.println("0 deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); + + digitalWrite(m2pwm1, LOW); + digitalWrite(m2pwm2, LOW); + + digitalWrite(m3pwm1, HIGH); + digitalWrite(m3pwm2, LOW); + }else if (direction>30 && direction <= 90){ + //60 deg + Serial.println("60deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, LOW); + + digitalWrite(m2pwm1, LOW); + digitalWrite(m2pwm2, HIGH); + + digitalWrite(m3pwm1, HIGH); + digitalWrite(m3pwm2, LOW); + }else if (direction>90 && direction <= 150){ + //120 deg + Serial.println("120 deg"); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); + + digitalWrite(m2pwm1, LOW); + digitalWrite(m2pwm2, HIGH); + + digitalWrite(m3pwm1, LOW); + digitalWrite(m3pwm2, LOW); + }else if (direction > 150 && direction <= 210) { + //180 degrees + Serial.println("on 180"); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); + + digitalWrite(m2pwm1, LOW); + digitalWrite(m2pwm2, LOW); + + digitalWrite(m3pwm1, LOW); + digitalWrite(m3pwm2, HIGH); + }else if (direction > 210 && direction <= 270) { + //240 degrees + Serial.println("240deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, LOW); + + digitalWrite(m2pwm1, HIGH); + digitalWrite(m2pwm2, LOW); + + digitalWrite(m3pwm1, LOW); + digitalWrite(m3pwm2, HIGH); + }else if (direction > 270 && direction <= 330) { + //300 degrees + Serial.println("300deg"); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); + + digitalWrite(m2pwm1, HIGH); + digitalWrite(m2pwm2, LOW); + + digitalWrite(m3pwm1, LOW); + digitalWrite(m3pwm2, LOW); + }else{ + Serial.println("how?"); + } +} + +//the loop routine runs over and over again forever: +void loop() { + drive(50, 0); //speed value between 0-100 + Serial.println("Motor one is at: "+ ONErpm + " RPM."); + Serial.println("Motor two is at: "+ TWOrpm + " RPM."); + Serial.println("Motor three is at: "+ THREErpm + " RPM."); + delay(1500); +} diff --git a/code/debug/motors/enc-pwm-3-motor/test/README b/code/debug/motors/enc-pwm-3-motor/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/code/debug/motors/enc-pwm-3-motor/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/code/main/teensy_player/src/main.cpp b/code/main/teensy_player/src/main.cpp index cb9fbba..dca27d8 100644 --- a/code/main/teensy_player/src/main.cpp +++ b/code/main/teensy_player/src/main.cpp @@ -1,18 +1 @@ #include - -// put function declarations here: -int myFunction(int, int); - -void setup() { - // put your setup code here, to run once: - int result = myFunction(2, 3); -} - -void loop() { - // put your main code here, to run repeatedly: -} - -// put function definitions here: -int myFunction(int x, int y) { - return x + y; -} \ No newline at end of file -- cgit v1.2.3