diff options
| author | Abel Tim <abel.tim.t@gmail.com> | 2026-02-08 10:52:55 +0100 |
|---|---|---|
| committer | Abel Tim <abel.tim.t@gmail.com> | 2026-02-08 10:52:55 +0100 |
| commit | 282231ea2829d286ae3432022d56a6c4f573ed33 (patch) | |
| tree | 41f9785885f60a4d45253453988f6b30390aa8b7 /code | |
| parent | a320df8fb9789016b17e98b019f32cff31e31773 (diff) | |
| download | robotica-282231ea2829d286ae3432022d56a6c4f573ed33.tar.gz robotica-282231ea2829d286ae3432022d56a6c4f573ed33.zip | |
SOFTPWM
Multi-line description of commit,
feel free to be detailed.
[Issue: X]
Diffstat (limited to 'code')
47 files changed, 457 insertions, 1548 deletions
diff --git a/code/debug/motors/.idea/.gitignore b/code/debug/motors/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/code/debug/motors/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/code/debug/motors/.idea/editor.xml b/code/debug/motors/.idea/editor.xml new file mode 100644 index 0000000..ca29dcc --- /dev/null +++ b/code/debug/motors/.idea/editor.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="BackendCodeEditorSettings"> + <option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/.idea/modules.xml b/code/debug/motors/.idea/modules.xml new file mode 100644 index 0000000..1984dbc --- /dev/null +++ b/code/debug/motors/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/motors.iml" filepath="$PROJECT_DIR$/.idea/motors.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/.idea/motors.iml b/code/debug/motors/.idea/motors.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/code/debug/motors/.idea/motors.iml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="CPP_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module>
\ No newline at end of file diff --git a/code/debug/motors/.idea/vcs.xml b/code/debug/motors/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/code/debug/motors/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/3motor_PWM/.gitignore b/code/debug/motors/3motor_PWM/.gitignore deleted file mode 100644 index 03f4a3c..0000000 --- a/code/debug/motors/3motor_PWM/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pio diff --git a/code/debug/motors/3motor_PWM/include/README b/code/debug/motors/3motor_PWM/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/motors/3motor_PWM/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/motors/3motor_PWM/lib/README b/code/debug/motors/3motor_PWM/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/motors/3motor_PWM/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 <Foo.h> -#include <Bar.h> - -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/3motor_PWM/platformio.ini b/code/debug/motors/3motor_PWM/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/motors/3motor_PWM/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/motors/3motor_PWM/src/main.cpp b/code/debug/motors/3motor_PWM/src/main.cpp deleted file mode 100644 index 1a0fa98..0000000 --- a/code/debug/motors/3motor_PWM/src/main.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include <TimerThree.h> - -//base code for six direction driving - -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; - -int pwmacc = 1000; //how accurate the PWM is, means you can enter value from 0 to the value of pwmacc -int PWMval1 = 0; //value of the PWM, means you can enter value from 0 to the value of pwmacc -int PWMval2 = 0; -int PWMval3 = 0; - - -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); - - Timer3.initialize(25); // 800 microseconds or 1.25Hz - Timer3.attachInterrupt(updatePWM); - - Serial.begin(9600); - Serial.print("start"); - -} - -void updatePWM() { - //1 - static int counter = 0; - if (PWMval1 < 0) { - PWMval1 = 0; - } - if (PWMval1 > pwmacc) { - PWMval1 = pwmacc; - } - - if (counter < PWMval1) { - digitalWrite(m1enA, HIGH); - } else { - digitalWrite(m1enA, LOW); - } - - counter++; - if (counter >= pwmacc) { - counter = 0; - } - - //2 - 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; - } - - //3 - 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 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(600, 0); - Serial.println("ffor"); - delay(1500); - -} diff --git a/code/debug/motors/3motor_PWM/test/README b/code/debug/motors/3motor_PWM/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/motors/3motor_PWM/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_test/include/README b/code/debug/motors/3motor_test/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/motors/3motor_test/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/motors/3motor_test/lib/README b/code/debug/motors/3motor_test/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/motors/3motor_test/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 <Foo.h> -#include <Bar.h> - -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/3motor_test/platformio.ini b/code/debug/motors/3motor_test/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/motors/3motor_test/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/motors/3motor_test/src/main.cpp b/code/debug/motors/3motor_test/src/main.cpp deleted file mode 100644 index 24a4aff..0000000 --- a/code/debug/motors/3motor_test/src/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -//a test to test all motors, no PWM -#include <Arduino.h> - -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; - - -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); - Serial.begin(9600); - Serial.print("debug 001"); - -} - -// the loop routine runs over and over again forever: -void loop() { - digitalWrite(led, HIGH); - - digitalWrite(m1enA, HIGH); - digitalWrite(m1enB, LOW); - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); - - - digitalWrite(m2enA, HIGH); - digitalWrite(m2enB, LOW); - digitalWrite(m2pwm1, HIGH); - digitalWrite(m2pwm2, LOW); - - digitalWrite(m3enA, HIGH); - digitalWrite(m3enB, LOW); - digitalWrite(m3pwm1, HIGH); - digitalWrite(m3pwm2, LOW); - - delay(5000); - - - digitalWrite(led, LOW); - - digitalWrite(m1enA, HIGH); - digitalWrite(m1enB, LOW); - digitalWrite(m1pwm1, LOW); - digitalWrite(m1pwm2, LOW); - - digitalWrite(m2enA, HIGH); - digitalWrite(m2enB, LOW); - digitalWrite(m2pwm1, LOW); - digitalWrite(m2pwm2, LOW); - - digitalWrite(m3enA, HIGH); - digitalWrite(m3enB, LOW); - digitalWrite(m3pwm1, LOW); - digitalWrite(m3pwm2, LOW); - - - delay(5000); - - -}
\ No newline at end of file diff --git a/code/debug/motors/3motor_test/test/README b/code/debug/motors/3motor_test/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/motors/3motor_test/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/PWM/.vscode/extensions.json b/code/debug/motors/PWM/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/code/debug/motors/PWM/.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/motors/PWM/include/README b/code/debug/motors/PWM/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/motors/PWM/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/motors/PWM/lib/README b/code/debug/motors/PWM/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/motors/PWM/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 <Foo.h> -#include <Bar.h> - -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/PWM/platformio.ini b/code/debug/motors/PWM/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/motors/PWM/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/motors/PWM/src/main.cpp b/code/debug/motors/PWM/src/main.cpp deleted file mode 100644 index c7d8fe0..0000000 --- a/code/debug/motors/PWM/src/main.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include <Arduino.h> - -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 - - -void setup() { -} -void setup() { - - Timer3.initialize(800); // 800 microseconds or 1.25Hz - Timer3.attachInterrupt(updatePWM); -} - -void updatePWM() { - static int counter = 0; - if PWMval < 0) { - PWMval = 0; - } - if (PWMval > pwmacc) { - PWMval = pwmacc; - } - - if (counter < PWMval) { - digitalWrite(pwmPin, HIGH); - } else { - digitalWrite(pwmPin, LOW); - } - - counter++; - if (counter >= pwmacc) { - counter = 0; - } -} - -void loop() { - for i (0; i < pwmacc; i++) { - PWMval = i; - delay(10); - } - for i (pwmacc; i > 0; i--) { - PWMval = i; - delay(10); - } -}
\ No newline at end of file diff --git a/code/debug/motors/PWM/test/README b/code/debug/motors/PWM/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/motors/PWM/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/base_drive/.vscode/extensions.json b/code/debug/motors/base_drive/.vscode/extensions.json deleted file mode 100644 index 080e70d..0000000 --- a/code/debug/motors/base_drive/.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/motors/base_drive/include/README b/code/debug/motors/base_drive/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/motors/base_drive/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/motors/base_drive/lib/README b/code/debug/motors/base_drive/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/motors/base_drive/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 <Foo.h> -#include <Bar.h> - -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/base_drive/platformio.ini b/code/debug/motors/base_drive/platformio.ini deleted file mode 100644 index a13d034..0000000 --- a/code/debug/motors/base_drive/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/motors/base_drive/src/main.cpp b/code/debug/motors/base_drive/src/main.cpp deleted file mode 100644 index 1130afe..0000000 --- a/code/debug/motors/base_drive/src/main.cpp +++ /dev/null @@ -1,233 +0,0 @@ - -//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 - -//encoder variables -const int refreshrate = 50; //refresh rate of the encoder -volatile long oneENCcount = 0; //the amount of pulses from motor one encoder - -double ONErpm = 0.00; //the amount of revolutions motor one makes per minute - - - -void setup() { - pinMode(m1enA, OUTPUT); - pinMode(m1enB, OUTPUT); - pinMode(m1pwm1, OUTPUT); - pinMode(m1pwm2, 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 - - Serial.begin(9600); - Serial.print("start"); - SetTunings(1, 1, 1); - -} - -void updatePWM() { - int counter1 = 0; - //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; - } -} - -void AoneIRS(){ - oneENCcount++; //adds one to the count -} -void BoneIRS(){ - oneENCcount++; //dieselbe -} - -void enc_refr(){ - //calculate RPM. It gets updated 48 times per rotation. - ONErpm = (oneENCcount/48.00) * (60000000.00 / refreshrate); - //reset the counting to zero for next cycle. - oneENCcount = 0; -} -void PID(int speed){ - Serial.println(ONErpm); - PWMval1 = Compute(); //enter output from PID algorith here - digitalWrite(m1enB, LOW); - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); -} - -/*working variables*/ -unsigned long lastTime; -double Input, Output, Setpoint; -double errSum, lastErr; -double kp, ki, kd; -int Compute() -{ - Input = ONErpm; - /*How long since we last calculated*/ - unsigned long now = millis(); - double timeChange = (double)(now - lastTime); - - /*Compute all the working error variables*/ - double error = Setpoint - Input; - errSum += (error * timeChange); - double dErr = (error - lastErr) / timeChange; - -/*Compute PID Output*/ - -/*Remember some variables for next time*/ - lastErr = error; - lastTime = now; - return kp * error + ki * errSum + kd * dErr; -} - -void SetTunings(double Kp, double Ki, double Kd) -{ -kp = Kp; -ki = Ki; -kd = Kd; -} - -//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."); - delay(50); -} - -void drive(int speed, int direction){ - // - // Direction............|.Motor 1.|.Motor 2.|.Motor 3. - // 0deg(forward)........|....0....|....-....|....+.... - // 60deg................|....+....|....-....|....0.... - // 120deg...............|....+....|....0....|....-.... - // 180 deg (backward)...|....0....|....+....|....-.... - // 240 deg..............|....-....|....+....|....0.... - // 300 deg..............|....-....|....0....|....+.... - // - - digitalWrite(m1enA, HIGH); - digitalWrite(m2enA, HIGH); - digitalWrite(m3enA, HIGH); - digitalWrite(m1enB, LOW); - digitalWrite(m2enB, LOW); - digitalWrite(m3enB, LOW); - Serial.println("debug2"); - Serial.println(direction); - if(direction>330 || direction<=30){ - //0 deg - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); - - digitalWrite(m2pwm1, LOW); - digitalWrite(m2pwm2, LOW); - - digitalWrite(m3pwm1, HIGH); - digitalWrite(m3pwm2, LOW); - Serial.println("0 deg"); - }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, LOW); - digitalWrite(m3pwm2, HIGH); - }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(m3pwm1, LOW); - digitalWrite(m3pwm2, LOW); - }else if (direction > 150 && direction <= 210) { - //180 degrees - Serial.println("on 180"); - digitalWrite(m1pwm1, LOW); - digitalWrite(m1pwm2, HIGH); - - digitalWrite(m2pwm1, LOW); - digitalWrite(m2pwm2, LOW); - - digitalWrite(m3pwm1, LOW); - digitalWrite(m3pwm2, HIGH); - }else if (direction > 210 && direction <= 270) { - //240 degrees - 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 - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); - - digitalWrite(m2pwm1, HIGH); - digitalWrite(m2pwm2, LOW); - - Serial.println("300deg"); - digitalWrite(m3pwm1, LOW); - digitalWrite(m3pwm2, LOW); - }else{ - Serial.println("how?"); - } -} diff --git a/code/debug/motors/base_drive/test/README b/code/debug/motors/base_drive/test/README deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/motors/base_drive/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/basic-motor-dr/.idea/.gitignore b/code/debug/motors/basic-motor-dr/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/code/debug/motors/basic-motor-dr/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/code/debug/motors/basic-motor-dr/.idea/editor.xml b/code/debug/motors/basic-motor-dr/.idea/editor.xml new file mode 100644 index 0000000..ca29dcc --- /dev/null +++ b/code/debug/motors/basic-motor-dr/.idea/editor.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="BackendCodeEditorSettings"> + <option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/basic-motor-dr/.idea/modules.xml b/code/debug/motors/basic-motor-dr/.idea/modules.xml new file mode 100644 index 0000000..9ddc8bc --- /dev/null +++ b/code/debug/motors/basic-motor-dr/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/pwm.iml" filepath="$PROJECT_DIR$/.idea/pwm.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/basic-motor-dr/.idea/pwm.iml b/code/debug/motors/basic-motor-dr/.idea/pwm.iml new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/code/debug/motors/basic-motor-dr/.idea/pwm.iml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module classpath="CIDR" type="CPP_MODULE" version="4" />
\ No newline at end of file diff --git a/code/debug/motors/basic-motor-dr/.idea/vcs.xml b/code/debug/motors/basic-motor-dr/.idea/vcs.xml new file mode 100644 index 0000000..4fce1d8 --- /dev/null +++ b/code/debug/motors/basic-motor-dr/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/basic-motor-dr/basic-motor-dr.ino b/code/debug/motors/basic-motor-dr/basic-motor-dr.ino new file mode 100755 index 0000000..b7f3b36 --- /dev/null +++ b/code/debug/motors/basic-motor-dr/basic-motor-dr.ino @@ -0,0 +1,32 @@ +int m1enA = 6; +int m1enB = 5; +int m1pwm1 = 4; +int m1pwm2 = 3; +int m1encoA = 32; +int m1encoB = 31; + +void setup() { + Serial.begin(9600); + + pinMode(m1enA, OUTPUT); + pinMode(m1enB, OUTPUT); + pinMode(m1pwm1, OUTPUT); + pinMode(m1pwm2, OUTPUT); + + pinMode(m1pwm1, INPUT); + pinMode(m1pwm2, INPUT); + +} + +void loop() { + digitalWrite(m1enA, HIGH); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); + delay(500); + digitalWrite(m1enA, HIGH); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); + delay(500); +} diff --git a/code/debug/motors/enc-pwm-3-motor/.gitignore b/code/debug/motors/enc-pwm-3-motor/.gitignore deleted file mode 100644 index 03f4a3c..0000000 --- a/code/debug/motors/enc-pwm-3-motor/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pio diff --git a/code/debug/motors/enc-pwm-3-motor/include/README b/code/debug/motors/enc-pwm-3-motor/include/README deleted file mode 100644 index 49819c0..0000000 --- a/code/debug/motors/enc-pwm-3-motor/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/motors/enc-pwm-3-motor/lib/README b/code/debug/motors/enc-pwm-3-motor/lib/README deleted file mode 100644 index 9379397..0000000 --- a/code/debug/motors/enc-pwm-3-motor/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 <Foo.h> -#include <Bar.h> - -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 deleted file mode 100644 index a13d034..0000000 --- a/code/debug/motors/enc-pwm-3-motor/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/motors/enc-pwm-3-motor/src/main.cpp b/code/debug/motors/enc-pwm-3-motor/src/main.cpp deleted file mode 100644 index 4e3cf37..0000000 --- a/code/debug/motors/enc-pwm-3-motor/src/main.cpp +++ /dev/null @@ -1,284 +0,0 @@ -//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 deleted file mode 100644 index 9b1e87b..0000000 --- a/code/debug/motors/enc-pwm-3-motor/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/pwm/.idea/.gitignore b/code/debug/motors/pwm/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/code/debug/motors/pwm/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/code/debug/motors/pwm/.idea/editor.xml b/code/debug/motors/pwm/.idea/editor.xml new file mode 100644 index 0000000..ca29dcc --- /dev/null +++ b/code/debug/motors/pwm/.idea/editor.xml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="BackendCodeEditorSettings"> + <option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" /> + <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> + <option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/pwm/.idea/modules.xml b/code/debug/motors/pwm/.idea/modules.xml new file mode 100644 index 0000000..9ddc8bc --- /dev/null +++ b/code/debug/motors/pwm/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/pwm.iml" filepath="$PROJECT_DIR$/.idea/pwm.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/pwm/.idea/pwm.iml b/code/debug/motors/pwm/.idea/pwm.iml new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/code/debug/motors/pwm/.idea/pwm.iml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module classpath="CIDR" type="CPP_MODULE" version="4" />
\ No newline at end of file diff --git a/code/debug/motors/pwm/.idea/vcs.xml b/code/debug/motors/pwm/.idea/vcs.xml new file mode 100644 index 0000000..4fce1d8 --- /dev/null +++ b/code/debug/motors/pwm/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/code/debug/motors/pwm/pwm.ino b/code/debug/motors/pwm/pwm.ino new file mode 100755 index 0000000..9743b09 --- /dev/null +++ b/code/debug/motors/pwm/pwm.ino @@ -0,0 +1,38 @@ +#include <SoftPWM.h> + +int m1enA = LED_BUILTIN; +int m1enB = 5; +int m1pwm1 = 4; +int m1pwm2 = 3; +int m1encoA = 32; +int m1encoB = 31; + +void setup() { + Serial.begin(9600); + + SoftPWMBegin(); + SoftPWMSetPolarity(m1enA, 0); + SoftPWMSet(m1enA, 0); + + pinMode(m1enB, OUTPUT); + pinMode(m1pwm1, OUTPUT); + pinMode(m1pwm2, OUTPUT); + + pinMode(m1pwm1, INPUT); + pinMode(m1pwm2, INPUT); + +} + +void loop() { + SoftPWMSet(m1enA, 50); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, HIGH); + digitalWrite(m1pwm2, LOW); + delay(500); + SoftPWMSet(m1enA, 255); + digitalWrite(m1enA, HIGH); + digitalWrite(m1enB, LOW); + digitalWrite(m1pwm1, LOW); + digitalWrite(m1pwm2, HIGH); + delay(500); +} diff --git a/code/debug/motors/with-pid/with-pid.ino b/code/debug/motors/with-pid/with-pid.ino deleted file mode 100644 index ce8e811..0000000 --- a/code/debug/motors/with-pid/with-pid.ino +++ /dev/null @@ -1,99 +0,0 @@ -//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 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 - -//encoder variables -const int refreshrate = 50; //refresh rate of the encoder -volatile long oneENCcount = 0; //the amount of pulses from motor one encoder - -double ONErpm = 0.00; //the amount of revolutions motor one makes per minute - - - -void setup() { - pinMode(m1enA, OUTPUT); - pinMode(m1enB, OUTPUT); - pinMode(m1pwm1, OUTPUT); - pinMode(m1pwm2, 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 - - 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; - } -} - -void AoneIRS(){ - oneENCcount++ //adds one to the count -} -void BoneIRS(){ - oneENCcount++ //dieselbe -} - -void enc_refr(){ - //calculate RPM. It gets updated 48 times per rotation. - ONErpm = (oneENCcount/48.00) * (60000000.00 / refreshrate) - //reset the counting to zero for next cycle. - oneENCcount = 0; -} -void PID(int speed){ - Serial.println(ONErpm); - PWMval1 = ; //enter output from PID algorith here - digitalWrite(m1enB, LOW); - digitalWrite(m1pwm1, HIGH); - digitalWrite(m1pwm2, LOW); -} - -//the loop routine runs over and over again forever: -void loop() { - drive(50); //speed value between 0-100 - Serial.println("Motor one is at: "+ ONErpm + " RPM."); - delay(50); -} |
