commit 2b86f8bdcd00c27f8467dbee7c761ea87ccbce3e Author: Willem Oldemans Date: Sun Sep 24 16:46:50 2023 +0200 initial commit diff --git a/JGA25-370 draw2.webp b/JGA25-370 draw2.webp new file mode 100644 index 0000000..79b27e5 Binary files /dev/null and b/JGA25-370 draw2.webp differ diff --git a/blinds/.gitignore b/blinds/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/blinds/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/blinds/.vscode/extensions.json b/blinds/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/blinds/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // 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/blinds/include/README b/blinds/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/blinds/include/README @@ -0,0 +1,39 @@ + +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 usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +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/blinds/lib/README b/blinds/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/blinds/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, 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 + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/blinds/platformio.ini b/blinds/platformio.ini new file mode 100644 index 0000000..6869843 --- /dev/null +++ b/blinds/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:wemos_d1_mini32] +platform = espressif32 +board = wemos_d1_mini32 +framework = arduino diff --git a/blinds/src/main.cpp b/blinds/src/main.cpp new file mode 100644 index 0000000..8e1854f --- /dev/null +++ b/blinds/src/main.cpp @@ -0,0 +1,109 @@ +#include + +/* + * Author: Automatic Addison + * Website: https://automaticaddison.com + * Description: Calculate the angular velocity in radians/second of a DC motor + * with a built-in encoder (forward = positive; reverse = negative) + */ + +// Motor encoder output pulses per 360 degree revolution (measured manually) +#define ENC_COUNT_REV (500 * 11) //12rmp motor + +// Encoder output to Arduino Interrupt pin. Tracks the pulse count. +#define ENC_IN_RIGHT_A 2 + +// Other encoder output to Arduino to keep track of wheel direction +// Tracks the direction of rotation. +#define ENC_IN_RIGHT_B 4 + +// True = Forward; False = Reverse +bool Direction_right = true; + +// Keep track of the number of right wheel pulses +volatile long right_wheel_pulse_count = 0; + +// One-second interval for measurements +int interval = 1000; + +// Counters for milliseconds during interval +long previousMillis = 0; +long currentMillis = 0; + +// Variable for RPM measuerment +float rpm_right = 0; + +// Variable for angular velocity measurement +float ang_velocity_right = 0; +float ang_velocity_right_deg = 0; + +const float rpm_to_radians = 0.10471975512; +const float rad_to_deg = 57.29578; + +void setup() { + + // Open the serial port at 9600 bps + serial.begin(9600); + + // Set pin states of the encoder + pinMode(ENC_IN_RIGHT_A , INPUT_PULLUP); + pinMode(ENC_IN_RIGHT_B , INPUT); + + // Every time the pin goes high, this is a pulse + attachInterrupt(digitalPinToInterrupt(ENC_IN_RIGHT_A), right_wheel_pulse, RISING); + +} + +void loop() { + + // Record the time + currentMillis = millis(); + + // If one second has passed, print the number of pulses + if (currentMillis - previousMillis > interval) { + + previousMillis = currentMillis; + + // Calculate revolutions per minute + rpm_right = (float)(right_wheel_pulse_count * 60 / ENC_COUNT_REV); + ang_velocity_right = rpm_right * rpm_to_radians; + ang_velocity_right_deg = ang_velocity_right * rad_to_deg; + + Serial.print(" Pulses: "); + Serial.println(right_wheel_pulse_count); + Serial.print(" Speed: "); + Serial.print(rpm_right); + Serial.println(" RPM"); + Serial.print(" Angular Velocity: "); + Serial.print(rpm_right); + Serial.print(" rad per second"); + Serial.print("\t"); + Serial.print(ang_velocity_right_deg); + Serial.println(" deg per second"); + Serial.println(); + + right_wheel_pulse_count = 0; + + } +} + +// Increment the number of pulses by 1 +void right_wheel_pulse() { + + // Read the value for the encoder for the right wheel + int val = digitalRead(ENC_IN_RIGHT_B); + + if(val == LOW) { + Direction_right = false; // Reverse + } + else { + Direction_right = true; // Forward + } + + if (Direction_right) { + right_wheel_pulse_count++; + } + else { + right_wheel_pulse_count--; + } +} \ No newline at end of file diff --git a/blinds/test/README b/blinds/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/blinds/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/drv8871.pdf b/drv8871.pdf new file mode 100644 index 0000000..039f42c Binary files /dev/null and b/drv8871.pdf differ diff --git a/hall-wires.jpg b/hall-wires.jpg new file mode 100644 index 0000000..9cd7730 Binary files /dev/null and b/hall-wires.jpg differ diff --git a/jga25-370 draw.jpg b/jga25-370 draw.jpg new file mode 100644 index 0000000..2749e50 Binary files /dev/null and b/jga25-370 draw.jpg differ diff --git a/jga25-370 spec.jpg b/jga25-370 spec.jpg new file mode 100644 index 0000000..aa9523c Binary files /dev/null and b/jga25-370 spec.jpg differ diff --git a/jga25-spec.txt b/jga25-spec.txt new file mode 100644 index 0000000..ac15483 --- /dev/null +++ b/jga25-spec.txt @@ -0,0 +1,18 @@ +DC12V 25GA370 Grote Koppel Speed Reductormotorgroep met Toerenteller Encoder +Specificatie: +Voltage: DC6V 12V 24V +Onbelast Toerental: 12RPM, 16RPM, 35RPM, 60RPM, 77RPM, 130RPM, 170RPM, 280RPM, 620RPM, 1360RPM +Fout: ± 5% +Motor Diameter: 24.5mm +Motor Lichaam Lengte: 40mm(ref) +Uitgaande As Diameter: 4mm(D-type) +Uitgaande As Lengte: ongeveer 9.5mm +Versnellingsbak Diameter: 25mm +Versnellingsbak Size Detal, zie de tabel +Bedradingen: +Rode Draad-positieve voeding van motor(+)(veranderen positieve en negatieve van motor de rotatie zal veranderen) +Witte Draad-negatieve voeding van motor(-)(veranderen positieve en negatieve van motor de rotatie zal veranderen)) +Gele Draad-signaal feedback (motor een turn heeft 11 signalen) +Groene Draad-signaal feedback (motor een turn heeft 11 signalen) +Blauwe Draad-positieve van encoder voeding (+)(3.3-5V), kan niet worden verkeerde +Zwarte Draad-negatieve van encoder voeding (-)(3.3-5V), kan niet worden verkeerde \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29